feat(lib/inventory): use clanLib instead of clan-core as internal specialArg. This has the benefit of beeing more narrow scoped.

This commit is contained in:
Johannes Kirschbauer
2025-03-30 16:41:03 +02:00
parent 06dd2ebf8c
commit f2e89d27fe
7 changed files with 14 additions and 18 deletions

View File

@@ -24,12 +24,9 @@ lib.fix (clanLib: {
inherit lib nixpkgs;
clan-core = self;
};
inventory = import ./inventory {
inherit lib;
clan-core = self;
};
# ------------------------------------
# Lib functions that don't depend on 'self'
inventory = clanLib.callLib ./inventory { };
modules = clanLib.callLib ./frontmatter { };
facts = import ./facts.nix { inherit lib; };
values = import ./values { inherit lib; };

View File

@@ -1,7 +1,7 @@
{
lib,
config,
clan-core,
clanLib,
...
}:
let
@@ -43,8 +43,7 @@ let
checkService =
modulepath: serviceName:
builtins.elem "inventory"
(clan-core.lib.modules.getFrontmatter modulepath serviceName).features or [ ];
builtins.elem "inventory" (clanLib.modules.getFrontmatter modulepath serviceName).features or [ ];
compileMachine =
{ machineConfig }:
@@ -160,7 +159,7 @@ in
inherit
resolveTags
inventory
clan-core
clanLib
machineName
serviceConfigs
;

View File

@@ -3,7 +3,7 @@
config,
resolveTags,
inventory,
clan-core,
clanLib,
machineName,
serviceConfigs,
...
@@ -14,7 +14,7 @@ in
{
# Roles resolution
# : List String
supportedRoles = clan-core.lib.modules.getRoles inventory.modules serviceName;
supportedRoles = clanLib.modules.getRoles inventory.modules serviceName;
matchedRoles = builtins.attrNames (
lib.filterAttrs (_: ms: builtins.elem machineName ms) config.machinesRoles
);
@@ -56,7 +56,7 @@ in
assertions = lib.concatMapAttrs (
instanceName: resolvedRoles:
clan-core.lib.modules.checkConstraints {
clanLib.modules.checkConstraints {
moduleName = serviceName;
allModules = inventory.modules;
inherit resolvedRoles instanceName;

View File

@@ -1,6 +1,6 @@
# Generate partial NixOS configurations for every machine in the inventory
# This function is responsible for generating the module configuration for every machine in the inventory.
{ lib, clan-core }:
{ lib, clanLib }:
let
/*
Returns a set with NixOS configuration for every machine in the inventory.
@@ -11,7 +11,7 @@ let
{ inventory, directory }:
(lib.evalModules {
specialArgs = {
inherit clan-core;
inherit clanLib;
};
modules = [
./builder

View File

@@ -1,5 +1,5 @@
{ lib, clan-core }:
{ lib, clanLib }:
{
inherit (import ./build-inventory { inherit lib clan-core; }) buildInventory;
inherit (import ./build-inventory { inherit lib clanLib; }) buildInventory;
interface = ./build-inventory/interface.nix;
}

View File

@@ -2,7 +2,8 @@
let
inventory = (
import ../build-inventory {
inherit lib clan-core;
inherit lib;
clanLib = clan-core.clanLib;
}
);
inherit (inventory) buildInventory;

View File

@@ -1,10 +1,9 @@
{
lib,
config,
clan-core,
...
}:
{
# Just some random stuff
config.user.user = lib.mapAttrs clan-core.users.root;
options.test = lib.mapAttrs clan-core;
}