From 98e1acc253ee7abd21d3a71ed31cb8cc0b43e764 Mon Sep 17 00:00:00 2001 From: DavHau Date: Wed, 28 Apr 2021 17:27:05 +0700 Subject: [PATCH] use iso image for nixos qemu test --- .github/workflows/nix-portable.yml | 1 - flake.nix | 5 +++-- testing/nixos-iso.nix | 29 +++++++++++++++++++++++++++++ testing/nixos-qcow2.nix | 23 ----------------------- 4 files changed, 32 insertions(+), 26 deletions(-) create mode 100644 testing/nixos-iso.nix delete mode 100644 testing/nixos-qcow2.nix diff --git a/.github/workflows/nix-portable.yml b/.github/workflows/nix-portable.yml index da58e36..a3e6618 100644 --- a/.github/workflows/nix-portable.yml +++ b/.github/workflows/nix-portable.yml @@ -58,7 +58,6 @@ jobs: install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install extra_nix_config: | experimental-features = nix-command flakes - system-features = benchmark big-parallel kvm nixos-test recursive-nix - uses: cachix/cachix-action@v8 with: diff --git a/flake.nix b/flake.nix index b4fd4f3..6ab82e1 100644 --- a/flake.nix +++ b/flake.nix @@ -40,10 +40,11 @@ excludeRuntimes = [ "bwrap" ]; }; nixos = { + # use iso image for nixos because building a qcow2 would require KVM img = (toString (nixosSystem { system = "x86_64-linux"; - modules = [(import ./testing/nixos-qcow2.nix)]; - }).config.system.build.qcow) + "/nixos.qcow2"; + modules = [(import ./testing/nixos-iso.nix)]; + }).config.system.build.isoImage) + "/iso/nixos.iso"; }; ubuntu = { url = "https://cloud-images.ubuntu.com/focal/20210415/focal-server-cloudimg-amd64.img"; diff --git a/testing/nixos-iso.nix b/testing/nixos-iso.nix new file mode 100644 index 0000000..a66740e --- /dev/null +++ b/testing/nixos-iso.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, modulesPath, ... }: +with builtins; +with lib; +{ + imports = [ + "${toString modulesPath}/installer/cd-dvd/iso-image.nix" + ]; + + boot.loader.timeout = mkForce 0; + + fileSystems."/" = { + fsType = "tmpfs"; + options = [ "mode=0755" "size=2G" ]; + }; + + # EFI booting + isoImage.makeEfiBootable = true; + + # USB booting + isoImage.makeUsbBootable = true; + + isoImage.squashfsCompression = "zstd -Xcompression-level 5"; + + users.users.test.isNormalUser = true; + users.users.test.openssh.authorizedKeys.keys = [ (readFile ./id_ed25519.pub) ]; + users.users.root.openssh.authorizedKeys.keys = config.users.users.test.openssh.authorizedKeys.keys; + services.openssh.enable = true; + +} \ No newline at end of file diff --git a/testing/nixos-qcow2.nix b/testing/nixos-qcow2.nix deleted file mode 100644 index f4f1c4c..0000000 --- a/testing/nixos-qcow2.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ config, lib, pkgs, modulesPath, ... }: -with builtins; -{ - fileSystems."/" = { - device = "/dev/disk/by-label/nixos"; - autoResize = true; - fsType = "ext4"; - }; - - boot.loader.grub.device = lib.mkDefault "/dev/vda"; - boot.loader.timeout = 0; - - users.users.test.isNormalUser = true; - users.users.test.openssh.authorizedKeys.keys = [ (readFile ./id_ed25519.pub) ]; - users.users.root.openssh.authorizedKeys.keys = config.users.users.test.openssh.authorizedKeys.keys; - services.openssh.enable = true; - - system.build.qcow = import "${toString modulesPath}/../lib/make-disk-image.nix" { - inherit lib config pkgs; - diskSize = 8192; - format = "qcow2"; - }; -} \ No newline at end of file