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