summaryrefslogtreecommitdiff
path: root/modules/services/activate-system
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2017-07-17 21:44:57 +0200
committerDaiderd Jordan <daiderd@gmail.com>2017-07-17 21:46:35 +0200
commit3730fdf15edff95bbb8d60c28632d003b24fdbde (patch)
treedd4e860cfd9e94b227ab11f6bb891401aba0d92a /modules/services/activate-system
parentd049c7b97aa00488d2b27697ba21db70cc9f0fe8 (diff)
enable activate-system serice by default
Diffstat (limited to 'modules/services/activate-system')
-rw-r--r--modules/services/activate-system/default.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/modules/services/activate-system/default.nix b/modules/services/activate-system/default.nix
new file mode 100644
index 0000000..b3f446e
--- /dev/null
+++ b/modules/services/activate-system/default.nix
@@ -0,0 +1,40 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ inherit (pkgs) stdenv;
+
+ cfg = config.services.activate-system;
+in
+
+{
+ options = {
+ services.activate-system.enable = mkOption {
+ type = types.bool;
+ default = true;
+ description = "Whether to activate system at boot time.";
+ };
+ };
+
+ config = mkIf cfg.enable {
+
+ launchd.daemons.activate-system = {
+ 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;
+ };
+
+ };
+}