inventory: make resolve module a clanLib function

Unclutter inventory logic
This commit is contained in:
Johannes Kirschbauer
2025-09-16 13:09:56 +02:00
parent 0bce953c2f
commit f49df8d574
7 changed files with 70 additions and 31 deletions

View File

@@ -4,6 +4,9 @@
self,
...
}:
let
inputOverrides = self.clanLib.flake-inputs.getOverrides inputs;
in
rec {
# TODO: automatically generate this from the directory conventions
imports = [
@@ -19,4 +22,47 @@ rec {
};
# TODO: remove this legacy alias
flake.lib = flake.clanLib;
perSystem =
{
pkgs,
lib,
system,
...
}:
let
# Common filtered source for module tests
inventoryTestsSrc = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.unions [
../flake.nix
../flake.lock
../lib
(lib.fileset.fileFilter (file: file.name == "flake-module.nix") ../.)
../flakeModules
# ../../nixosModules/clanCore
# ../../machines
# ../../inventory.json
];
};
in
{
legacyPackages.eval-tests-resolve-module = import ./resolve-module/test.nix {
inherit lib;
};
checks = {
eval-lib-resolve-module = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
export HOME="$(realpath .)"
nix-unit --eval-store "$HOME" \
--extra-experimental-features flakes \
--show-trace \
${inputOverrides} \
--flake ${inventoryTestsSrc}#legacyPackages.${system}.eval-tests-resolve-module
touch $out
'';
};
};
}