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.
|
# 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
|
||||||
|
|
|
@ -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" )
|
||||||
|
|
|
@ -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; }
|
||||||
|
|
Loading…
Reference in a new issue