2013-02-03 09:35:11 +00:00
|
|
|
# Management of static files in /etc.
|
|
|
|
|
2010-09-13 16:41:38 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2006-12-11 15:32:10 +00:00
|
|
|
|
2009-01-02 16:06:52 +00:00
|
|
|
let
|
|
|
|
|
2013-02-03 09:35:11 +00:00
|
|
|
etc = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "etc";
|
|
|
|
|
|
|
|
builder = ./make-etc.sh;
|
|
|
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
|
|
|
/* !!! Use toXML. */
|
|
|
|
sources = map (x: x.source) config.environment.etc;
|
|
|
|
targets = map (x: x.target) config.environment.etc;
|
|
|
|
modes = map (x: x.mode) config.environment.etc;
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2009-05-28 14:17:56 +01:00
|
|
|
environment.etc = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [
|
2011-10-30 15:19:58 +00:00
|
|
|
{ source = "/nix/store/.../etc/dir/file.conf.example";
|
2009-05-28 14:17:56 +01:00
|
|
|
target = "dir/file.conf";
|
|
|
|
mode = "0440";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
description = ''
|
2012-05-12 00:06:35 +01:00
|
|
|
List of files that have to be linked in <filename>/etc</filename>.
|
2009-05-28 14:17:56 +01:00
|
|
|
'';
|
2012-05-12 00:06:35 +01:00
|
|
|
type = types.listOf types.optionSet;
|
|
|
|
options = {
|
|
|
|
source = mkOption {
|
|
|
|
description = "Source file.";
|
|
|
|
};
|
|
|
|
target = mkOption {
|
|
|
|
description = "Name of symlink (relative to <filename>/etc</filename>).";
|
|
|
|
};
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2009-01-02 16:06:52 +00:00
|
|
|
};
|
2013-02-03 09:35:11 +00:00
|
|
|
|
2009-01-02 16:06:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-02-03 09:35:11 +00:00
|
|
|
###### implementation
|
2009-08-16 14:14:33 +01:00
|
|
|
|
2013-02-03 09:35:11 +00:00
|
|
|
config = {
|
2009-08-16 14:14:33 +01:00
|
|
|
|
2013-02-03 09:35:11 +00:00
|
|
|
system.build.etc = etc;
|
2012-05-09 22:35:47 +01:00
|
|
|
|
2013-02-03 09:35:11 +00: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 16:06:52 +00:00
|
|
|
|
2013-02-03 09:35:11 +00:00
|
|
|
};
|
2009-10-30 08:37:08 +00:00
|
|
|
|
2007-02-26 21:18:13 +00:00
|
|
|
}
|