Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
uses: DeterminateSystems/flakehub-cache-action@main

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

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ref-statuses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ jobs:
ref_statuses_json=$(nix develop --command cargo run --features ref-statuses -- --get-ref-statuses | jq --sort-keys .)
echo "${ref_statuses_json}" > ref-statuses.json

- name: Update README in light of new list
if: failure()
run: |
nix develop --command update-readme

- name: Create pull request
if: failure()
uses: peter-evans/create-pull-request@v6
with:
commit-message: Update ref-statuses.json to new valid Git refs list
commit-message: Update ref-statuses.json to new valid Git refs list and update README
title: Update ref-statuses.json
body: |
Nixpkgs has changed its list of maintained references. This PR updates `ref-statuses.json` to reflect that change.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,4 @@ If you'd like to help make the parser more exhaustive, [pull requests][prs] are
[rust]: https://rust-lang.org
[telemetry]: https://github.com/DeterminateSystems/nix-flake-checker/blob/main/src/telemetry.rs#L29-L43
[val]: https://docs.rs/serde_json/latest/serde_json/value/enum.Value.html

76 changes: 75 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

236 changes: 143 additions & 93 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,64 @@
url = "https://flakehub.com/f/nix-community/naersk/0";
inputs.nixpkgs.follows = "nixpkgs";
};

easy-template = {
url = "https://flakehub.com/f/DeterminateSystems/easy-template/0";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, ... }@inputs:
outputs =
{ self, ... }@inputs:
let
lastModifiedDate = self.lastModifiedDate or self.lastModified or "19700101";
version = "${builtins.substring 0 8 lastModifiedDate}-${self.shortRev or "dirty"}";

supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];

forSystems = s: f: inputs.nixpkgs.lib.genAttrs s (system: f rec {
inherit system;
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
});
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

forSystems =
s: f:
inputs.nixpkgs.lib.genAttrs s (
system:
f rec {
inherit system;
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
}
);

forAllSystems = forSystems supportedSystems;
in
{
overlays.default = final: prev:
overlays.default =
final: prev:
let
inherit (final.stdenv.hostPlatform) system;

rustToolchain = with inputs.fenix.packages.${system};
combine ([
stable.clippy
stable.rustc
stable.cargo
stable.rustfmt
stable.rust-src
] ++ inputs.nixpkgs.lib.optionals (system == "x86_64-linux") [
targets.x86_64-unknown-linux-musl.stable.rust-std
] ++ inputs.nixpkgs.lib.optionals (system == "aarch64-linux") [
targets.aarch64-unknown-linux-musl.stable.rust-std
]);
rustToolchain =
with inputs.fenix.packages.${system};
combine (
[
stable.clippy
stable.rustc
stable.cargo
stable.rustfmt
stable.rust-src
]
++ inputs.nixpkgs.lib.optionals (system == "x86_64-linux") [
targets.x86_64-unknown-linux-musl.stable.rust-std
]
++ inputs.nixpkgs.lib.optionals (system == "aarch64-linux") [
targets.aarch64-unknown-linux-musl.stable.rust-std
]
);
in
{
inherit rustToolchain;
Expand All @@ -57,76 +79,104 @@
};
};

packages = forAllSystems ({ pkgs, system }: rec {
default = flake-checker;

flake-checker = pkgs.naerskLib.buildPackage
({
name = "flake-checker";
src = self;
doCheck = true;
nativeBuildInputs = with pkgs; [ ] ++ lib.optionals stdenv.isDarwin [ libiconv ];
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
CARGO_BUILD_TARGET =
if system == "x86_64-linux" then
"x86_64-unknown-linux-musl"
else if system == "aarch64-linux" then
"aarch64-unknown-linux-musl"
else
throw "Unsupported Linux system: ${system}";
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
});
});

devShells = forAllSystems ({ pkgs, ... }: {
default =
let
check-nixpkgs-fmt = pkgs.writeShellApplication {
name = "check-nixpkgs-fmt";
runtimeInputs = with pkgs; [ git nixpkgs-fmt ];
text = ''
nixpkgs-fmt --check "$(git ls-files '*.nix')"
'';
};
check-rustfmt = pkgs.writeShellApplication {
name = "check-rustfmt";
runtimeInputs = with pkgs; [ rustToolchain ];
text = "cargo fmt --check";
};
get-ref-statuses = pkgs.writeShellApplication {
name = "get-ref-statuses";
runtimeInputs = with pkgs; [ rustToolchain ];
text = "cargo run --features ref-statuses -- --get-ref-statuses";
};
in
pkgs.mkShell {
packages = with pkgs; [
bashInteractive

# Rust
rustToolchain
cargo-bloat
cargo-edit
cargo-machete
cargo-watch
rust-analyzer

# Nix
nixpkgs-fmt

# CI checks
check-nixpkgs-fmt
check-rustfmt

# Scripts
get-ref-statuses
];

env = {
# Required by rust-analyzer
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
packages = forAllSystems (
{ pkgs, system }:
rec {
default = flake-checker;

flake-checker = pkgs.naerskLib.buildPackage (
{
name = "flake-checker";
src = self;
doCheck = true;
nativeBuildInputs = with pkgs; [ ] ++ lib.optionals stdenv.isDarwin [ libiconv ];
}
// pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
CARGO_BUILD_TARGET =
if system == "x86_64-linux" then
"x86_64-unknown-linux-musl"
else if system == "aarch64-linux" then
"aarch64-unknown-linux-musl"
else
throw "Unsupported Linux system: ${system}";
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
}
);
}
);

devShells = forAllSystems (
{ pkgs, system }:
{
default =
let
check-nixpkgs-fmt = pkgs.writeShellApplication {
name = "check-nixpkgs-fmt";
runtimeInputs = with pkgs; [
git
nixpkgs-fmt
];
text = ''
nixpkgs-fmt --check "$(git ls-files '*.nix')"
'';
};
check-rustfmt = pkgs.writeShellApplication {
name = "check-rustfmt";
runtimeInputs = with pkgs; [ rustToolchain ];
text = "cargo fmt --check";
};
get-ref-statuses = pkgs.writeShellApplication {
name = "get-ref-statuses";
runtimeInputs = with pkgs; [ rustToolchain ];
text = "cargo run --features ref-statuses -- --get-ref-statuses";
};
update-readme = pkgs.writeShellApplication {
name = "update-readme";
runtimeInputs = [
inputs.easy-template.packages.${system}.default
pkgs.jq
];
text = ''
tmp=$(mktemp -d)
inputs="''${tmp}/template-inputs.json"

jq '{supported: .}' ./ref-statuses.json > "''${inputs}"
easy-template ./templates/README.md.handlebars "''${inputs}" > README.md

rm -rf "''${tmp}"
'';
};
in
pkgs.mkShell {
packages = with pkgs; [
bashInteractive

# Rust
rustToolchain
cargo-bloat
cargo-edit
cargo-machete
cargo-watch
rust-analyzer

# Nix
nixpkgs-fmt

# CI checks
check-nixpkgs-fmt
check-rustfmt

# Scripts
get-ref-statuses
update-readme
];

env = {
# Required by rust-analyzer
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
};
};
};
});
}
);
};
}
Loading
Loading