Skip to content

Commit 603e7de

Browse files
authored
Merge pull request #199 from DeterminateSystems/templatize-readme
Auto-update README when supported branches list changes
2 parents 9753d4a + f51d974 commit 603e7de

File tree

6 files changed

+386
-95
lines changed

6 files changed

+386
-95
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
uses: DeterminateSystems/flakehub-cache-action@main
3939

4040
- name: Build and cache dev shell for ${{ matrix.systems.nix-system }} on ${{ matrix.systems.runner }}
41+
# We still support this system but caching the dev shell fails due to system support mismatch,
42+
# and we don't really need this cached anyway
43+
if: ${{ matrix.systems.nix-system != 'x86_64-darwin' }}
4144
run: |
4245
nix build -L ".#devShells.${{ matrix.systems.nix-system }}.default"
4346

.github/workflows/ref-statuses.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ jobs:
2424
ref_statuses_json=$(nix develop --command cargo run --features ref-statuses -- --get-ref-statuses | jq --sort-keys .)
2525
echo "${ref_statuses_json}" > ref-statuses.json
2626
27+
- name: Update README in light of new list
28+
if: failure()
29+
run: |
30+
nix develop --command update-readme
31+
2732
- name: Create pull request
2833
if: failure()
2934
uses: peter-evans/create-pull-request@v6
3035
with:
31-
commit-message: Update ref-statuses.json to new valid Git refs list
36+
commit-message: Update ref-statuses.json to new valid Git refs list and update README
3237
title: Update ref-statuses.json
3338
body: |
3439
Nixpkgs has changed its list of maintained references. This PR updates `ref-statuses.json` to reflect that change.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,4 @@ If you'd like to help make the parser more exhaustive, [pull requests][prs] are
162162
[rust]: https://rust-lang.org
163163
[telemetry]: https://github.com/DeterminateSystems/nix-flake-checker/blob/main/src/telemetry.rs#L29-L43
164164
[val]: https://docs.rs/serde_json/latest/serde_json/value/enum.Value.html
165+

flake.lock

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

flake.nix

Lines changed: 143 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,64 @@
1111
url = "https://flakehub.com/f/nix-community/naersk/0";
1212
inputs.nixpkgs.follows = "nixpkgs";
1313
};
14+
15+
easy-template = {
16+
url = "https://flakehub.com/f/DeterminateSystems/easy-template/0";
17+
inputs.nixpkgs.follows = "nixpkgs";
18+
};
1419
};
1520

16-
outputs = { self, ... }@inputs:
21+
outputs =
22+
{ self, ... }@inputs:
1723
let
1824
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
1925
version = "${builtins.substring 0 8 lastModifiedDate}-${self.shortRev or "dirty"}";
2026

21-
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
22-
23-
forSystems = s: f: inputs.nixpkgs.lib.genAttrs s (system: f rec {
24-
inherit system;
25-
pkgs = import inputs.nixpkgs {
26-
inherit system;
27-
overlays = [ self.overlays.default ];
28-
};
29-
});
27+
supportedSystems = [
28+
"x86_64-linux"
29+
"aarch64-linux"
30+
"x86_64-darwin"
31+
"aarch64-darwin"
32+
];
33+
34+
forSystems =
35+
s: f:
36+
inputs.nixpkgs.lib.genAttrs s (
37+
system:
38+
f rec {
39+
inherit system;
40+
pkgs = import inputs.nixpkgs {
41+
inherit system;
42+
overlays = [ self.overlays.default ];
43+
};
44+
}
45+
);
3046

3147
forAllSystems = forSystems supportedSystems;
3248
in
3349
{
34-
overlays.default = final: prev:
50+
overlays.default =
51+
final: prev:
3552
let
3653
inherit (final.stdenv.hostPlatform) system;
3754

38-
rustToolchain = with inputs.fenix.packages.${system};
39-
combine ([
40-
stable.clippy
41-
stable.rustc
42-
stable.cargo
43-
stable.rustfmt
44-
stable.rust-src
45-
] ++ inputs.nixpkgs.lib.optionals (system == "x86_64-linux") [
46-
targets.x86_64-unknown-linux-musl.stable.rust-std
47-
] ++ inputs.nixpkgs.lib.optionals (system == "aarch64-linux") [
48-
targets.aarch64-unknown-linux-musl.stable.rust-std
49-
]);
55+
rustToolchain =
56+
with inputs.fenix.packages.${system};
57+
combine (
58+
[
59+
stable.clippy
60+
stable.rustc
61+
stable.cargo
62+
stable.rustfmt
63+
stable.rust-src
64+
]
65+
++ inputs.nixpkgs.lib.optionals (system == "x86_64-linux") [
66+
targets.x86_64-unknown-linux-musl.stable.rust-std
67+
]
68+
++ inputs.nixpkgs.lib.optionals (system == "aarch64-linux") [
69+
targets.aarch64-unknown-linux-musl.stable.rust-std
70+
]
71+
);
5072
in
5173
{
5274
inherit rustToolchain;
@@ -57,76 +79,104 @@
5779
};
5880
};
5981

