2013-02-03 10:35:11 +01:00
|
|
|
# Management of static files in /etc.
|
|
|
|
|
2010-09-13 17:41:38 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2006-12-11 16:32:10 +01:00
|
|
|
|
2009-01-02 17:06:52 +01:00
|
|
|
let
|
|
|
|
|
2013-02-03 13:24:22 +01:00
|
|
|
etc' = attrValues config.environment.etc;
|
|
|
|
|
2013-02-03 10:35:11 +01:00
|
|
|
etc = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "etc";
|
|
|
|
|
|
|
|
builder = ./make-etc.sh;
|
|
|
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
|
|
|
/* !!! Use toXML. */
|
2013-02-03 13:24:22 +01:00
|
|
|
sources = map (x: x.source) etc';
|
|
|
|
targets = map (x: x.target) etc';
|
|
|
|
modes = map (x: x.mode) etc';
|
2013-02-03 10:35:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2009-05-28 15:17:56 +02:00
|
|
|
environment.etc = mkOption {
|
2013-02-03 13:24:22 +01:00
|
|
|
type = types.loaOf types.optionSet;
|
|
|
|
default = {};
|
|
|
|
example =
|
|
|
|
{ hosts =
|
|
|
|
{ source = "/nix/store/.../etc/dir/file.conf.example";
|
|
|
|
mode = "0440";
|
|
|
|
};
|
|
|
|
"default/useradd".text = "GROUP=100 ...";
|
|
|
|
};
|
2009-05-28 15:17:56 +02:00
|
|
|
description = ''
|
2013-02-03 13:24:22 +01:00
|
|
|
Set of files that have to be linked in <filename>/etc</filename>.
|
2009-05-28 15:17:56 +02:00
|
|
|
'';
|
2013-02-03 13:24:22 +01:00
|
|
|
|
|
|
|
options = singleton ({ name, config, ... }:
|
|
|
|
{ options = {
|
|
|
|
source = mkOption {
|
|
|
|
description = "Path of the source file.";
|
|
|
|
};
|
|
|
|
|
|
|
|
target = mkOption {
|
|
|
|
description = ''
|
|
|
|
Name of symlink (relative to
|
|
|
|
<filename>/etc</filename>). Defaults to the attribute
|
|
|
|
name.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
mode = mkOption {
|
|
|
|
default = "symlink";
|
|
|
|
example = "0600";
|
|
|
|
description = ''
|
|
|
|
If set to something else than <literal>symlink</literal>,
|
|
|
|
the file is copied instead of symlinked, with the given
|
|
|
|
file mode.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
target = mkDefault name;
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2009-01-02 17:06:52 +01:00
|
|
|
};
|
2013-02-03 10:35:11 +01:00
|
|
|
|
2009-01-02 17:06:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-02-03 10:35:11 +01:00
|
|
|
###### implementation
|
2009-08-16 15:14:33 +02:00
|
|
|
|
2013-02-03 10:35:11 +01:00
|
|
|
config = {
|
2009-08-16 15:14:33 +02:00
|
|
|
|
2013-02-03 10:35:11 +01:00
|
|
|
system.build.etc = etc;
|
2012-05-09 23:35:47 +02:00
|
|
|
|
2013-02-03 10:35:11 +01:00
|
|
|
system.activationScripts.etc = stringAfter [ "stdio" ]
|
|
|
|
''
|
|
|
|
# Set up the statically computed bits of /etc.
|
|
|
|
echo "setting up /etc..."
|
|
|
|
${pkgs.perl}/bin/perl ${./setup-etc.pl} ${etc}/etc
|
|
|
|
'';
|
2009-01-02 17:06:52 +01:00
|
|
|
|
2013-02-03 10:35:11 +01:00
|
|
|
};
|
2009-10-30 09:37:08 +01:00
|
|
|
|
2007-02-26 22:18:13 +01:00
|
|
|
}
|