From 01baa46b3612a8276566eca66e3be321e40de889 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Fri, 26 Sep 2025 15:04:27 +0200 Subject: [PATCH 1/4] flake: make `privateInputs` actually the `inputs` --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index e0cf78543..d643309cf 100644 --- a/flake.nix +++ b/flake.nix @@ -56,7 +56,7 @@ else (import ./devFlake/flake-compat.nix { src = ./devFlake; - }).outputs; + }).outputs.inputs; in flake-parts.lib.mkFlake { inherit inputs; } ( { ... }: From dc66321a721b5bde57da6114ce9c9cd57e9167f1 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Thu, 25 Sep 2025 22:33:55 +0200 Subject: [PATCH 2/4] test-fixtures: move to `devFlake` --- checks/flash/flake-module.nix | 5 +- checks/installation/facter-report.nix | 10 --- checks/installation/flake-module.nix | 5 +- checks/morph/flake-module.nix | 8 +-- checks/update/flake-module.nix | 7 +-- devFlake/flake.lock | 43 +++++++++++++ devFlake/flake.nix | 3 + flake.nix | 88 ++++++++++++++------------- 8 files changed, 101 insertions(+), 68 deletions(-) delete mode 100644 checks/installation/facter-report.nix diff --git a/checks/flash/flake-module.nix b/checks/flash/flake-module.nix index 0acbc64d2..cec47a976 100644 --- a/checks/flash/flake-module.nix +++ b/checks/flash/flake-module.nix @@ -2,6 +2,7 @@ config, self, lib, + privateInputs, ... }: { @@ -69,9 +70,7 @@ self.nixosConfigurations."test-flash-machine-${pkgs.hostPlatform.system}".config.system.build.diskoScript.drvPath ] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs) - ++ builtins.map (import ../installation/facter-report.nix) ( - lib.filter (lib.hasSuffix "linux") config.systems - ); + ++ builtins.map (i: i.outPath) (builtins.attrValues privateInputs); closureInfo = pkgs.closureInfo { rootPaths = dependencies; }; in { diff --git a/checks/installation/facter-report.nix b/checks/installation/facter-report.nix deleted file mode 100644 index ed950194f..000000000 --- a/checks/installation/facter-report.nix +++ /dev/null @@ -1,10 +0,0 @@ -system: -builtins.fetchurl { - url = "https://git.clan.lol/clan/test-fixtures/raw/commit/4a2bc56d886578124b05060d3fb7eddc38c019f8/nixos-vm-facter-json/${system}.json"; - sha256 = - { - aarch64-linux = "sha256:1rlfymk03rmfkm2qgrc8l5kj5i20srx79n1y1h4nzlpwaz0j7hh2"; - x86_64-linux = "sha256:16myh0ll2gdwsiwkjw5ba4dl23ppwbsanxx214863j7nvzx42pws"; - } - .${system}; -} diff --git a/checks/installation/flake-module.nix b/checks/installation/flake-module.nix index 5cef1e428..db9b987e1 100644 --- a/checks/installation/flake-module.nix +++ b/checks/installation/flake-module.nix @@ -28,7 +28,7 @@ lib.map ( system: lib.nameValuePair "test-install-machine-${system}" { - facter.reportPath = import ./facter-report.nix system; + facter.reportPath = privateInputs.test-fixtures + /nixos-vm-facter-json/${system}.json; fileSystems."/".device = lib.mkDefault "/dev/vda"; boot.loader.grub.device = lib.mkDefault "/dev/vda"; @@ -151,7 +151,6 @@ let closureInfo = pkgs.closureInfo { rootPaths = [ - privateInputs.clan-core-for-checks self.nixosConfigurations."test-install-machine-${pkgs.hostPlatform.system}".config.system.build.toplevel self.nixosConfigurations."test-install-machine-${pkgs.hostPlatform.system}".config.system.build.initialRamdisk self.nixosConfigurations."test-install-machine-${pkgs.hostPlatform.system}".config.system.build.diskoScript @@ -160,7 +159,7 @@ pkgs.buildPackages.xorg.lndir ] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs) - ++ builtins.map (import ./facter-report.nix) (lib.filter (lib.hasSuffix "linux") config.systems); + ++ builtins.map (i: i.outPath) (builtins.attrValues privateInputs); }; in pkgs.lib.mkIf (pkgs.stdenv.isLinux && !pkgs.stdenv.isAarch64) { diff --git a/checks/morph/flake-module.nix b/checks/morph/flake-module.nix index 92a262867..f0d5fe9e4 100644 --- a/checks/morph/flake-module.nix +++ b/checks/morph/flake-module.nix @@ -1,6 +1,6 @@ { self, - config, + privateInputs, ... }: { @@ -30,7 +30,7 @@ nodes = { actual = - { pkgs, lib, ... }: + { pkgs, ... }: let dependencies = [ pkgs.stdenv.drvPath @@ -38,9 +38,7 @@ self.nixosConfigurations.test-morph-machine.config.system.build.toplevel ] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs) - ++ builtins.map (import ../installation/facter-report.nix) ( - lib.filter (lib.hasSuffix "linux") config.systems - ); + ++ builtins.map (i: i.outPath) (builtins.attrValues privateInputs); closureInfo = pkgs.closureInfo { rootPaths = dependencies; }; in diff --git a/checks/update/flake-module.nix b/checks/update/flake-module.nix index 33fb859f6..da638a642 100644 --- a/checks/update/flake-module.nix +++ b/checks/update/flake-module.nix @@ -1,4 +1,4 @@ -{ self, config, ... }: +{ self, privateInputs, ... }: { # Machine for update test clan.machines.test-update-machine = { @@ -105,7 +105,6 @@ perSystem = { pkgs, - lib, ... }: { @@ -125,9 +124,7 @@ pkgs.bubblewrap ] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs) - ++ builtins.map (import ../installation/facter-report.nix) ( - lib.filter (lib.hasSuffix "linux") config.systems - ); + ++ builtins.map (i: i.outPath) (builtins.attrValues privateInputs); }; in self.clanLib.test.containerTest { diff --git a/devFlake/flake.lock b/devFlake/flake.lock index e82cc03a1..e5087bed9 100644 --- a/devFlake/flake.lock +++ b/devFlake/flake.lock @@ -18,6 +18,27 @@ "url": "https://git.clan.lol/clan/clan-core" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "test-fixtures", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1741352980, + "narHash": "sha256-+u2UunDA4Cl5Fci3m7S643HzKmIDAe+fiXrLqYsR2fs=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f4330d22f1c5d2ba72d3d22df5597d123fdb60a9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": [ @@ -127,6 +148,7 @@ "nixpkgs-dev": "nixpkgs-dev", "nuschtos": "nuschtos", "systems": "systems_2", + "test-fixtures": "test-fixtures", "treefmt-nix": "treefmt-nix" } }, @@ -160,6 +182,27 @@ "type": "github" } }, + "test-fixtures": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs-dev" + ] + }, + "locked": { + "lastModified": 1742806412, + "narHash": "sha256-ZoAN0/sHEHY+ymJnkdkBAuZ/6sc66RYR4xMHpLf7++E=", + "ref": "refs/heads/main", + "rev": "4a2bc56d886578124b05060d3fb7eddc38c019f8", + "revCount": 2, + "type": "git", + "url": "https://git.clan.lol/clan/test-fixtures" + }, + "original": { + "type": "git", + "url": "https://git.clan.lol/clan/test-fixtures" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [] diff --git a/devFlake/flake.nix b/devFlake/flake.nix index dda6483d3..7d3ad5907 100644 --- a/devFlake/flake.nix +++ b/devFlake/flake.nix @@ -18,5 +18,8 @@ inputs.clan-core-for-checks.url = "git+https://git.clan.lol/clan/clan-core?ref=main&shallow=1"; inputs.clan-core-for-checks.flake = false; + inputs.test-fixtures.url = "git+https://git.clan.lol/clan/test-fixtures"; + inputs.test-fixtures.inputs.nixpkgs.follows = "nixpkgs-dev"; + outputs = inputs: inputs; } diff --git a/flake.nix b/flake.nix index d643309cf..6b88b7509 100644 --- a/flake.nix +++ b/flake.nix @@ -58,53 +58,57 @@ src = ./devFlake; }).outputs.inputs; in - flake-parts.lib.mkFlake { inherit inputs; } ( - { ... }: + flake-parts.lib.mkFlake { - _module.args = { + inherit inputs; + specialArgs = { inherit privateInputs; }; - clan = { - meta.name = "clan-core"; - inventory = { - machines = { - "test-darwin-machine" = { - machineClass = "darwin"; + } + ( + { ... }: + { + clan = { + meta.name = "clan-core"; + inventory = { + machines = { + "test-darwin-machine" = { + machineClass = "darwin"; + }; }; }; }; - }; - systems = import systems; - imports = [ - flake-parts.flakeModules.modules - ] - ++ - # only importing existing paths allows to minimize the flake for test - # by removing files - filter pathExists [ - ./checks/flake-module.nix - ./clanModules/flake-module.nix - ./clanServices/flake-module.nix - ./devShell.nix - ./docs/nix/flake-module.nix - ./flakeModules/demo_iso.nix - ./flakeModules/flake-module.nix - ./lib/filter-clan-core/flake-module.nix - ./lib/flake-module.nix - ./lib/flake-parts/clan-nixos-test.nix - ./nixosModules/clanCore/vars/flake-module.nix - ./nixosModules/flake-module.nix - ./pkgs/clan-cli/clan_cli/tests/flake-module.nix - ./pkgs/flake-module.nix - ./templates/flake-module.nix + systems = import systems; + imports = [ + flake-parts.flakeModules.modules ] - ++ [ - (if pathExists ./flakeModules/clan.nix then import ./flakeModules/clan.nix inputs.self else { }) - ] - # Make treefmt-nix optional - # This only works if you set inputs.clan-core.inputs.treefmt-nix.follows - # to a non-empty input that doesn't export a flakeModule - ++ optional (pathExists ./formatter.nix && inputs.treefmt-nix ? flakeModule) ./formatter.nix; - } - ); + ++ + # only importing existing paths allows to minimize the flake for test + # by removing files + filter pathExists [ + ./checks/flake-module.nix + ./clanModules/flake-module.nix + ./clanServices/flake-module.nix + ./devShell.nix + ./docs/nix/flake-module.nix + ./flakeModules/demo_iso.nix + ./flakeModules/flake-module.nix + ./lib/filter-clan-core/flake-module.nix + ./lib/flake-module.nix + ./lib/flake-parts/clan-nixos-test.nix + ./nixosModules/clanCore/vars/flake-module.nix + ./nixosModules/flake-module.nix + ./pkgs/clan-cli/clan_cli/tests/flake-module.nix + ./pkgs/flake-module.nix + ./templates/flake-module.nix + ] + ++ [ + (if pathExists ./flakeModules/clan.nix then import ./flakeModules/clan.nix inputs.self else { }) + ] + # Make treefmt-nix optional + # This only works if you set inputs.clan-core.inputs.treefmt-nix.follows + # to a non-empty input that doesn't export a flakeModule + ++ optional (pathExists ./formatter.nix && inputs.treefmt-nix ? flakeModule) ./formatter.nix; + } + ); } From 9d0cec1422273b020c196f840e959bc7dd5cf4ac Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sun, 5 Oct 2025 22:53:42 +0200 Subject: [PATCH 3/4] checks/installation: don't require `privateInputs` for eval --- checks/flash/flake-module.nix | 6 +----- checks/installation/flake-module.nix | 18 +++++++++++++----- checks/morph/flake-module.nix | 4 +--- checks/update/flake-module.nix | 5 ++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/checks/flash/flake-module.nix b/checks/flash/flake-module.nix index cec47a976..0d1e1a5fc 100644 --- a/checks/flash/flake-module.nix +++ b/checks/flash/flake-module.nix @@ -2,7 +2,6 @@ config, self, lib, - privateInputs, ... }: { @@ -14,8 +13,6 @@ fileSystems."/".device = lib.mkDefault "/dev/vda"; boot.loader.grub.device = lib.mkDefault "/dev/vda"; - # We need to use `mkForce` because we inherit from `test-install-machine` - # which currently hardcodes `nixpkgs.hostPlatform` nixpkgs.hostPlatform = lib.mkForce system; imports = [ self.nixosModules.test-flash-machine ]; @@ -69,8 +66,7 @@ self.nixosConfigurations."test-flash-machine-${pkgs.hostPlatform.system}".config.system.build.diskoScript self.nixosConfigurations."test-flash-machine-${pkgs.hostPlatform.system}".config.system.build.diskoScript.drvPath ] - ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs) - ++ builtins.map (i: i.outPath) (builtins.attrValues privateInputs); + ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs); closureInfo = pkgs.closureInfo { rootPaths = dependencies; }; in { diff --git a/checks/installation/flake-module.nix b/checks/installation/flake-module.nix index db9b987e1..dc7bcfa6b 100644 --- a/checks/installation/flake-module.nix +++ b/checks/installation/flake-module.nix @@ -28,12 +28,20 @@ lib.map ( system: lib.nameValuePair "test-install-machine-${system}" { - facter.reportPath = privateInputs.test-fixtures + /nixos-vm-facter-json/${system}.json; + imports = [ + self.nixosModules.test-install-machine-without-system + ( + if privateInputs ? test-fixtures then + { + facter.reportPath = privateInputs.test-fixtures + /nixos-vm-facter-json/${system}.json; + } + else + { nixpkgs.hostPlatform = system; } + ) + ]; fileSystems."/".device = lib.mkDefault "/dev/vda"; boot.loader.grub.device = lib.mkDefault "/dev/vda"; - - imports = [ self.nixosModules.test-install-machine-without-system ]; } ) (lib.filter (lib.hasSuffix "linux") config.systems) )); @@ -151,6 +159,7 @@ let closureInfo = pkgs.closureInfo { rootPaths = [ + privateInputs.clan-core-for-checks self.nixosConfigurations."test-install-machine-${pkgs.hostPlatform.system}".config.system.build.toplevel self.nixosConfigurations."test-install-machine-${pkgs.hostPlatform.system}".config.system.build.initialRamdisk self.nixosConfigurations."test-install-machine-${pkgs.hostPlatform.system}".config.system.build.diskoScript @@ -158,8 +167,7 @@ pkgs.bash.drvPath pkgs.buildPackages.xorg.lndir ] - ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs) - ++ builtins.map (i: i.outPath) (builtins.attrValues privateInputs); + ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs); }; in pkgs.lib.mkIf (pkgs.stdenv.isLinux && !pkgs.stdenv.isAarch64) { diff --git a/checks/morph/flake-module.nix b/checks/morph/flake-module.nix index f0d5fe9e4..cd8cfc4b0 100644 --- a/checks/morph/flake-module.nix +++ b/checks/morph/flake-module.nix @@ -1,6 +1,5 @@ { self, - privateInputs, ... }: { @@ -37,8 +36,7 @@ pkgs.stdenvNoCC self.nixosConfigurations.test-morph-machine.config.system.build.toplevel ] - ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs) - ++ builtins.map (i: i.outPath) (builtins.attrValues privateInputs); + ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs); closureInfo = pkgs.closureInfo { rootPaths = dependencies; }; in diff --git a/checks/update/flake-module.nix b/checks/update/flake-module.nix index da638a642..ddeef5c71 100644 --- a/checks/update/flake-module.nix +++ b/checks/update/flake-module.nix @@ -1,4 +1,4 @@ -{ self, privateInputs, ... }: +{ self, ... }: { # Machine for update test clan.machines.test-update-machine = { @@ -123,8 +123,7 @@ pkgs.buildPackages.xorg.lndir pkgs.bubblewrap ] - ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs) - ++ builtins.map (i: i.outPath) (builtins.attrValues privateInputs); + ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs); }; in self.clanLib.test.containerTest { From 3295e1561ddaadbb27d34b819f3164e67f4a7a27 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sun, 5 Oct 2025 23:43:52 +0200 Subject: [PATCH 4/4] checks: use new `clan-core-for-checks` to fix tests I manually updated `flake.lock` and then evaluated the flake input to get the correct NAR hash and last modified time. --- devFlake/flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/devFlake/flake.lock b/devFlake/flake.lock index e5087bed9..73305e5bf 100644 --- a/devFlake/flake.lock +++ b/devFlake/flake.lock @@ -3,10 +3,10 @@ "clan-core-for-checks": { "flake": false, "locked": { - "lastModified": 1759676877, - "narHash": "sha256-HNkfhYUo3QyzepUq+bb4oASNcA8bTQABG6N4jimF/c0=", + "lastModified": 1759699593, + "narHash": "sha256-6J/iZFJ3nv5ciioISitb8DK32aQmRQV7dfpR8mO7+6Y=", "ref": "main", - "rev": "b681737dceae23c8f241d34700211e85c5ed216b", + "rev": "9d0cec1422273b020c196f840e959bc7dd5cf4ac", "shallow": true, "type": "git", "url": "https://git.clan.lol/clan/clan-core"