From 27eab436bd6c9bb50bf48e9c4587bdf135ec3fdd Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 7 Mar 2023 13:28:02 +0100 Subject: nixos/tests/hostname.nix: nixpkgs-fmt --- nixos/tests/hostname.nix | 86 ++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'nixos') diff --git a/nixos/tests/hostname.nix b/nixos/tests/hostname.nix index 1de8f19267af..27265d195626 100644 --- a/nixos/tests/hostname.nix +++ b/nixos/tests/hostname.nix @@ -1,6 +1,6 @@ -{ system ? builtins.currentSystem, - config ? {}, - pkgs ? import ../.. { inherit system config; } +{ system ? builtins.currentSystem +, config ? { } +, pkgs ? import ../.. { inherit system config; } }: with import ../lib/testing-python.nix { inherit system pkgs; }; @@ -14,55 +14,55 @@ let let res = builtins.tryEval str; in if (res.success && res.value != null) then res.value else "null"; in - makeTest { - name = "hostname-${fqdn}"; - meta = with pkgs.lib.maintainers; { - maintainers = [ primeos blitz ]; - }; + makeTest { + name = "hostname-${fqdn}"; + meta = with pkgs.lib.maintainers; { + maintainers = [ primeos blitz ]; + }; - nodes.machine = { lib, ... }: { - networking.hostName = hostName; - networking.domain = domain; + nodes.machine = { lib, ... }: { + networking.hostName = hostName; + networking.domain = domain; - environment.systemPackages = with pkgs; [ - inetutils - ]; - }; + environment.systemPackages = with pkgs; [ + inetutils + ]; + }; - testScript = { nodes, ... }: '' - start_all() + testScript = { nodes, ... }: '' + start_all() - machine = ${hostName} + machine = ${hostName} - machine.wait_for_unit("network-online.target") + machine.wait_for_unit("network-online.target") - # Test if NixOS computes the correct FQDN (either a FQDN or an error/null): - assert "${getStr nodes.machine.config.networking.fqdn}" == "${getStr fqdnOrNull}" + # Test if NixOS computes the correct FQDN (either a FQDN or an error/null): + assert "${getStr nodes.machine.config.networking.fqdn}" == "${getStr fqdnOrNull}" - # The FQDN, domain name, and hostname detection should work as expected: - assert "${fqdn}" == machine.succeed("hostname --fqdn").strip() - assert "${optionalString (domain != null) domain}" == machine.succeed("dnsdomainname").strip() - assert ( - "${hostName}" - == machine.succeed( - 'hostnamectl status | grep "Static hostname" | cut -d: -f2' - ).strip() - ) + # The FQDN, domain name, and hostname detection should work as expected: + assert "${fqdn}" == machine.succeed("hostname --fqdn").strip() + assert "${optionalString (domain != null) domain}" == machine.succeed("dnsdomainname").strip() + assert ( + "${hostName}" + == machine.succeed( + 'hostnamectl status | grep "Static hostname" | cut -d: -f2' + ).strip() + ) - # 127.0.0.1 and ::1 should resolve back to "localhost": - assert ( - "localhost" == machine.succeed("getent hosts 127.0.0.1 | awk '{print $2}'").strip() - ) - assert "localhost" == machine.succeed("getent hosts ::1 | awk '{print $2}'").strip() + # 127.0.0.1 and ::1 should resolve back to "localhost": + assert ( + "localhost" == machine.succeed("getent hosts 127.0.0.1 | awk '{print $2}'").strip() + ) + assert "localhost" == machine.succeed("getent hosts ::1 | awk '{print $2}'").strip() - # 127.0.0.2 should resolve back to the FQDN and hostname: - fqdn_and_host_name = "${optionalString (domain != null) "${hostName}.${domain} "}${hostName}" - assert ( - fqdn_and_host_name - == machine.succeed("getent hosts 127.0.0.2 | awk '{print $2,$3}'").strip() - ) - ''; - }; + # 127.0.0.2 should resolve back to the FQDN and hostname: + fqdn_and_host_name = "${optionalString (domain != null) "${hostName}.${domain} "}${hostName}" + assert ( + fqdn_and_host_name + == machine.succeed("getent hosts 127.0.0.2 | awk '{print $2,$3}'").strip() + ) + ''; + }; in { -- cgit 1.4.1 From 5566961d2e43a688b0892fafe6c0f65aea1bf6b5 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 7 Mar 2023 13:28:33 +0100 Subject: nixosTests.hostname: stop using deprecated nodes.machine.config Module argument `nodes.machine.config` is deprecated. --- nixos/tests/hostname.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos') diff --git a/nixos/tests/hostname.nix b/nixos/tests/hostname.nix index 27265d195626..6122e2ffeb83 100644 --- a/nixos/tests/hostname.nix +++ b/nixos/tests/hostname.nix @@ -37,7 +37,7 @@ let machine.wait_for_unit("network-online.target") # Test if NixOS computes the correct FQDN (either a FQDN or an error/null): - assert "${getStr nodes.machine.config.networking.fqdn}" == "${getStr fqdnOrNull}" + assert "${getStr nodes.machine.networking.fqdn}" == "${getStr fqdnOrNull}" # The FQDN, domain name, and hostname detection should work as expected: assert "${fqdn}" == machine.succeed("hostname --fqdn").strip() -- cgit 1.4.1