zerotier: fix eval if meshname is not known yet
This commit is contained in:
parent
fdfe02fb77
commit
2306b2ec50
@ -1,7 +1,7 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.clan.networking.zerotier;
|
cfg = config.clan.networking.zerotier;
|
||||||
facts = config.clanCore.secrets.zerotier.facts;
|
facts = config.clanCore.secrets.zerotier.facts or { };
|
||||||
networkConfig = {
|
networkConfig = {
|
||||||
authTokens = [
|
authTokens = [
|
||||||
null
|
null
|
||||||
@ -56,7 +56,9 @@ in
|
|||||||
type = lib.types.nullOr lib.types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default =
|
default =
|
||||||
if cfg.networkId != null then
|
if cfg.networkId == null then
|
||||||
|
null
|
||||||
|
else
|
||||||
let
|
let
|
||||||
part0 = builtins.substring 0 2 cfg.networkId;
|
part0 = builtins.substring 0 2 cfg.networkId;
|
||||||
part1 = builtins.substring 2 2 cfg.networkId;
|
part1 = builtins.substring 2 2 cfg.networkId;
|
||||||
@ -67,9 +69,7 @@ in
|
|||||||
part6 = builtins.substring 12 2 cfg.networkId;
|
part6 = builtins.substring 12 2 cfg.networkId;
|
||||||
part7 = builtins.substring 14 2 cfg.networkId;
|
part7 = builtins.substring 14 2 cfg.networkId;
|
||||||
in
|
in
|
||||||
"fd${part0}:${part1}${part2}:${part3}${part4}:${part5}${part6}:${part7}99:9300::/88"
|
"fd${part0}:${part1}${part2}:${part3}${part4}:${part5}${part6}:${part7}99:9300::/88";
|
||||||
else
|
|
||||||
null;
|
|
||||||
description = ''
|
description = ''
|
||||||
zerotier subnet
|
zerotier subnet
|
||||||
'';
|
'';
|
||||||
@ -91,9 +91,10 @@ in
|
|||||||
# having to re-import nixpkgs.
|
# having to re-import nixpkgs.
|
||||||
services.zerotierone.package = lib.mkDefault (pkgs.zerotierone.overrideAttrs (_old: { meta = { }; }));
|
services.zerotierone.package = lib.mkDefault (pkgs.zerotierone.overrideAttrs (_old: { meta = { }; }));
|
||||||
})
|
})
|
||||||
(lib.mkIf (cfg.networkId != null) {
|
(lib.mkIf (facts ? zerotier-meshname && (facts.zerotier-meshname.value or null) != null) {
|
||||||
environment.etc."zerotier/hostname".text = "${facts.zerotier-meshname.value}.vpn";
|
environment.etc."zerotier/hostname".text = "${facts.zerotier-meshname.value}.vpn";
|
||||||
|
})
|
||||||
|
(lib.mkIf (cfg.networkId != null) {
|
||||||
clan.networking.meshnamed.networks.vpn.subnet = cfg.subnet;
|
clan.networking.meshnamed.networks.vpn.subnet = cfg.subnet;
|
||||||
|
|
||||||
systemd.network.enable = true;
|
systemd.network.enable = true;
|
||||||
@ -152,7 +153,7 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
(lib.mkIf (cfg.controller.enable && config.clanCore.secrets ? zerotier && facts.zerotier-network-id.value != null) {
|
(lib.mkIf (cfg.controller.enable && (facts.zerotier-network-id.value or null) != null) {
|
||||||
clan.networking.zerotier.networkId = facts.zerotier-network-id.value;
|
clan.networking.zerotier.networkId = facts.zerotier-network-id.value;
|
||||||
environment.etc."zerotier/network-id".text = facts.zerotier-network-id.value;
|
environment.etc."zerotier/network-id".text = facts.zerotier-network-id.value;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user