From c342942f41ef0999d781d6b2f0931438f5ae83e2 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 21 Jun 2024 17:00:44 +0200 Subject: [PATCH] inventory: rename clan.services --- clanModules/borgbackup/roles/client.nix | 2 +- clanModules/borgbackup/roles/server.nix | 6 +++--- inventory/README.md | 6 ++++-- inventory/default.nix | 5 +++-- nixosModules/clanCore/inventory/interface.nix | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/clanModules/borgbackup/roles/client.nix b/clanModules/borgbackup/roles/client.nix index 661cb4f3..182e0dc0 100644 --- a/clanModules/borgbackup/roles/client.nix +++ b/clanModules/borgbackup/roles/client.nix @@ -1,6 +1,6 @@ { config, lib, ... }: let - instances = config.clan.inventory.borgbackup; + instances = config.clan.services.borgbackup; # roles = { ${role_name} :: { machines :: [string] } } allServers = lib.foldlAttrs ( acc: _instanceName: instanceConfig: diff --git a/clanModules/borgbackup/roles/server.nix b/clanModules/borgbackup/roles/server.nix index c25230da..24d18047 100644 --- a/clanModules/borgbackup/roles/server.nix +++ b/clanModules/borgbackup/roles/server.nix @@ -3,7 +3,8 @@ let clanDir = config.clan.core.clanDir; machineDir = clanDir + "/machines/"; inherit (config.clan.core) machineName; - instances = config.clan.inventory.borgbackup; + + instances = config.clan.services.borgbackup; # roles = { ${role_name} :: { machines :: [string] } } allClients = lib.foldlAttrs ( @@ -20,7 +21,6 @@ in { config.services.borgbackup.repos = let - filteredMachines = allClients; borgbackupIpMachinePath = machines: machineDir + machines + "/facts/borgbackup.ssh.pub"; machinesMaybeKey = builtins.map ( @@ -29,7 +29,7 @@ in fullPath = borgbackupIpMachinePath machine; in if builtins.pathExists fullPath then machine else null - ) filteredMachines; + ) allClients; machinesWithKey = lib.filter (x: x != null) machinesMaybeKey; diff --git a/inventory/README.md b/inventory/README.md index effdfc0e..89a1b1e5 100644 --- a/inventory/README.md +++ b/inventory/README.md @@ -47,10 +47,12 @@ Architecture ``` nixosConfig < machine_module < inventory --------------------------------------------- -nixos < borgbackup + borgbackup-static > UI +nixos < borgbackup <- inventory <-> UI creates the config Maps from high level services to the borgbackup clan module - for ONE machine + for ONE machine Inventory is completely serializable. + UI can interact with the inventory to define machines, and services + Defining Users is out of scope for the first prototype. ``` - [ ] Why do we need 2 modules? diff --git a/inventory/default.nix b/inventory/default.nix index 8d8e9c8e..f55d01d1 100644 --- a/inventory/default.nix +++ b/inventory/default.nix @@ -92,7 +92,7 @@ let ]; } { - config.clan.inventory.${moduleName}.${instanceName} = { + config.clan.services.${moduleName}.${instanceName} = { roles = resolvedRoles; # inherit inverseRoles; }; @@ -107,7 +107,8 @@ in { inherit clan-core; - new_clan = clan-core.lib.buildInventory { + # Extension of the build clan interface + new_clan = clan-core.lib.buildClan { # High level services. # If you need multiple instances of a service configure them via: # inventory.services.[serviceName].[instanceName] = ... diff --git a/nixosModules/clanCore/inventory/interface.nix b/nixosModules/clanCore/inventory/interface.nix index 7280b560..0e3b99b0 100644 --- a/nixosModules/clanCore/inventory/interface.nix +++ b/nixosModules/clanCore/inventory/interface.nix @@ -30,7 +30,7 @@ let in { # clan.inventory.${moduleName}.${instanceName} = { ... } - options.clan.inventory = lib.mkOption { + options.clan.services = lib.mkOption { type = lib.types.attrsOf (lib.types.attrsOf instanceOptions); }; }