99 Commits
Author SHA1 Message Date
Paul Meyer bc557b7168 nixos/qemu-firmware: init
Link QEMU firmware descriptors to /etc/qemu/firmware, where
systemd-vmspawn and other tools discover firmware for running VMs.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-07-21 10:36:49 +02:00
nikstur 7c2629ab70 nixos/test-instrumentation: disable minimum uptime for tests 2026-06-23 13:21:21 +02:00
Jamie Magee 0522a75d35 nixos/systemd/user: migrate to RFC 42-style settings
Replace `systemd.user.extraConfig` with a freeform `systemd.user.settings.Manager` submodule, rendered via `utils.systemdUtils.lib.settingsToSections`. `extraConfig` is removed via `mkRemovedOptionModule`. Mirrors the existing `systemd.settings.Manager` migration of the system-side manager.

Updates the two in-tree consumers (`nixos/modules/testing/test-instrumentation.nix` and `nixos/tests/systemd.nix`) to the new option.

Adds `nixos/tests/systemd-user-settings` to assert the rendered `user.conf` contents.
2026-05-19 19:27:58 -07:00
Maximilian BoschandGitHub 2880cab1d0 nixos/test-driver: add support for nspawn containers (#478109) 2026-03-18 23:14:04 +00:00
Kierán MeinhardtandJeremy Fleischman 23f1e6370d nixos/test-driver: add support for nspawn containers
Co-authored-by: Jeremy Fleischman <jeremyfleischman@gmail.com>
2026-01-28 11:28:32 +01:00
quantenzitrone 3e622a5110 nixos: remove references to the xorg namespace
this only creates the usual nixos module rebuilds
2026-01-25 22:58:40 +01:00
Philip Taron 9d6ee21262 nixos: pass stdenv into qemu-common
We also don't export it from `vmTools` anymore.
2026-01-05 09:57:13 -08:00
Jeremy Fleischman 545712933a nixos/test-instrumentation: fix rotten comment about the backdoor
This comment hasn't been accurate for a long time:

- In 363806e89b, we stopped using port 514
- In be0fca5781, we started using qemu's
  paravirtualised console device for the backdoor (`/dev/hvc0`)
2025-12-12 13:04:21 -08:00
nikstur 9cff1cca05 nixos/test-instrumentation: add backdoor option
This allows using the test-instrumentation without the backdoor. This is
useful for example for bashless tests.
2025-10-09 23:52:38 +02:00
nikstur 3ae9229600 nixos/test-instrumentation: use bash directly 2025-08-09 17:39:01 +02:00
Will Fancher fa11c3e9d0 nixos/tests/systemd: Reuse intentional settings, not the entire Manager section 2025-07-29 02:27:30 -04:00
Grimmauld 222ee8fabf nixos/testing: migrate to systemd.settings.Manager 2025-07-28 11:24:09 +02:00
Maximilian Bosch b8b86834b7 nixos/test-driver: move sshBackdoor cfg from test-instrumentation to driver
That way, we don't need to duplicate the sshBackdoor options on NixOS-level.

Suggested-by: Jacek Galowicz <jacek@galowicz.de>
2025-05-10 10:40:35 +02:00
Maximilian BoschandJacek Galowicz 12c544e008 nixos/testing: improve wording of vsockOffset description
Co-authored-by: Jacek Galowicz <jacek@galowicz.de>
2025-05-10 10:28:44 +02:00
Maximilian Bosch a9adfc631a nixos/test-driver: allow assigning other vsock number ranges
I'm a little annoyed at myself that I only realized this _after_ #392030
got merged. But I realized that if something else is using AF_VSOCK or
you simply have another interactive test running (e.g. by another user
on a larger builder), starting up VMs in the driver fails with

    qemu-system-x86_64: -device vhost-vsock-pci,guest-cid=3: vhost-vsock: unable to set guest cid: Address already in use

Multi-user setups are broken anyways because you usually don't have
permissions to remove the VM state from another user and thus starting
the driver fails with

    PermissionError: [Errno 13] Permission denied: PosixPath('/tmp/vm-state-machine')

but this is something you can work around at least.

I was considering to generate random offsets, but that's not feasible
given we need to know the numbers at eval time to inject them into the
QEMU args. Also, while we could do this via the test-driver, we should
also probe if the vsock numbers are unused making the code even more
complex for a use-case I consider rather uncommon.

Hence the solution is to do

    sshBackdoor.vsockOffset = 23542;

when encountering conflicts.
2025-05-09 11:54:00 +02:00
Maximilian Bosch 1bd8073958 nixos/test-driver: add backdoor based on systemd-ssh-proxy & AF_VSOCK
With this it's possible to trivially SSH into running machines from the
test-driver. This is especially useful when running VM tests
interactively on a remote system.

This is based on `systemd-ssh-proxy(1)`, so there's no need to configure
any additional networking on the host-side.

Suggested-by: Ryan Lahfa <masterancpp@gmail.com>
2025-04-26 11:35:47 +02:00
Silvan Mosberger 374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Frédéric Christ 459ddaec26 nixos/testing: Fix graphical tty output
Prior to this commit, the graphical output of an application
running during the boot process was only redirected to the serial
console. Therefore, testing those applications inside the driver (eg.
using `enableOCR = true` was not possible by default.

Limiting the consoles to only the `qemuSerialDevice` has originally been
introduced with fb9f5e4a03 to fix journal
output after the activation of both consoles have been introduced with
d4468bedb5.

However limiting the consoles to only `qemuSerialDevice`this is no longer
necessary since 6aba98aefd makes sure the
journal is always forwarded to the serial console used by the testing
driver.

This is a follow-up on https://github.com/NixOS/nixpkgs/pull/339730
2025-03-07 10:09:23 +01:00
a-kenji 84e5852c3b testing/test-instrumentation: Decrease stateVersion priority
Set the priority of `system.stateVersion` between `mkDefault` and
`mkOptionDefault`.
Since this is set unconditionally for test instrumentation purposes, and
it is specifically set to:
```
Squelch warning about unset system.stateVersion
```
it should be no problem to not conflict if someone if setting this
option as `mkDefault`.
2025-02-25 17:17:34 +07:00
Sefa EyeogluandGitHub 6d85c0552c nixos/test-instrumentation: fix shellcheck findings with enableStrictShellChecks enabled (#349579) 2025-01-13 10:28:43 +01:00
Sefa Eyeoglu 5c30f8caf4 nixos/test-instrumentation: fix shellcheck findings with enableStrictShellChecks enabled
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2025-01-13 09:03:51 +01:00
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
nikstur ea9b0daeee nixos/test-instrumentation: forward journald to correct tty also in systemd initrd
This is a follow up for #339730 where forwarding was correctly setup for
stage 2 but not for stage 1 if it is using systemd.
2024-10-18 10:08:29 +02:00
Frédéric Christ 6aba98aefd nixos/testing: Fix tty output
Prior to this contribution, the Kernel's frame buffer output
boot log wasn't visible on the graphical console.

Now, we can also test applications with graphical output that run
during the boot process.
2024-09-05 10:54:55 +02:00
éclairevoyant 7d8742da87 treewide: fix mkEnableOption usage 2024-06-14 02:41:42 -04:00
K900 4733c9feec nixos/tests: set non-conflicting priority for logrotate disabling
CC https://github.com/NixOS/nixpkgs/pull/267880
2024-05-10 16:25:51 +03:00
Izorkin 772ae48e69 nixos/tests: disable logrotate service by default in tests 2024-05-06 14:53:38 +03:00
stuebinmandJonathan Ringer 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
Sandro Jäckel 476b8c276e treewide: rename renamed sddm/displayManager settings 2024-04-08 21:56:38 +02:00
Alyssa Ross 16821ddb55 nixos/test-instrumentation: fix deprecation warning
Linux prints a deprecation warning when clock= is used on the command
line, and has done since 2006.  The replacement is clocksource=.

The clocksource output on the console looks like same before and after
this change.
2024-04-05 15:06:47 +02:00
nikstur c0feba86fb nixos/test-instrumentation: use full path to env
It is sometimes useful to have a seprate /usr partition to make systemd
tools happy (e.g. repart, sysupdate, gpt-auto-generator etc.). The test
script should not depend on usrbinenv to make this possible.
2024-03-04 16:12:56 +01:00
nikstur 4b128008c5 nixos/test-instrumentation: use file to set root password 2024-01-18 23:08:13 +01:00
Will Fancher 1a2f2cf95d nixos/test-instrumentation: Fix backdoor ordering
In #256226, `backdoor.service` was changed to be part of
`sysinit.target` instead of having default dependencies. This broke
several tests that relied on `backdoor.service` starting after default
targets. For example, `systemd-boot.update` expects `/boot` to be
mounted as soon as the backdoor is running.

These tests really ought to be declaring their dependencies properly
with things like `machine.wait_for_unit("local-fs.target")`, because
it's useful for the backdoor to start as early as possible. But for
now, let's just order it the way it was before in stage 2, and use the
earlier ordering in the new stage 1 context.
2023-11-12 15:04:38 -05:00
Will Fancher 9a0f523372 systemd-stage-1: Enable backdoor in nixos tests 2023-11-09 17:53:48 -05:00
Will Fancher f8ba8be54b testing-instrumentation: Factor backdoor service out to variable 2023-11-09 17:02:01 -05:00
Majiir Paktu 088da23f9e nixos/test-instrumentation: fix unsetting of defaultGateway
The empty string is coerced to an attrset:

    { address = ""; interface = null; metric = null; }

The new defaultGateway logic (correctly) complains that interface must
be defined when using networkd. We instead clear defaultGateway by
setting it to its actual default value, which is null.
2023-10-07 16:09:11 -04:00
SandroandGitHub 8eec7326a3 Merge pull request #219106 from m-bdf/nixos-testing-increase-device-timeout 2023-06-20 11:48:45 +02:00
figsoda 701bcdbead nixos: fix typos 2023-05-19 22:31:04 -04:00
r-vdp 4147b878bc nixos-test-driver: include a timeout for the recv call, do not assume sh == bash 2023-04-26 01:05:53 +02:00
Maëlys Bras de ferandGitHub f24f7ed242 nixos/testing: increase systemd device timeout 2023-02-20 05:27:12 +01:00
Janne HeßandGitHub 18be00a2d9 Merge pull request #207801 from ElvishJerricco/systemd-stage-1-test-instrumentation
systemd-stage-1: Improve test-instrumentation output
2022-12-28 01:43:03 +01:00
Will Fancher 9a497aab1b systemd-stage-1: Improve test-instrumentation output 2022-12-24 19:36:29 -05:00
Naïm Favier f677cbabe9 nixos/tests: remove minimal-kernel module
It's not used, doesn't build, and seems like the only reason to have
`manualConfig` take `stdenv` as an argument.
2022-12-22 01:42:15 +01:00
pennae 9547123258 nixos/*: convert internal option descriptions to MD
we'll have to do it eventually, may as well be now.
2022-08-31 16:32:54 +02:00
Janne Heß e2703d2697 nixos/version: Warn about using the default of system.stateVersion 2022-05-05 12:22:31 +02:00
Janne Heß 007108f04d nixos/*qemu*: Add systemd initrd support 2022-04-30 20:47:42 +02:00
Naïm Favier a298b23c10 nixos/tests: also set TimeoutStart in systemd.user.extraConfig 2022-01-21 04:18:05 +01:00
rnhmjoj b29c2f97c3 nixos/lib/qemu-flags: rename to qemu-common
The current name is misleading: it doesn't contain cli arguments,
but several constants and utility functions related to qemu.
This commit also removes the use of `with import ...` for clarity.
2021-09-18 16:58:16 +02:00
rnhmjoj 61b7cab481 treewide: use perl.withPackages when possible
Since 03eaa48 added perl.withPackages, there is a canonical way to
create a perl interpreter from a list of libraries, for use in script
shebangs or generic build inputs. This method is declarative (what we
are doing is clear), produces short shebangs[1] and needs not to wrap
existing scripts.

Unfortunately there are a few exceptions that I've found:

  1. Scripts that are calling perl with the -T switch. This makes perl
  ignore PERL5LIB, which is what perl.withPackages is using to inform
  the interpreter of the library paths.

  2. Perl packages that depends on libraries in their own path. This
  is not possible because perl.withPackages works at build time. The
  workaround is to add `-I $out/${perl.libPrefix}` to the shebang.

In all other cases I propose to switch to perl.withPackages.

[1]: https://lwn.net/Articles/779997/
2021-03-31 21:35:37 +02:00
Michael Raskin 9486375887 nixos/service-runner: fix evaluation
Follow-up to: nixos/systemd: allow preStart with other ExecStartPre cmdlines #109976

As the additional ExecStartPre and ExecStartPost are now lists, update
their processing by service-runner.nix
2021-02-05 13:02:56 +01:00