File tree Expand file tree Collapse file tree 10 files changed +489
-188
lines changed
Expand file tree Collapse file tree 10 files changed +489
-188
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ jobs:
1111 steps :
1212 - uses : actions/checkout@v5
1313 - uses : cachix/install-nix-action@v31
14- - run : cd tests && nix fmt .. -- --fail-on-change
14+ - run : nix build .#checks.x86_64-linux.formatting
1515 tests :
1616 needs : nixfmt
1717 runs-on : ubuntu-latest
1818 steps :
1919 - uses : actions/checkout@v5
2020 - uses : cachix/install-nix-action@v31
21- - run : nix run ./tests #run .
21+ - run : nix run .#run-tests
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ Link the profile in the table in README.md and in flake.nix.
4242
4343## 3. Testing
4444
45- Run ` nix run ./tests #run . ` to evaluate all hardware profiles.
45+ Run ` nix run .#run-tests ` to evaluate all hardware profiles.
4646Because profiles can only be tested with the appropriate hardware, quality
4747assurance is up to * you* .
4848
Original file line number Diff line number Diff line change 22 description = "nixos-hardware" ;
33
44 outputs =
5- { ... } :
5+ { self , ... } :
6+ let
7+ # Import private inputs (for development)
8+ privateInputs =
9+ ( import ./tests/flake-compat.nix {
10+ src = ./tests ;
11+ } ) . defaultNix ;
12+
13+ systems = [
14+ "aarch64-linux"
15+ "riscv64-linux"
16+ "x86_64-linux"
17+ ] ;
18+
19+ formatSystems = [ "aarch64-linux" "x86_64-linux" ] ;
20+
21+ # Helper to iterate over systems
22+ eachSystem =
23+ f :
24+ privateInputs . nixos-unstable-small . lib . genAttrs systems (
25+ system : f privateInputs . nixos-unstable-small . legacyPackages . ${ system } system
26+ ) ;
27+
28+ eachSystemFormat =
29+ f :
30+ privateInputs . nixos-unstable-small . lib . genAttrs formatSystems (
31+ system : f privateInputs . nixos-unstable-small . legacyPackages . ${ system } system
32+ ) ;
33+ in
634 {
735
836 nixosModules =
420448 common-pc-laptop-ssd = import ./common/pc/ssd ;
421449 common-pc-ssd = import ./common/pc/ssd ;
422450 } ;
451+
452+ # Add formatter for `nix fmt`
453+ formatter = eachSystemFormat (
454+ pkgs : _system :
455+ ( privateInputs . treefmt-nix . lib . evalModule pkgs ./tests/treefmt.nix ) . config . build . wrapper
456+ ) ;
457+
458+ # Add packages
459+ packages = eachSystem (
460+ pkgs : _system : {
461+ run-tests = pkgs . callPackage ./tests/run-tests.nix {
462+ inherit self ;
463+ } ;
464+ }
465+ ) ;
466+
467+ # Add checks for `nix run .#run-tests`
468+ checks = eachSystem (
469+ pkgs : system :
470+ let
471+ treefmtEval = privateInputs . treefmt-nix . lib . evalModule pkgs ./tests/treefmt.nix ;
472+ nixosTests = import ./tests/nixos-tests.nix {
473+ inherit
474+ self
475+ privateInputs
476+ system
477+ pkgs
478+ ;
479+ } ;
480+ in
481+ pkgs . lib . optionalAttrs ( self . formatter ? ${ system } ) {
482+ formatting = treefmtEval . config . build . check self ;
483+ }
484+ // nixosTests
485+ ) ;
423486 } ;
424487}
You can’t perform that action at this time.
0 commit comments