update clanlib.nix

This commit is contained in:
Ingolf Wagner 2024-06-07 07:54:43 +02:00
parent b8cf22c653
commit 5574cf652d
Signed by: palo
GPG key ID: 76BF5F1928B9618B
3 changed files with 27 additions and 10 deletions

View file

@ -196,13 +196,10 @@
# Statically configure the host names of machines based on their respective zerotier-ip. # Statically configure the host names of machines based on their respective zerotier-ip.
inputs.clan-core.clanModules.static-hosts inputs.clan-core.clanModules.static-hosts
# generate ssh host keys with facts # generate ssh host keys with facts
# fixme: not working
inputs.clan-core.clanModules.sshd inputs.clan-core.clanModules.sshd
]; ];
documentation.nixos.enable = true;
clan.static-hosts.topLevelDomain = "bear"; clan.static-hosts.topLevelDomain = "bear";
#clan.static-hosts.excludeHosts = lib.mkForce [ ];
environment.systemPackages = [ environment.systemPackages = [
clan-core.packages.${pkgs.system}.clan-cli clan-core.packages.${pkgs.system}.clan-cli
]; ];
@ -234,6 +231,7 @@
nix.settings.max-jobs = 1; nix.settings.max-jobs = 1;
# no channesl needed this way # no channesl needed this way
nix.nixPath = [ "nixpkgs=${pkgs.path}" ]; nix.nixPath = [ "nixpkgs=${pkgs.path}" ];
documentation.nixos.enable = true;
}) })
# some modules I always use # some modules I always use
permown.nixosModules.permown permown.nixosModules.permown

View file

@ -2,6 +2,14 @@
let let
syncthingPub = clanLib.readFact "syncthing.pub"; syncthingPub = clanLib.readFact "syncthing.pub";
zerotierIp = clanLib.readFact "zerotier-ip"; zerotierIp = clanLib.readFact "zerotier-ip";
clanMachines =
lib.mapAttrs
(machine: facts: {
name = machine;
id = facts."syncthing.pub";
addresses = [ "tcp://[${facts."zerotier-ip"}]:22000" ];
})
(clanLib.readFactsFromAllMachines [ "syncthing.pub" "zerotier-ip" ]);
in in
with lib; { with lib; {
@ -40,12 +48,7 @@ with lib; {
}; };
}; };
in in
{ } clanMachines
// (zeroDevice "orbi")
// (zeroDevice "cream")
// (zeroDevice "cherry")
// (zeroDevice "chungus")
#// (device "mobi" ) #// (device "mobi" )
#// (device "bobi" ) #// (device "bobi" )

View file

@ -15,6 +15,7 @@ let
else else
null; null;
# machine -> factvalue
readFactFromAllMachines = fact: readFactFromAllMachines = fact:
let let
machines = allMachineNames; machines = allMachineNames;
@ -23,5 +24,20 @@ let
in in
filteredFacts; filteredFacts;
# returns an Attrs of machines and it's facts which have all given facts set.
# machine -> fact -> value
readFactsFromAllMachines = facts:
let
# machine -> fact -> factvalue
machinesFactsAttrs = lib.genAttrs allMachineNames (machine: lib.genAttrs facts (fact: readFact fact machine));
# remove all machines which don't have all facts set
filteredMachineFactAttrs =
lib.filterAttrs (_machine: values: builtins.all (fact: values.${fact} != null) facts)
machinesFactsAttrs;
in
filteredMachineFactAttrs;
in in
{ inherit allMachineNames getFactPath readFact readFactFromAllMachines; } { inherit allMachineNames getFactPath readFact readFactFromAllMachines readFactsFromAllMachines; }