diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2017-05-15 08:34:53 +0200 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2017-05-15 08:34:53 +0200 |
| commit | 7ca9f3d5bb32b45733ed16c54264823adf03aebf (patch) | |
| tree | a816929db86ca90d562041bcd3173ccfd8ae6a4a /modules/services | |
| parent | fa03cd4939abb5cc150bd3205db268b3723be680 (diff) | |
launchd: add script option for services
Diffstat (limited to 'modules/services')
| -rw-r--r-- | modules/services/activate-system.nix | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/modules/services/activate-system.nix b/modules/services/activate-system.nix index 5ee7cfb..445c78b 100644 --- a/modules/services/activate-system.nix +++ b/modules/services/activate-system.nix @@ -8,42 +8,34 @@ let cfg = config.services.activate-system; - activateScript = pkgs.writeScript "activate-system" '' - #! ${stdenv.shell} - - # Make this configuration the current configuration. - # The readlink is there to ensure that when $systemConfig = /system - # (which is a symlink to the store), /run/current-system is still - # used as a garbage collection root. - ln -sfn $(cat ${config.system.profile}/systemConfig) /run/current-system - - # Prevent the current configuration from being garbage-collected. - ln -sfn /run/current-system /nix/var/nix/gcroots/current-system - - ${config.system.activationScripts.nix.text} - ''; - in { options = { - services.activate-system = { - - enable = mkOption { - type = types.bool; - default = false; - description = '' - Whether to activate system at boot time. - ''; - }; - + services.activate-system.enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to activate system at boot time. + ''; }; }; config = mkIf cfg.enable { launchd.daemons.activate-system = { - command = activateScript; + script = '' + # Make this configuration the current configuration. + # The readlink is there to ensure that when $systemConfig = /system + # (which is a symlink to the store), /run/current-system is still + # used as a garbage collection root. + ln -sfn $(cat ${config.system.profile}/systemConfig) /run/current-system + + # Prevent the current configuration from being garbage-collected. + ln -sfn /run/current-system /nix/var/nix/gcroots/current-system + + ${config.system.activationScripts.nix.text} + ''; serviceConfig.RunAtLoad = true; serviceConfig.KeepAlive.SuccessfulExit = false; }; |
