Skip to content

nixos/*: Fix some pkgs.systemd references - #547726

Merged
vcunat merged 2 commits into
NixOS:staging-nextfrom
dramforever:nixos-fix-some-pkgs-systemd-refs
Aug 1, 2026
Merged

vcunat merged 2 commits into
NixOS:staging-nextfrom
dramforever:nixos-fix-some-pkgs-systemd-refs

Conversation

@dramforever

@dramforever dramforever commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

pkgs.systemd does not respect config.systemd.package and config.boot.initrd.systemd.package overrides. Fix references to the systemd package to ensure that the udevadm used is copied into the initrd.

Fixes nixosTests.predictable-interface-names (#547195 (comment)) Also nixosTests.ifstate.initrd no longer complains about udevadm missing.

I also went through all instances of pkgs.systemd in nixos/ and I'll post a comment below listing what I found

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.
  • Follows the automation/AI policy.

pkgs.systemd does not respect config.systemd.package and
config.boot.initrd.systemd.package overrides. Fix references to the
systemd package to ensure that the udevadm used is copied into the
initrd.

While we're at it, fix the non-initrd reference to systemd as well.
pkgs.systemd does not respect config.systemd.package and
config.boot.initrd.systemd.package overrides. Fix references to the
systemd package to ensure that the udevadm used is copied into the
initrd.
@dramforever

Copy link
Copy Markdown
Contributor Author
Every pkgs.systemd in nixos/
  • Needs fixing!!!

    nixos/tests/predictable-interface-names.nix
      48             script = ''
      49:              ${lib.getExe' pkgs.systemd "udevadm"} settle --timeout=180
      50               ip link
    
  • Needs fixing!!!

    nixos/modules/services/networking/ifstate.nix:
      93      # FIXME: use .device units dependecies instead.
      94:     serviceConfig.ExecStartPre = "-${lib.getExe' pkgs.systemd "udevadm"} settle --timeout=180";
      95  
    
  • Unsure what this is, probably okay?

    nixos/modules/system/boot/clevis-luks-askpass.nix:
      57          cfg.package
      58:         "${pkgs.systemd}/lib/systemd/systemd-reply-password"
      59          "${pkgs.jose}/bin/jose"
    
  • Sudoers rule, needs checking that it handles the right systemctl

    nixos/modules/services/home-automation/homebridge.nix:
      407              # Ability to restart homebridge service
      408:             command = "${pkgs.systemd}/bin/systemctl restart homebridge";
      409              options = [ "NOPASSWD" ];
    
  • Sudoers rule, needs checking that it handles the right systemctl

    
      412              # Ability to shutdown server
      413:             command = "${pkgs.systemd}/bin/shutdown -h now";
      414              options = [ "NOPASSWD" ];
    
  • Sudoers rule, needs checking that it handles the right systemctl

    
      417              # Ability to restart server
      418:             command = "${pkgs.systemd}/bin/shutdown -r now";
      419              options = [ "NOPASSWD" ];
    
  • Unsure, I'm tempted to say it's just for systemctl or something.

    nixos/modules/services/misc/duckdns.nix:
      98          pkgs.gnused
      99:         pkgs.systemd
      100          pkgs.curl
    

  • Probably okay to defer, just systemd-boot

    nixos/doc/manual/installation/building-images-via-systemd-repart.chapter.md:
      155                "/EFI/BOOT/BOOT${lib.toUpper efiArch}.EFI".source =
      156:                 "${pkgs.systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi";
      157  
    
  • Probably okay to defer, just 20-systemd-ssh-proxy.conf

    nixos/lib/testing/run.nix:
      177              ln -sf \
      178:               ${hostPkgs.systemd}/lib/systemd/ssh_config.d/20-systemd-ssh-proxy.conf \
      179                ssh_config
    
  • Probably okay to defer, just systemd-boot

    nixos/modules/image/repart.nix:
      60                "/EFI/BOOT/BOOTX64.EFI".source =
      61:                 "''${pkgs.systemd}/lib/systemd/boot/efi/systemd-bootx64.efi";
      62  
    
  • Probably okay to defer, just systemd-boot

    
      229                "/EFI/BOOT/BOOTX64.EFI".source =
      230:                 "''${pkgs.systemd}/lib/systemd/boot/efi/systemd-bootx64.efi";
      231              };
    
  • Probably okay to defer, just systemd-inhibit

    nixos/modules/services/backup/borgbackup.nix:
      156          + lib.optionalString cfg.inhibitsSleep ''
      157:           ${pkgs.systemd}/bin/systemd-inhibit \
      158                --who="borgbackup" \
    
  • Probably okay to defer, just systemd-inhibit

    nixos/modules/services/backup/restic.nix:
      394          inhibitCmd = lib.concatStringsSep " " [
      395:           "${pkgs.systemd}/bin/systemd-inhibit"
      396            "--mode='block'"
    
  • Probably okay to defer, just systemd-cat

    nixos/modules/services/display-managers/dms-greeter.nix:
      293            inherit (cfgAutoLogin) user;
      294:           command = ''${getExe pkgs.bash} -lc "${pkgs.systemd}/bin/systemd-cat $(<${autoLoginCommand})"'';
      295          };
    
  • Probably okay to defer, just udevadm

    nixos/modules/services/hardware/nvidia-container-toolkit/default.nix:
      334            # an attempt to fix this issue.
      335:           ExecStartPre = "-${lib.getExe' pkgs.systemd "udevadm"} settle --timeout=180";
      336            ExecStart =
    
  • Probably okay to defer, just systemd-creds

    nixos/modules/services/misc/blenderfarm.nix:
      98        + lib.optionalString (cfg.basicSecurityPasswordFile != null) ''
      99:         BLENDFARM_PASSWORD=$(${pkgs.systemd}/bin/systemd-creds cat BLENDFARM_PASS_FILE)
      100          sed -i "s/null/\"$BLENDFARM_PASSWORD\"/g" ServerSettings
    
  • Probably okay to defer, just systemd-creds

    nixos/modules/services/misc/cfdyndns.nix:
      80          ${lib.optionalString (cfg.apiTokenFile != null) ''
      81:           export CLOUDFLARE_APITOKEN=$(${pkgs.systemd}/bin/systemd-creds cat CLOUDFLARE_APITOKEN_FILE)
      82          ''}
    
  • Probably okay to defer, just shutdown

    nixos/modules/services/monitoring/ups.nix:
      363              POWERDOWNFLAG = "/run/killpower";
      364:             SHUTDOWNCMD = "''${pkgs.systemd}/bin/shutdown now";
      365            }
    
  • Probably okay to defer, just shutdown

    
      400          POWERDOWNFLAG = lib.mkDefault "/run/killpower";
      401:         SHUTDOWNCMD = lib.mkDefault "${pkgs.systemd}/bin/shutdown now";
      402        };
    
  • Probably okay to defer, just systemd-notify

    nixos/modules/services/networking/autossh-ng.nix:
      122                  ready = pkgs.writers.writeBash "systemd-signal-ready" ''
      123:                   ${pkgs.systemd}/bin/systemd-notify --ready
      124                  '';
    
  • Probably okay to defer, just systemctl

    nixos/modules/services/networking/clatd.nix:
      99            [ "$2" != "up" ] && [ "$2" != "down" ] && exit 0
      100:           ${pkgs.systemd}/bin/systemctl restart clatd.service
      101          '';
    
  • Probably okay to defer, just hostnamectl

    nixos/modules/services/networking/dhcpcd.nix:
      304            pkgs.writeShellScriptBin "hostname" ''
      305:             ${lib.getExe' pkgs.systemd "hostnamectl"} set-hostname --transient $1
      306            ''
    
  • Probably okay to defer, just systemd-creds

    nixos/modules/services/security/pocket-id.nix:
      33  
      34:   exportCredentials = n: _: ''export ${n}="$(${pkgs.systemd}/bin/systemd-creds cat ${n}_FILE)"'';
      35    exportAllCredentials = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList exportCredentials vars);
    
  • Probably okay to defer, just systemd-creds

    nixos/modules/services/web-apps/librechat.nix:
      11    configFile = format.generate "librechat.yaml" cfg.settings;
      12:   exportCredentials = n: _: ''export ${n}="$(${pkgs.systemd}/bin/systemd-creds cat ${n}_FILE)"'';
      13    exportAllCredentials = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList exportCredentials vars);
    
  • Okay to defer, just docs. What even is this?

    nixos/modules/system/boot/systemd.nix:
      321        type = types.listOf types.package;
      322:       example = literalExpression "[ pkgs.systemd-cryptsetup-generator ]";
      323        description = "Packages providing systemd units and hooks.";
    
  • Okay to defer, just docs. What even is this?

    nixos/modules/system/boot/systemd/initrd.nix:
      399        type = types.listOf types.package;
      400:       example = literalExpression "[ pkgs.systemd-cryptsetup-generator ]";
      401        description = "Packages providing systemd units and hooks.";
    
  • Probably okay to defer, just systemd-journal-gatewayd

    nixos/modules/system/boot/systemd/journald-gateway.nix:
      94        ""
      95:       "${pkgs.systemd}/lib/systemd/systemd-journal-gatewayd ${cliArgs}"
      96      ];
    
  • Probably okay to defer, just systemd-journal-remote

    nixos/modules/system/boot/systemd/journald-remote.nix:
      125        ""
      126:       "${pkgs.systemd}/lib/systemd/systemd-journal-remote ${cliArgs}"
      127      ];
    
  • Probably okay to defer, but seems a bit more important than most

    nixos/modules/virtualisation/nspawn-container/run-nspawn/default.nix:
      3  python3Packages.callPackage ./package.nix {
      4:   # We want `pkgs.systemd`, *not* `python3Packages.systemd`.
      5    inherit systemd;
    
  • Probably okay to defer, just systemd-boot

    nixos/tests/appliance-repart-image.nix:
      59                  "/EFI/BOOT/BOOT${lib.toUpper efiArch}.EFI".source =
      60:                   "${pkgs.systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi";
      61  
    
  • Probably okay to defer, just systemd-cat

    nixos/tests/keymap.nix:
      57              machine.succeed(
      58:                 "${pkgs.systemd}/bin/systemd-cat -t input-test-reader -- {} {} {} &".format(
      59                      cmd,
    

nixos/tests/switch-test.nix:

  • Probably okay to defer, just systemctl

      760                  rm -f "$HOME/.config/systemd/user/default.target.wants/migrated.service"
      761:                 ${pkgs.systemd}/bin/systemctl --user daemon-reload
      762:                 ${pkgs.systemd}/bin/systemctl --user stop migrated.service || true
      763                fi
    
  • Probably okay to defer, just systemctl

    
      775                  rm -f "$HOME/.config/systemd/user/default.target.wants/migrated.service"
      776:                 ${pkgs.systemd}/bin/systemctl --user daemon-reload
      777                fi
    
  • This one should be fine

    nixos/tests/systemd-coredump.nix:
      37        systemd.coredump.enable = false;
      38:       systemd.package = pkgs.systemd.override {
      39          withCoredump = false;
    
  • Probably okay to defer, just systemd-detect-virt

    nixos/tests/virtualbox.nix:
      370    sysdDetectVirt = pkgs: ''
      371:     ${pkgs.systemd}/bin/systemd-detect-virt > /mnt-root/result
      372    '';
    
  • Probably okay to defer, just 20-systemd-ssh-proxy.conf

    nixos/tests/nixos-test-driver/ssh-backdoor.nix:
      28              # instead of terminating the test execution if it fails.
      29:             "${pkgs.systemd}/lib/systemd/ssh_config.d/20-systemd-ssh-proxy.conf",
      30              "--",
    

@nixpkgs-ci
nixpkgs-ci Bot requested a review from MarcelCoding July 31, 2026 12:03
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 12.approvals: 1 This PR was reviewed and approved by one person. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jul 31, 2026
@dramforever

Copy link
Copy Markdown
Contributor Author

cc (clevis) @JulienMalka, @camillemndn, (homebridge) @fmoda3, (duckdns) @notthebee,

Would appreciate taking a look to see if your modules are broken by overriding config.systemd.package and/or config.boot.initrd.systemd.package. We're doing this temporarily in upstream NixOS to work around a libaudit bug. See #547195.

@MarcelCoding MarcelCoding left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(as the ifstate maintainer)

Thx, I seem to have overlooked this when it was introduced in dramforever@1e4eb2d. Funnily enough I've done the same yesterday in my system configurations.

Also, great catch, that the sore path for the inited systemd and normal systemd don't necessarily need to be the same.

I think this probably should also be backported.


The other change also seems correct to me.

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Jul 31, 2026
@vcunat
vcunat added this pull request to the merge queue Aug 1, 2026
@vcunat

vcunat commented Aug 1, 2026

Copy link
Copy Markdown
Member

Let's get these already, even if some other may also benefit from further checking/fixing.

Merged via the queue into NixOS:staging-next with commit 338d5c3 Aug 1, 2026
36 checks passed
@MarcelCoding MarcelCoding added the backport release-26.05 Backport PR automatically label Aug 1, 2026
@nixpkgs-ci

nixpkgs-ci Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release-26.05:

@github-actions github-actions Bot added the 8.has: port to stable This PR already has a backport to the stable release. label Aug 1, 2026
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 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons. backport release-26.05 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants