From 68dd2b9b9d9e5590d6e6561c0d06cc5ce44f730f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 6 Dec 2024 15:04:23 +0100 Subject: [PATCH 1/3] installation: fix correct binary on aarch64 --- checks/installation/flake-module.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/checks/installation/flake-module.nix b/checks/installation/flake-module.nix index 80e04fe29..d23abb541 100644 --- a/checks/installation/flake-module.nix +++ b/checks/installation/flake-module.nix @@ -1,4 +1,9 @@ -{ self, lib, ... }: +{ + self, + inputs, + lib, + ... +}: { clan.machines.test-install-machine = { clan.core.networking.targetHost = "test-install-machine"; @@ -42,6 +47,7 @@ pkgs.nixos-anywhere ] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs); closureInfo = pkgs.closureInfo { rootPaths = dependencies; }; + qemu-common = import "${inputs.nixpkgs}/nixos/lib/qemu-common.nix" { inherit lib pkgs; }; in { checks = pkgs.lib.mkIf (pkgs.stdenv.isLinux) { @@ -86,7 +92,7 @@ testScript = '' def create_test_machine(oldmachine=None, args={}): # taken from - startCommand = "${pkgs.qemu_test}/bin/qemu-kvm" + startCommand = "${qemu-common.qemuBinary pkgs.qemu_test}" startCommand += " -cpu max -m 1024 -virtfs local,path=/nix/store,security_model=none,mount_tag=nix-store" startCommand += f' -drive file={oldmachine.state_dir}/empty0.qcow2,id=drive1,if=none,index=1,werror=report' startCommand += ' -device virtio-blk-pci,drive=drive1' From 0a4cf8a8b8a7dd04b6727672177fd81649c54e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 6 Dec 2024 15:06:12 +0100 Subject: [PATCH 2/3] tests/sshd: also log what platform we received in the assert --- pkgs/clan-cli/tests/sshd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/clan-cli/tests/sshd.py b/pkgs/clan-cli/tests/sshd.py index 24f55840c..7bb2798a7 100644 --- a/pkgs/clan-cli/tests/sshd.py +++ b/pkgs/clan-cli/tests/sshd.py @@ -78,7 +78,7 @@ exec {bash} -l "${{@}}" lib_path = None assert ( platform == "linux" - ), "we do not support the ld_preload trick on non-linux just now" + ), f"we do not support the ld_preload trick on non-linux just now. Got {platform}" # This enforces a login shell by overriding the login shell of `getpwnam(3)` lib_path = tmpdir / "libgetpwnam-preload.so" From 73c265bc435d054d2df41075fc70b0dbf6caf520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 6 Dec 2024 16:07:04 +0100 Subject: [PATCH 3/3] simplify runInLinuxVM test --- pkgs/distro-packages/flake-module.nix | 116 ++++---------------------- 1 file changed, 16 insertions(+), 100 deletions(-) diff --git a/pkgs/distro-packages/flake-module.nix b/pkgs/distro-packages/flake-module.nix index 29432c28a..4824e15a4 100644 --- a/pkgs/distro-packages/flake-module.nix +++ b/pkgs/distro-packages/flake-module.nix @@ -3,109 +3,25 @@ perSystem = { self', - inputs', lib, + pkgs, ... }: - let - pkgs = inputs'.nixpkgs.legacyPackages; - - images = { - "ubuntu-22-04" = { - image = import { - url = "https://app.vagrantup.com/generic/boxes/ubuntu2204/versions/4.1.12/providers/libvirt.box"; - hash = "sha256-HNll0Qikw/xGIcogni5lz01vUv+R3o8xowP2EtqjuUQ="; - }; - rootDisk = "box.img"; - system = "x86_64-linux"; - package = self'.checks.package-gui-installer-deb; - installCmd = "dpkg -i package/*.deb"; - }; - }; - - makeTest = - imageName: testName: - let - image = images.${imageName}; - in - pkgs.runCommand "package-${testName}-install-test-${imageName}" - { - buildInputs = [ - pkgs.qemu_kvm - pkgs.openssh - ]; - image = image.image; - postBoot = image.postBoot or ""; - installCmd = image.installCmd; - package = image.package; - } - '' - shopt -s nullglob - - echo "Unpacking Vagrant box $image..." - tar xvf $image - - image_type=$(qemu-img info ${image.rootDisk} | sed 's/file format: \(.*\)/\1/; t; d') - - qemu-img create -b ./${image.rootDisk} -F "$image_type" -f qcow2 ./disk.qcow2 - - extra_qemu_opts="${image.extraQemuOpts or ""}" - - # Add the config disk, required by the Ubuntu images. - config_drive=$(echo *configdrive.vmdk || true) - if [[ -n $config_drive ]]; then - extra_qemu_opts+=" -drive id=disk2,file=$config_drive,if=virtio" - fi - - echo "Starting qemu..." - qemu-kvm -m 4096 -nographic \ - -drive id=disk1,file=./disk.qcow2,if=virtio \ - -netdev user,id=net0,restrict=yes,hostfwd=tcp::20022-:22 -device virtio-net-pci,netdev=net0 \ - $extra_qemu_opts & - qemu_pid=$! - trap "kill $qemu_pid" EXIT - - if ! [ -e ./vagrant_insecure_key ]; then - cp ${./vagrant_insecure_key} vagrant_insecure_key - fi - - chmod 0400 ./vagrant_insecure_key - - ssh_opts="-o StrictHostKeyChecking=no -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa -i ./vagrant_insecure_key" - ssh="ssh -p 20022 -q $ssh_opts vagrant@localhost" - - echo "Waiting for SSH..." - for ((i = 0; i < 120; i++)); do - echo "[ssh] Trying to connect..." - if $ssh -- true; then - echo "[ssh] Connected!" - break - fi - if ! kill -0 $qemu_pid; then - echo "qemu died unexpectedly" - exit 1 - fi - sleep 1 - done - - if [[ -n $postBoot ]]; then - echo "Running post-boot commands..." - $ssh "set -ex; $postBoot" - fi - - echo "Copying package..." - scp -r -P 20022 $ssh_opts $package vagrant@localhost:package - - echo "Installing Package..." - $ssh "set -eux; $installScript" - - touch $out - ''; - in { - checks = lib.mapAttrs' (imageName: _image: { - name = "package-gui-install-test-${imageName}"; - value = makeTest imageName "gui"; - }) images; + checks = lib.mkIf (pkgs.hostPlatform.system == "x86_64-linux") { + deb-gui-install-test = pkgs.vmTools.runInLinuxVM ( + pkgs.runCommand "deb-gui-install-test" { } '' + ${pkgs.dpkg}/bin/dpkg -i ${self'.checks.package-gui-installer-deb}/*.deb + ls -la /usr/bin/clan-app + ${pkgs.expect}/bin/expect -c ' + spawn /usr/bin/clan-app + expect "Clan requires Nix to be installed. Would you like to install it now? (y/n)" + send "n" + expect "Clan cannot run without Nix. Exiting." + ' + touch $out + '' + ); + }; }; }