···124124 };
125125 hostName = mkOption {
126126 type = types.str;
127127- default = config.networking.hostName;
127127+ default = config.networking.fqdn;
128128+ defaultText = "\${config.networking.fqdn}";
128129 example = "somewhere.example.com";
129130 description = "DNS name for the urls generated in the cgi.";
130131 };
···156157 ownerEmail = mkOption {
157158 type = types.str;
158159 default = "no-reply@${cfg.hostName}";
160160+ defaultText = "no-reply@\${hostName}";
159161 example = "no-reply@yourdomain.com";
160162 description = "Email contact for owner";
161163 };
···239241 targetConfig = mkOption {
240242 type = types.lines;
241243 default = ''
242242- probe = FPing
243243- menu = Top
244244- title = Network Latency Grapher
245245- remark = Welcome to the SmokePing website of xxx Company. \
246246- Here you will learn all about the latency of our network.
247247- + Local
248248- menu = Local
249249- title = Local Network
250250- ++ LocalMachine
251251- menu = Local Machine
252252- title = This host
253253- host = localhost
244244+ probe = FPing
245245+ menu = Top
246246+ title = Network Latency Grapher
247247+ remark = Welcome to the SmokePing website of xxx Company. \
248248+ Here you will learn all about the latency of our network.
249249+ + Local
250250+ menu = Local
251251+ title = Local Network
252252+ ++ LocalMachine
253253+ menu = Local Machine
254254+ title = This host
255255+ host = localhost
254256 '';
255257 description = "Target configuration";
256258 };
+18
nixos/modules/tasks/network-interfaces.nix
···398398 '';
399399 };
400400401401+ networking.fqdn = mkOption {
402402+ readOnly = true;
403403+ type = types.str;
404404+ default = if (cfg.hostName != "" && cfg.domain != null)
405405+ then "${cfg.hostName}.${cfg.domain}"
406406+ else throw ''
407407+ The FQDN is required but cannot be determined. Please make sure that
408408+ both networking.hostName and networking.domain are set properly.
409409+ '';
410410+ defaultText = literalExample ''''${networking.hostName}.''${networking.domain}'';
411411+ description = ''
412412+ The fully qualified domain name (FQDN) of this host. It is the result
413413+ of combining networking.hostName and networking.domain. Using this
414414+ option will result in an evaluation error if the hostname is empty or
415415+ no domain is specified.
416416+ '';
417417+ };
418418+401419 networking.hostId = mkOption {
402420 default = null;
403421 example = "4e98920d";
+10-4
nixos/tests/hostname.nix
···77with pkgs.lib;
8899let
1010- makeHostNameTest = hostName: domain:
1010+ makeHostNameTest = hostName: domain: fqdnOrNull:
1111 let
1212 fqdn = hostName + (optionalString (domain != null) ".${domain}");
1313+ getStr = str: # maybeString2String
1414+ let res = builtins.tryEval str;
1515+ in if (res.success && res.value != null) then res.value else "null";
1316 in
1417 makeTest {
1518 name = "hostname-${fqdn}";
···2629 ];
2730 };
28312929- testScript = ''
3232+ testScript = { nodes, ... }: ''
3033 start_all()
31343235 machine = ${hostName}
33363437 machine.wait_for_unit("network-online.target")
35383939+ # Test if NixOS computes the correct FQDN (either a FQDN or an error/null):
4040+ assert "${getStr nodes.machine.config.networking.fqdn}" == "${getStr fqdnOrNull}"
4141+3642 # The FQDN, domain name, and hostname detection should work as expected:
3743 assert "${fqdn}" == machine.succeed("hostname --fqdn").strip()
3844 assert "${optionalString (domain != null) domain}" == machine.succeed("dnsdomainname").strip()
···60666167in
6268{
6363- noExplicitDomain = makeHostNameTest "ahost" null;
6969+ noExplicitDomain = makeHostNameTest "ahost" null null;
64706565- explicitDomain = makeHostNameTest "ahost" "adomain";
7171+ explicitDomain = makeHostNameTest "ahost" "adomain" "ahost.adomain";
6672}