-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nix flake with nightly, stable, and msrv devshells
an .envrc file that uses the flake is provided for convenience also includes nix formatting using alejandra, and a flake check that enforces formatting of nix code
- Loading branch information
1 parent
d940ed2
commit bab0756
Showing
3 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake . |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
description = "rust-payjoin"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
rust-overlay = { | ||
url = "github:oxalica/rust-overlay"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
outputs = { | ||
self, | ||
nixpkgs, | ||
flake-utils, | ||
rust-overlay, | ||
}: | ||
flake-utils.lib.eachDefaultSystem ( | ||
system: let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [rust-overlay.overlays.default]; | ||
}; | ||
|
||
msrv = "1.63.0"; | ||
rustVersions = with pkgs.rust-bin; | ||
builtins.mapAttrs (_name: rust-bin: | ||
rust-bin.override { | ||
extensions = ["rust-src" "rustfmt"]; | ||
}) | ||
{ | ||
msrv = stable.${msrv}.default; | ||
stable = stable.latest.default; | ||
nightly = nightly.latest.default; | ||
}; | ||
|
||
mkShell = rust-bin: | ||
pkgs.mkShell { | ||
packages = with pkgs; [ | ||
(rust-bin.override { | ||
extensions = ["rust-src" "rustfmt"]; | ||
}) | ||
]; | ||
}; | ||
devShells = builtins.mapAttrs (_name: rustVersion: mkShell rustVersion) rustVersions; | ||
|
||
simpleCheck = args: | ||
pkgs.stdenvNoCC.mkDerivation ({ | ||
doCheck = true; | ||
dontFixup = true; | ||
installPhase = "mkdir $out"; | ||
} | ||
// args); | ||
in { | ||
devShells = devShells // {default = devShells.nightly;}; | ||
formatter = pkgs.alejandra; | ||
checks = { | ||
nix-fmt-check = simpleCheck { | ||
name = "nix-fmt-check"; | ||
src = pkgs.lib.sources.sourceFilesBySuffices ./. [".nix"]; | ||
nativeBuildInputs = [pkgs.alejandra]; | ||
checkPhase = '' | ||
alejandra -c . | ||
''; | ||
}; | ||
}; | ||
} | ||
); | ||
} |