3728 Commits

Author SHA1 Message Date
Robert Hensing aa1345fd8a lib/services: fix reload/readiness bugs and add compliance coverage (#540857) 2026-07-23 16:49:52 +00:00
Martin Weinelt 9351f979e0 nixos/resolved: apply transformations to keys within resolved section (#535649) 2026-07-23 01:00:19 +00:00
cinereal ae9994806c lib/services: fix reload/readiness bugs and add compliance coverage
Fixes several correctness bugs primarily around modular services' recent
reload/notification options (#535695) and adds compliance coverage to guard them.

Fixes:

- `lib/services/service.nix`:
  - the reload-conflict assertion had inverted polarity, so it fired on the
    default configuration
  - the `mkIf` guard on `process.reloadCommand` had a misplaced paren, applying
    `!= null` to the `mkIf` result rather than to the condition
  - `process.reloadSignal` derives `process.reloadCommand`, so the assertion
    could not check `reloadCommand != null` -- that fired on every signal-only
    service. The command is now derived at `mkDefault` priority and the
    assertion is gated on `options.process.reloadCommand.highestPrio`, firing
    only when the user also set `reloadCommand` explicitly.
  - change `notificationProtocol` to a sub-module type
- `nixos/modules/system/service/systemd/service.nix`:
  - `systemd.mainExecReload`'s default ran `escapeSystemdExecArgs` (a list
    escaper) on the `nullOr str` `process.reloadCommand`; this threw
    `expected a list but found a string` and would have mangled `$MAINPID`. It
    now uses `process.reloadCommand` verbatim.
  - the `Type` default read a non-existent
    `config.serviceManager.notificationProtocol` instead of
    `config.notificationProtocol`.

Tests:

Extend the modular-service compliance suite to guard the above:

- Portable (manager-agnostic) eval assertions: `reloadSignal` derives
  `reloadCommand`, the conflict assertion does not fire on signal-only services
  but does when both are set explicitly, and `notificationProtocol.systemd`/`.s6`
  default to `false`.
- systemd-specific eval assertions: `serviceConfig.Type` (simple/notify) and
  `serviceConfig.ExecReload` are asserted on the resolved host units. This
  directly guards the `mainExecReload` fix, which threw before it.
- Runtime reload compliance test: a nested reloadable sub-service is started and
  reloaded, asserting the service observed the reload (recorded a SIGHUP marker).
  `callReload` receives the service's name path (the list of names from the
  top-level service down to the target sub-service); each integration joins it
  per its own unit-naming convention (NixOS dash-joins to the systemd unit name,
  e.g. `reload-inner.service`). Keeping it a path list rather than a read-only
  submodule option keeps the suite manager-agnostic.
- `doc/build-helpers/testers.chapter.md`: document `callReload`.

Follow-up to #535695.

Signed-off-by: cinereal <cinereal@riseup.net>
Assisted-by: Claude:claude-opus-4-8
2026-07-20 11:01:04 +02:00
nixpkgs-ci[bot] 866d350c81 Merge master into staging-nixos 2026-07-17 00:33:21 +00:00
nikstur 412c6fbc6e nixos/systemd/tpm2: add systemd-pcrlogin@.service (#541382) 2026-07-16 21:47:04 +00:00
Nick Cao 23171017c7 nixos/plymouth: add showDelay option (#532392) 2026-07-16 19:23:35 +00:00
nikstur 974b31ae59 nixos/systemd/fido2: add libpcsclite_real.so.1 to initrd (#541383) 2026-07-16 19:09:11 +00:00
phanirithvij 4abe0c81a7 various: replace deprecated os.system with subprocess calls
Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
2026-07-13 16:27:07 +05:30
r-vdp 503bfeb10f nixos/systemd/fido2: add libpcsclite_real.so.1 to initrd
libfido2 links against pcsclite's libpcsclite.so.1, which since
pcsclite 2.3.1 is a shim that dlopens libpcsclite_real.so.1. nixpkgs
patches that dlopen to an absolute store path. make-initrd-ng only
follows DT_NEEDED, so the real library never ends up in the initrd.

systemd-cryptsetup then logs at boot:

  loading ".../pcsclite-2.4.1-lib/lib/libpcsclite_real.so.1" failed:
  cannot open shared object file: No such file or directory

and FIDO2 tokens behind PC/SC (NFC readers) cannot be used to unlock
LUKS in stage 1. Add the real library to the initrd store paths.
2026-07-13 12:54:41 +02:00
r-vdp 74abe2fea2 nixos/systemd/tpm2: add systemd-pcrlogin@.service
systemd v261 added systemd-pcrlogin@.service, which logind starts on
first login of a user to measure the user record into the 'login'
NvPCR. NixOS does not install the unit, so every first login logs:

  systemd-logind: Failed to start user measurement service
  'systemd-pcrlogin@1000.service', ignoring: Unit not found.

Install the unit on systems with systemd.tpm2.enable. The unit has ConditionSecurity=measured-os and does nothing elsewhere.
2026-07-13 12:54:32 +02:00
Aaron Andersen fa6488337a lib/services: add some generalization options (#535695) 2026-07-11 12:26:04 +00:00
eveeifyeve aae4936e07 lib/services: add reload support for service management 2026-07-11 04:21:03 +10:00
eveeifyeve 03deb31b6b lib/services: add service readiness protocol support 2026-07-11 04:21:03 +10:00
Florian Klink 22ef2ba154 nixos/limine: fix location for boot.loader.limine.additionalFiles
The documentation describes this as a set of files copied to /boot, with
the attribute name denoting the destination file name in /boot.

This uses essentially the same description as refind, systemd-boot and
grub. However limine put it into limine_install_dir (/boot/limine by
default) by accident, which broke downstream users.

For example, nixos-apple-silicon uses boot.loader.limine.additionalFiles
(and similar directives for other bootloaders) to update its m1n1
bootloader (which chainloads into u-boot, which chainloads into the
bootloader selected in NixOS), and due to this bug, put new versions of
it in the wrong location, effectively never updating m1n1.

Fix this, by updating the location. The next commit adds a regression VM
test for it.
2026-07-07 23:14:45 +03:00
r-vdp bb258c2dbe nixos/systemd-boot: update via Varlink instead of parsing bootctl status
systemd v261 lists the new systemd-boot-fallback binary in `bootctl
status`, so our regex picked up the older fallback version and ran
`bootctl update` on an already current ESP, which then exits non-zero.

Switch from parsing the `bootctl --status` output to having bootctl
compare versions itself by calling io.systemd.BootControl.Install over
Varlink. bootctl is spawned as a stdio Varlink server so that we always
use the bootctl from the target closure. An already current binary comes
back as an io.systemd.System error carrying ESTALE, which we treat as
success.
2026-07-01 12:08:51 +02:00
Martin Weinelt 66353ca989 nixos/resolved: apply transformations to keys within resolved section
Because all options are below the [Resolve] section, and we nest them as
such below `settings.Resolve` we need to apply the transformations one
level down for it to match the relevant keys.
2026-06-26 15:06:21 +02:00
nixpkgs-ci[bot] 081f72db10 Merge master into staging-nixos 2026-06-26 12:46:27 +00:00
Florian Klink d2bde3cf5a Allow to pass extra initrd archives to the bootloader (#534265) 2026-06-26 10:46:37 +00:00
r-vdp 5f267f4dda nixos/boot: allow passing extra initrd archives to the bootloader
This is for instance useful on Asahi where an additional initrd archive
containing firmware blobs and per-device calibration files is placed
on the ESP and updated by the Asahi Linux Installer.
These need to be loaded alongside the NixOS initrd.

Implemented for systemd-boot and Limine. Grub is left out since its
install script does not use bootspec yet.

Co-authored-by: Florian Klink <flokli@flokli.de>
2026-06-26 13:39:08 +03:00
r-vdp 86a665d5b6 nixos/etc-overlay: fix machine-id-commit on first-boot when /etc is RO
The upstream unit has ConditionPathIsReadWrite=/etc, which is always
false on the read-only overlay, so the previous commit alone requires
users that want persistence to override the conditions themselves before
the generated ID can be written back.

Use ConditionFirstBoot instead, with the empty placeholder
first-boot is "no" and commit stays skipped, but when a writable
file containing "uninitialized" is bind-mounted over /etc/machine-id,
first-boot is "yes" once and commit writes the ID through the bind.
2026-06-26 10:50:58 +02:00
r-vdp 3eaafe4d48 nixos/etc-overlay: ship empty /etc/machine-id on immutable /etc
The symlink to /var/lib/nixos/machine-id never persists the ID,
systemd-machine-id-commit.service requires a writable /etc, and
machine_id_commit() does not follow symlinks for its mountpoint check.
So the backing file stays "uninitialized", every boot is
ConditionFirstBoot=yes, and the machine-id is random per boot.

Ship an empty regular file instead, systemd then overlays /run/machine-id
for the session, ConditionFirstBoot is correctly "no", commit is
cleanly condition-skipped, and the file is a usable bind target for
users that want persistence.

Fixes #523878
2026-06-26 10:50:57 +02:00
r-vdp 5640e1f935 nixos/limine: add extraInstallCommands option
Allows running additional shell commands after the limine install script
generates menu entries, mirroring the systemd-boot option of the same
name.

Co-authored-by: Florian Klink <flokli@flokli.de>
2026-06-25 22:58:22 +02:00
nixpkgs-ci[bot] 68cd6bba16 Merge master into staging-nixos 2026-06-25 18:47:24 +00:00
nixpkgs-ci[bot] 42814ad4b8 Merge master into staging-next 2026-06-25 18:46:06 +00:00
Arian van Putten 37d4094e73 nixos/systemd/tmpfiles: add credstore.conf (#534998) 2026-06-25 16:23:49 +00:00
Florian Klink d406556640 nixos/journald-{gateway,remote}: remove TLS support (#535263) 2026-06-25 16:12:50 +00:00
Arian van Putten 921383b2ce nixos/journald-{gateway,remote}: remove TLS support
We aren't linking systemd to gnutls anymore so these options
were all silently ignored. Which is pretty bad!

Assisted-by: Claude <noreply@anthropic.com>
2026-06-25 15:47:45 +02:00
Florian Klink 68439b2129 nixos/etc: inline small regular files into the etc-overlay metadata image (#510323) 2026-06-25 13:20:50 +00:00
Arian van Putten 3d47d8331a nixos/systemd: add many Varlink APIs since v260 (#533730) 2026-06-25 08:06:37 +00:00
Raito Bezarius 588eb06fcc nixos/systemd/tpm2/pcrextend: add Varlink API
This adds io.systemd.PCRExtend if the system has TPM2
enabled.

Additionally, this requires the system to fullfill
ConditionSecurity=measured-uki.

Change-Id: I3f1046cdc7463f3b6d3205030f7f12ac95e5cd9e
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:39 +02:00
Raito Bezarius 13684b8470 nixos/systemd/resolved: add Varlink APIs
This adds:

- /run/systemd/resolve/io.systemd.Resolve (resolution)
- /run/systemd/resolve/io.systemd.Resolve.Monitor (monitoring)

Change-Id: I43f22be5c42757f3dad1e4a9d209b0a91f404a55
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:38 +02:00
Raito Bezarius 5c6a1e2b3d nixos/systemd/udevd: add Varlink API
This adds io.systemd.Udev by default.

Change-Id: I41fec3831049aec03041a9ac8a282088e1773b79
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:38 +02:00
Raito Bezarius 04f7553ac2 nixos/systemd/networkd: add Varlink APIs
This adds:

- /run/systemd/resolve.hook/io.systemd.Network (DNS hook)
- /run/systemd/report/io.systemd.Network (metrics)
- /run/systemd/netif/io.systemd.Network (management)

Change-Id: I3d63b0723ae5f8f9496418d8f5d857809302155e
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:38 +02:00
Raito Bezarius b8b65f1616 nixos/systemd/factory-reset: add Varlink API
This adds io.systemd.FactoryReset by default.

Change-Id: I2ef8ae8812e76bc81a5f962e9bfeb99967f6df83
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:38 +02:00
Raito Bezarius 65cdcfc133 nixos/systemd/mute-console: add Varlink API
This adds io.systemd.MuteConsole by default.

Change-Id: I613d5f12e5b2742206c3023e4d57ccdfbaf0e704
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:38 +02:00
Raito Bezarius ff55fdd003 nixos/systemd/machined: add Varlink API
This adds io.systemd.Machine by default.

Change-Id: I05e595d22ad06504e2b3aacb48c74e7683057ce3
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:38 +02:00
Raito Bezarius 3003651b5a nixos/systemd/importd: add Varlink API
This adds io.systemd.Import by default.

Change-Id: Idad216f83af2f3402b864a162373f04968725b7b
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:38 +02:00
Raito Bezarius 7dacd14feb nixos/systemd/ask-password: add Varlink API
This adds io.systemd.AskPassword Varlink API by default.

Change-Id: I45b9a53d489ec3ea5561006c9c91ccb7016b3ee1
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:38 +02:00
Raito Bezarius 1fc433dc51 nixos/systemd/repart: add Varlink socket
This enables the ability to use systemd-repart over Varlink at
/run/systemd/io.systemd.Repart.

Change-Id: Ia74fdf8c2cbc4ec52994ba8ceb5796acc731abd3
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-25 09:50:38 +02:00
nixpkgs-ci[bot] a3eab19ade Merge master into staging-nixos 2026-06-25 00:46:31 +00:00
nixpkgs-ci[bot] 7ac2687f5f Merge master into staging-next 2026-06-25 00:45:19 +00:00
Raito Bezarius 6a63a4ad8b pkgs/*: drop maintenanceship of various packages
I have effectively renounced on maintaining all these packages and I do
not plan to return them except if I'm forced to.

I am also fine with most of these packages being dropped for next
releases if no maintainer shows up.

Change-Id: I8d167c8029b6991181bd7a094af21c3313af2b51
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2026-06-24 20:34:45 +02:00
Arian van Putten 8651ab7d4d nixos/systemd/tmpfiles: add credstore.conf
This creates the /{etc,run}/credstore{,.encrypted} directories
from which ImportCredential= picks up credentials
2026-06-24 18:20:31 +02:00
Vladimír Čunát 105327541b Reapply "staging-nixos merge for 2026-06-19" (#534864)
This reverts commit 532f984da0, reversing
changes made to 421ceaeef8.
2026-06-24 12:17:06 +02:00
Vladimír Čunát a6c3b1d396 Merge master into staging-nixos 2026-06-24 12:16:37 +02:00
Vladimír Čunát 6e628a4f79 Revert "staging-nixos merge for 2026-06-19" 2026-06-24 10:55:53 +02:00
nixpkgs-ci[bot] 5c3bf48741 Merge master into staging-nixos 2026-06-23 12:59:56 +00:00
nikstur efd34ae45a nixos/uki: use config systemd package (#530536) 2026-06-23 12:36:04 +00:00
r-vdp b3a73f17ba nixos/limine: format the install script 2026-06-22 16:21:35 +02:00
Will Fancher d54bf2afa2 nixos/systemd-initrd: add systemd.*.services.path to initrd store (#462515) 2026-06-20 03:42:37 +00:00