2007-11-15 17:16:16 +00:00
|
|
|
|
{ config, pkgs, upstartJobs, systemPath, wrapperDir
|
2008-01-12 23:37:17 +00:00
|
|
|
|
, defaultShell, extraEtc, nixEnvVars, modulesTree
|
2007-11-15 17:16:16 +00:00
|
|
|
|
}:
|
2006-12-11 15:32:10 +00:00
|
|
|
|
|
2007-01-16 16:09:43 +00:00
|
|
|
|
let
|
|
|
|
|
|
2007-06-10 21:02:07 +01:00
|
|
|
|
|
2007-11-09 18:49:45 +00:00
|
|
|
|
optional = pkgs.lib.optional;
|
2007-01-16 16:09:43 +00:00
|
|
|
|
|
2007-06-10 21:02:07 +01:00
|
|
|
|
|
|
|
|
|
# !!! ugh, these files shouldn't be created here.
|
|
|
|
|
|
|
|
|
|
|
2008-01-04 17:05:48 +00:00
|
|
|
|
envConf = pkgs.writeText "environment" ''
|
2007-02-06 10:17:13 +00:00
|
|
|
|
PATH=${systemPath}/bin:${systemPath}/sbin:${pkgs.openssh}/bin
|
2007-03-01 15:31:05 +00:00
|
|
|
|
NIX_REMOTE=daemon
|
2008-01-04 17:05:48 +00:00
|
|
|
|
'' /* ${pkgs.openssh}/bin is a hack to get remote scp to work */;
|
2007-06-10 21:02:07 +01:00
|
|
|
|
|
|
|
|
|
|
2008-01-04 17:05:48 +00:00
|
|
|
|
pamConsoleHandlers = pkgs.writeText "console.handlers" ''
|
|
|
|
|
console consoledevs /dev/tty[0-9][0-9]* :[0-9]\.[0-9] :[0-9]
|
|
|
|
|
${pkgs.pam_console}/sbin/pam_console_apply lock logfail wait -t tty -s -c ${pamConsolePerms}
|
|
|
|
|
${pkgs.pam_console}/sbin/pam_console_apply unlock logfail wait -r -t tty -s -c ${pamConsolePerms}
|
|
|
|
|
'';
|
2007-06-10 21:02:07 +01:00
|
|
|
|
|
|
|
|
|
pamConsolePerms = ./security/console.perms;
|
|
|
|
|
|
2007-01-16 16:09:43 +00:00
|
|
|
|
in
|
2007-06-10 21:02:07 +01:00
|
|
|
|
|
2007-01-16 16:09:43 +00:00
|
|
|
|
|
2006-12-11 15:32:10 +00:00
|
|
|
|
import ../helpers/make-etc.nix {
|
|
|
|
|
inherit (pkgs) stdenv;
|
|
|
|
|
|
|
|
|
|
configFiles = [
|
|
|
|
|
|
|
|
|
|
{ # TCP/UDP port assignments.
|
|
|
|
|
source = pkgs.iana_etc + "/etc/services";
|
|
|
|
|
target = "services";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ # IP protocol numbers.
|
|
|
|
|
source = pkgs.iana_etc + "/etc/protocols";
|
|
|
|
|
target = "protocols";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ # Hostname-to-IP mappings.
|
2008-01-04 17:05:48 +00:00
|
|
|
|
source = pkgs.substituteAll {
|
|
|
|
|
src = ./hosts;
|
|
|
|
|
extraHosts = config.networking.extraHosts;
|
|
|
|
|
};
|
2006-12-11 15:32:10 +00:00
|
|
|
|
target = "hosts";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ # Name Service Switch configuration file. Required by the C library.
|
2007-03-30 13:59:43 +01:00
|
|
|
|
source = ./nsswitch.conf;
|
2006-12-11 15:32:10 +00:00
|
|
|
|
target = "nsswitch.conf";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ # Configuration file for the system logging daemon.
|
2007-03-30 13:59:43 +01:00
|
|
|
|
source = ./syslog.conf;
|
2006-12-11 15:32:10 +00:00
|
|
|
|
target = "syslog.conf";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ # Friendly greeting on the virtual consoles.
|
2008-01-04 17:05:48 +00:00
|
|
|
|
source = pkgs.writeText "issue" ''
|
|
|
|
|
|
|
|
|
|
[1;32m${config.services.mingetty.greetingLine}[0m
|
|
|
|
|
${config.services.mingetty.helpLine}
|
|
|
|
|
|
|
|
|
|
'';
|
2006-12-11 15:32:10 +00:00
|
|
|
|
target = "issue";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ # Configuration for pwdutils (login, passwd, useradd, etc.).
|
|
|
|
|
# You cannot login without it!
|
2007-03-30 13:59:43 +01:00
|
|
|
|
source = ./login.defs;
|
2006-12-11 15:32:10 +00:00
|
|
|
|
target = "login.defs";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ # The Upstart events defined above.
|
|
|
|
|
source = upstartJobs + "/etc/event.d";
|
|
|
|
|
target = "event.d";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{ # Configuration for passwd and friends (e.g., hash algorithm
|
|
|
|
|
# for /etc/passwd).
|
2007-03-30 13:59:43 +01:00
|
|
|
|
source = ./default/passwd;
|
2006-12-11 15:32:10 +00:00
|
|
|
|
target = "default/passwd";
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-20 13:30:14 +00:00
|
|
|
|
{ # Configuration for useradd.
|
|
|
|
|
source = pkgs.substituteAll {
|
2007-03-30 13:59:43 +01:00
|
|
|
|
src = ./default/useradd;
|
2007-03-20 13:30:14 +00:00
|
|
|
|
inherit defaultShell;
|
|
|
|
|
};
|
|
|
|
|
target = "default/useradd";
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-22 17:28:25 +00:00
|
|
|
|
{ # Dhclient hooks for emitting ip-up/ip-down events.
|
|
|
|
|
source = pkgs.substituteAll {
|
2007-03-30 13:59:43 +01:00
|
|
|
|
src = ./dhclient-exit-hooks;
|
2007-01-23 10:22:00 +00:00
|
|
|
|
inherit (pkgs) upstart glibc;
|
2006-12-22 17:28:25 +00:00
|
|
|
|
};
|
|
|
|
|
target = "dhclient-exit-hooks";
|
|
|
|
|
}
|
2007-01-15 14:43:56 +00:00
|
|
|
|
|
|
|
|
|
{ # Script executed when the shell starts.
|
|
|
|
|
source = pkgs.substituteAll {
|
2007-03-30 13:59:43 +01:00
|
|
|
|
src = ./profile.sh;
|
2008-01-12 23:37:17 +00:00
|
|
|
|
inherit systemPath wrapperDir modulesTree;
|
2008-01-06 18:45:13 +00:00
|
|
|
|
inherit (pkgs) glibc;
|
2007-11-09 18:49:45 +00:00
|
|
|
|
timeZone = config.time.timeZone;
|
|
|
|
|
defaultLocale = config.i18n.defaultLocale;
|
2007-11-15 17:16:16 +00:00
|
|
|
|
inherit nixEnvVars;
|
2007-01-15 14:43:56 +00:00
|
|
|
|
};
|
|
|
|
|
target = "profile";
|
|
|
|
|
}
|
2007-01-16 16:09:43 +00:00
|
|
|
|
|
2007-05-02 10:55:35 +01:00
|
|
|
|
{ # Configuration for readline in bash.
|
|
|
|
|
source = ./inputrc;
|
|
|
|
|
target = "inputrc";
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-05 11:19:51 +00:00
|
|
|
|
{ # Nix configuration.
|
2008-01-04 17:05:48 +00:00
|
|
|
|
source = pkgs.writeText "nix.conf" ''
|
2007-11-05 11:19:51 +00:00
|
|
|
|
# WARNING: this file is generated.
|
|
|
|
|
build-users-group = nixbld
|
2007-11-09 18:49:45 +00:00
|
|
|
|
build-max-jobs = ${toString (config.nix.maxJobs)}
|
|
|
|
|
build-use-chroot = ${if config.nix.useChroot then "true" else "false"}
|
2007-11-05 11:19:51 +00:00
|
|
|
|
build-chroot-dirs = /dev /proc /bin /etc
|
2007-11-09 18:49:45 +00:00
|
|
|
|
${config.nix.extraOptions}
|
2008-01-04 17:05:48 +00:00
|
|
|
|
'';
|
2007-11-05 11:19:51 +00:00
|
|
|
|
target = "nix.conf"; # will be symlinked from /nix/etc/nix/nix.conf in activate-configuration.sh.
|
|
|
|
|
}
|
2007-11-08 18:15:12 +00:00
|
|
|
|
|
2008-01-16 13:59:03 +00:00
|
|
|
|
{ # SSH configuration. Slight duplication of the sshd_config
|
|
|
|
|
# generation in the sshd service.
|
|
|
|
|
source = pkgs.writeText "ssh_config" ''
|
|
|
|
|
${if config.services.sshd.forwardX11 then ''
|
|
|
|
|
ForwardX11 yes
|
|
|
|
|
XAuthLocation ${pkgs.xorg.xauth}/bin/xauth
|
|
|
|
|
'' else ''
|
|
|
|
|
ForwardX11 no
|
|
|
|
|
''}
|
|
|
|
|
'';
|
|
|
|
|
target = "ssh/ssh_config";
|
|
|
|
|
}
|
|
|
|
|
|
2006-12-11 15:32:10 +00:00
|
|
|
|
]
|
|
|
|
|
|
2007-11-08 18:15:12 +00:00
|
|
|
|
# Configuration for ssmtp.
|
2007-11-09 18:49:45 +00:00
|
|
|
|
++ optional config.networking.defaultMailServer.directDelivery {
|
2008-01-04 17:05:48 +00:00
|
|
|
|
source = let cfg = config.networking.defaultMailServer; in pkgs.writeText "ssmtp.conf" ''
|
|
|
|
|
mailhub=${cfg.hostName}
|
|
|
|
|
${if cfg.domain != "" then "rewriteDomain=${cfg.domain}" else ""}
|
|
|
|
|
UseTLS=${if cfg.useTLS then "YES" else "NO"}
|
|
|
|
|
UseSTARTTLS=${if cfg.useSTARTTLS then "YES" else "NO"}
|
|
|
|
|
#Debug=YES
|
|
|
|
|
'';
|
2007-11-08 18:15:12 +00:00
|
|
|
|
target = "ssmtp/ssmtp.conf";
|
2007-11-09 18:49:45 +00:00
|
|
|
|
}
|
2007-11-08 18:15:12 +00:00
|
|
|
|
|
2007-01-22 16:42:29 +00:00
|
|
|
|
# Configuration file for fontconfig used to locate
|
|
|
|
|
# (X11) client-rendered fonts.
|
2008-02-14 07:42:52 +00:00
|
|
|
|
++ optional config.fonts.enableFontConfig {
|
2007-01-22 16:42:29 +00:00
|
|
|
|
source = pkgs.runCommand "fonts.conf"
|
|
|
|
|
{
|
2007-09-25 20:00:20 +01:00
|
|
|
|
fontDirectories = import ../system/fonts.nix {inherit pkgs config;};
|
2007-01-22 16:42:29 +00:00
|
|
|
|
buildInputs = [pkgs.libxslt];
|
|
|
|
|
inherit (pkgs) fontconfig;
|
|
|
|
|
}
|
|
|
|
|
"xsltproc --stringparam fontDirectories \"$fontDirectories\" \\
|
2007-10-05 13:56:44 +01:00
|
|
|
|
--stringparam fontconfig \"$fontconfig\" \\
|
2007-03-30 13:59:43 +01:00
|
|
|
|
${./fonts/make-fonts-conf.xsl} $fontconfig/etc/fonts/fonts.conf \\
|
2007-01-22 16:42:29 +00:00
|
|
|
|
> $out
|
|
|
|
|
";
|
|
|
|
|
target = "fonts/fonts.conf";
|
2007-11-09 18:49:45 +00:00
|
|
|
|
}
|
2007-01-22 16:42:29 +00:00
|
|
|
|
|
2007-01-16 16:09:43 +00:00
|
|
|
|
# LDAP configuration.
|
2007-11-09 18:49:45 +00:00
|
|
|
|
++ optional config.users.ldap.enable {
|
2007-04-10 15:10:45 +01:00
|
|
|
|
source = import ./ldap.conf.nix {
|
2007-01-16 16:09:43 +00:00
|
|
|
|
inherit (pkgs) writeText;
|
|
|
|
|
inherit config;
|
|
|
|
|
};
|
|
|
|
|
target = "ldap.conf";
|
2007-11-09 18:49:45 +00:00
|
|
|
|
}
|
2007-01-16 16:09:43 +00:00
|
|
|
|
|
2007-08-16 16:09:06 +01:00
|
|
|
|
# "sudo" configuration.
|
2007-11-09 18:49:45 +00:00
|
|
|
|
++ optional config.security.sudo.enable {
|
2007-08-16 16:09:06 +01:00
|
|
|
|
source = pkgs.runCommand "sudoers"
|
2007-11-09 18:49:45 +00:00
|
|
|
|
{ src = pkgs.writeText "sudoers-in" (config.security.sudo.configFile);
|
2007-08-16 16:09:06 +01:00
|
|
|
|
}
|
|
|
|
|
# Make sure that the sudoers file is syntactically valid.
|
2007-10-10 15:28:40 +01:00
|
|
|
|
# (currently disabled - NIXOS-66)
|
|
|
|
|
#"${pkgs.sudo}/sbin/visudo -f $src -c && cp $src $out";
|
|
|
|
|
"cp $src $out";
|
2007-08-16 16:09:06 +01:00
|
|
|
|
target = "sudoers";
|
|
|
|
|
mode = "0440";
|
2007-11-09 18:49:45 +00:00
|
|
|
|
}
|
2007-08-16 16:09:06 +01:00
|
|
|
|
|
2006-12-11 15:32:10 +00:00
|
|
|
|
# A bunch of PAM configuration files for various programs.
|
|
|
|
|
++ (map
|
|
|
|
|
(program:
|
2007-11-09 18:49:45 +00:00
|
|
|
|
let isLDAPEnabled = config.users.ldap.enable; in
|
2006-12-11 15:32:10 +00:00
|
|
|
|
{ source = pkgs.substituteAll {
|
2007-03-30 13:59:43 +01:00
|
|
|
|
src = ./pam.d + ("/" + program);
|
2007-06-10 21:02:07 +01:00
|
|
|
|
inherit (pkgs) pam_unix2 pam_console;
|
2007-01-16 16:09:43 +00:00
|
|
|
|
pam_ldap =
|
2007-06-10 21:02:07 +01:00
|
|
|
|
if isLDAPEnabled
|
2007-01-16 16:09:43 +00:00
|
|
|
|
then pkgs.pam_ldap
|
|
|
|
|
else "/no-such-path";
|
2007-01-16 22:25:28 +00:00
|
|
|
|
inherit (pkgs.xorg) xauth;
|
2007-06-10 21:02:07 +01:00
|
|
|
|
inherit envConf pamConsoleHandlers;
|
|
|
|
|
isLDAPEnabled = if isLDAPEnabled then "" else "#";
|
2006-12-11 15:32:10 +00:00
|
|
|
|
};
|
|
|
|
|
target = "pam.d/" + program;
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
[
|
|
|
|
|
"login"
|
2007-06-05 12:28:18 +01:00
|
|
|
|
"slim"
|
2007-01-11 15:32:48 +00:00
|
|
|
|
"su"
|
2007-07-09 12:21:04 +01:00
|
|
|
|
"sudo"
|
2006-12-16 21:48:12 +00:00
|
|
|
|
"other"
|
2006-12-11 15:32:10 +00:00
|
|
|
|
"passwd"
|
2006-12-16 21:48:12 +00:00
|
|
|
|
"shadow"
|
|
|
|
|
"sshd"
|
2006-12-11 15:32:10 +00:00
|
|
|
|
"useradd"
|
2007-02-26 21:18:13 +00:00
|
|
|
|
"chsh"
|
2007-01-30 15:03:43 +00:00
|
|
|
|
"common"
|
2007-06-10 21:02:07 +01:00
|
|
|
|
"common-console" # shared stuff for interactive local sessions
|
2006-12-11 15:32:10 +00:00
|
|
|
|
]
|
2007-03-30 13:55:09 +01:00
|
|
|
|
)
|
|
|
|
|
|
2007-11-15 17:16:16 +00:00
|
|
|
|
# List of machines for distributed Nix builds in the format expected
|
|
|
|
|
# by build-remote.pl.
|
|
|
|
|
++ optional config.nix.distributedBuilds {
|
|
|
|
|
source = pkgs.writeText "nix.machines"
|
|
|
|
|
(pkgs.lib.concatStrings (map (machine:
|
|
|
|
|
"${machine.sshUser}@${machine.hostName} ${machine.system} ${machine.sshKey} ${toString machine.maxJobs}\n"
|
|
|
|
|
) config.nix.buildMachines));
|
|
|
|
|
target = "nix.machines";
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-30 13:55:09 +01:00
|
|
|
|
# Additional /etc files declared by Upstart jobs.
|
|
|
|
|
++ extraEtc;
|
|
|
|
|
|
2007-02-26 21:18:13 +00:00
|
|
|
|
}
|