2009-01-02 17:06:46 +01:00
|
|
|
# generate the script used to activate the configuration.
|
|
|
|
{pkgs, config, ...}:
|
|
|
|
|
|
|
|
let
|
2009-05-18 12:49:28 +02:00
|
|
|
inherit (pkgs.stringsWithDeps) textClosureMap noDepEntry;
|
2009-02-23 00:33:58 +01:00
|
|
|
inherit (pkgs.lib) mkOption mergeTypedOption mergeAttrs mapRecordFlatten
|
2009-05-20 03:35:46 +02:00
|
|
|
mapAttrs addErrorContext fold id filter;
|
|
|
|
inherit (builtins) attrNames;
|
2009-01-02 17:06:46 +01:00
|
|
|
|
2009-05-20 03:35:46 +02:00
|
|
|
addAttributeName = mapAttrs (a: v: v // {
|
2009-01-02 17:07:24 +01:00
|
|
|
text = ''
|
2009-05-20 03:35:46 +02:00
|
|
|
#### actionScripts snippet ${a} :
|
|
|
|
# ========================================
|
2009-01-02 17:07:24 +01:00
|
|
|
${v.text}
|
|
|
|
'';
|
|
|
|
});
|
2009-01-02 17:06:46 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
system = {
|
|
|
|
activationScripts = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = {
|
|
|
|
stdio = {
|
|
|
|
text = "
|
|
|
|
# Needed by some programs.
|
|
|
|
ln -sfn /proc/self/fd /dev/fd
|
|
|
|
ln -sfn /proc/self/fd/0 /dev/stdin
|
|
|
|
ln -sfn /proc/self/fd/1 /dev/stdout
|
|
|
|
ln -sfn /proc/self/fd/2 /dev/stderr
|
|
|
|
";
|
|
|
|
deps = [];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
description = ''
|
|
|
|
Activate the new configuration (i.e., update /etc, make accounts,
|
|
|
|
and so on).
|
|
|
|
'';
|
2009-02-23 00:33:58 +01:00
|
|
|
merge = mergeTypedOption "script" builtins.isAttrs (fold mergeAttrs {});
|
|
|
|
apply = set:
|
2009-05-20 03:35:46 +02:00
|
|
|
let withHeadlines = addAttributeName set;
|
|
|
|
activateLib = removeAttrs withHeadlines ["activate"];
|
|
|
|
activateLibNames = attrNames activateLib;
|
|
|
|
in {
|
2009-05-25 01:13:23 +02:00
|
|
|
script = pkgs.writeScript "nixos-activation-script"
|
2009-05-20 03:35:46 +02:00
|
|
|
("#!/bin/sh\n"
|
|
|
|
+ textClosureMap id activateLib activateLibNames + "\n"
|
|
|
|
# make sure that the activate snippet is added last.
|
|
|
|
+ withHeadlines.activate.text);
|
2009-01-02 17:06:46 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|