tests: add buildwmwithbootloader stub

This commit is contained in:
steveej 2018-09-23 14:09:35 +02:00
parent 71ad857210
commit 617a84a384
3 changed files with 86 additions and 0 deletions

View file

@ -0,0 +1,32 @@
{ system ? builtins.currentSystem
, vmPkgsPath
, buildPkgsPath
, nixosConfigPath
}:
let
buildPkgs = import buildPkgsPath {};
vmPkgs'= import vmPkgsPath {};
vmPkgs = vmPkgs' // {
runtimeShell = "${vmPkgs'.bash}/${vmPkgs'.bash.shellPath}";
};
importWithPkgs = { path, pkgs }: args: import path (args // { inherit pkgs; });
nixosConfig = importWithPkgs { path = "${nixosConfigPath}"; pkgs = vmPkgs; };
vmConfig = importWithPkgs { path = "${buildPkgsPath}/nixos/modules/virtualisation/qemu-vm.nix"; pkgs = vmPkgs; };
evalConfig = importWithPkgs { path = "${vmPkgsPath}/nixos/lib/eval-config.nix"; pkgs = null; };
vmWithBootLoaderConfigMixed = (evalConfig {
modules = [
nixosConfig
vmConfig
{
virtualisation.useBootLoader = true;
}
];
}).config;
in {
vmWithBootLoaderMixed = vmWithBootLoaderConfigMixed.system.build.vm;
}

View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -x
rm *.qcow2
rm result*
set -e
BUILD_NIXPKGS="${BUILD_NIXPKGS:-${HOME}/src/github/NixOS/nixpkgs.dev}"
NIXOS_CONFIG="${NIXOS_CONFIG_OVERRIDE:-${PWD}/configuration.nix}"
nix-build -K --show-trace build-vm.nix \
--arg vmPkgsPath '<nixos-18.03>' \
--argstr buildPkgsPath "${BUILD_NIXPKGS}" \
--argstr nixosConfigPath "${NIXOS_CONFIG}" \
-A vmWithBootLoaderMixed
./result/bin/run-*-vm

View file

@ -0,0 +1,38 @@
{ pkgs, lib, ... }:
let
in
{
boot.loader.grub = {
enable = true;
version = 2;
device = "/dev/vda";
efiSupport = true;
enableCryptodisk = true;
};
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.systemd-boot.enable = true;
boot.initrd.luks.devices = [ {
name = "crypt";
device = "/dev/disk/uuid/463d886d-7dfe-421b-8cef-f9af3a3fa09d";
preLVM = true;
allowDiscards = true;
}
];
fileSystems."/" = {
label = "root";
};
fileSystems."/boot" = {
label = "boot";
};
boot.tmpOnTmpfs = true;
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
users.extraUsers.root.initialPassword = lib.mkForce "toorroot";
users.mutableUsers = false;
}