Commit Graph

243 Commits

Author SHA1 Message Date
stuebinm
6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
K900
15d95c7b74 nixos/qemu-vm: split up the "keep EFI variables from system image" logic 2024-04-05 09:00:12 +03:00
K900
7b602cff5c nixos/tests/installer: avoid create_machine, clean up
- use normal VM nodes for target, with some extra trickery
- rename preBootCommands to postBootCommands to match its actual intent
- rename VMs to installer and target, so they're not all called machine
- set platforms on non-UEFI tests properly
- add missing packages for systemd-boot test
- fix initrd secrets leaking into the store and having wrong paths
2024-04-03 16:16:11 +03:00
nikstur
ce1d1f3e6c nixos/qemu-vm: remove implicit dependency on SSM
The qemu module shouldn't implicitly (and for all architectures) enable
SSM when enabling Secure Boot.

Additionally, this breaks aarch64 Secure Boot tests because this module
doesn't use the right machine type for anything but X86.
2024-03-01 23:40:36 +01:00
Shea Levy
9188bb5186
OVMF: Add test with secure boot enabled
Co-authored-by: Arthur Gautier <arthur.gautier@arista.com>
2024-02-15 12:13:05 -05:00
Will Fancher
d4ee957afa
Merge pull request #287445 from fricklerhandwerk/qemu-env-vars
doc: expand on parameters passed to QEMU VMs
2024-02-10 22:12:06 -05:00
Valentin Gagarin
e385b36a32
Merge pull request #287438 from fricklerhandwerk/qemu-docs-link 2024-02-09 15:37:35 +01:00
Valentin Gagarin
85f4b05e39 doc: add link to QEMU reference documentation in QEMU module 2024-02-09 11:21:07 +01:00
Valentin Gagarin
11c26d4cc5 use code for env var notation 2024-02-09 11:16:28 +01:00
Valentin Gagarin
d9009e0028 doc: expand on parameters passed to QEMU VMs 2024-02-09 10:48:52 +01:00
WilliButz
0139970416
nixos/qemu-vm: convert tmpfiles rules to settings
This change replaces the previously hard-coded `/boot` path with a
reference to `efiSysMountPoint` and more importantly this change makes
it possible to override these rules in scenarios in which they are not
desired.

One such scenario would be when `systemd-gpt-auto-generator(8)` is used
to automount the ESP. Consider this section from the mentioned manpage:

> The ESP is mounted to /boot/ if that directory exists and is not used
> for XBOOTLDR, and otherwise to /efi/. Same as for /boot/, an automount
> unit is used. The mount point will be created if necessary.

Prior to this change, the ESP would be automounted under `/efi` on first
boot, then the previous tmpfiles rules caused `/boot` to be created.
Following the quote above, this meant that the ESP is mounted under
`/boot` for each subsequent boot.
2024-02-07 16:25:30 +01:00
nikstur
c9569af3e0
Merge pull request #271326 from philiptaron/shutdown.target
treewide: depend on `shutdown.target` if `DefaultDependencies=no` in almost every case
2023-12-27 08:33:26 +01:00
Philip Taron
0a226a0639
nixos/qemu: ensure correct ordering w.r.t. shutdown.target 2023-11-30 15:44:36 -08:00
h7x4
79d3d59f58
treewide: replace mkPackageOptionMD with mkPackageOption 2023-11-30 19:03:14 +01:00
Alyssa Ross
8ab2f09522 nixos/qemu-vm: fix infinite recursion
The virtualisation.directBoot.initrd option was added for netboot
images, but the assertion to check directBoot enabled if it was used
caused an infinite recursion if it was.  Minimal reproduction:

	import nixos/tests/make-test-python.nix ({ pkgs, ... }: {
	  name = "";

	  nodes = {
	    machine = { config, ...}: {
	      imports = [ nixos/modules/installer/netboot/netboot-minimal.nix ];

	      virtualisation.directBoot = {
	        enable = true;
	        initrd = "${config.system.build.netbootRamdisk}/${config.system.boot.loader.initrdFile}";
	      };
	    };
	  };
	  testScript = "";
	}) {}

The fix is to swap the two conditions, so that cfg.directBoot.enable
is checked first, and the initrd comparision will be short circuited.

