2010-09-13 17:41:38 +02:00
|
|
|
# Produce a script to generate /etc.
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2006-12-11 16:32:10 +01:00
|
|
|
|
2009-01-02 17:06:52 +01:00
|
|
|
###### interface
|
|
|
|
let
|
|
|
|
|
|
|
|
option = {
|
2009-05-28 15:17:56 +02:00
|
|
|
environment.etc = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [
|
2011-10-30 16:19:58 +01:00
|
|
|
{ source = "/nix/store/.../etc/dir/file.conf.example";
|
2009-05-28 15:17:56 +02:00
|
|
|
target = "dir/file.conf";
|
|
|
|
mode = "0440";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
description = ''
|
2012-05-12 01:06:35 +02:00
|
|
|
List of files that have to be linked in <filename>/etc</filename>.
|
2009-05-28 15:17:56 +02:00
|
|
|
'';
|
2012-05-12 01:06:35 +02: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 17:06:52 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
let
|
|
|
|
|
2010-09-13 19:26:42 +02:00
|
|
|
etc = pkgs.stdenv.mkDerivation {
|
2009-08-16 15:14:33 +02:00
|
|
|
name = "etc";
|
|
|
|
|
|
|
|
builder = ./make-etc.sh;
|
|
|
|
|
2012-05-09 23:35:47 +02:00
|
|
|
preferLocalBuild = true;
|
|
|
|
|
2009-08-16 15:14:33 +02:00
|
|
|
/* !!! Use toXML. */
|
|
|
|
sources = map (x: x.source) config.environment.etc;
|
|
|
|
targets = map (x: x.target) config.environment.etc;
|
2012-05-12 01:06:35 +02:00
|
|
|
modes = map (x: x.mode) config.environment.etc;
|
2009-01-02 17:06:52 +01:00
|
|
|
};
|
2009-08-16 15:14:33 +02:00
|
|
|
|
2009-01-02 17:06:52 +01:00
|
|
|
in
|
2008-06-12 01:06:53 +02:00
|
|
|
|
2009-01-02 17:06:52 +01:00
|
|
|
{
|
2009-05-28 15:17:56 +02:00
|
|
|
require = [option];
|
2009-01-02 17:06:52 +01:00
|
|
|
|
2010-09-13 19:26:42 +02:00
|
|
|
system.build.etc = etc;
|
2009-01-02 17:06:52 +01:00
|
|
|
|
2010-09-13 20:19:15 +02:00
|
|
|
system.activationScripts.etc = stringAfter [ "stdio" ]
|
2010-09-13 17:41:38 +02:00
|
|
|
''
|
|
|
|
# Set up the statically computed bits of /etc.
|
|
|
|
echo "setting up /etc..."
|
2010-09-13 19:26:42 +02:00
|
|
|
${pkgs.perl}/bin/perl ${./setup-etc.pl} ${etc}/etc
|
2010-09-13 17:41:38 +02:00
|
|
|
'';
|
2009-10-30 09:37:08 +01:00
|
|
|
|
2007-02-26 22:18:13 +01:00
|
|
|
}
|