Skip to content

Commit c4ec1e4

Browse files
build: use nightly toolchain
This change adds `fenix` to the nix flake to enable the use of nightly toolchains. Using nightly rust toolchains enables the use of the features behind the `exit_status_error`[^1] feature flag, which allows the use of `ExitStatusError`[^2]. [^1]: rust-lang/rust#84908 [^2]: https://doc.rust-lang.org/std/process/struct.ExitStatusError.html
1 parent 5914f95 commit c4ec1e4

File tree

5 files changed

+110
-11
lines changed

5 files changed

+110
-11
lines changed

flake.lock

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
url = "github:ipetkov/crane";
66
inputs.nixpkgs.follows = "nixpkgs";
77
};
8+
fenix = {
9+
url = "github:nix-community/fenix";
10+
inputs.nixpkgs.follows = "nixpkgs";
11+
};
812
};
913

1014
outputs = {
1115
self,
1216
nixpkgs,
1317
crane,
18+
fenix,
1419
}: let
1520
forEachSystem = nixpkgs.lib.genAttrs [
1621
"aarch64-darwin"
@@ -21,7 +26,7 @@
2126
in {
2227
packages = forEachSystem (system: let
2328
craneDerivations = nixpkgs.legacyPackages.${system}.callPackage ./nix/default.nix {
24-
inherit crane;
29+
inherit crane fenix;
2530
};
2631
in {
2732
default = craneDerivations.myCrate;

nix/default.nix

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22
pkgs,
33
system,
44
crane,
5+
fenix,
56
}: let
6-
craneLib = crane.lib.${system};
7+
fenix-channel = fenix.packages.${system}.latest;
8+
fenix-toolchain = fenix-channel.withComponents [
9+
"cargo"
10+
"clippy"
11+
"rust-analyzer"
12+
"rust-src"
13+
"rustc"
14+
"rustfmt"
15+
];
16+
17+
craneLib = crane.lib.${system}.overrideToolchain fenix-toolchain;
718

819
# Common derivation arguments used for all builds
920
commonArgs = {
1021
src = craneLib.cleanCargoSource ../.;
1122

1223
nativeBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
24+
pkgs.darwin.apple_sdk.frameworks.Security
25+
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
1326
pkgs.libiconv
1427
];
1528
};
@@ -51,5 +64,6 @@ in {
5164
myCrate
5265
myCrateClippy
5366
myCrateCoverage
67+
fenix-toolchain
5468
;
5569
}

nix/flake.lock

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/flake.nix

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
url = "github:ipetkov/crane";
66
inputs.nixpkgs.follows = "nixpkgs";
77
};
8+
fenix = {
9+
url = "github:nix-community/fenix";
10+
inputs.nixpkgs.follows = "nixpkgs";
11+
};
812
pre-commit-hooks = {
913
url = "github:cachix/pre-commit-hooks.nix";
1014
inputs.nixpkgs.follows = "nixpkgs";
@@ -15,6 +19,7 @@
1519
self,
1620
nixpkgs,
1721
crane,
22+
fenix,
1823
pre-commit-hooks,
1924
}: let
2025
forEachSystem = nixpkgs.lib.genAttrs [
@@ -25,7 +30,8 @@
2530
];
2631
in {
2732
checks = forEachSystem (system: let
28-
craneDerivations = nixpkgs.legacyPackages.${system}.callPackage ./default.nix {inherit crane;};
33+
pkgs = import nixpkgs {inherit system;};
34+
craneDerivations = pkgs.callPackage ./default.nix {inherit crane fenix;};
2935
pre-commit-check = pre-commit-hooks.lib.${system}.run {
3036
src = ../.;
3137
hooks = {
@@ -46,17 +52,13 @@
4652
});
4753

4854
devShells = forEachSystem (system: let
49-
pkgs = nixpkgs.legacyPackages.${system};
50-
craneDerivations = pkgs.callPackage ./default.nix {inherit crane;};
55+
pkgs = import nixpkgs {inherit system;};
56+
craneDerivations = pkgs.callPackage ./default.nix {inherit crane fenix;};
5157
in {
5258
default = pkgs.mkShell {
53-
nativeBuildInputs = with pkgs;
59+
packages = with pkgs;
5460
[
55-
cargo
56-
clippy
57-
rust-analyzer
58-
rustc
59-
rustfmt
61+
craneDerivations.fenix-toolchain
6062
]
6163
++ craneDerivations.commonArgs.nativeBuildInputs;
6264

0 commit comments

Comments
 (0)