60-
packages = forAllSystems ({ pkgs, system }: rec {
61-
default = flake-checker;
62-
63-
flake-checker = pkgs.naerskLib.buildPackage
64-
({
65-
name = "flake-checker";
66-
src = self;
67-
doCheck = true;
68-
nativeBuildInputs = with pkgs; [ ] ++ lib.optionals stdenv.isDarwin [ libiconv ];
69-
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
70-
CARGO_BUILD_TARGET =
71-
if system == "x86_64-linux" then
72-
"x86_64-unknown-linux-musl"
73-
else if system == "aarch64-linux" then
74-
"aarch64-unknown-linux-musl"
75-
else
76-
throw "Unsupported Linux system: ${system}";
77-
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
78-
});
79-
});
80-
81-
devShells = forAllSystems ({ pkgs, ... }: {
82-
default =
83-
let
84-
check-nixpkgs-fmt = pkgs.writeShellApplication {
85-
name = "check-nixpkgs-fmt";
86-
runtimeInputs = with pkgs; [ git nixpkgs-fmt ];
87-
text = ''
88-
nixpkgs-fmt --check "$(git ls-files '*.nix')"
89-
'';
90-
};
91-
check-rustfmt = pkgs.writeShellApplication {
92-
name = "check-rustfmt";
93-
runtimeInputs = with pkgs; [ rustToolchain ];
94-
text = "cargo fmt --check";
95-
};
96-
get-ref-statuses = pkgs.writeShellApplication {
97-
name = "get-ref-statuses";
98-
runtimeInputs = with pkgs; [ rustToolchain ];
99-
text = "cargo run --features ref-statuses -- --get-ref-statuses";
100-
};
101-
in
102-
pkgs.mkShell {
103-
packages = with pkgs; [
104-
bashInteractive
105-
106-
# Rust
107-
rustToolchain
108-
cargo-bloat
109-
cargo-edit
110-
cargo-machete
111-
cargo-watch
112-
rust-analyzer
113-
114-
# Nix
115-
nixpkgs-fmt
116-
117-
# CI checks
118-
check-nixpkgs-fmt
119-
check-rustfmt
120-
121-
# Scripts
122-
get-ref-statuses
123-
];
124-
125-
env = {
126-
# Required by rust-analyzer
127-
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
82+
packages = forAllSystems (
83+
{ pkgs, system }:
84+
rec {
85+
default = flake-checker;
86+
87+
flake-checker = pkgs.naerskLib.buildPackage (
88+
{
89+
name = "flake-checker";
90+
src = self;
91+
doCheck = true;
92+
nativeBuildInputs = with pkgs; [ ] ++ lib.optionals stdenv.isDarwin [ libiconv ];
93+
}
94+
// pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
95+
CARGO_BUILD_TARGET =
96+
if system == "x86_64-linux" then
97+
"x86_64-unknown-linux-musl"
98+
else if system == "aarch64-linux" then
99+
"aarch64-unknown-linux-musl"
100+
else
101+
throw "Unsupported Linux system: ${system}";
102+
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
103+
}
104+
);
105+
}
106+
);
107+
108+
devShells = forAllSystems (
109+
{ pkgs, system }:
110+
{
111+
default =
112+
let
113+
check-nixpkgs-fmt = pkgs.writeShellApplication {
114+
name = "check-nixpkgs-fmt";
115+
runtimeInputs = with pkgs; [
116+
git
117+
nixpkgs-fmt
118+
];
119+
text = ''
120+
nixpkgs-fmt --check "$(git ls-files '*.nix')"
121+
'';
122+
};
123+
check-rustfmt = pkgs.writeShellApplication {
124+
name = "check-rustfmt";
125+
runtimeInputs = with pkgs; [ rustToolchain ];
126+
text = "cargo fmt --check";
127+
};
128+
get-ref-statuses = pkgs.writeShellApplication {
129+
name = "get-ref-statuses";
130+
runtimeInputs = with pkgs; [ rustToolchain ];
131+
text = "cargo run --features ref-statuses -- --get-ref-statuses";
132+
};
133+
update-readme = pkgs.writeShellApplication {
134+
name = "update-readme";
135+
runtimeInputs = [
136+
inputs.easy-template.packages.${system}.default
137+
pkgs.jq
138+
];
139+
text = ''
140+
tmp=$(mktemp -d)
141+
inputs="''${tmp}/template-inputs.json"
142+
143+
jq '{supported: .}' ./ref-statuses.json > "''${inputs}"
144+
easy-template ./templates/README.md.handlebars "''${inputs}" > README.md
145+
146+
rm -rf "''${tmp}"
147+
'';
148+
};
149+
in
150+
pkgs.mkShell {
151+
packages = with pkgs; [
152+
bashInteractive
153+
154+
# Rust
155+
rustToolchain
156+
cargo-bloat
157+
cargo-edit
158+
cargo-machete
159+
cargo-watch
160+
rust-analyzer
161+
162+
# Nix
163+
nixpkgs-fmt
164+
165+
# CI checks
166+
check-nixpkgs-fmt
167+
check-rustfmt
168+
169+
# Scripts
170+
get-ref-statuses
171+
update-readme
172+
];
173+
174+
env = {
175+
# Required by rust-analyzer
176+
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
177+
};
128178
};
129-
};
130-
});
179+
}
180+
);
131181
};
132182
}

0 commit comments

Comments
 (0)