2016-12-04 10:38:21 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.activate-system;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
2017-05-15 08:34:53 +02:00
|
|
|
services.activate-system.enable = mkOption {
|
|
|
|
type = types.bool;
|
2017-07-17 21:44:57 +02:00
|
|
|
default = true;
|
2023-06-22 12:21:32 +01:00
|
|
|
description = lib.mdDoc "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 = ''
|
2020-10-25 15:17:36 +01:00
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
export PATH="${pkgs.gnugrep}/bin:${pkgs.coreutils}/bin:@out@/sw/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
|
|
|
2020-10-25 16:02:23 +01:00
|
|
|
systemConfig=$(cat ${config.system.profile}/systemConfig)
|
|
|
|
|
2017-05-15 08:34:53 +02:00
|
|
|
# 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
|
|
|
|
|
2023-07-12 08:35:11 +01:00
|
|
|
${config.system.activationScripts.etcChecks.text}
|
2020-10-25 16:02:23 +01:00
|
|
|
${config.system.activationScripts.etc.text}
|
2018-02-28 20:18:49 +01:00
|
|
|
${config.system.activationScripts.keyboard.text}
|
2017-05-15 08:34:53 +02:00
|
|
|
'';
|
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
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|