From f4a3bdd6afa31671bfc18fd22417b04914dfa0a8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 8 Jan 2013 18:24:06 +0100 Subject: [PATCH] Install {rescue,emergency}.{target,service} Also, symlink kbrequest.target to rescue.target as suggested by the systemd.special manpage. This way, you can start a sulogin rescue shell by pressing Alt+Up. --- modules/system/boot/systemd.nix | 39 ++++++++------------------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix index f72d15d01299..83911d179fde 100644 --- a/modules/system/boot/systemd.nix +++ b/modules/system/boot/systemd.nix @@ -28,7 +28,6 @@ let "graphical.target" "multi-user.target" "getty.target" - "rescue.target" "network.target" "nss-lookup.target" "nss-user-lookup.target" @@ -37,6 +36,12 @@ let #"cryptsetup.target" "sigpwr.target" + # Rescue/emergency. + "rescue.target" + "rescue.service" + "emergency.target" + "emergency.service" + # Udev. "systemd-udevd-control.socket" "systemd-udevd-kernel.socket" @@ -139,33 +144,6 @@ let "shutdown.target.wants" ]; - rescueService = - '' - [Unit] - Description=Rescue Shell - DefaultDependencies=no - Conflicts=shutdown.target - After=sysinit.target - Before=shutdown.target - - [Service] - Environment=HOME=/root - WorkingDirectory=/root - ExecStartPre=-${pkgs.coreutils}/bin/echo 'Welcome to rescue mode. Use "systemctl default" or ^D to enter default mode.' - #ExecStart=-/sbin/sulogin - ExecStart=-${pkgs.bashInteractive}/bin/bash --login - ExecStopPost=-${systemd}/bin/systemctl --fail --no-block default - Type=idle - StandardInput=tty-force - StandardOutput=inherit - StandardError=inherit - KillMode=process - - # Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash - # terminates cleanly. - KillSignal=SIGHUP - ''; - makeJobScript = name: text: let x = pkgs.writeTextFile { name = "unit-script"; executable = true; destination = "/bin/${name}"; inherit text; }; in "${x}/bin/${name}"; @@ -347,6 +325,8 @@ let ln -s ${cfg.defaultUnit} $out/default.target + ln -s rescue.target $out/kbrequest.target + #ln -s ../getty@tty1.service $out/multi-user.target.wants/ ln -s ../local-fs.target ../remote-fs.target ../network.target ../nss-lookup.target \ ../nss-user-lookup.target ../swap.target $out/multi-user.target.wants/ @@ -525,8 +505,7 @@ in }; boot.systemd.units = - { "rescue.service".text = rescueService; } - // mapAttrs' (n: v: nameValuePair "${n}.target" (targetToUnit n v)) cfg.targets + mapAttrs' (n: v: nameValuePair "${n}.target" (targetToUnit n v)) cfg.targets // mapAttrs' (n: v: nameValuePair "${n}.service" (serviceToUnit n v)) cfg.services // mapAttrs' (n: v: nameValuePair "${n}.socket" (socketToUnit n v)) cfg.sockets // listToAttrs (map