Inventory: fix options

This commit is contained in:
Johannes Kirschbauer
2024-07-17 10:55:46 +02:00
parent ef18d60286
commit 0bfba72739
5 changed files with 10 additions and 10 deletions

View File

@@ -11,8 +11,8 @@
"icon": "./path/to/icon.png", "icon": "./path/to/icon.png",
"tags": ["1", "2", "3"], "tags": ["1", "2", "3"],
"system": "x86_64-linux", "system": "x86_64-linux",
"deployment_info": { "deploy": {
"target_host": "root@remote.com" "targetHost": "root@remote.com"
} }
} }
}, },

View File

@@ -89,7 +89,7 @@ let
]; ];
inventoryPath = [ "system" ]; inventoryPath = [ "system" ];
}) })
# deploymentInfo.targetHost # deploy.targetHost
// (clanToInventory config { // (clanToInventory config {
clanPath = [ clanPath = [
"clan" "clan"
@@ -98,7 +98,7 @@ let
"targetHost" "targetHost"
]; ];
inventoryPath = [ inventoryPath = [
"deploymentInfo" "deploy"
"targetHost" "targetHost"
]; ];
}) })

View File

@@ -148,8 +148,8 @@ let
(lib.optionalAttrs (machineConfig.system or null != null) { (lib.optionalAttrs (machineConfig.system or null != null) {
config.nixpkgs.hostPlatform = machineConfig.system; config.nixpkgs.hostPlatform = machineConfig.system;
}) })
(lib.optionalAttrs (machineConfig.deploymentInfo.targetHost or null != null) { (lib.optionalAttrs (machineConfig.deploy.targetHost or null != null) {
config.clan.core.networking.targetHost = machineConfig.deploymentInfo.targetHost; config.clan.core.networking.targetHost = machineConfig.deploy.targetHost;
}) })
] ]
) inventory.machines or { }; ) inventory.machines or { };

View File

@@ -49,7 +49,7 @@ in
default = null; default = null;
type = types.nullOr types.str; type = types.nullOr types.str;
}; };
deploymentInfo = lib.mkOption { deploy = lib.mkOption {
default = { }; default = { };
type = types.submodule { type = types.submodule {
options = { options = {

View File

@@ -63,7 +63,7 @@ class Machine:
tags: list[str] = field(default_factory=list) tags: list[str] = field(default_factory=list)
system: Literal["x86_64-linux"] | str | None = None system: Literal["x86_64-linux"] | str | None = None
deployment_info: DeploymentInfo | None = None deploy: DeploymentInfo | None = None
@staticmethod @staticmethod
def from_dict(d: dict[str, Any]) -> "Machine": def from_dict(d: dict[str, Any]) -> "Machine":
@@ -73,8 +73,8 @@ class Machine:
icon=d.get("icon", None), icon=d.get("icon", None),
tags=d.get("tags", []), tags=d.get("tags", []),
system=d.get("system", None), system=d.get("system", None),
deployment_info=DeploymentInfo( deploy=DeploymentInfo(
target_host=d.get("deploymentInfo", {}).get("targetHost", None) target_host=d.get("deploy", {}).get("targetHost", None)
), ),
) )