Files
nikstur 640c05e8f3 systemd: add passthru.nixosTests
Reorganize the passthru.tests to be able to comment out/disable
individual tests that were previously hidden in an attrset.

Also comment out tests that are currently broken on master. Once this is
merged, the tests in passthru.nixosTests serve as a hard quality gate
for merging changes to systemd as per the newly addded README that lives
next to the systemd derivation. These tests were only commented out
because I believe they are still valuable and should be fixed. However,
actually fixing them is out of scope for this change.

This removed the `installer-systemd-stage-1` tests because they were to
costly to evaluate and build for normal maintainers. We also don't have
all the other installer tests here. All tests use systemd, but we need
to balance the executability in a sensible timescale with test coverage.
2026-06-05 15:02:27 +02:00
..
2026-06-05 15:02:27 +02:00
2026-06-05 12:27:40 +02:00

Maintaining systemd

This document guides you through some of the important parts of maintaining systemd.

Preparing and Testing Changes

Changing systemd (most importantly updating!) is quite cumbersome:

  • It is very close to the root of the dependency tree and thus causes rebuilds of a lot of packages. It always needs to target staging.
  • ALL tests need to be rebuilt if systemd changes because systemd is a mandatory part of NixOS.

To alleviate this, we have a special procedure for preparing and testing changes to systemd. It is quite different from maintaining other packages in Nixpkgs. Please read this carefully if you want to open a PR for systemd.

  1. In your fork of Nixpkgs, create a new branch from the merge base of the master branch and staging. Changes to systemd need to target staging and this helps to keep the number of rebuilds minimal.
git switch --create systemd-changes $(git merge-base upstream/master upstream/staging)
  1. Change the systemd package. Test it by (1) building the systemd package and (2) building systemd.nixosTests.simple-vm. When this is successful, commit the changes.

  2. Check out master again and add your new branch to a new worktree.

git switch master
git worktree add ../systemd-changes systemd-changes
  1. Apply this patch to your master checkout of Nixpkgs so that all tests use the systemd package from the newly created worktree. This allows you to only rebuild the systemd package itself without having to build all the other packages that depend on systemd. Note that the path for systemdTest in this patch will depend on the name of your worktree.
diff --git i/nixos/modules/module-list.nix w/nixos/modules/module-list.nix
index c57b627e875c..89f026efd786 100644
--- i/nixos/modules/module-list.nix
+++ w/nixos/modules/module-list.nix
@@ -2040,4 +2040,5 @@
       ./image/repart.nix
     ];
   }
+  ({ pkgs, ... }: {systemd.package = pkgs.systemdTest;})
 ]
diff --git i/pkgs/top-level/all-packages.nix w/pkgs/top-level/all-packages.nix
index 0e2defb6566c..c60c1f201828 100644
--- i/pkgs/top-level/all-packages.nix
+++ w/pkgs/top-level/all-packages.nix
@@ -8538,6 +8538,10 @@ with pkgs;

   libsysprof-capture = callPackage ../development/tools/profiling/sysprof/capture.nix { };

+  systemdTest = callPackage ../../../systemd-changes/pkgs/os-specific/linux/systemd {
+    # break some cyclic dependencies
+    util-linux = util-linuxMinimal;
+  };
   systemd = callPackage ../os-specific/linux/systemd {
     # break some cyclic dependencies
     util-linux = util-linuxMinimal;
  1. Build all the systemd NixOS tests
nix-build -A systemd.nixosTests

You are encouraged to use a tool like brr or nix-fast-build to speed up evaluation and building all these tests.

In conclusion, there are three quality gates for changes to systemd:

  1. The package needs to build on staging.
  2. The test systemd.nixosTests.simple-vm needs to pass on staging.
  3. All systemd.nixosTests must pass on master with the changed systemd from a separate worktree.