feat(buildInventory): move instance resolution into buildInventory
Such that buildClan doesn't have to compose the results buildInventory should be more self contained. But it is NOT meant a public API! use buildClan argument 'inventory' instead
This commit is contained in:
@@ -162,8 +162,6 @@ in
|
||||
inventoryFile = lib.mkOption { type = lib.types.raw; };
|
||||
# The machine 'imports' generated by the inventory per machine
|
||||
inventoryClass = lib.mkOption { type = lib.types.raw; };
|
||||
# new attribute
|
||||
distributedServices = lib.mkOption { type = lib.types.raw; };
|
||||
# clan-core's modules
|
||||
clanModules = lib.mkOption { type = lib.types.raw; };
|
||||
source = lib.mkOption { type = lib.types.raw; };
|
||||
|
||||
@@ -46,6 +46,7 @@ let
|
||||
inventoryClass = (
|
||||
buildInventory {
|
||||
inherit inventory directory;
|
||||
flakeInputs = config.self.inputs;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -76,19 +77,16 @@ let
|
||||
clan-core.nixosModules.clanCore
|
||||
extraConfig
|
||||
(machines.${name} or { })
|
||||
# Inherit the inventory assertions ?
|
||||
# { inherit (mergedInventory) assertions; }
|
||||
|
||||
{ imports = inventoryClass.machines.${name}.machineImports or [ ]; }
|
||||
|
||||
# Import the distribute services
|
||||
{ imports = config.clanInternals.distributedServices.allMachines.${name} or [ ]; }
|
||||
(
|
||||
{
|
||||
# Settings
|
||||
clan.core.settings = {
|
||||
inherit directory;
|
||||
inherit (config.inventory.meta) name icon;
|
||||
|
||||
inherit directory;
|
||||
machine = {
|
||||
inherit name;
|
||||
};
|
||||
@@ -254,12 +252,14 @@ in
|
||||
inherit darwinConfigurations;
|
||||
|
||||
clanInternals = {
|
||||
moduleSchemas = clan-core.clanLib.modules.getModulesSchema config.inventory.modules;
|
||||
inherit inventoryClass;
|
||||
distributedServices = clan-core.clanLib.inventory.mapInstances {
|
||||
inherit inventory;
|
||||
flakeInputs = config.self.inputs;
|
||||
moduleSchemas = clan-core.clanLib.modules.getModulesSchema {
|
||||
modules = config.inventory.modules;
|
||||
# TODO: make this function system agnostic
|
||||
pkgs = nixpkgs.legacyPackages."x86_64-linux";
|
||||
inherit clan-core;
|
||||
};
|
||||
inherit inventoryClass;
|
||||
|
||||
# TODO: unify this interface
|
||||
# We should have only clan.modules. (consistent with clan.templates)
|
||||
inherit (clan-core) clanModules clanLib;
|
||||
|
||||
@@ -9,6 +9,9 @@ in
|
||||
directory = mkOption {
|
||||
type = types.path;
|
||||
};
|
||||
distributedServices = mkOption {
|
||||
type = types.raw;
|
||||
};
|
||||
inventory = mkOption {
|
||||
type = types.raw;
|
||||
};
|
||||
|
||||
@@ -8,7 +8,11 @@ let
|
||||
machinesFromInventory :: Inventory -> { ${machine_name} :: NixOSConfiguration }
|
||||
*/
|
||||
buildInventory =
|
||||
{ inventory, directory }:
|
||||
{
|
||||
inventory,
|
||||
directory,
|
||||
flakeInputs,
|
||||
}:
|
||||
(lib.evalModules {
|
||||
specialArgs = {
|
||||
inherit clanLib;
|
||||
@@ -16,6 +20,19 @@ let
|
||||
modules = [
|
||||
./builder
|
||||
{ inherit directory inventory; }
|
||||
(
|
||||
# config.distributedServices.allMachines.${name} or [ ];
|
||||
{ config, ... }:
|
||||
{
|
||||
distributedServices = clanLib.inventory.mapInstances {
|
||||
inherit (config) inventory;
|
||||
inherit flakeInputs;
|
||||
};
|
||||
machines = lib.mapAttrs (machineName: v: {
|
||||
machineImports = v;
|
||||
}) config.distributedServices.allMachines;
|
||||
}
|
||||
)
|
||||
];
|
||||
}).config;
|
||||
in
|
||||
|
||||
Reference in New Issue
Block a user