actually including nixos-facter + nixos test
This commit is contained in:
parent
1420644027
commit
8650b1df8f
2 changed files with 8 additions and 1 deletions
|
@ -34,7 +34,7 @@
|
||||||
# for copying extra files of nixos-anywhere
|
# for copying extra files of nixos-anywhere
|
||||||
pkgs.rsync
|
pkgs.rsync
|
||||||
# alternative to nixos-generate-config
|
# 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
|
# 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;
|
system.installer.channel.enable = false;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{ pkgs
|
{ pkgs
|
||||||
, lib
|
, lib
|
||||||
, kexecTarball
|
, kexecTarball
|
||||||
|
, nixos-facter ? null
|
||||||
}:
|
}:
|
||||||
|
|
||||||
pkgs.testers.runNixOSTest {
|
pkgs.testers.runNixOSTest {
|
||||||
|
@ -69,6 +70,7 @@ pkgs.testers.runNixOSTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = /*python*/ ''
|
testScript = /*python*/ ''
|
||||||
|
import json
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
import socket
|
import socket
|
||||||
|
@ -163,6 +165,11 @@ pkgs.testers.runNixOSTest {
|
||||||
host = ssh(["hostname"], stdout=subprocess.PIPE).stdout.strip()
|
host = ssh(["hostname"], stdout=subprocess.PIPE).stdout.strip()
|
||||||
assert host == "nixos-installer", f"hostname is {host}, not nixos-installer"
|
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()
|
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}'"
|
assert host_ed25519_before == host_ed25519_after, f"'{host_ed25519_before}' != '{host_ed25519_after}'"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue