Commit Graph

892 Commits

Author SHA1 Message Date
Raito Bezarius
4d38fa043b nixos/networkd: support netdev MAC addresses
According to systemd.netdev manpage:

```
MACAddress=
           Specifies the MAC address to use for the device, or takes the special value "none". When "none", systemd-networkd does not request the MAC address for
           the device, and the kernel will assign a random MAC address. For "tun", "tap", or "l2tp" devices, the MACAddress= setting in the [NetDev] section is
           not supported and will be ignored. Please specify it in the [Link] section of the corresponding systemd.network(5) file. If this option is not set,
           "vlan" device inherits the MAC address of the master interface. For other kind of netdevs, if this option is not set, then the MAC address is
           generated based on the interface name and the machine-id(5).

           Note, even if "none" is specified, systemd-udevd will assign the persistent MAC address for the device, as 99-default.link has
           MACAddressPolicy=persistent. So, it is also necessary to create a custom .link file for the device, if the MAC address assignment is not desired.
```

Therefore, `none` is an acceptable value.
2023-07-04 01:21:35 +02:00
Arthur Gautier
18c734d7f2 nixosTest: adds support for lib.extend
When lib overrides were used, before this commit, they would not be made
available in the configuration evaluation of nixosTest's nodes.

Sample code:
``` nix
let
  pkgs = import ./. {
    overlays = [
      (new: old: {
        lib = old.lib.extend (self: super: {
          sorry_dave = builtins.trace "There are no pod bay doors" "sorry dave";
        });
      })
    ];
  };
in
pkgs.testers.nixosTest {
  name = "demo lib overlay";

  nodes = {
    machine = { lib, ... }: {
      environment.etc."got-lib-overlay".text = lib.sorry_dave;
    };
  };

  testScript = { nodes }:
    ''
      start_all()
      machine.succeed('grep dave /etc/got-lib-overlay')
    '';
}
```
2023-06-29 09:13:44 -07:00
Alyssa Ross
3959a7bef5 nixos/qemu: set qemuSerialDevice for loongarch64
Link: https://www.qemu.org/docs/master/system/loongarch/virt.html#boot-options
2023-06-26 08:58:20 +00:00
pennae
c8b4e5d557
Merge pull request #237557 from pennae/dedocbookify-nixos
nixos/doc: dedocbookify
2023-06-19 14:05:03 +02:00
Ryan Lahfa
3d941b6be8
Merge pull request #236656 from nikstur/qemu-vm-persistent-block-device-names 2023-06-17 14:52:26 +02:00
Raito Bezarius
7088e386ff nixosTests.kexec: reconnect properly after 2nd kexec
By some miracle, before, it was possible to reconnect to the `node1` without
doing any relevant dance.

But now we are direct booting (¿), it seems like we need to do the right things.

This introduces a `check_output` flag for `execute` because we do not want to steal the
messages from the backdoor service as we might execute the kexec too fast compared
to when we will reconnect.

Therefore, we will let the message in the pipe if needed.
2023-06-16 19:43:40 +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
Jörg Thalheim
4f992e8da0
Merge pull request #237840 from lilyinstarlight/fix/systemd-initrd-vconsole-test
nixos/tests/systemd-initrd-vconsole: fix test and improve reliability
2023-06-15 19:41:08 +01:00
Lily Foster
f1f0d4fbdd
nixos/test-driver: fix timeout option for wait_for_console_text 2023-06-15 06:47:49 -04:00
pennae
f52f531a4e nixos/make-options-doc: deprecate docbook outputs
they're no longer necessary for us and will almost definitely start to
rot now (like commonmark and asciidoc outputs did previously). most
existing users seem to take the docbook output and run it through pandoc
to generate html, those can easily migrate to use commonmark instead.
other users will hopefully pipe up when they notice that things they rely
on are going away.