This wasn't noticed during review because in earlier versions of the
virtualisation.directBoot patch, the assertion was accidentally in the
conditional above, so wasn't evaluated unless port forwarding was in
use.
2023-11-06 13:49:31 +01:00
Robert Hensing
5dfc78a8ad
Merge pull request #262021 from Enzime/linux-builder-cross
linux-builder: support `x86_64-linux` on `aarch64`
2023-10-24 14:34:29 +02:00
Michael Hoang
ab1f45f3d3 linux-builder: support x86_64-linux on aarch64 2023-10-24 13:35:37 +02:00
Ryan Lahfa
b9337215cd
Merge pull request #229035 from NixOS/qemu-vm/tpm
qemu-vm: support TPM usecases
2023-10-23 10:10:27 +01:00
Arthur Gautier
08f4fe2087 qemu-vm: stop the swtpm once qemu stops
The idea is to run an async process waiting for swtpm
and we have to ensure that `FD_CLOEXEC` is cleared on this process'
stdin file descriptor, we use `fdflags` for this, a loadable builtin in
Bash ≥ 5.

The async process when exited will terminate `swtpm`, we bind the
termination of the async process to the termination of QEMU by virtue of
having `qemu` exec in that Bash script.

Signed-off-by: Arthur Gautier <baloo@superbaloo.net>
Co-authored-by: Raito Bezarius <masterancpp@gmail.com>
2023-10-23 01:02:24 +02:00
Raito Bezarius
25872524f0 nixos/qemu-vm: add virtualisation.tpm for running TPM in QEMU infrastructure 2023-10-22 16:01:37 +02:00
Robert Hensing
7096340f9e nixos/qemu-vm: Rename nixos-disk-image -> nix-store-image
For the image that's actually a store image only.
Helps with visibility. The name "nixos-disk-image" has no special
significance, by grepping nixpkgs.
2023-10-21 19:13:58 +02:00
nikstur
62e95d095d nixos/qemu-vm: optionally disable overriding fileSystems
Allow the user to disable overriding the fileSystems option with
virtualisation.fileSystems by setting
`virtualisation.fileSystems = lib.mkForce { };`.

