diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2016-12-04 10:38:21 +0100 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2016-12-04 10:38:21 +0100 |
| commit | 7b3ace08c53d2555dc95d37b3b414b99055cf6ff (patch) | |
| tree | ed22d3599dd4fe42e6e08139bd07d69e4c630edf /modules | |
| parent | 9a5af2ee4a7530e36c400525098ca1990eaea27b (diff) | |
add service module for system activation
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/services/activate-system.nix | 47 | ||||
| -rw-r--r-- | modules/system/activation-scripts.nix | 13 | ||||
| -rw-r--r-- | modules/system/default.nix | 8 |
3 files changed, 55 insertions, 13 deletions
diff --git a/modules/services/activate-system.nix b/modules/services/activate-system.nix new file mode 100644 index 0000000..a92576f --- /dev/null +++ b/modules/services/activate-system.nix @@ -0,0 +1,47 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.activate-system; + + activateScript = pkgs.writeScript "activate-system" '' + #! ${pkgs.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 + ''; + +in + +{ + options = { + services.activate-system = { + + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to activate system at boot time. + ''; + }; + + }; + }; + + config = { + + launchd.daemons.activate-system = mkIf cfg.enable { + serviceConfig.Program = "${activateScript}"; + serviceConfig.RunAtLoad = true; + }; + + }; +} diff --git a/modules/system/activation-scripts.nix b/modules/system/activation-scripts.nix index fe3131d..fda882f 100644 --- a/modules/system/activation-scripts.nix +++ b/modules/system/activation-scripts.nix @@ -34,19 +34,6 @@ in config = { - system.build.activate = pkgs.writeScript "activate-system" '' - #! ${pkgs.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 /nix/var/nix/profiles/system/systemConfig) /run/current-system - - # Prevent the current configuration from being garbage-collected. - ln -sfn /run/current-system /nix/var/nix/gcroots/current-system - ''; - system.activationScripts.script.text = '' #! ${pkgs.stdenv.shell} diff --git a/modules/system/default.nix b/modules/system/default.nix index 9cf190e..d1d9f72 100644 --- a/modules/system/default.nix +++ b/modules/system/default.nix @@ -27,6 +27,14 @@ in ''; }; + system.profile = mkOption { + type = types.path; + default = "/nix/var/nix/profiles/system"; + description = '' + Profile to use for the system. + ''; + }; + system.nixdarwinLabel = mkOption { type = types.str; default = "16.09"; |