optionsUsedDocbook has only been around for one release and only exposed
to allow other places to generate warnings, so that does not deserve
such precautions.
2023-06-13 16:56:32 +02:00
pennae
20152b4269 nixos/doc: remove docbook options compatibility
no longer needed or useful, and may even produce false positives now
that markdown is the default language for option docs.
2023-06-13 16:56:31 +02:00
pennae
1418c986b0 nixos/make-options-doc: remove options postprocessing
with everything being rendered from markdown now we no longer need to
postprocess any options.xml that may be requested from elsewhere. we'll
don't need to keep the module path check either since that's done by
optionsJSON now.
2023-06-13 16:56:31 +02:00
pennae
af1f07ff03 nixos/make-options-doc: check for manual paths in options.json
since we no longer use the docbook path the check there will no longer
fire. add one to optionsJSON to not lose this functionality.
2023-06-13 16:56:31 +02:00
pennae
34eeac5544 nixos-render-docs: default to markdown for options
docbook is now gone and we can flip the defaults. we won't keep the
command line args around (unlike the make-options-docs argument) because
nixos-render-docs should not be considered an exposed API.
2023-06-13 16:56:31 +02:00
pennae
c01244394c nixos/make-options-doc: force markdownByDefault
with docbook no longer supported we can default to markdown option docs.
we'll keep the parameter around for a bit to not break external users
who set it to true. we don't know of any users that do, so the
deprecation period may be rather short for this one.
2023-06-13 16:56:30 +02:00
pennae
0997ae1903 nixos/manual: disallow docbook option docs
it's been long in the making, and with 23.05 out we can finally disable
docbook option docs and default to markdown instead. this brings a
massive speed boost in manual and manpage builds, so much so that we may
consider enabling user module documentation by default.

we don't remove the docbook support code entirely yet because it's a lot
all over, and probably better removed in multiple separate changes.
2023-06-13 16:56:30 +02:00
Thomas Baggaley
491efa0b3e test-driver: respect timeout in wait_until_fails
- `wait_until_fails` was not passing through its `timeout` argument to
  the internal `retry` function, hence was always using 900 seconds (the
  default timeout for `retry`) rather than the user-specified value.
2023-06-13 05:11:33 +01:00
Alyssa Ross
507ff39251 nixos/test-driver: fix formatting
This caused the test driver to fail to build.

Fixes: 406de94b41 ("nixos/test-driver: add `timeout` option for `wait_for_console_text`")
2023-05-28 12:29:26 +00:00
Jacek Galowicz
b4b45ee6d2
Revert "nixos/lib/test-driver: enable EFI variable reads at runtime" 2023-05-28 13:05:59 +02:00
Jacek Galowicz
d9626034f1
Merge pull request #234513 from NixOS/test-driver/wait_for_console_timeout
nixos/test-driver: add `timeout` option for `wait_for_console_text`
2023-05-28 09:57:00 +02:00
Jacek Galowicz
be62469b22
Merge pull request #229027 from NixOS/qemu-vm/read-efi-var
nixos/lib/test-driver: enable EFI variable reads at runtime
2023-05-28 09:51:29 +02:00
Raito Bezarius
d1104e2109 nixos/test-driver: add timeout option for wait_for_console_text (variant 2) 2023-05-28 00:07:43 +02:00
Raito Bezarius
406de94b41 nixos/test-driver: add timeout option for wait_for_console_text
Previously, `wait_for_console_text` would block indefinitely until there were lines
shown in the buffer.

This is highly annoying when testing for things that can just hang for some reasons.

This introduces a classical timeout mechanism via non-blocking get on the Queue.
2023-05-27 23:55:52 +02:00
Raito Bezarius
f1aee66f92 nixos/lib/test-driver: enable EFI variable reads at runtime
This is useful whenever you want to diagnose the current state of UEFI
variables, to assert that bootloaders or boot programs (systemd-stub)
did their job correctly and set their variables accordingly.

In the future, it can enable inspecting SecureBoot keys also.
2023-05-27 22:44:58 +02:00
Jacek Galowicz
3580ac6c65
Merge pull request #234427 from alyssais/create_machine
nixos/test-driver: undeprecate create_machine
2023-05-27 17:02:11 +02:00
Alyssa Ross
e33c2a5e4c nixos/test-driver: add missing spaces to warning 2023-05-27 15:00:00 +00:00
Alyssa Ross
845576aac4
nixos/test-driver: undeprecate create_machine
This warning was added a year and a half ago, but still no test in
NixOS directly instantiates the machine class, presumably because it's
not actually possible for a test to do so without losing
functionality.  For example, there's no way for a NixOS test to access
the output directory that create_machine passes to the Machine
constructor.

