The dynamic test 2 works, which uses a file on the filesystem. When I put the same contents of the file in agenix, I don’t get the ip when running host home1.example.com
. I tried debugging but I don’t see it. This is currently the closest I get.
secret.nix:
...
"secrets/dynamic-dns.env.age".publicKeys = all-hosts ++ users;
...
agenix -e secrets/dynamic-dns.env.age
DDNS_SUBDOMAIN1=home1.example.com
DDNS_SUBDOMAIN2=home2.example.com
DDNS_P=2sESR62IN2N1
module:
config = {
age.secrets."dynamic-dns.env".file = ../../../secrets/dynamic-dns.env.age;
# 1 Doesn't work
systemd.services.dynamicdns1 = {
description = "Update DynamicDNS";
serviceConfig = {
EnvironmentFile = config.age.secrets."dynamic-dns.env".path;
ExecStart = "${pkgs.curl}/bin/curl https://dynamicdns.key-systems.net/update.php?hostname=\${DDNS_SUBDOMAIN1}&password=\${DDNS_P}&ip=auto";
};
};
systemd.timers.dynamicdns1 = {
description = "Update DynamicDNS test1";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "timers.target" ];
timerConfig = {
OnActiveSec = "2m";
OnUnitActiveSec = "3m";
};
};
# 2 Works
systemd.services.dynamicdns2 = {
description = "Update DynamicDNS";
serviceConfig = {
EnvironmentFile = "/home/myname/myddns.env";
ExecStart = "${pkgs.curl}/bin/curl https://dynamicdns.key-systems.net/update.php?hostname=\${DDNS_SUBDOMAIN2}&password=\${DDNS_P}&ip=auto";
};
};
systemd.timers.dynamicdns2 = {
description = "Update DynamicDNS test2";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "timers.target" ];
timerConfig = {
OnActiveSec = "2m";
OnUnitActiveSec = "3m";
};
};
}