Skip to content

Various systemd fixes and cleanups#121371

Closed
arianvp wants to merge 4 commits intoNixOS:stagingfrom
arianvp:systemd-align-kmod
Closed

Various systemd fixes and cleanups#121371
arianvp wants to merge 4 commits intoNixOS:stagingfrom
arianvp:systemd-align-kmod

Conversation

@arianvp
Copy link
Member

@arianvp arianvp commented May 1, 2021

Motivation for this change

I am working on a systemd based initrd and I needed the fixes for kmod-static-nodes.service and systemd-tmpfiles-setup-dev.service which in conjunction makes sure that any static devices nodes are set up in very early boot so that udev functions properly. Without it I had trouble mounting for example btrfs as it requires the presence of /dev/btrfs-control before udev even runs for the btrfs rules to work properly.

I also took the liberty to cleanup some other units that were left from the autoLuks deprecation in 20.03

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

arianvp added 4 commits May 1, 2021 10:32
kmod in NixOS loads from three locations:

/lib/modules   (Used in stage-1)
/run/{current-system,booted-system}/kernel-modules/lib/modules (stage 2)

I am working on systemd-initrd; and because we do not set up the
/run symlinks in stage-1 currently; this caused
kmod-static-nodes.service
to not execute.

Now the paths with this unit and the kmod package are aligned
It was originally moved because of nixops autoLuks feature which
has been unsupported for a while.

See:
* NixOS#62211
* NixOS/nixops#1156 (comment)

systemd-tmpfiles-setup-dev.service needs to run very  early (even before
udev runs) because udev rules assume static device nodes already exist
even before udev is started. If these static device nodes do not exist;
systemd might have trouble mounting filesystems that require static
device nodes (like loopfs and btrfs).
…rget

Since https://github.com/NixOS/nixpkgs/pull/56184/files  local-fs.target
is already pulled in by sysinit.target

swap.target has always already been pulled in by sysinit.target
There is no real harm having them there; but it means these units really
only become active if there is a service providing the underlying
functionality.

nss-lookup.target should not be pulled in unconditionally. It should be
pulled in by providers of DNS lookups. E.g. systemd-resolved.service has
a Wants=nss-lookup.target, Before=nss-lookup.target. So once
systemd-resolved.service has finished starting up; other units that rely
on DNS can be started; but if systemd-resolved is not enabled; those
units can start up immediately.

Same story goes for nss-user-lookup.target and daemons like sssd.

From https://systemd.io/UIDS-GIDS/:

 Note that nss-user-lookup.target is a passive unit: in order to
 minimize synchronization points on systems that don’t need it the unit
 is pulled into the initial transaction only if there’s at least one
 service that really needs it, and that means only if there’s a service
 providing the local user database somehow through IPC or suchlike.
@arianvp arianvp requested a review from flokli May 1, 2021 08:38
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: systemd Software suite that provides an array of system components for Linux operating systems. 8.has: module (update) This PR changes an existing module in `nixos/` labels May 1, 2021
Before=sysinit.target systemd-tmpfiles-setup-dev.service
ConditionCapability=CAP_SYS_MODULE
-ConditionFileNotEmpty=/lib/modules/%v/modules.devname
+ConditionFileNotEmpty=/run/booted-system/kernel-modules/lib/modules/%v/modules.devname
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeesh gihub is bad at visualizing patches of patches :)

@ofborg ofborg bot requested review from andir, edolstra and kloenk May 1, 2021 08:47
@ofborg ofborg bot added 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels May 1, 2021
@flokli
Copy link
Member

flokli commented May 20, 2021

@arianvp can you either finish this up, or split the individual fixes into ready-for-review PRs?

@dasJ dasJ mentioned this pull request Sep 8, 2021
12 tasks
@stale
Copy link

stale bot commented Nov 16, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 16, 2021
@flokli
Copy link
Member

flokli commented Nov 16, 2021

@arianvp can you break this into individual PRs and rebase against latest staging?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 16, 2021
@flokli
Copy link
Member

flokli commented Dec 7, 2021

Closing in favor of #149153.

@flokli flokli closed this Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: systemd Software suite that provides an array of system components for Linux operating systems. 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants