Commit graph

3153 commits

Author SHA1 Message Date
Will Fancher 0a53886700
nixos/{tmpfiles, wrappers}: explicitly set RestrictSUIDSGID false (#426882) 2025-07-30 04:31:21 -04:00
Grimmauld fad6dbb9e6
nixos/systemd: remove enableCgroupAccounting option 2025-07-28 11:26:44 +02:00
Grimmauld 231c142766
nixos/systemd: remove obsolete DefaultCPUAccounting option
This option is made uncondiotional in systemd 258 [1].
Earlier, it defaulted to true on kernels newer than 4.15,
which applies to all supported nixos kernels.
This means removing the option does not change behavior.

[1] 29da53dde3
2025-07-28 11:26:37 +02:00
Grimmauld f47b100763
nixos/systemd: remove obsolete DefaultBlockIOAccounting option
This option is now being ignored by systemd,
so we do not need to explicitly define it.
2025-07-28 11:26:34 +02:00
Grimmauld 265152f770
nixos/systemd: explicitly set systemd.settings.Manager.Default*Accounting 2025-07-28 11:26:30 +02:00
Grimmauld 9c429f004d
nixos/systemd: remove obsolete definition for DefaultLimitCORE
The limit was introduced in 2016 in 840f3230a2,
and broken iin 2019 in bafc256915. Since then,
it is the exact same as systemd itself sets as default.
2025-07-28 11:26:27 +02:00
Grimmauld 69e833f187
nixos/systemd: set DefaultLimitCORE in systemd.settings.Manager explicitly 2025-07-28 11:26:24 +02:00
Grimmauld 62acc59148
nixos/systemd: move systemd.watchdog.* to systemd.settings.Manager 2025-07-28 11:26:21 +02:00
Grimmauld 493f1339b0
nixos/systemd: move systemd.watchdog.* to systemd.settings.Manager 2025-07-28 11:26:08 +02:00
Grimmauld 4d3ab0e8d3
nixos/systemd: make systemd.managerEnvironment affect systemd.settings.Manager 2025-07-28 11:24:39 +02:00
Grimmauld 897933fc9e
nixos/systemd: move systemd.managerEnvironment to systemd.settings.Manager.ManagerEnvironment 2025-07-28 11:24:36 +02: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 1a846a2fff
nixos/systemd: remove systemd.extraConfig 2025-07-28 11:24:26 +02:00
Grimmauld f0b71eebdc
nixos/systemd: add boot.initrd.systemd.settings.Manager option 2025-07-28 11:24:06 +02:00
Grimmauld ebaf7a33ec
nixos/systemd: add settings.Manager option 2025-07-28 11:23:57 +02:00
Will Fancher 4b3b18a44f
nixos/systemd-boot: refactor json.load() logic for better error message (#421916) 2025-07-27 23:08:42 -04:00
jack dedf852ccd nixos/systemd-boot: refactor json.load() logic for better error message 2025-07-27 13:05:03 +02:00
Grimmauld fb51cc802d
nixos/systemd: run0: enable setLoginUid, disable pamMount
This brings our `run0` in line with the upstream defaults:
bcc73cafdb/src/run/systemd-run0.in

While working on `auditd`, i noticed differences in how `run0` behaves
in regard to `/proc/$pid/sessionid` and `/proc/$pid/loginuid`. Particularly,
both files were set to `4294967295`, the magic value denoting `unset`.

While the manual page says elevators such as sudo should not set the loginuid,
run0 is a bit of a special case: The unit spawned by it is not child of
the running user session, and as such there is no id to inherit.

`systemd` upstream uses `pam_loginuid`, and for consistency we should too.
Especially because it prevents a whole lot of pain when working with `auditd`.

As to pam mounts:
On nixos we enable those if they are globally enabled. Upstream does not.
Considering the password entered into polkit is usually not the user password
of the account which will own the unit, pam mount will fail for any partition
which requires a password. Thus it makes sense to also disable pam mounts
for our run0, it prevents unnecessary unexpected pain.
2025-07-25 23:49:59 +02:00
Robert Hensing f5ee08446a
Modular services (#372170) 2025-07-24 16:46:34 +02:00
Wolfgang Walther 5a0711127c
treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Wolfgang Walther 62fe016519
treewide: run treefmt with mdcr/nixfmt 2025-07-24 13:52:31 +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
Robert Hensing b51a6c3531 nixos/system/service: Use copy of escapeSystemdExecArgs
This unblocks modular services while providing opportunity to
improve this when a solution is agreed on.
2025-07-20 03:02:03 +02:00
Robert Hensing af04a80c76 modular-services: merge process.argv from executable and args 2025-07-20 03:01:06 +02:00
Robert Hensing b9e4118e6d nixosTests.modularService: adjust quoting expectations 2025-07-20 03:01:06 +02:00
Robert Hensing 109a6a9d1e Add assertions and warnings to modular services 2025-07-20 03:01:05 +02:00
Robert Hensing 1acabeebed Add modular services, system.services 2025-07-20 03:01:05 +02:00
nikstur 3fd41447c7
nixos/systemd/repart: add extraArgs option and Encrypt=tpm2 test (#422511) 2025-07-18 16:52:18 +02:00
Franz Pletz 71064c4808
nixos/systemd: fix run0 failing to run commands (#419588) 2025-07-17 22:18:10 +02:00
sanana 6baed48380 limine-install: fix profile enumeration
Fixes #425158.
2025-07-15 13:49:05 +05:30
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
Martin Weinelt 3beaa4d288
nixos/activatable-script: drop nettools dependency
The hostname is not set over nettools since d300940637.
2025-07-06 00:59:35 +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
Sandro Jäckel 5e4801914b
nixos/stage-1: fix option path in message 2025-07-03 17:54:49 +02: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
Florian Klink 32f7b63557
nixos/systemd-oomd: use the correct name for the top-level user slice (#418480) 2025-06-25 00:06:50 +03:00
Jason Yundt d54262911c nixos/systemd: fix run0 failing to run commands
Fixes #361592.

I was able to test this change by doing the following:

1. Create a file named “test-systemd-run0.nix” that contains this Nix
expression:

    let
      nixpkgs = /path/to/nixpkgs;
      pkgs = import nixpkgs { };
    in
    pkgs.testers.runNixOSTest {
      name = "test-systemd-run0";
      nodes.machine = {
        security.polkit.enable = true;
      };
      testScript = ''
        start_all()
        machine.succeed("run0 env")
      '';
    }

2. Replace “/path/to/nixpkgs” with the actual path to an actual copy of
Nixpkgs.

3. Run the integration test by running this command:

    nix-build <path to test-systemd-run0.nix>
2025-06-24 10:18:56 -04:00
Masum Reza a2b5af4710
limine-install: cleanup, improve type hinting (#416188) 2025-06-23 23:08:45 +05:30
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
Emily dc90d27011
treewide: remove Perl-based switch-to-configuration (#414882) 2025-06-19 20:30:55 +01:00
K900 458a0d727d Merge remote-tracking branch 'origin/master' into staging-next 2025-06-16 12:41:22 +03:00
nikstur 50d0a81800 nixos/nix-store-veritysetup: init 2025-06-16 10:28:53 +02:00
Jared Baur c59d4343f9
treewide: remove Perl-based switch-to-configuration 2025-06-11 08:56:42 -07:00
K900 c9dd2063b7 Merge remote-tracking branch 'origin/master' into staging-next 2025-06-06 09:28:07 +03:00
Philip Taron 1755d9399b
nixos/networkd: update valid KeepConfiguration values (#395621) 2025-06-05 16:17:48 -07:00
nixpkgs-ci[bot] 1c8c1864d6
Merge master into staging-next 2025-06-03 18:06:20 +00:00
Masum Reza 4c902775b8
nixos/limine: make the install script more resilent (#413390) 2025-06-03 20:40:14 +05:30
nixpkgs-ci[bot] 3a906e9756
Merge master into staging-next 2025-05-31 06:05:28 +00:00
Jörg Thalheim 51ecd58047 system.etc.overlay: build erofs also locally
images in etc tends to be small in size (mostly contains symlinks)
so it's not worth it to reach out to a remote builder for that.
2025-05-30 18:52:30 +02:00