flake: Add NixOS tests to checks

This commit is contained in:
Lorenz Leutgeb 2026-05-07 16:06:49 +02:00 committed by Fintan Halpenny
parent 767b80e7fe
commit 9158df5067
1 changed files with 60 additions and 27 deletions

View File

@ -34,22 +34,47 @@
outputs = { outputs = {
self, self,
advisory-db, advisory-db,
crane, crane,
flake-utils, flake-utils,
nixpkgs, nixpkgs,
nixpkgs-stable,
nixpkgs-unstable,
rust-overlay, rust-overlay,
... ...
} @ inputs: } @ inputs: let
version = "nix-" + (self.shortRev or self.dirtyShortRev or "unknown");
lib = nixpkgs.lib;
srcFilters = pkgs: path: type:
builtins.any (suffix: lib.hasSuffix suffix path) [
".sql" # schemas
".diff" # testing
".md" # testing
".adoc" # man pages
".json" # testing samples
".txt" # might be included with `include_str!`
"rad-cob-multiset" # testing external COBs
]
||
# Default filter from crane (allow .rs files)
((crane.mkLib pkgs).filterCargoSources path type);
mkSrc = pkgs:
lib.cleanSourceWith {
src = ./.;
filter = srcFilters pkgs;
};
in
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system: let
lib = nixpkgs.lib;
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [(import rust-overlay)]; overlays = [(import rust-overlay)];
}; };
src = mkSrc pkgs;
msrv = let msrv = let
msrv = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.rust-version; msrv = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.rust-version;
in rec { in rec {
@ -72,27 +97,8 @@
commonArgs = mkCommonArgs craneLib; commonArgs = mkCommonArgs craneLib;
}; };
srcFilters = path: type:
builtins.any (suffix: lib.hasSuffix suffix path) [
".sql" # schemas
".diff" # testing
".md" # testing
".adoc" # man pages
".json" # testing samples
".txt" # might be included with `include_str!`
"rad-cob-multiset" # testing external COBs
]
||
# Default filter from crane (allow .rs files)
(rustup.craneLib.filterCargoSources path type);
src = lib.cleanSourceWith {
src = ./.;
filter = srcFilters;
};
basicArgs = { basicArgs = {
inherit src; src = mkSrc pkgs;
pname = "Heartwood"; pname = "Heartwood";
strictDeps = true; strictDeps = true;
}; };
@ -120,7 +126,7 @@
env = env =
{ {
RADICLE_VERSION = "nix-" + (self.shortRev or self.dirtyShortRev or "unknown"); RADICLE_VERSION = version;
} }
// ( // (
if self ? rev || self ? dirtyRev if self ? rev || self ? dirtyRev
@ -331,7 +337,21 @@
env.CARGO_PROFILE = "dev"; env.CARGO_PROFILE = "dev";
cargoNextestExtraArgs = "--no-capture"; cargoNextestExtraArgs = "--no-capture";
}); });
}; }
// (
let
nixos = nixpkgs:
(import nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
}).radicle-node.tests.nixos-run;
in {
nixos-stable = nixos nixpkgs-stable;
nixos-unstable = nixos nixpkgs-unstable;
}
);
packages = let packages = let
crates = buildCrates {}; crates = buildCrates {};
@ -388,5 +408,18 @@
# the simulation justfile to symlink into a location talosctl can find. # the simulation justfile to symlink into a location talosctl can find.
env.OVMF_FD_PATH = "${pkgs.OVMF.fd}/FV"; env.OVMF_FD_PATH = "${pkgs.OVMF.fd}/FV";
}; };
}); })
// {
overlays = {
default = final: prev: {
radicle-node = prev.radicle-node.overrideAttrs (finalAttrs: prevAttrs: {
inherit version;
src = mkSrc final;
cargoDeps = final.rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
};
});
};
};
};
} }