From 783f40bb703220acfe93c9496295958dd1c929fb Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:28:29 +0200 Subject: [PATCH 01/17] nixos/power-management: always run systemctl of the currently running systemd --- nixos/modules/config/power-management.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/config/power-management.nix b/nixos/modules/config/power-management.nix index 64cdf50f141..cc0ff732ffa 100644 --- a/nixos/modules/config/power-management.nix +++ b/nixos/modules/config/power-management.nix @@ -94,7 +94,7 @@ in after = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" ]; script = '' - ${config.systemd.package}/bin/systemctl try-restart post-resume.target + /run/current-system/systemd/bin/systemctl try-restart post-resume.target ${cfg.resumeCommands} ${cfg.powerUpCommands} ''; From ea462c742e5faa418650ffa3b49d3319167fe848 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:29:22 +0200 Subject: [PATCH 02/17] nixos/resolvconf: always run systemctl of the currently running systemd --- nixos/modules/config/resolvconf.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/config/resolvconf.nix b/nixos/modules/config/resolvconf.nix index cc202bca6c4..cd0ed491383 100644 --- a/nixos/modules/config/resolvconf.nix +++ b/nixos/modules/config/resolvconf.nix @@ -21,7 +21,7 @@ let '' + optionalString config.services.nscd.enable '' # Invalidate the nscd cache whenever resolv.conf is # regenerated. - libc_restart='${pkgs.systemd}/bin/systemctl try-restart --no-block nscd.service 2> /dev/null' + libc_restart='/run/current-system/systemd/bin/systemctl try-restart --no-block nscd.service 2> /dev/null' '' + optionalString (length resolvconfOptions > 0) '' # Options as described in resolv.conf(5) resolv_conf_options='${concatStringsSep " " resolvconfOptions}' From 8aaca0addc8827ed37035b5297a21605b8980a71 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:29:37 +0200 Subject: [PATCH 03/17] nixos/docker-registry: always run systemctl of the currently running systemd --- nixos/modules/services/misc/docker-registry.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/docker-registry.nix b/nixos/modules/services/misc/docker-registry.nix index 89bac4f47d7..1c2e2cc5359 100644 --- a/nixos/modules/services/misc/docker-registry.nix +++ b/nixos/modules/services/misc/docker-registry.nix @@ -138,7 +138,7 @@ in { script = '' ${pkgs.docker-distribution}/bin/registry garbage-collect ${configFile} - ${pkgs.systemd}/bin/systemctl restart docker-registry.service + /run/current-system/systemd/bin/systemctl restart docker-registry.service ''; startAt = optional cfg.enableGarbageCollect cfg.garbageCollectDates; From 73392b748feec1640be75d359417890628c834a2 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:29:52 +0200 Subject: [PATCH 04/17] nixos/freeswitch: always run systemctl of the currently running systemd --- nixos/modules/services/misc/freeswitch.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/freeswitch.nix b/nixos/modules/services/misc/freeswitch.nix index 0de5ba42811..d27dbe220d3 100644 --- a/nixos/modules/services/misc/freeswitch.nix +++ b/nixos/modules/services/misc/freeswitch.nix @@ -78,7 +78,7 @@ in { wantedBy = [ "multi-user.target" ]; restartTriggers = [ configDirectory ]; serviceConfig = { - ExecStart = "${pkgs.systemd}/bin/systemctl try-reload-or-restart freeswitch.service"; + ExecStart = "/run/current-system/systemd/bin/systemctl try-reload-or-restart freeswitch.service"; RemainAfterExit = true; Type = "oneshot"; }; From b0222a5e9c67b97ff73af80ca84ca94bd11e6471 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:30:21 +0200 Subject: [PATCH 05/17] nixos/dhcpcd: always run systemctl of the currently running systemd --- nixos/modules/services/networking/dhcpcd.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/dhcpcd.nix b/nixos/modules/services/networking/dhcpcd.nix index c0619211c2f..0507b739d49 100644 --- a/nixos/modules/services/networking/dhcpcd.nix +++ b/nixos/modules/services/networking/dhcpcd.nix @@ -81,7 +81,7 @@ let # anything ever again ("couldn't resolve ..., giving up on # it"), so we silently lose time synchronisation. This also # applies to openntpd. - ${config.systemd.package}/bin/systemctl try-reload-or-restart ntpd.service openntpd.service chronyd.service || true + /run/current-system/systemd/bin/systemctl try-reload-or-restart ntpd.service openntpd.service chronyd.service || true fi ${cfg.runHook} @@ -217,7 +217,7 @@ in powerManagement.resumeCommands = mkIf config.systemd.services.dhcpcd.enable '' # Tell dhcpcd to rebind its interfaces if it's running. - ${config.systemd.package}/bin/systemctl reload dhcpcd.service + /run/current-system/systemd/bin/systemctl reload dhcpcd.service ''; }; From 52e104cfdfc75148bb7461cf2e3b58627896e2aa Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:30:40 +0200 Subject: [PATCH 06/17] nixos/nsd: always run systemctl of the currently running systemd --- nixos/modules/services/networking/nsd.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/nsd.nix b/nixos/modules/services/networking/nsd.nix index 429580e5c6c..6e3eed0c557 100644 --- a/nixos/modules/services/networking/nsd.nix +++ b/nixos/modules/services/networking/nsd.nix @@ -252,7 +252,7 @@ let Use imports or pkgs.lib.readFile if you don't want this data in your config file. ''; }; - + dnssec = mkEnableOption "DNSSEC"; dnssecPolicy = { @@ -970,7 +970,7 @@ in script = signZones; postStop = '' - ${pkgs.systemd}/bin/systemctl kill -s SIGHUP nsd.service + /run/current-system/systemd/bin/systemctl kill -s SIGHUP nsd.service ''; }; From 1955982190ca86a412cc7022dbbb96217ddc5263 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:31:08 +0200 Subject: [PATCH 07/17] nixos/wpa_supplicant: always run systemctl of the currently running systemd --- nixos/modules/services/networking/wpa_supplicant.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/wpa_supplicant.nix b/nixos/modules/services/networking/wpa_supplicant.nix index de0f11595a9..a7dea95056a 100644 --- a/nixos/modules/services/networking/wpa_supplicant.nix +++ b/nixos/modules/services/networking/wpa_supplicant.nix @@ -253,12 +253,12 @@ in { }; powerManagement.resumeCommands = '' - ${config.systemd.package}/bin/systemctl try-restart wpa_supplicant + /run/current-system/systemd/bin/systemctl try-restart wpa_supplicant ''; # Restart wpa_supplicant when a wlan device appears or disappears. services.udev.extraRules = '' - ACTION=="add|remove", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", RUN+="${config.systemd.package}/bin/systemctl try-restart wpa_supplicant.service" + ACTION=="add|remove", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", RUN+="/run/current-system/systemd/bin/systemctl try-restart wpa_supplicant.service" ''; }; From a3678ed34711eccfa1ef27f22b51217b1e6c2821 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:31:26 +0200 Subject: [PATCH 08/17] nixos/nginx: always run systemctl of the currently running systemd Also, make the postRun script refer to that systemctl, and not just rely on $PATH for consistency. --- nixos/modules/services/web-servers/nginx/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index 312d2b0a21a..8a015bb3556 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -756,9 +756,9 @@ in serviceConfig.Type = "oneshot"; serviceConfig.TimeoutSec = 60; script = '' - if ${pkgs.systemd}/bin/systemctl -q is-active nginx.service ; then + if /run/current-system/systemd/bin/systemctl -q is-active nginx.service ; then ${execCommand} -t && \ - ${pkgs.systemd}/bin/systemctl reload nginx.service + /run/current-system/systemd/bin/systemctl reload nginx.service fi ''; serviceConfig.RemainAfterExit = true; @@ -772,7 +772,7 @@ in webroot = vhostConfig.acmeRoot; extraDomains = genAttrs vhostConfig.serverAliases (alias: null); postRun = '' - systemctl reload nginx + /run/current-system/systemd/bin/systemctl reload nginx ''; }; }) acmeEnabledVhosts; in From 3fcfcb8bcb5f390da45d12702bb1a7afb07287f3 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:32:59 +0200 Subject: [PATCH 09/17] nixos/display-managers: always run systemctl of the currently running systemd --- .../modules/services/x11/display-managers/default.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index a69e4743173..aa6a5ec42be 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -39,8 +39,8 @@ let ${optionalString cfg.startDbusSession '' if test -z "$DBUS_SESSION_BUS_ADDRESS"; then - ${config.systemd.package}/bin/systemctl --user start dbus.socket - export `${config.systemd.package}/bin/systemctl --user show-environment | grep '^DBUS_SESSION_BUS_ADDRESS'` + /run/current-system/systemd/bin/systemctl --user start dbus.socket + export `/run/current-system/systemd/bin/systemctl --user show-environment | grep '^DBUS_SESSION_BUS_ADDRESS'` fi ''} @@ -60,7 +60,7 @@ let # # Also tell systemd about the dbus session bus address. # This is required by user units using the session bus. - ${config.systemd.package}/bin/systemctl --user import-environment DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS + /run/current-system/systemd/bin/systemctl --user import-environment DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS # Load X defaults. This should probably be safe on wayland too. ${xorg.xrdb}/bin/xrdb -merge ${xresourcesXft} @@ -89,7 +89,7 @@ let fi # Start systemd user services for graphical sessions - ${config.systemd.package}/bin/systemctl --user start graphical-session.target + /run/current-system/systemd/bin/systemctl --user start graphical-session.target # Allow the user to setup a custom session type. if test -x ~/.xsession; then @@ -394,7 +394,7 @@ in test -n "$waitPID" && wait "$waitPID" - ${config.systemd.package}/bin/systemctl --user stop graphical-session.target + /run/current-system/systemd/bin/systemctl --user stop graphical-session.target exit 0 ''; From de358a00b5be1cf168f1aebca49e493a0af21f42 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:33:22 +0200 Subject: [PATCH 10/17] nixos/sddm: always run systemctl of the currently running systemd --- nixos/modules/services/x11/display-managers/sddm.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/x11/display-managers/sddm.nix b/nixos/modules/services/x11/display-managers/sddm.nix index 4224c557ed6..2f42271da87 100644 --- a/nixos/modules/services/x11/display-managers/sddm.nix +++ b/nixos/modules/services/x11/display-managers/sddm.nix @@ -30,8 +30,8 @@ let cfgFile = pkgs.writeText "sddm.conf" '' [General] - HaltCommand=${pkgs.systemd}/bin/systemctl poweroff - RebootCommand=${pkgs.systemd}/bin/systemctl reboot + HaltCommand=/run/current-system/systemd/bin/systemctl poweroff + RebootCommand=/run/current-system/systemd/bin/systemctl reboot ${optionalString cfg.autoNumlock '' Numlock=on ''} From 062302e006dfdeefe88389d251ece488ad5d0086 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:33:37 +0200 Subject: [PATCH 11/17] nixos/xautolock: always run systemctl of the currently running systemd --- nixos/modules/services/x11/xautolock.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/x11/xautolock.nix b/nixos/modules/services/x11/xautolock.nix index 3e03131ca11..5ce08fce7c4 100644 --- a/nixos/modules/services/x11/xautolock.nix +++ b/nixos/modules/services/x11/xautolock.nix @@ -66,7 +66,7 @@ in killer = mkOption { default = null; # default according to `man xautolock` is none - example = "${pkgs.systemd}/bin/systemctl suspend"; + example = "/run/current-system/systemd/bin/systemctl suspend"; type = types.nullOr types.str; description = '' From ad26d7c0449438e76248c6b8cc519b2738af8781 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:33:51 +0200 Subject: [PATCH 12/17] nixos/network-interfaces-scripted: always run systemctl of the currently running systemd --- nixos/modules/tasks/network-interfaces-scripted.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/tasks/network-interfaces-scripted.nix b/nixos/modules/tasks/network-interfaces-scripted.nix index 9720d90217c..f6fce3b1c8b 100644 --- a/nixos/modules/tasks/network-interfaces-scripted.nix +++ b/nixos/modules/tasks/network-interfaces-scripted.nix @@ -327,7 +327,7 @@ let # if `libvirtd.service` is not running, do not use `virsh` which would try activate it via 'libvirtd.socket' and thus start it out-of-order. # `libvirtd.service` will set up bridge interfaces when it will start normally. # - if ${pkgs.systemd}/bin/systemctl --quiet is-active 'libvirtd.service'; then + if /run/current-system/systemd/bin/systemctl --quiet is-active 'libvirtd.service'; then for uri in qemu:///system lxc:///; do for dom in $(${pkgs.libvirt}/bin/virsh -c $uri list --name); do ${pkgs.libvirt}/bin/virsh -c $uri dumpxml "$dom" | \ From 45c03c0dd27e0c9cb42a6e235492d3aef993fcee Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:34:11 +0200 Subject: [PATCH 13/17] nixos/azure-agent: always run systemctl of the currently running systemd --- nixos/modules/virtualisation/azure-agent.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/azure-agent.nix b/nixos/modules/virtualisation/azure-agent.nix index 036b1036f92..e85482af839 100644 --- a/nixos/modules/virtualisation/azure-agent.nix +++ b/nixos/modules/virtualisation/azure-agent.nix @@ -48,7 +48,7 @@ let provisionedHook = pkgs.writeScript "provisioned-hook" '' #!${pkgs.runtimeShell} - ${config.systemd.package}/bin/systemctl start provisioned.target + /run/current-system/systemd/bin/systemctl start provisioned.target ''; in From c7e8ceae0ce3619d4531d2ab72d361c71cfcbe41 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:34:29 +0200 Subject: [PATCH 14/17] deepin.dde-control-center: always run systemctl of the currently running systemd --- pkgs/desktops/deepin/dde-control-center/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/desktops/deepin/dde-control-center/default.nix b/pkgs/desktops/deepin/dde-control-center/default.nix index be2846fc87e..850e39b9367 100644 --- a/pkgs/desktops/deepin/dde-control-center/default.nix +++ b/pkgs/desktops/deepin/dde-control-center/default.nix @@ -121,7 +121,7 @@ mkDerivation rec { substituteInPlace dde-control-center.desktop \ --replace "dbus-send" "${dbus}/bin/dbus-send" substituteInPlace com.deepin.controlcenter.addomain.policy \ - --replace "/bin/systemctl" "${systemd}/bin/systemctl" + --replace "/bin/systemctl" "/run/current-system/sw/bin/systemctl" ''; dontWrapQtApps = true; From 5cca4853967c15df7dda53b8522fe6157e369d63 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:35:07 +0200 Subject: [PATCH 15/17] displaylink: run systemctl of the currently running systemd --- pkgs/os-specific/linux/displaylink/udev-installer.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/displaylink/udev-installer.patch b/pkgs/os-specific/linux/displaylink/udev-installer.patch index bd7d9d145c9..880c073fbcf 100644 --- a/pkgs/os-specific/linux/displaylink/udev-installer.patch +++ b/pkgs/os-specific/linux/displaylink/udev-installer.patch @@ -5,13 +5,13 @@ start_service() { - systemctl start displaylink-driver -+ @systemd@/bin/systemctl start --no-block dlm ++ /run/current-system/systemd/bin/systemctl start --no-block dlm } stop_service() { - systemctl stop displaylink-driver -+ @systemd@/bin/systemctl stop dlm ++ /run/current-system/systemd/bin/systemctl stop dlm } EOF From 2d5de92f8e3b3f34f1ea1e156a16b41ce3e923e4 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:35:21 +0200 Subject: [PATCH 16/17] autorandr: run systemctl of the currently running systemd --- pkgs/tools/misc/autorandr/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/misc/autorandr/default.nix b/pkgs/tools/misc/autorandr/default.nix index 03827d75905..b2bbb161f28 100644 --- a/pkgs/tools/misc/autorandr/default.nix +++ b/pkgs/tools/misc/autorandr/default.nix @@ -34,7 +34,7 @@ in SYSTEMD_UNIT_DIR=/lib/systemd/system \ UDEV_RULES_DIR=/etc/udev/rules.d substituteInPlace $out/etc/udev/rules.d/40-monitor-hotplug.rules \ - --replace /bin/systemctl "${systemd}/bin/systemctl" + --replace /bin/systemctl "/run/current-system/systemd/bin/systemctl" '' else '' make install TARGETS='pmutils' DESTDIR=$out \ PM_SLEEPHOOKS_DIR=/lib/pm-utils/sleep.d From d69f95e2fe4f7fe157539ad8312c73390d456688 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 21 May 2020 10:35:34 +0200 Subject: [PATCH 17/17] google-compute-engine: run systemctl of the currently running systemd --- pkgs/tools/virtualization/google-compute-engine/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/virtualization/google-compute-engine/default.nix b/pkgs/tools/virtualization/google-compute-engine/default.nix index 48255ca68a7..34f2bc9e190 100644 --- a/pkgs/tools/virtualization/google-compute-engine/default.nix +++ b/pkgs/tools/virtualization/google-compute-engine/default.nix @@ -29,7 +29,7 @@ buildPythonApplication rec { postPatch = '' for file in $(find google_compute_engine -type f); do substituteInPlace "$file" \ - --replace /bin/systemctl "/run/current-system/sw/bin/systemctl" \ + --replace /bin/systemctl "/run/current-system/systemd/bin/systemctl" \ --replace /bin/bash "${bashInteractive}/bin/bash" \ --replace /sbin/hwclock "${utillinux}/bin/hwclock" # SELinux tool ??? /sbin/restorecon