From 62bfb23a26bd730af99518908fe8bb121b0060b5 Mon Sep 17 00:00:00 2001 From: nikstur Date: Sat, 11 Apr 2026 14:28:06 +0200 Subject: [PATCH] systemd: remove remaining binaryReplacements These were only replaying paths in man pages or tests. Since we do not run the tests (because they don't work yet on NixOS), this is just maintenance churn without being useful. Patching manpages is IMO also not useful because manpages that diverge from their canonical form are more confusing than helpful. --- pkgs/os-specific/linux/systemd/default.nix | 93 ++-------------------- 1 file changed, 5 insertions(+), 88 deletions(-) diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index eb1a51f58205..5459706c6922 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -558,95 +558,12 @@ stdenv.mkDerivation (finalAttrs: { (lib.mesonBool "gshadow" false) (lib.mesonBool "idn" false) ]; - preConfigure = - let - # A list of all the runtime binaries referenced by the source code (plus - # scripts and unit files) of systemd executables, tests and libraries. - # As soon as a dependency is lo longer required we should remove it from - # the list. - # The `where` attribute for each of the replacement patterns must be - # exhaustive. If another (unhandled) case is found in the source code the - # build fails with an error message. - binaryReplacements = [ - { - search = "/sbin/mkswap"; - replacement = "${lib.getBin util-linux}/sbin/mkswap"; - where = [ - "man/systemd-makefs@.service.xml" - ]; - } - { - search = "/bin/echo"; - replacement = "${coreutils}/bin/echo"; - where = [ - "man/systemd-analyze.xml" - "man/systemd.service.xml" - "man/systemd-run.xml" - "src/analyze/test-verify.c" - "src/test/test-env-file.c" - "src/test/test-load-fragment.c" - ]; - } - { - search = "/bin/cat"; - replacement = "${coreutils}/bin/cat"; - where = [ - "test/test-execute/exec-noexecpaths-simple.service" - ]; - } - { - search = "/usr/lib/systemd/systemd-fsck"; - replacement = "$out/lib/systemd/systemd-fsck"; - where = [ "man/systemd-fsck@.service.xml" ]; - } - ]; + preConfigure = '' + mesonFlagsArray+=(-Dntp-servers="0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org") - # { replacement, search, where, ignore } -> List[str] - mkSubstitute = - { - replacement, - search, - where, - ignore ? [ ], - }: - map (path: "substituteInPlace ${path} --replace '${search}' \"${replacement}\"") where; - mkEnsureSubstituted = - { - replacement, - search, - where, - ignore ? [ ], - }: - let - ignore' = lib.concatStringsSep "|" ( - ignore - ++ [ - "^test" - "NEWS" - ] - ); - in - '' - set +e - search=$(grep '${search}' -r | grep -v "${replacement}" | grep -Ev "${ignore'}") - set -e - if [[ -n "$search" ]]; then - echo "Not all references to '${search}' have been replaced. Found the following matches:" - echo "$search" - exit 1 - fi - ''; - in - '' - mesonFlagsArray+=(-Dntp-servers="0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org") - export LC_ALL="en_US.UTF-8"; - - ${lib.concatStringsSep "\n" (lib.flatten (map mkSubstitute binaryReplacements))} - ${lib.concatMapStringsSep "\n" mkEnsureSubstituted binaryReplacements} - - substituteInPlace src/libsystemd/sd-journal/catalog.c \ - --replace /usr/lib/systemd/catalog/ $out/lib/systemd/catalog/ - ''; + substituteInPlace src/libsystemd/sd-journal/catalog.c \ + --replace /usr/lib/systemd/catalog/ $out/lib/systemd/catalog/ + ''; # These defines are overridden by CFLAGS and would trigger annoying # warning messages