From 8650b1df8f965bf33dec79351646e19406ff9d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 24 Sep 2024 18:00:35 +0200 Subject: [PATCH] actually including nixos-facter + nixos test --- nix/installer.nix | 2 +- nix/kexec-installer/test.nix | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nix/installer.nix b/nix/installer.nix index 3423b3a..dfce43a 100644 --- a/nix/installer.nix +++ b/nix/installer.nix @@ -34,7 +34,7 @@ # for copying extra files of nixos-anywhere pkgs.rsync # alternative to nixos-generate-config - ] ++ lib.optional (pkgs.lib.versionAtLeast lib.version "24.11") pkgs.nixos-facter; + ] ++ lib.optional (pkgs ? nixos-facter) pkgs.nixos-facter; # Don't add nixpkgs to the image to save space, for our intended use case we don't need it system.installer.channel.enable = false; diff --git a/nix/kexec-installer/test.nix b/nix/kexec-installer/test.nix index 72360aa..e5a3bb3 100644 --- a/nix/kexec-installer/test.nix +++ b/nix/kexec-installer/test.nix @@ -1,6 +1,7 @@ { pkgs , lib , kexecTarball +, nixos-facter ? null }: pkgs.testers.runNixOSTest { @@ -69,6 +70,7 @@ pkgs.testers.runNixOSTest { }; testScript = /*python*/ '' + import json import time import subprocess import socket @@ -163,6 +165,11 @@ pkgs.testers.runNixOSTest { host = ssh(["hostname"], stdout=subprocess.PIPE).stdout.strip() assert host == "nixos-installer", f"hostname is {host}, not nixos-installer" + has_nixos_facter=${if nixos-facter != null then "True" else "False"} + if has_nixos_facter == True: + data = json.loads(ssh(["nixos-facter"], stdout=subprocess.PIPE).stdout) + assert data["virtualisation"] == "kvm", f"virtualisation is {data['virtualisation']}, not kvm" + host_ed25519_after = ssh(["cat", "/etc/ssh/ssh_host_ed25519_key.pub"], stdout=subprocess.PIPE).stdout.strip() assert host_ed25519_before == host_ed25519_after, f"'{host_ed25519_before}' != '{host_ed25519_after}'"