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; };
|
inventoryFile = lib.mkOption { type = lib.types.raw; };
|
||||||
# The machine 'imports' generated by the inventory per machine
|
# The machine 'imports' generated by the inventory per machine
|
||||||
inventoryClass = lib.mkOption { type = lib.types.raw; };
|
inventoryClass = lib.mkOption { type = lib.types.raw; };
|
||||||
# new attribute
|
|
||||||
distributedServices = lib.mkOption { type = lib.types.raw; };
|
|
||||||
# clan-core's modules
|
# clan-core's modules
|
||||||
clanModules = lib.mkOption { type = lib.types.raw; };
|
clanModules = lib.mkOption { type = lib.types.raw; };
|
||||||
source = lib.mkOption { type = lib.types.raw; };
|
source = lib.mkOption { type = lib.types.raw; };
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ let
|
|||||||
inventoryClass = (
|
inventoryClass = (
|
||||||
buildInventory {
|
buildInventory {
|
||||||
inherit inventory directory;
|
inherit inventory directory;
|
||||||
|
flakeInputs = config.self.inputs;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -76,19 +77,16 @@ let
|
|||||||
clan-core.nixosModules.clanCore
|
clan-core.nixosModules.clanCore
|
||||||
extraConfig
|
extraConfig
|
||||||
(machines.${name} or { })
|
(machines.${name} or { })
|
||||||
# Inherit the inventory assertions ?
|
|
||||||
# { inherit (mergedInventory) assertions; }
|
|
||||||
{ imports = inventoryClass.machines.${name}.machineImports or [ ]; }
|
{ imports = inventoryClass.machines.${name}.machineImports or [ ]; }
|
||||||
|
|
||||||
# Import the distribute services
|
|
||||||
{ imports = config.clanInternals.distributedServices.allMachines.${name} or [ ]; }
|
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
# Settings
|
# Settings
|
||||||
clan.core.settings = {
|
clan.core.settings = {
|
||||||
inherit directory;
|
|
||||||
inherit (config.inventory.meta) name icon;
|
inherit (config.inventory.meta) name icon;
|
||||||
|
|
||||||
|
inherit directory;
|
||||||
machine = {
|
machine = {
|
||||||
inherit name;
|
inherit name;
|
||||||
};
|
};
|
||||||
@@ -254,12 +252,14 @@ in
|
|||||||
inherit darwinConfigurations;
|
inherit darwinConfigurations;
|
||||||
|
|
||||||
clanInternals = {
|
clanInternals = {
|
||||||
moduleSchemas = clan-core.clanLib.modules.getModulesSchema config.inventory.modules;
|
moduleSchemas = clan-core.clanLib.modules.getModulesSchema {
|
||||||
inherit inventoryClass;
|
modules = config.inventory.modules;
|
||||||
distributedServices = clan-core.clanLib.inventory.mapInstances {
|
# TODO: make this function system agnostic
|
||||||
inherit inventory;
|
pkgs = nixpkgs.legacyPackages."x86_64-linux";
|
||||||
flakeInputs = config.self.inputs;
|
inherit clan-core;
|
||||||
};
|
};
|
||||||
|
inherit inventoryClass;
|
||||||
|
|
||||||
# TODO: unify this interface
|
# TODO: unify this interface
|
||||||
# We should have only clan.modules. (consistent with clan.templates)
|
# We should have only clan.modules. (consistent with clan.templates)
|
||||||
inherit (clan-core) clanModules clanLib;
|
inherit (clan-core) clanModules clanLib;
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ in
|
|||||||
directory = mkOption {
|
directory = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
};
|
};
|
||||||
|
distributedServices = mkOption {
|
||||||
|
type = types.raw;
|
||||||
|
};
|
||||||
inventory = mkOption {
|
inventory = mkOption {
|
||||||
type = types.raw;
|
type = types.raw;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ let
|
|||||||
machinesFromInventory :: Inventory -> { ${machine_name} :: NixOSConfiguration }
|
machinesFromInventory :: Inventory -> { ${machine_name} :: NixOSConfiguration }
|
||||||
*/
|
*/
|
||||||
buildInventory =
|
buildInventory =
|
||||||
{ inventory, directory }:
|
{
|
||||||
|
inventory,
|
||||||
|
directory,
|
||||||
|
flakeInputs,
|
||||||
|
}:
|
||||||
(lib.evalModules {
|
(lib.evalModules {
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit clanLib;
|
inherit clanLib;
|
||||||
@@ -16,6 +20,19 @@ let
|
|||||||
modules = [
|
modules = [
|
||||||
./builder
|
./builder
|
||||||
{ inherit directory inventory; }
|
{ 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;
|
}).config;
|
||||||
in
|
in
|
||||||
|
|||||||
Reference in New Issue
Block a user