Skip to content

Commit ca7cfb3

Browse files
authored
Merge pull request #147 from DeterminateSystems/rust-stable
Switch to stable Rust
2 parents 7df9350 + f831109 commit ca7cfb3

File tree

6 files changed

+134
-162
lines changed

6 files changed

+134
-162
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
run: |
4949
nix develop -c \
5050
cargo run -- \
51-
--condition "supportedRefs.contains(gitRef) && numDaysOld < 30 && owner == 'NixOS'" \
51+
--condition "supportedRefs.contains(gitRef) && numDaysOld > 30 && owner == 'NixOS'" \
5252
./tests/flake.cel.0.lock
5353
5454
check-flake-dirty:

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "flake-checker"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
edition = "2021"
55

66
[workspace]

crane.nix

Lines changed: 0 additions & 108 deletions
This file was deleted.

flake.lock

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

flake.nix

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,99 @@
11
{
22
inputs = {
3-
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2405.*";
4-
rust-overlay = {
5-
url = "https://flakehub.com/f/oxalica/rust-overlay/*";
3+
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2411.*";
4+
5+
fenix = {
6+
url = "https://flakehub.com/f/nix-community/fenix/0.1.*";
67
inputs.nixpkgs.follows = "nixpkgs";
78
};
8-
crane.url = "https://flakehub.com/f/ipetkov/crane/0.19.*";
9+
10+
naersk.url = "https://flakehub.com/f/nix-community/naersk/0.1.*";
911
};
1012

1113
outputs = { self, ... }@inputs:
1214
let
15+
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
16+
version = "${builtins.substring 0 8 lastModifiedDate}-${self.shortRev or "dirty"}";
17+
1318
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
14-
forAllSystems = f: inputs.nixpkgs.lib.genAttrs supportedSystems (system: f rec {
19+
20+
forSystems = s: f: inputs.nixpkgs.lib.genAttrs s (system: f rec {
21+
inherit system;
1522
pkgs = import inputs.nixpkgs {
1623
inherit system;
17-
overlays = [
18-
inputs.rust-overlay.overlays.default
19-
];
20-
};
21-
22-
cranePkgs = pkgs.callPackage ./crane.nix {
23-
inherit (inputs) crane;
24-
inherit supportedSystems;
24+
overlays = [ self.overlays.default ];
2525
};
2626
});
27+
28+
forAllSystems = forSystems supportedSystems;
2729
in
2830
{
29-
packages = forAllSystems ({ cranePkgs, ... }: rec {
30-
inherit (cranePkgs) flake-checker;
31+
overlays.default = final: prev:
32+
let
33+
inherit (final.stdenv.hostPlatform) system;
34+
35+
rustToolchain = with inputs.fenix.packages.${system};
36+
combine ([
37+
stable.clippy
38+
stable.rustc
39+
stable.cargo
40+
stable.rustfmt
41+
stable.rust-src
42+
] ++ inputs.nixpkgs.lib.optionals (system == "x86_64-linux") [
43+
targets.x86_64-unknown-linux-musl.stable.rust-std
44+
] ++ inputs.nixpkgs.lib.optionals (system == "aarch64-linux") [
45+
targets.aarch64-unknown-linux-musl.stable.rust-std
46+
]);
47+
in
48+
{
49+
inherit rustToolchain;
50+
51+
naerskLib = final.callPackage inputs.naersk {
52+
cargo = rustToolchain;
53+
rustc = rustToolchain;
54+
};
55+
};
56+
57+
packages = forAllSystems ({ pkgs, system }: rec {
3158
default = flake-checker;
59+
60+
flake-checker = pkgs.naerskLib.buildPackage
61+
({
62+
name = "flake-checker-${version}";
63+
src = self;
64+
doCheck = true;
65+
buildInputs = with pkgs; [ ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Security SystemConfiguration ]);
66+
nativeBuildInputs = with pkgs; [ ] ++ lib.optionals stdenv.isDarwin [ libiconv ];
67+
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
68+
CARGO_BUILD_TARGET =
69+
if system == "x86_64-linux" then
70+
"x86_64-unknown-linux-musl"
71+
else if system == "aarch64-linux" then
72+
"aarch64-unknown-linux-musl"
73+
else
74+
throw "Unsupported Linux system: ${system}";
75+
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
76+
});
3277
});
3378

34-
devShells = forAllSystems ({ pkgs, cranePkgs }: {
79+
devShells = forAllSystems ({ pkgs, ... }: {
3580
default =
3681
let
3782
check-nixpkgs-fmt = pkgs.writeShellApplication {
3883
name = "check-nixpkgs-fmt";
3984
runtimeInputs = with pkgs; [ git nixpkgs-fmt ];
4085
text = ''
41-
git ls-files '*.nix' | xargs nixpkgs-fmt --check
86+
nixpkgs-fmt --check "$(git ls-files '*.nix')"
4287
'';
4388
};
4489
check-rustfmt = pkgs.writeShellApplication {
4590
name = "check-rustfmt";
46-
runtimeInputs = [ cranePkgs.rustNightly ];
91+
runtimeInputs = with pkgs; [ rustToolchain ];
4792
text = "cargo fmt --check";
4893
};
4994
get-allowed-refs = pkgs.writeShellApplication {
5095
name = "get-allowed-refs";
51-
runtimeInputs = [ cranePkgs.rustNightly ];
96+
runtimeInputs = with pkgs; [ rustToolchain ];
5297
text = "cargo run --features allowed-refs -- --get-allowed-refs";
5398
};
5499
in
@@ -57,7 +102,7 @@
57102
bashInteractive
58103

59104
# Rust
60-
cranePkgs.rustNightly
105+
rustToolchain
61106
cargo-bloat
62107
cargo-edit
63108
cargo-machete
@@ -77,7 +122,7 @@
77122

78123
env = {
79124
# Required by rust-analyzer
80-
RUST_SRC_PATH = "${cranePkgs.rustNightly}/lib/rustlib/src/rust/library";
125+
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
81126
};
82127
};
83128
});

0 commit comments

Comments
 (0)