Commit Graph

373 Commits

Author SHA1 Message Date
Florian Klink
cadd6c49ee nixos/systemd-user: enable systemd-tmpfiles-clean.timer (#391976) 2025-08-26 11:34:47 +03:00
Florian Klink
6d3383c9e3 nixos/logind: migrate to settings option (#435407) 2025-08-25 13:31:13 +03:00
Felix Buehler
89526e1171 nixos/logind: migrate to settings option 2025-08-24 18:52:40 +02:00
schnusch
44c7414cc6 nixos/systemd-user: add systemd.user.tmpfiles.enable
enabled by default, see #391976
2025-08-22 17:52:13 +02:00
schnusch
5241898a20 nixos/systemd-user: enable systemd-tmpfiles-clean.timer
Set systemd.user.timers.systemd-tmpfiles-clean.wantedBy when any user tmpfiles
rules are set so NixOS knows to enable the unit.
2025-08-22 17:47:17 +02:00
nixpkgs-ci[bot]
8721febb4b Merge master into staging-next 2025-08-20 00:16:19 +00:00
Will Fancher
bf9cb5e0d4 nixos/boot/kernel: allow kernel without MODULES support (#411792) 2025-08-19 21:28:36 +00:00
Martin Weinelt
ab44040de2 Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
	pkgs/development/python-modules/reflex-hosting-cli/default.nix
	pkgs/development/python-modules/reflex/default.nix
2025-08-16 00:32:32 +02:00
andre4ik3
8fdcd28f9d nixos/systemd/userdbd: add warning for system users >= UID 1000
When a disposition is not set in a user record, systemd determines user
disposition depending on the range the user's UID falls in. For system
users with UIDs above 1000, this will cause them to be incorrectly
identified as "regular" users.

This will cause `userctl` to report the user as a regular user, and more
importantly, `systemd-homed` will not run the first boot user creation
flow, as regular users are already present on the machine (when they are
really system users).

The most common source of high UID system users will undoubtedly be Nix
build users, so the warning provides additional guidance on how to
remove them or adjust their IDs to be within the system range.

The warning is shown only when userdbd/homed is enabled, and the option
to hide the warning is deliberately hidden, to ensure users will have to
read and acknowledge the warning before proceeding, as otherwise users
could end up deploying an OS with no users and no way of creating one
due to the first boot flow being skipped.
2025-08-15 16:17:58 +00:00
andre4ik3
21a816c3ce nixos/systemd/homed: add module options, SSH integration support 2025-08-15 16:17:51 +00:00
Fiona Behrens
c8e3d79271 nixos/boot/kernel: allow kernel without MODULES support
Allow building a systemd initrd with a kernel that does not have
modules support enabled (`CONFIG_MODULES=n`), by removing the
assertion and only include the modulesClosure, kmod and support files
if MODULES is enabled or unset in the kernel.
2025-08-11 13:39:29 +00:00
andre4ik3
d54387fcd0 nixos/systemd/userdbd: add SSH integration support 2025-08-10 05:21:10 +00:00
nixpkgs-ci[bot]
0b79387651 Merge staging-next into staging 2025-07-30 12:11:23 +00:00
Will Fancher
0a53886700 nixos/{tmpfiles, wrappers}: explicitly set RestrictSUIDSGID false (#426882) 2025-07-30 04:31:21 -04:00
nixpkgs-ci[bot]
44dfdaf4d6 Merge staging-next into staging 2025-07-29 00:20:45 +00:00
Grimmauld
5bc2d42ba9 nixos/systemd: make boot.initrd.systemd.managerEnvironment affect boot.initrd.systemd.settings.Manager 2025-07-28 11:24:33 +02:00
Grimmauld
071ce0b44a nixos/systemd: remove boot.initrd.systemd.extraConfig 2025-07-28 11:24:29 +02:00
Grimmauld
f0b71eebdc nixos/systemd: add boot.initrd.systemd.settings.Manager option 2025-07-28 11:24:06 +02:00
Wolfgang Walther
90604d95bc Merge branch 'staging-next' into staging 2025-07-24 14:33:09 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Grimmauld
248c463f69 nixos/tmpfiles: explicitly set RestrictSUIDSGID = false
This ensures the tmpfiles resetup service has permissions
to create suid/sgid files, even if `DefaultRestrictSUIDSGID`
is set in system.conf. This is required, as tmpfiles
are used to e.g. set file permissions on the journal
directory.`DefaultRestrictSUIDSGID` is a new feature
coming in systemd 258 [1].

[1] https://github.com/systemd/systemd/pull/38126
2025-07-20 12:40:26 +02:00
nixpkgs-ci[bot]
0ac23e27dd Merge staging-next into staging 2025-07-18 18:06:01 +00:00
nikstur
3fd41447c7 nixos/systemd/repart: add extraArgs option and Encrypt=tpm2 test (#422511) 2025-07-18 16:52:18 +02:00
Florian Klink
27752d2b39 systemd: add sysupdated (#424101) 2025-07-17 02:04:13 +02:00
Jared Baur
996cc69171 nixos/sysupdate: add jmbaur as maintainer 2025-07-15 09:09:36 -07:00
Jared Baur
7b981efa88 nixos/sysupdate: add support for sysupdated/updatectl 2025-07-15 09:09:32 -07:00
Jared Baur
45a71d67a7 nixos/sysupdate: add assertion for systemd built with sysupdate support 2025-07-11 14:07:01 -07:00
phaer
dd88db29ed modules/systemd-oomd: add After=systemd-sysusers.service
Before this change, systemd-oomd startup was flaky at least with
either systemd-sysusers or userborn enabled. It would restart several
times until users were provisioned, so that it finally succeeded.

An alternative would be to use a DynamicUser which was my first
approach, before I discovered that upstream added the after statement
in Dec 2024[1]. DynamicUsers could have further
implications (sandboxing, etc), so we follow upstream here.

It's not clear to me we why Upstreams "After=systemd-sysusers.service"
doesn't show up on nixos-unstable systems (systemd v257.6).

Userborn is covered, as its unit is aliased to systemd-sysusers.service.

The following test succeeded after this change on x86_64-linux:

  nix-build -A nixosTests.systemd-oomd

[1]: 36dd429680
2025-07-11 15:13:25 +02:00
Florian Klink
e47cbf3942 nixos/systemd/repart: add extraArgs option
There's lots of options regarding dm-crypt, dm-verity and TPMs.
Creating individual NixOS options for all of them would be infeasible.
2025-07-04 23:15:23 +03:00
Bogdan-Cristian Tătăroiu
3332613add nixos/systemd-initrd: Fix fsck.xfs failing due to missing sh
When running with a xfs root partition and using systemd for stage 1
initrd, I noticed in journalctl that fsck.xfs always failed to execute.

The issue is that it is trying to use the below sh interpreter:

`#!/nix/store/xy4jjgw87sbgwylm5kn047d9gkbhsr9x-bash-5.2p37/bin/sh -f`

but the file does not exist in the initrd image.

/nix/store/xy4jjgw87sbgwylm5kn047d9gkbhsr9x-bash-5.2p37/bin/**bash**
exists since it gets pulled in by some package, but the rest of the
directory is not being pulled in.

boot/systemd/initrd.nix mentions that xfs_progs references the sh
interpreter and seems to explicitly try to address this by adding
${pkgs.bash}/bin to storePaths, but that's the wrong bash package.

Update the `storePaths` value to pull in `pkgs.bashNonInteractive`
rather than `pkgs.bash`.
2025-06-28 14:50:51 +01:00
r-vdp
c28b3143da nixos/systemd-oomd: use the correct name for the top-level user slice
`user-.slice` does not seem to exist, and the config we generate for it is
rejected by systemd (see `systemctl status user-.slice`).
I suppose that what was really intended here, was to configure
`user.slice`, which is the one that is documented in `man systemd.special`.

Reported-by: Ian Sollars <Ian.Sollars@brussels.msf.org>
2025-06-20 18:53:16 +02:00
nixpkgs-ci[bot]
bc2e6e0ae4 Merge master into staging-next 2025-05-29 18:05:35 +00:00
Florian Klink
9dd801dea7 nixos/systemd-initrd: honor the enable option in contents (#411800) 2025-05-29 18:06:12 +03:00
nixpkgs-ci[bot]
96ecef502b Merge master into staging-next 2025-05-29 12:06:54 +00:00
Fiona Behrens
99da5ec2bc nixos/systemd-initrd: honor the enable option in contents
The enable attribute of `boot.initrd.systemd.contents.<name>` was
ignored for building initrd storePaths. This resulted in building
derivations for the initrd even if it was disabled.

Found while testing a to build a nixos system with a kernel without
lodable modules[0]

[0]: https://github.com/NixOS/nixpkgs/pull/411792
2025-05-28 17:10:02 +00:00
Peter Marshall
7d36daa76a nixos/systemd-stage-1: follow systemd /run propagation
We currently bypass systemd's switch-root logic by premounting
/sysroot/run. Make sure to propagate its sub-mounts with the recursive
flag, in accordance with the default switch-root logic.

This is required for creds at /run/credentials to survive the transition
from initrd -> host.
2025-05-28 13:02:39 -04:00
nixpkgs-ci[bot]
cc7ffdded8 Merge master into staging-next 2025-05-26 18:05:25 +00:00
Jörg Thalheim
131462b962 emergencyMode, emergencyAccess: cross reference options in docs. (#410418) 2025-05-26 14:12:41 +02:00
DavHau
d5d323a907 emergencyMode, emergencyAccess: cross reference options in docs.
I was confused why I could not get an emergency access console despite setting systemd.emergencyMode=true.

Turns out there is another similar option `boot.initrd.systemd.emergencyAccess` that I should have used.

This is confusing and this change should make it more clear vie the docs of both these options.
2025-05-24 14:01:22 +07:00
nixpkgs-ci[bot]
7ac4ee7b2a Merge master into staging-next 2025-05-20 18:05:35 +00:00
benaryorg
e434130d0b nixos/systemd: unconditional systemd-journald-audit.socket
Containers did not have *systemd-journald-audit.socket* in *additionalUpstreamSystemUnits*, which meant that the unit was not provided.
However the *wantedBy* was added without any additional check, therefore creating an empty unit with just the *WantedBy* on *boot.isContainer* machines.
This caused `systemd-analyze verify` to fail:

```text
systemd-journald-audit.socket: Unit has no Listen setting (ListenStream=, ListenDatagram=, ListenFIFO=, ...). Refusing.
systemd-journald-audit.socket: Cannot add dependency job, ignoring: Unit systemd-journald-audit.socket has a bad unit file setting.
systemd-journald-audit.socket: Cannot add dependency job, ignoring: Unit systemd-journald-audit.socket has a bad unit file setting.
```

The upstream unit already contains the following, which should make it safe to include regardless:

```ini
[Unit]
ConditionSecurity=audit
ConditionCapability=CAP_AUDIT_READ
```

For reference, this popped up in the context of #[360426](https://redirect.github.com/NixOS/nixpkgs/issues/360426) as well as #[407696](https://redirect.github.com/NixOS/nixpkgs/pull/407696).

Co-authored-by: Bruce Toll <4109762+tollb@users.noreply.github.com>
Signed-off-by: benaryorg <binary@benary.org>
2025-05-18 19:58:59 +00:00
Winter
b7ea2eaa7d nixos/kernel: Module inclusion improvements (#375975) 2025-05-16 01:44:53 -04:00
Will Fancher
028b3e1411 nixos: Use common modulesClosure in scripted and systemd initrd 2025-05-15 00:00:56 -04:00
Gerg-L
98313e2b81 nixos/systemd-initrd: deprecate strip
It only saved ~1MiB of initramfs size, but caused a few issues
like unloadable kernel modules.
2025-05-08 19:08:14 -04:00
nikstur
bf2bc08b37 repart: Enable discard option (#397906) 2025-04-28 13:34:32 +02:00
Martin Weinelt
fbf76bf72b make-initrd-ng: Restore stripped file permissions (#398396) 2025-04-13 18:11:19 +02:00
Will Fancher
c9ea864d6f nixos/shutdown: Create /run/initramfs with mode 0700 2025-04-13 12:02:16 -04:00
Markus Sütter
c6476ca119 repart: Enable discard option
systemd-repart can be configured to not automatically issue BLKDISCARD commands
to the underlying hardware.

This PR exposes this option in the repart module.
2025-04-11 12:46:50 +02:00
Mikael Voss
045fbc389f nixos/tmpfiles: properly escape argument option
The systemd.tmpfiles.settings.<name>.<path>.<type>.argument option may
contain arbitrary strings. This could allow intentional or unintentional
introduction of new configuration lines.

The argument field cannot be quoted, C‐style \xNN escape sequences are
however permitted. By escaping whitespace and newline characters, the
issue can be mitigated.
2025-04-02 13:23:42 +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](8616af08d9/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