Merge pull request 'clanCore.secrets: facts.value can be null or str' (#350) from lassulus-facts_null into main
This commit is contained in:
@@ -93,11 +93,12 @@
|
|||||||
};
|
};
|
||||||
value = lib.mkOption {
|
value = lib.mkOption {
|
||||||
defaultText = lib.literalExpression "\${config.clanCore.clanDir}/\${fact.config.path}";
|
defaultText = lib.literalExpression "\${config.clanCore.clanDir}/\${fact.config.path}";
|
||||||
|
type = lib.types.nullOr lib.types.str;
|
||||||
default =
|
default =
|
||||||
if builtins.pathExists "${config.clanCore.clanDir}/${fact.config.path}" then
|
if builtins.pathExists "${config.clanCore.clanDir}/${fact.config.path}" then
|
||||||
builtins.readFile "${config.clanCore.clanDir}/${fact.config.path}"
|
builtins.readFile "${config.clanCore.clanDir}/${fact.config.path}"
|
||||||
else
|
else
|
||||||
"";
|
null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,6 +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;
|
||||||
networkConfig = {
|
networkConfig = {
|
||||||
authTokens = [
|
authTokens = [
|
||||||
null
|
null
|
||||||
@@ -87,17 +88,19 @@ in
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
(lib.mkIf cfg.controller.enable {
|
(lib.mkIf cfg.controller.enable {
|
||||||
clan.networking.zerotier.networkId = lib.mkDefault config.clanCore.secrets.zerotier.facts."zerotier-network-id".value;
|
|
||||||
# only the controller needs to have the key in the repo, the other clients can be dynamic
|
# only the controller needs to have the key in the repo, the other clients can be dynamic
|
||||||
# we generate the zerotier code manually for the controller, since it's part of the bootstrap command
|
# we generate the zerotier code manually for the controller, since it's part of the bootstrap command
|
||||||
clanCore.secrets.zerotier = {
|
clanCore.secrets.zerotier = {
|
||||||
facts."zerotier-network-id" = { };
|
facts.zerotier-network-id = { };
|
||||||
secrets."zerotier-identity-secret" = { };
|
secrets.zerotier-identity-secret = { };
|
||||||
generator = ''
|
generator = ''
|
||||||
export PATH=${lib.makeBinPath [ config.services.zerotierone.package pkgs.fakeroot ]}
|
export PATH=${lib.makeBinPath [ config.services.zerotierone.package pkgs.fakeroot ]}
|
||||||
${pkgs.python3.interpreter} ${./generate-network.py} "$facts/zerotier-network-id" "$secrets/zerotier-identity-secret"
|
${pkgs.python3.interpreter} ${./generate-network.py} "$facts/zerotier-network-id" "$secrets/zerotier-identity-secret"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
(lib.mkIf ((config.clanCore.secrets ? zerotier) && (facts.zerotier-network-id.value != null)) {
|
||||||
|
clan.networking.zerotier.networkId = facts.zerotier-network-id.value;
|
||||||
|
|
||||||
systemd.services.zerotierone.serviceConfig.ExecStartPre = [
|
systemd.services.zerotierone.serviceConfig.ExecStartPre = [
|
||||||
"+${pkgs.writeShellScript "init-zerotier" ''
|
"+${pkgs.writeShellScript "init-zerotier" ''
|
||||||
|
|||||||
Reference in New Issue
Block a user