Inventory: extend model by deployment info
This commit is contained in:
@@ -30,6 +30,15 @@ let
|
||||
# - Machines that exist in the machines directory
|
||||
# Checks on the module level:
|
||||
# - Each service role must reference a valid machine after all machines are merged
|
||||
|
||||
clanToInventory =
|
||||
config:
|
||||
{ clanPath, inventoryPath }:
|
||||
let
|
||||
v = lib.attrByPath clanPath null config;
|
||||
in
|
||||
lib.optionalAttrs (v != null) (lib.setAttrByPath inventoryPath v);
|
||||
|
||||
mergedInventory =
|
||||
(lib.evalModules {
|
||||
modules = [
|
||||
@@ -63,23 +72,36 @@ let
|
||||
"name"
|
||||
] name config
|
||||
);
|
||||
tags = lib.attrByPath [
|
||||
}
|
||||
# tags
|
||||
// (clanToInventory config {
|
||||
clanPath = [
|
||||
"clan"
|
||||
"tags"
|
||||
] [ ] config;
|
||||
|
||||
system = lib.attrByPath [
|
||||
];
|
||||
inventoryPath = [ "tags" ];
|
||||
})
|
||||
# system
|
||||
// (clanToInventory config {
|
||||
clanPath = [
|
||||
"nixpkgs"
|
||||
"hostSystem"
|
||||
] null config;
|
||||
|
||||
deploymentInfo.targetHost = lib.attrByPath [
|
||||
];
|
||||
inventoryPath = [ "system" ];
|
||||
})
|
||||
# deploymentInfo.targetHost
|
||||
// (clanToInventory config {
|
||||
clanPath = [
|
||||
"clan"
|
||||
"core"
|
||||
"networking"
|
||||
"targetHost"
|
||||
] null config;
|
||||
}
|
||||
];
|
||||
inventoryPath = [
|
||||
"deploymentInfo"
|
||||
"targetHost"
|
||||
];
|
||||
})
|
||||
) machines;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,9 @@ let
|
||||
(lib.optionalAttrs (machineConfig.system or null != null) {
|
||||
config.nixpkgs.hostPlatform = machineConfig.system;
|
||||
})
|
||||
(lib.optionalAttrs (machineConfig.deploymentInfo.targetHost or null != null) {
|
||||
config.clan.core.networking.targetHost = machineConfig.deploymentInfo.targetHost;
|
||||
})
|
||||
]
|
||||
) inventory.machines or { };
|
||||
in
|
||||
|
||||
Reference in New Issue
Block a user