update clanlib.nix
This commit is contained in:
parent
b8cf22c653
commit
5574cf652d
3 changed files with 27 additions and 10 deletions
|
@ -196,13 +196,10 @@
|
|||
# Statically configure the host names of machines based on their respective zerotier-ip.
|
||||
inputs.clan-core.clanModules.static-hosts
|
||||
# generate ssh host keys with facts
|
||||
# fixme: not working
|
||||
inputs.clan-core.clanModules.sshd
|
||||
];
|
||||
documentation.nixos.enable = true;
|
||||
clan.static-hosts.topLevelDomain = "bear";
|
||||
|
||||
#clan.static-hosts.excludeHosts = lib.mkForce [ ];
|
||||
environment.systemPackages = [
|
||||
clan-core.packages.${pkgs.system}.clan-cli
|
||||
];
|
||||
|
@ -234,6 +231,7 @@
|
|||
nix.settings.max-jobs = 1;
|
||||
# no channesl needed this way
|
||||
nix.nixPath = [ "nixpkgs=${pkgs.path}" ];
|
||||
documentation.nixos.enable = true;
|
||||
})
|
||||
# some modules I always use
|
||||
permown.nixosModules.permown
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
let
|
||||
syncthingPub = clanLib.readFact "syncthing.pub";
|
||||
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
|
||||
with lib; {
|
||||
|
||||
|
@ -40,12 +48,7 @@ with lib; {
|
|||
};
|
||||
};
|
||||
in
|
||||
{ }
|
||||
|
||||
// (zeroDevice "orbi")
|
||||
// (zeroDevice "cream")
|
||||
// (zeroDevice "cherry")
|
||||
// (zeroDevice "chungus")
|
||||
clanMachines
|
||||
|
||||
#// (device "mobi" )
|
||||
#// (device "bobi" )
|
||||
|
|
|
@ -15,6 +15,7 @@ let
|
|||
else
|
||||
null;
|
||||
|
||||
# machine -> factvalue
|
||||
readFactFromAllMachines = fact:
|
||||
let
|
||||
machines = allMachineNames;
|
||||
|
@ -23,5 +24,20 @@ let
|
|||
in
|
||||
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
|
||||
{ inherit allMachineNames getFactPath readFact readFactFromAllMachines; }
|
||||
{ inherit allMachineNames getFactPath readFact readFactFromAllMachines readFactsFromAllMachines; }
|
||||
|
|
Loading…
Reference in a new issue