clean configurations
[myNix.git] / lbhost / conf.ddns6.nix
blob719d1a2c0e0d9072dca6d8eecd9ed7de4a0e8fc8
1 { config
2 , lib
3 , ...
4 }:
6 let
8   inherit (builtins)
9     trace
10     hasAttr
11     getAttr
12     ;
13   inherit (lib)
14     optionalAttrs
15     ;
17   hostname = config.networking.hostName;
18   has-ipv6 = config.networking.enableIPv6 or false;
19   duckdns-token = config.services.duckdns.token or "";
20   has-token = duckdns-token != "";
22   host2domain = {
23     "msi-pri" = "msi-pri-lb-func-xyz";
24     "nuc-pri" = "nuc-pri-lb-func-xyz";
25   };
27   maybe = optionalAttrs (
28     has-ipv6 &&
29     (hasAttr hostname host2domain)
30   );
34   services.duckdns = maybe {
35     enable =
36       if has-token then
37         trace "Enabled DuckDNS updater" true
38       else
39         trace "Disabled DuckDNS updater, missing token" false
40     ;
41     ipv4 = false;
42     ipv6 = has-ipv6;
43     domain = getAttr hostname host2domain;
44   };