With this change you can use the qemu-vm module to boot from an external
image that was not produced by the qemu-vm module itself. The user can
now re-use the modularly set fileSystems option instead of having to
reproduce it in virtualisation.fileSystems.
2023-10-02 11:13:26 +02:00
Valentin Gagarin
295a5e1e2b
fix capitalization (#254542) 2023-09-15 09:59:11 +02:00
Michael Hoang
98d970bc37 nixos/qemu-vm: use CA certificates from host 2023-07-06 21:32:08 +10:00
nikstur
f6b37ddaf2 nixos/qemu-vm: use cfg.host.pkgs 2023-06-24 00:45:15 +02:00
nikstur
0bdba6c99b nixos/qemu-vm: use persistent block device names
This change removes the bespoke logic around identifying block devices.
Instead of trying to find the right device by iterating over
`qemu.drives` and guessing the right partition number (e.g.
/dev/vda{1,2}), devices are now identified by persistent names provided
by udev in /dev/disk/by-*.

Before this change, the root device was formatted on demand in the
initrd. However, this makes it impossible to use filesystem identifiers
to identify devices. Now, the formatting step is performed before the VM
is started. Because some tests, however, rely on this behaviour, a
utility function to replace this behaviour in added in
/nixos/tests/common/auto-format-root-device.nix.

Devices that contain neither a partition table nor a filesystem are
identified by their hardware serial number which is injecetd via QEMU
(and is thus persistent and predictable). PCI paths are not a reliably
way to identify devices because their availability and numbering depends
on the QEMU machine type.

This change makes the module more robust against changes in QEMU and the
kernel (non-persistent device naming) and by decoupling abstractions
(i.e. rootDevice, bootPartition, and bootLoaderDevice) enables further
improvement down the line.
2023-06-16 19:36:03 +02:00
Raito Bezarius
610f60231f nixos/qemu-vm: introduce virtualisation.directBoot
As with many things, we have scenarios where we don't want to boot on a
disk / bootloader and also we don't want to boot directly.

Sometimes, we want to boot through an OptionROM of our NIC, e.g. netboot
scenarios or let the firmware decide something, e.g. UEFI PXE (or even
UEFI OptionROM!).

This is composed of:

- `directBoot.enable`: whether to direct boot or not
- `directBoot.initrd`: enable overriding the
  `config.system.build.initialRamdisk` defaults, useful for
  netbootRamdisk for example.

This makes it possible.
2023-06-09 14:51:18 +02:00
nikstur
003fec835c nixos/qemu-vm: remove grub references from useBootLoader description 2023-06-01 01:38:08 +02:00
nikstur
8ea8154a32 nixos/qemu-vm: (re-)move old/incorrect comments 2023-06-01 01:38:06 +02:00
Raito Bezarius
09d1022782 nixos/qemu-vm: fix 32-bits assert for memorySize
It should be an implication, rather than &&.
2023-05-27 17:20:08 +02:00
Ryan Lahfa
537c6ede55
Merge pull request #234266 from emilylange/qemu-vm-2047mb
nixos/qemu-vm: add `virtualisation.memorySize < 2048` assertion on 32bit
2023-05-27 15:31:00 +02:00
emilylange
5dbd4f3243
nixos/qemu-vm: add virtualisation.memorySize < 2048 assertion on 32bit 2023-05-26 19:43:58 +02:00
Graham Dennis
93502aa3b1 nixos/qemu-vm: add option for named network interfaces
Adds a new option to the virtualisation modules that enables specifying explicitly named network interfaces in QEMU VMs.
The existing `virtualisation.vlans` option is still supported for cases where the name of the network interface is irrelevant.
2023-05-24 08:54:20 +10:00
Vladimír Čunát
5674901601
Revert "nixos/qemu-vm: fix diskless VMs" 2023-05-06 21:41:14 +02:00
Ryan Lahfa
1ab4d7d0c3
Merge pull request #228047 from RaitoBezarius/diskless-vm
nixos/qemu-vm: fix diskless VMs
2023-05-05 15:37:11 +02:00
Peter Kling
996db6d059
virtualisation/qemu-vm: escape bash variable in shell script
Fixes #229729
2023-05-04 09:52:49 +02:00
Raito Bezarius
6e8248c8b2 nixos/qemu-vm: make it possible to use UEFI without bootloaders
`useEFIBoot` is somewhat misleading, but we should make it possible to
enable UEFI environment / firmware without buying into a bootloader.

This makes it possible.
2023-05-02 23:20:03 +02:00
Raito Bezarius
be4e7ef905 nixos/qemu-vm: fix diskless VMs
Previously, it was possible to run with a tmpfs / with
`virtualisation.diskImage = null;`, this was likely broken by my changes
in 4b4e4c3ef9.

It is reintroduced by disabling properly the bootloader for now, as it
is complicated to make it work with.
2023-04-25 02:12:26 +02:00
Raito Bezarius
0df5257b82 nixos/qemu-vm: introduce virtualisation.mountHostNixStore option
Now that `useBootLoader` produces a full system image, moving disk
images can be slow because they have a full Nix store in them.

It does not make sense to keep the 9p mountpoint to shadow the
/nix/store of the VM.

We disable it if we have `useBootLoader` and introduce an option for
easy overrides.
2023-04-23 23:58:46 +02:00
Florian Klink
6b27ed3229
Merge pull request #169116 from ElvishJerricco/systemd-stage-1-networkd
Systemd stage 1 networkd
2023-04-21 18:40:59 +02:00
Raito Bezarius
614b83a328 nixos/virtualisation/qemu-vm: remove persistBootDevice option
This option has been introduced in 678eed323f without realizing there was this
PR inflight, unfortunately, it collide with what this PR does and make
it irrelevant.

Therefore, I remove it here.
2023-04-21 13:00:19 +02:00
Raito Bezarius
76c7b656bf nixos/qemu-vm: refactor bootDisk generation using make-disk-image 2023-04-21 13:00:18 +02:00
Artturi
b83db86a9e
Merge pull request #222080 from Stunkymonkey/nixos-optionalString 2023-04-20 16:07:30 +03:00
Will Fancher
fef26d88e2 systemd-initrd: Support secrets when boot loader doesn't
initrd-secrets: Fix service config with systemd-stage-1
2023-04-11 15:20:47 -04:00
Felix Buehler
327b0cff7a treewide: use more lib.optionalString 2023-04-07 13:38:33 +02:00
Sandro Jäckel
a5d95ac5fc
nixos/tmp: move /tmp options under boot.tmp 2023-03-19 18:49:37 +01:00
Martin Weinelt
d03d74aa67
Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
- pkgs/development/python-modules/aiopulse/default.nix
- pkgs/development/python-modules/identify/default.nix
- pkgs/development/python-modules/spur/default.nix
2023-03-12 23:28:23 +01:00
Guillaume Girol
db901673ea
Merge pull request #209156 from pwaller/issue-114594
nixos/grub: Name initrd-secrets by system, not by initrd
2023-03-12 18:50:33 +00:00
github-actions[bot]
98d00577f6
Merge master into staging-next 2023-03-09 06:01:01 +00:00
Will Fancher
46089f7efe
Merge pull request #217886 from lilyinstarlight/fix/qemu-vm-initrd-mkdir-0755
nixos/qemu-vm: fix minor typo
2023-03-08 19:17:28 -05:00