2009-01-02 16:06:46 +00:00
|
|
|
# generate the script used to activate the configuration.
|
|
|
|
{pkgs, config, ...}:
|
|
|
|
|
|
|
|
let
|
2009-05-18 11:49:28 +01:00
|
|
|
inherit (pkgs.stringsWithDeps) textClosureMap noDepEntry;
|
2009-02-22 23:33:58 +00:00
|
|
|
inherit (pkgs.lib) mkOption mergeTypedOption mergeAttrs mapRecordFlatten
|
2009-05-20 02:35:46 +01:00
|
|
|
mapAttrs addErrorContext fold id filter;
|
|
|
|
inherit (builtins) attrNames;
|
2009-01-02 16:06:46 +00:00
|
|
|
|
2009-05-20 02:35:46 +01:00
|
|
|
addAttributeName = mapAttrs (a: v: v // {
|
2009-01-02 16:07:24 +00:00
|
|
|
text = ''
|
2009-05-20 02:35:46 +01:00
|
|
|
#### actionScripts snippet ${a} :
|
|
|
|
# ========================================
|
2009-01-02 16:07:24 +00:00
|
|
|
${v.text}
|
|
|
|
'';
|
|
|
|
});
|
2009-01-02 16:06:46 +00: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-22 23:33:58 +00:00
|
|
|
merge = mergeTypedOption "script" builtins.isAttrs (fold mergeAttrs {});
|
|
|
|
apply = set:
|
2009-05-20 02:35:46 +01:00
|
|
|
let withHeadlines = addAttributeName set;
|
|
|
|
activateLib = removeAttrs withHeadlines ["activate"];
|
|
|
|
activateLibNames = attrNames activateLib;
|
|
|
|
in {
|
2009-05-25 00:13:23 +01:00
|
|
|
script = pkgs.writeScript "nixos-activation-script"
|
2009-05-20 02:35:46 +01:00
|
|
|
("#!/bin/sh\n"
|
|
|
|
+ textClosureMap id activateLib activateLibNames + "\n"
|
|
|
|
# make sure that the activate snippet is added last.
|
|
|
|
+ withHeadlines.activate.text);
|
2009-01-02 16:06:46 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|