2016-12-04 10:38:21 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2016-12-07 23:06:18 +01:00
|
|
|
inherit (pkgs) stdenv;
|
|
|
|
|
2016-12-04 10:38:21 +01:00
|
|
|
cfg = config.services.activate-system;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
2017-05-15 08:34:53 +02:00
|
|
|
services.activate-system.enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to activate system at boot time.
|
|
|
|
'';
|
2016-12-04 10:38:21 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-12-14 21:15:02 +01:00
|
|
|
config = mkIf cfg.enable {
|
2016-12-04 10:38:21 +01:00
|
|
|
|
2016-12-14 21:15:02 +01:00
|
|
|
launchd.daemons.activate-system = {
|
2017-05-15 08:34:53 +02:00
|
|
|
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}
|
|
|
|
'';
|
2016-12-04 10:38:21 +01:00
|
|
|
serviceConfig.RunAtLoad = true;
|
2017-01-25 21:20:00 +01:00
|
|
|
serviceConfig.KeepAlive.SuccessfulExit = false;
|
2016-12-04 10:38:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|