This warning is therefore just contributing to alert fatigue for
users, who are unable to follow its advice.  Once it's actually
possible to do what it suggests, the warning can be reintroduced.
2023-05-27 12:56:04 +00:00
Graham Dennis
8e58daad02 nixos/qemu-vm: quoted string reformat 2023-05-24 08:54:22 +10: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
figsoda
202699c918 nixos/tests: fix typos 2023-05-19 22:31:04 -04:00
Will Fancher
a13191189f
Merge pull request #230316 from wrvsrx/fix-x-restart-triggers
nixos/lib: hash triggers after converting them to string in systemd-lib
2023-05-19 09:25:56 -04:00
Naïm Favier
3ac4b371b3
Merge pull request #214373 from ncfavier/make-image-structured-attrs
make-squashfs,make-iso9660-image: use `__structuredAttrs`
2023-05-18 19:33:59 +02:00
Et7f3
edf5659688
systemd.units.<name>.wantedBy: fix documentation rendering
It need to be marked as inline code block
2023-05-18 18:04:31 +02:00
Ryan Lahfa
5a7e90bc95
Merge pull request #228801 from NixOS/make-disk-image-faster
nixos/lib/make-disk-image: do not compile a full arch QEMU to convert images
2023-05-15 13:24:08 +02:00
Robert Hensing
5c3e59b6d6
Merge pull request #230523 from hercules-ci/fast-nixos-test-eval
Fast nixos test eval
2023-05-11 17:34:46 +02:00
Robert Hensing
b0e17891f2 nixos/testing/nodes.nix: Do not rely on disabledModules
It's just not necessary.
2023-05-11 16:24:01 +02:00
Robert Hensing
0f83261f0e nixos/testing: Add node.pkgsReadOnly escape hatch
By adding this option indirection, a test can declare all by itself
that it needs a custom nixpkgs. This is a more convenient way of
going about this when the caller of the test framework receives a
`node.pkgs` unconditionally.
2023-05-11 16:24:01 +02:00
Robert Hensing
f659db7ba2 nixos/testing: Add node.pkgs option
By factoring out this logic, it's easier for other projects to make
use of it this optimization too (and do it correctly).
2023-05-11 16:24:00 +02:00
Robert Hensing
b213791e7e nixos/all-tests.nix: Add readOnlyPkgs module 2023-05-11 16:24:00 +02:00
Naïm Favier
ea81a2465e
make-iso9660-image: use __structuredAttrs
Makes it easier to enable discarding of references, a feature of Nix
2.14 which requires structured attrs.
2023-05-11 14:25:44 +02:00
Naïm Favier
56226c4674
make-squashfs: use __structuredAttrs
Makes it easier to enable discarding of references, a feature of Nix
2.14 which requires structured attrs.
2023-05-11 14:25:31 +02:00
wrvsrx
05129aab01
nixos/lib: save triggers of systemd into nix store 2023-05-11 17:38:54 +08:00
Robert Hensing
cd358fe24e nixos/all-tests.nix: Set nixpkgs.system 2023-05-10 15:55:09 +02:00
Robert Hensing
693e2c3287 nixos/eval-config: Remove statically known mkIf
mkIf is unnecessary when the condition is statically known - that is
knowable before entering the module evaluation.

By changing this to a precomputed module, we support changing the
defined options to readOnly options.
2023-05-10 15:55:09 +02:00
Jacek Galowicz
b7dfa5082a
Merge pull request #228220 from R-VdP/test_driver_guest_shell_timeout
nixos-test-driver: include a timeout for the recv call, do not assume sh == bash
2023-05-09 13:05:28 +02:00
wrvsrx
cc41b47c6f
nixos/lib: hash triggers after converting them to string in systemd-lib
This change is made for two reasons:

1.  If `toString config.restartTriggers` containes `\n`, systemd unit
    file will be ill-formed.
2.  This change can limit length of the trigger, although it doesn't
    matter in most cases.
2023-05-07 09:04:18 +08:00
Robert Hensing
8054785157 lib/modules: Move class out of specialArgs 2023-05-06 18:32:58 +02:00
Robert Hensing
79703eef08 nixos,nixpkgs: Add module classes
This allows modules that declare their class to be checked.
While that's not most user modules, frameworks can take advantage
of this by setting declaring the module class for their users.
That way, the mistake of importing a module into the wrong hierarchy
can be reported more clearly in some cases.
2023-05-06 18:29:04 +02:00
Raito Bezarius
a22826f46a nixos/lib/make-(multi|single)-disk-zfs-image: use qemu_kvm (host arch) instead of qemu (all arches) 2023-04-28 23:50:44 +02:00
Raito Bezarius
77c0b522b7 nixos/lib/make-disk-image: do not compile a full arch QEMU to convert images 2023-04-28 23:40:57 +02:00