1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-09-11 15:08:33 +01:00
nixpkgs/modules/system/etc/etc.nix

80 lines
1.6 KiB
Nix
Raw Normal View History

2013-02-03 09:35:11 +00:00
# Management of static files in /etc.
{ config, pkgs, ... }:
with pkgs.lib;
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 = {
environment.etc = mkOption {
default = [];
example = [
{ source = "/nix/store/.../etc/dir/file.conf.example";
target = "dir/file.conf";
mode = "0440";
}
];
description = ''
List of files that have to be linked in <filename>/etc</filename>.
'';
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.
'';
};
};
};
2013-02-03 09:35:11 +00:00
};
2013-02-03 09:35:11 +00:00
###### implementation
2013-02-03 09:35:11 +00:00
config = {
2013-02-03 09:35:11 +00:00
system.build.etc = etc;
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
'';
2013-02-03 09:35:11 +00:00
};
}