From 337423af8e63f6d89cfd5818a27e48163239d6bd Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 19 Jun 2012 17:36:02 -0400 Subject: [PATCH] Backdoor: depend on /dev/hvc0 Systemd is the shit: units can declare a dependency on the appearance of device nodes. Yay! --- modules/system/boot/systemd.nix | 21 ++++++++++++++++++++- modules/testing/test-instrumentation.nix | 15 +++++---------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix index 7fafc94a4bb..6976a204e7f 100644 --- a/modules/system/boot/systemd.nix +++ b/modules/system/boot/systemd.nix @@ -12,6 +12,23 @@ let description = "Description of this unit used in systemd messages and progress indicators."; }; + requires = mkOption { + default = []; + types = types.listOf types.string; + description = '' + Start the specified units when this unit is started, and stop + this unit when the specified units are stopped or fail. + ''; + }; + + wants = mkOption { + default = []; + types = types.listOf types.string; + description = '' + Start the specified units when this unit is started. + ''; + }; + after = mkOption { default = []; types = types.listOf types.string; @@ -33,7 +50,7 @@ let wantedBy = mkOption { default = []; types = types.listOf types.string; - description = "Units that want (i.e. depend on) this unit."; + description = "Start this unit when the specified units are started."; }; environment = mkOption { @@ -249,6 +266,8 @@ let ${optionalString (def.description != "") '' Description=${def.description} ''} + Requires=${concatStringsSep " " def.requires} + Wants=${concatStringsSep " " def.wants} Before=${concatStringsSep " " def.before} After=${concatStringsSep " " def.after} diff --git a/modules/testing/test-instrumentation.nix b/modules/testing/test-instrumentation.nix index 5e40cf215b7..468a3030ca6 100644 --- a/modules/testing/test-instrumentation.nix +++ b/modules/testing/test-instrumentation.nix @@ -21,15 +21,12 @@ in { - config = - # Require a patch to the kernel to increase the 15s CIFS timeout. - mkAssert (config.boot.kernelPackages.kernel.features ? cifsTimeout) " - VM tests require that the kernel has the CIFS timeout patch. - " { + config = { - jobs.backdoor = - { startOn = "started udev"; - stopOn = ""; + boot.systemd.services."backdoor.service" = + { wantedBy = [ "multi-user.target" ]; + requires = [ "dev-hvc0.device" ]; + after = [ "dev-hvc0.device" ]; script = '' @@ -43,8 +40,6 @@ in stty -F /dev/hvc0 raw -echo # prevent nl -> cr/nl conversion ${pkgs.socat}/bin/socat stdio exec:${rootShell} ''; - - respawn = false; }; boot.initrd.postDeviceCommands =