Skip to content

Commit

Permalink
actually including nixos-facter + nixos test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 authored and mergify[bot] committed Sep 24, 2024
1 parent 1420644 commit 8650b1d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nix/installer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions nix/kexec-installer/test.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ pkgs
, lib
, kexecTarball
, nixos-facter ? null
}:

pkgs.testers.runNixOSTest {
Expand Down Expand Up @@ -69,6 +70,7 @@ pkgs.testers.runNixOSTest {
};

testScript = /*python*/ ''
import json
import time
import subprocess
import socket
Expand Down Expand Up @@ -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}'"
Expand Down

0 comments on commit 8650b1d

Please sign in to comment.