inventory: rename clan.services
All checks were successful
checks / checks-impure (pull_request) Successful in 2m39s
buildbot/nix-eval Build done.

This commit is contained in:
Johannes Kirschbauer 2024-06-21 17:00:44 +02:00
parent 074058dbe1
commit c342942f41
Signed by: hsjobeki
SSH Key Fingerprint: SHA256:vX3utDqig7Ph5L0JPv87ZTPb/w7cMzREKVZzzLFg9qU
5 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{ config, lib, ... }: { config, lib, ... }:
let let
instances = config.clan.inventory.borgbackup; instances = config.clan.services.borgbackup;
# roles = { ${role_name} :: { machines :: [string] } } # roles = { ${role_name} :: { machines :: [string] } }
allServers = lib.foldlAttrs ( allServers = lib.foldlAttrs (
acc: _instanceName: instanceConfig: acc: _instanceName: instanceConfig:

View File

@ -3,7 +3,8 @@ let
clanDir = config.clan.core.clanDir; clanDir = config.clan.core.clanDir;
machineDir = clanDir + "/machines/"; machineDir = clanDir + "/machines/";
inherit (config.clan.core) machineName; inherit (config.clan.core) machineName;
instances = config.clan.inventory.borgbackup;
instances = config.clan.services.borgbackup;
# roles = { ${role_name} :: { machines :: [string] } } # roles = { ${role_name} :: { machines :: [string] } }
allClients = lib.foldlAttrs ( allClients = lib.foldlAttrs (
@ -20,7 +21,6 @@ in
{ {
config.services.borgbackup.repos = config.services.borgbackup.repos =
let let
filteredMachines = allClients;
borgbackupIpMachinePath = machines: machineDir + machines + "/facts/borgbackup.ssh.pub"; borgbackupIpMachinePath = machines: machineDir + machines + "/facts/borgbackup.ssh.pub";
machinesMaybeKey = builtins.map ( machinesMaybeKey = builtins.map (
@ -29,7 +29,7 @@ in
fullPath = borgbackupIpMachinePath machine; fullPath = borgbackupIpMachinePath machine;
in in
if builtins.pathExists fullPath then machine else null if builtins.pathExists fullPath then machine else null
) filteredMachines; ) allClients;
machinesWithKey = lib.filter (x: x != null) machinesMaybeKey; machinesWithKey = lib.filter (x: x != null) machinesMaybeKey;

View File

@ -47,10 +47,12 @@ Architecture
``` ```
nixosConfig < machine_module < inventory 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 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? - [ ] Why do we need 2 modules?

View File

@ -92,7 +92,7 @@ let
]; ];
} }
{ {
config.clan.inventory.${moduleName}.${instanceName} = { config.clan.services.${moduleName}.${instanceName} = {
roles = resolvedRoles; roles = resolvedRoles;
# inherit inverseRoles; # inherit inverseRoles;
}; };
@ -107,7 +107,8 @@ in
{ {
inherit clan-core; inherit clan-core;
new_clan = clan-core.lib.buildInventory { # Extension of the build clan interface
new_clan = clan-core.lib.buildClan {
# High level services. # High level services.
# If you need multiple instances of a service configure them via: # If you need multiple instances of a service configure them via:
# inventory.services.[serviceName].[instanceName] = ... # inventory.services.[serviceName].[instanceName] = ...

View File

@ -30,7 +30,7 @@ let
in in
{ {
# clan.inventory.${moduleName}.${instanceName} = { ... } # clan.inventory.${moduleName}.${instanceName} = { ... }
options.clan.inventory = lib.mkOption { options.clan.services = lib.mkOption {
type = lib.types.attrsOf (lib.types.attrsOf instanceOptions); type = lib.types.attrsOf (lib.types.attrsOf instanceOptions);
}; };
} }