* Eliminate all calls to config.get.

svn path=/nixos/trunk/; revision=9619
This commit is contained in:
Eelco Dolstra 2007-11-09 18:49:45 +00:00
parent 62c1f0ddcc
commit 2fc94b76fe
16 changed files with 178 additions and 229 deletions

View File

@ -144,7 +144,7 @@ rec {
timeout 60 timeout 60
label linux label linux
kernel vmlinuz kernel vmlinuz
append initrd=initrd ${toString (system.config.get ["boot" "kernelParams"])} append initrd=initrd ${toString (system.config.boot.kernelParams)}
"; ";

View File

@ -28,7 +28,7 @@ in
nixFallback = system.nix; nixFallback = system.nix;
manifests = system.config.get ["installer" "manifests"]; # exported here because nixos-rebuild uses it manifests = system.config.installer.manifests; # exported here because nixos-rebuild uses it
upstartJobsCombined = system.upstartJobs; upstartJobsCombined = system.upstartJobs;

View File

@ -3,8 +3,7 @@
let let
optional = option: file: optional = pkgs.lib.optional;
if config.get option then [file] else [];
# !!! ugh, these files shouldn't be created here. # !!! ugh, these files shouldn't be created here.
@ -47,7 +46,7 @@ import ../helpers/make-etc.nix {
{ # Hostname-to-IP mappings. { # Hostname-to-IP mappings.
source = pkgs.substituteAll{ source = pkgs.substituteAll{
src = ./hosts; src = ./hosts;
extraHosts = config.get ["networking" "extraHosts"]; extraHosts = config.networking.extraHosts;
}; };
target = "hosts"; target = "hosts";
} }
@ -105,8 +104,8 @@ import ../helpers/make-etc.nix {
src = ./profile.sh; src = ./profile.sh;
inherit systemPath wrapperDir; inherit systemPath wrapperDir;
inherit (pkgs) systemKernel glibc; inherit (pkgs) systemKernel glibc;
timeZone = config.get ["time" "timeZone"]; timeZone = config.time.timeZone;
defaultLocale = config.get ["i18n" "defaultLocale"]; defaultLocale = config.i18n.defaultLocale;
}; };
target = "profile"; target = "profile";
} }
@ -120,10 +119,10 @@ import ../helpers/make-etc.nix {
source = pkgs.writeText "nix.conf" " source = pkgs.writeText "nix.conf" "
# WARNING: this file is generated. # WARNING: this file is generated.
build-users-group = nixbld build-users-group = nixbld
build-max-jobs = ${toString (config.get ["nix" "maxJobs"])} build-max-jobs = ${toString (config.nix.maxJobs)}
build-use-chroot = ${if config.get ["nix" "useChroot"] then "true" else "false"} build-use-chroot = ${if config.nix.useChroot then "true" else "false"}
build-chroot-dirs = /dev /proc /bin /etc build-chroot-dirs = /dev /proc /bin /etc
${config.get ["nix" "extraOptions"]} ${config.nix.extraOptions}
"; ";
target = "nix.conf"; # will be symlinked from /nix/etc/nix/nix.conf in activate-configuration.sh. target = "nix.conf"; # will be symlinked from /nix/etc/nix/nix.conf in activate-configuration.sh.
} }
@ -131,19 +130,19 @@ import ../helpers/make-etc.nix {
] ]
# Configuration for ssmtp. # Configuration for ssmtp.
++ (optional ["networking" "defaultMailServer" "directDelivery"] { ++ optional config.networking.defaultMailServer.directDelivery {
source = pkgs.writeText "ssmtp.conf" " source = pkgs.writeText "ssmtp.conf" "
mailhub=${config.get ["networking" "defaultMailServer" "hostName"]} mailhub=${config.networking.defaultMailServer.hostName}
UseTLS=${if config.get ["networking" "defaultMailServer" "useTLS"] then "YES" else "NO"} UseTLS=${if config.networking.defaultMailServer.useTLS then "YES" else "NO"}
UseSTARTTLS=${if config.get ["networking" "defaultMailServer" "useSTARTTLS"] then "YES" else "NO"} UseSTARTTLS=${if config.networking.defaultMailServer.useSTARTTLS then "YES" else "NO"}
#Debug=YES #Debug=YES
"; ";
target = "ssmtp/ssmtp.conf"; target = "ssmtp/ssmtp.conf";
}) }
# Configuration file for fontconfig used to locate # Configuration file for fontconfig used to locate
# (X11) client-rendered fonts. # (X11) client-rendered fonts.
++ (optional ["fonts" "enableFontConfig"] { ++ optional config.fonts.enableFontConfig {
source = pkgs.runCommand "fonts.conf" source = pkgs.runCommand "fonts.conf"
{ {
fontDirectories = import ../system/fonts.nix {inherit pkgs config;}; fontDirectories = import ../system/fonts.nix {inherit pkgs config;};
@ -156,21 +155,21 @@ UseSTARTTLS=${if config.get ["networking" "defaultMailServer" "useSTARTTLS"] the
> $out > $out
"; ";
target = "fonts/fonts.conf"; target = "fonts/fonts.conf";
}) }
# LDAP configuration. # LDAP configuration.
++ (optional ["users" "ldap" "enable"] { ++ optional config.users.ldap.enable {
source = import ./ldap.conf.nix { source = import ./ldap.conf.nix {
inherit (pkgs) writeText; inherit (pkgs) writeText;
inherit config; inherit config;
}; };
target = "ldap.conf"; target = "ldap.conf";
}) }
# "sudo" configuration. # "sudo" configuration.
++ (optional ["security" "sudo" "enable"] { ++ optional config.security.sudo.enable {
source = pkgs.runCommand "sudoers" source = pkgs.runCommand "sudoers"
{ src = pkgs.writeText "sudoers-in" (config.get ["security" "sudo" "configFile"]); { src = pkgs.writeText "sudoers-in" (config.security.sudo.configFile);
} }
# Make sure that the sudoers file is syntactically valid. # Make sure that the sudoers file is syntactically valid.
# (currently disabled - NIXOS-66) # (currently disabled - NIXOS-66)
@ -178,12 +177,12 @@ UseSTARTTLS=${if config.get ["networking" "defaultMailServer" "useSTARTTLS"] the
"cp $src $out"; "cp $src $out";
target = "sudoers"; target = "sudoers";
mode = "0440"; mode = "0440";
}) }
# A bunch of PAM configuration files for various programs. # A bunch of PAM configuration files for various programs.
++ (map ++ (map
(program: (program:
let isLDAPEnabled = config.get ["users" "ldap" "enable"]; in let isLDAPEnabled = config.users.ldap.enable; in
{ source = pkgs.substituteAll { { source = pkgs.substituteAll {
src = ./pam.d + ("/" + program); src = ./pam.d + ("/" + program);
inherit (pkgs) pam_unix2 pam_console; inherit (pkgs) pam_unix2 pam_console;

View File

@ -5,11 +5,11 @@
writeText "ldap.conf" " writeText "ldap.conf" "
uri ${config.get ["users" "ldap" "server"]} uri ${config.users.ldap.server}
base ${config.get ["users" "ldap" "base"]} base ${config.users.ldap.base}
${ ${
if config.get ["users" "ldap" "useTLS"] then " if config.users.ldap.useTLS then "
ssl start_tls ssl start_tls
tls_checkpeer no tls_checkpeer no
" else "" " else ""

View File

@ -5,4 +5,4 @@ stdenv.mkDerivation {
builder = ./builder.sh; builder = ./builder.sh;
setuidWrapper = ./setuid-wrapper.c; setuidWrapper = ./setuid-wrapper.c;
inherit wrapperDir; inherit wrapperDir;
} }

View File

@ -1,40 +0,0 @@
# Given a configuration, this function returns an object with a `get'
# method for retrieving the values of options, falling back to the
# defaults declared in options.nix if no value is given for an
# option.
pkgs: config:
let
lib = pkgs.library;
# The option declarations, i.e., option names with defaults and
# documentation.
declarations = import ./options.nix {inherit pkgs; inherit (lib) mkOption;};
configFilled = lib.addDefaultOptionValues declarations config;
# Get the option named `name' from the user configuration, using
# its default value if it's not defined.
get = name:
/*
let
decl =
lib.findSingle (decl: lib.eqLists decl.name name)
(abort ("Undeclared option `" + printName name + "'."))
(abort ("Multiple declarations for option `" + printName name + "'."))
declarations;
default =
if !decl ? default
then abort ("Option `" + printName name + "' has no default.")
else decl.default;
in lib.getAttr name default config;
*/
let
default = abort ("Undeclared option `" + printName name + "'.");
in lib.getAttr name default configFilled;
printName = name: lib.concatStrings (lib.intersperse "." name);
in configFilled // {inherit get;}

View File

@ -20,6 +20,6 @@
pkgs.xorg.fontcursormisc pkgs.xorg.fontcursormisc
] ]
++ pkgs.lib.optional (config.get ["fonts" "enableGhostscriptFonts"]) "${pkgs.ghostscript}/share/ghostscript/fonts" ++ pkgs.lib.optional (config.fonts.enableGhostscriptFonts) "${pkgs.ghostscript}/share/ghostscript/fonts"
++ ((config.get ["fonts" "extraFonts"]) pkgs) ++ ((config.fonts.extraFonts) pkgs)

View File

@ -7,8 +7,10 @@ rec {
# Make a configuration object from which we can retrieve option # Make a configuration object from which we can retrieve option
# values. # values.
config = import ./config.nix pkgs configuration; config = pkgs.lib.addDefaultOptionValues optionDeclarations configuration;
optionDeclarations = import ./options.nix {inherit pkgs; inherit (pkgs.lib) mkOption;};
pkgs = import ../pkgs/top-level/all-packages.nix {system = platform;}; pkgs = import ../pkgs/top-level/all-packages.nix {system = platform;};
@ -27,7 +29,7 @@ rec {
allPackages = import ../pkgs/top-level/all-packages.nix; allPackages = import ../pkgs/top-level/all-packages.nix;
}; };
manifests = config.get ["installer" "manifests"]; # exported here because nixos-rebuild uses it manifests = config.installer.manifests; # exported here because nixos-rebuild uses it
nix = pkgs.nixUnstable; # we need the exportReferencesGraph feature nix = pkgs.nixUnstable; # we need the exportReferencesGraph feature
@ -53,8 +55,8 @@ rec {
inherit (pkgsStatic) utillinux; inherit (pkgsStatic) utillinux;
inherit (pkgsDiet) udev; inherit (pkgsDiet) udev;
e2fsprogs = pkgs.e2fsprogsDiet; e2fsprogs = pkgs.e2fsprogsDiet;
devicemapper = if config.get ["boot" "initrd" "lvm"] then pkgs.devicemapperStatic else null; devicemapper = if config.boot.initrd.lvm then pkgs.devicemapperStatic else null;
lvm2 = if config.get ["boot" "initrd" "lvm"] then pkgs.lvm2Static else null; lvm2 = if config.boot.initrd.lvm then pkgs.lvm2Static else null;
allowedReferences = []; # prevent accidents like glibc being included in the initrd allowedReferences = []; # prevent accidents like glibc being included in the initrd
} }
" "
@ -76,12 +78,12 @@ rec {
inherit (pkgs) substituteAll; inherit (pkgs) substituteAll;
inherit (pkgsDiet) module_init_tools; inherit (pkgsDiet) module_init_tools;
inherit extraUtils; inherit extraUtils;
autoDetectRootDevice = config.get ["boot" "autoDetectRootDevice"]; autoDetectRootDevice = config.boot.autoDetectRootDevice;
fileSystems = fileSystems =
pkgs.lib.filter pkgs.lib.filter
(fs: fs.mountPoint == "/" || (fs ? neededForBoot && fs.neededForBoot)) (fs: fs.mountPoint == "/" || (fs ? neededForBoot && fs.neededForBoot))
(config.get ["fileSystems"]); (config.fileSystems);
rootLabel = config.get ["boot" "rootLabel"]; rootLabel = config.boot.rootLabel;
inherit stage2Init; inherit stage2Init;
modulesDir = modulesClosure; modulesDir = modulesClosure;
modules = rootModules; modules = rootModules;
@ -98,7 +100,7 @@ rec {
{ object = bootStage1; { object = bootStage1;
symlink = "/init"; symlink = "/init";
} }
] ++ (if config.get ["boot" "initrd" "enableSplashScreen"] then [ ] ++ (if config.boot.initrd.enableSplashScreen then [
{ object = pkgs.runCommand "splashutils" {} " { object = pkgs.runCommand "splashutils" {} "
ensureDir $out/bin ensureDir $out/bin
cp ${pkgs.splashutils}/bin/splash_helper $out/bin cp ${pkgs.splashutils}/bin/splash_helper $out/bin
@ -108,7 +110,7 @@ rec {
} }
{ object = import ../helpers/unpack-theme.nix { { object = import ../helpers/unpack-theme.nix {
inherit (pkgs) stdenv; inherit (pkgs) stdenv;
theme = config.get ["services" "ttyBackgrounds" "defaultTheme"]; theme = config.services.ttyBackgrounds.defaultTheme;
}; };
symlink = "/etc/splash"; symlink = "/etc/splash";
} }
@ -120,7 +122,7 @@ rec {
nixosInstall = import ../installer/nixos-install.nix { nixosInstall = import ../installer/nixos-install.nix {
inherit (pkgs) perl runCommand substituteAll; inherit (pkgs) perl runCommand substituteAll;
inherit nix; inherit nix;
nixpkgsURL = config.get ["installer" "nixpkgsURL"]; nixpkgsURL = config.installer.nixpkgsURL;
}; };
nixosRebuild = import ../installer/nixos-rebuild.nix { nixosRebuild = import ../installer/nixos-rebuild.nix {
@ -134,7 +136,7 @@ rec {
# NSS modules. Hacky! # NSS modules. Hacky!
nssModules = nssModules =
if config.get ["users" "ldap" "enable"] then [pkgs.nss_ldap] else []; if config.users.ldap.enable then [pkgs.nss_ldap] else [];
nssModulesPath = pkgs.lib.concatStrings (pkgs.lib.intersperse ":" nssModulesPath = pkgs.lib.concatStrings (pkgs.lib.intersperse ":"
(map (mod: mod + "/lib") nssModules)); (map (mod: mod + "/lib") nssModules));
@ -228,11 +230,11 @@ rec {
nixosCheckout nixosCheckout
setuidWrapper setuidWrapper
] ]
++ pkgs.lib.optional (config.get ["security" "sudo" "enable"]) pkgs.sudo ++ pkgs.lib.optional (config.security.sudo.enable) pkgs.sudo
++ pkgs.lib.optional (config.get ["networking" "defaultMailServer" "directDelivery"]) pkgs.ssmtp ++ pkgs.lib.optional (config.networking.defaultMailServer.directDelivery) pkgs.ssmtp
++ pkgs.lib.concatLists (map (job: job.extraPath) upstartJobs.jobs) ++ pkgs.lib.concatLists (map (job: job.extraPath) upstartJobs.jobs)
++ (config.get ["environment" "extraPackages"]) pkgs ++ (config.environment.extraPackages) pkgs
++ pkgs.lib.optional (config.get ["fonts" "enableFontDir"]) fontDir; ++ pkgs.lib.optional (config.fonts.enableFontDir) fontDir;
# We don't want to put all of `startPath' and `path' in $PATH, since # We don't want to put all of `startPath' and `path' in $PATH, since
@ -261,12 +263,12 @@ rec {
isExecutable = true; isExecutable = true;
inherit etc wrapperDir systemPath modprobe defaultShell kernel; inherit etc wrapperDir systemPath modprobe defaultShell kernel;
readOnlyRoot = config.get ["boot" "readOnlyRoot"]; readOnlyRoot = config.boot.readOnlyRoot;
hostName = config.get ["networking" "hostName"]; hostName = config.networking.hostName;
setuidPrograms = setuidPrograms =
config.get ["security" "setuidPrograms"] ++ config.security.setuidPrograms ++
config.get ["security" "extraSetuidPrograms"] ++ config.security.extraSetuidPrograms ++
pkgs.lib.optional (config.get ["security" "sudo" "enable"]) "sudo"; pkgs.lib.optional (config.security.sudo.enable) "sudo";
inherit (usersGroups) createUsersGroups usersList groupsList; inherit (usersGroups) createUsersGroups usersList groupsList;
@ -286,7 +288,7 @@ rec {
inherit (pkgs) substituteAll writeText coreutils inherit (pkgs) substituteAll writeText coreutils
utillinux udev upstart; utillinux udev upstart;
inherit kernel activateConfiguration; inherit kernel activateConfiguration;
readOnlyRoot = config.get ["boot" "readOnlyRoot"]; readOnlyRoot = config.boot.readOnlyRoot;
upstartPath = [ upstartPath = [
pkgs.coreutils pkgs.coreutils
pkgs.findutils pkgs.findutils
@ -294,7 +296,7 @@ rec {
pkgs.gnused pkgs.gnused
pkgs.upstart pkgs.upstart
]; ];
bootLocal = config.get ["boot" "localCommands"]; bootLocal = config.boot.localCommands;
}; };
@ -305,8 +307,8 @@ rec {
isExecutable = true; isExecutable = true;
inherit (pkgs) bash; inherit (pkgs) bash;
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep]; path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
copyKernels = config.get ["boot" "copyKernels"]; copyKernels = config.boot.copyKernels;
extraGrubEntries = config.get ["boot" "extraGrubEntries"]; extraGrubEntries = config.boot.extraGrubEntries;
}; };
@ -320,10 +322,10 @@ rec {
builder = ./system.sh; builder = ./system.sh;
switchToConfiguration = ./switch-to-configuration.sh; switchToConfiguration = ./switch-to-configuration.sh;
inherit (pkgs) grub coreutils gnused gnugrep diffutils findutils upstart; inherit (pkgs) grub coreutils gnused gnugrep diffutils findutils upstart;
grubDevice = config.get ["boot" "grubDevice"]; grubDevice = config.boot.grubDevice;
kernelParams = kernelParams =
(config.get ["boot" "kernelParams"]) ++ (config.boot.kernelParams) ++
(config.get ["boot" "extraKernelParams"]); (config.boot.extraKernelParams);
inherit bootStage2; inherit bootStage2;
inherit activateConfiguration; inherit activateConfiguration;
inherit grubMenuBuilder; inherit grubMenuBuilder;
@ -340,7 +342,7 @@ rec {
pkgs.diffutils pkgs.diffutils
pkgs.upstart # for initctl pkgs.upstart # for initctl
]; ];
configurationName = config.get ["boot" "configurationName"]; configurationName = config.boot.configurationName;
}) (pkgs.getConfig ["checkConfigurationOptions"] false) }) (pkgs.getConfig ["checkConfigurationOptions"] false)
config.declarations configuration ; config.declarations configuration ;
} }

View File

@ -82,4 +82,4 @@ rec {
usersList = pkgs.writeText "users" (pkgs.lib.concatStrings (map (u: "${u.name}\n${u.description}\n${toString u.uid}\n${u.group}\n${toString u.extraGroups}\n${u.home}\n${u.shell}\n") systemUsers)); usersList = pkgs.writeText "users" (pkgs.lib.concatStrings (map (u: "${u.name}\n${u.description}\n${toString u.uid}\n${u.group}\n${toString u.extraGroups}\n${u.home}\n${u.shell}\n") systemUsers));
groupsList = pkgs.writeText "groups" (pkgs.lib.concatStrings (map (g: "${g.name}\n${toString g.gid}\n") systemGroups)); groupsList = pkgs.writeText "groups" (pkgs.lib.concatStrings (map (g: "${g.name}\n${toString g.gid}\n") systemGroups));
} }

View File

@ -6,11 +6,10 @@ let
inherit (pkgs) runCommand; inherit (pkgs) runCommand;
}; };
optional = option: service: optional = cond: service: pkgs.lib.optional cond (makeJob service);
if config.get option then [(makeJob service)] else [];
requiredTTYs = requiredTTYs =
(config.get ["services" "mingetty" "ttys"]) (config.services.mingetty.ttys)
++ [10] /* !!! sync with syslog.conf */ ; ++ [10] /* !!! sync with syslog.conf */ ;
in in
@ -30,11 +29,11 @@ import ../upstart-jobs/gather.nix {
inherit (pkgs) stdenv writeText substituteAll udev procps; inherit (pkgs) stdenv writeText substituteAll udev procps;
inherit (pkgs.lib) cleanSource; inherit (pkgs.lib) cleanSource;
firmwareDirs = firmwareDirs =
pkgs.lib.optional (config.get ["networking" "enableIntel2200BGFirmware"]) pkgs.ipw2200fw pkgs.lib.optional (config.networking.enableIntel2200BGFirmware) pkgs.ipw2200fw
++ ++
(config.get ["services" "udev" "addFirmware"]); (config.services.udev.addFirmware);
extraUdevPkgs = extraUdevPkgs =
pkgs.lib.optional (config.get ["services" "hal" "enable"]) pkgs.hal; pkgs.lib.optional (config.services.hal.enable) pkgs.hal;
}) })
# Makes LVM logical volumes available. # Makes LVM logical volumes available.
@ -52,30 +51,30 @@ import ../upstart-jobs/gather.nix {
# Hardware scan; loads modules for PCI devices. # Hardware scan; loads modules for PCI devices.
(import ../upstart-jobs/hardware-scan.nix { (import ../upstart-jobs/hardware-scan.nix {
inherit modprobe; inherit modprobe;
doHardwareScan = config.get ["boot" "hardwareScan"]; doHardwareScan = config.boot.hardwareScan;
kernelModules = config.get ["boot" "kernelModules"]; kernelModules = config.boot.kernelModules;
}) })
# Mount file systems. # Mount file systems.
(import ../upstart-jobs/filesystems.nix { (import ../upstart-jobs/filesystems.nix {
inherit (pkgs) utillinux e2fsprogs; inherit (pkgs) utillinux e2fsprogs;
fileSystems = config.get ["fileSystems"]; fileSystems = config.fileSystems;
}) })
# Swapping. # Swapping.
(import ../upstart-jobs/swap.nix { (import ../upstart-jobs/swap.nix {
inherit (pkgs) utillinux library; inherit (pkgs) utillinux library;
swapDevices = config.get ["swapDevices"]; swapDevices = config.swapDevices;
}) })
# Network interfaces. # Network interfaces.
(import ../upstart-jobs/network-interfaces.nix { (import ../upstart-jobs/network-interfaces.nix {
inherit modprobe; inherit modprobe;
inherit (pkgs) nettools wirelesstools bash writeText; inherit (pkgs) nettools wirelesstools bash writeText;
nameservers = config.get ["networking" "nameservers"]; nameservers = config.networking.nameservers;
defaultGateway = config.get ["networking" "defaultGateway"]; defaultGateway = config.networking.defaultGateway;
interfaces = config.get ["networking" "interfaces"]; interfaces = config.networking.interfaces;
localCommands = config.get ["networking" "localCommands"]; localCommands = config.networking.localCommands;
}) })
# Nix daemon - required for multi-user Nix. # Nix daemon - required for multi-user Nix.
@ -99,9 +98,9 @@ import ../upstart-jobs/gather.nix {
(import ../upstart-jobs/kbd.nix { (import ../upstart-jobs/kbd.nix {
inherit (pkgs) glibc kbd gzip; inherit (pkgs) glibc kbd gzip;
ttyNumbers = requiredTTYs; ttyNumbers = requiredTTYs;
defaultLocale = config.get ["i18n" "defaultLocale"]; defaultLocale = config.i18n.defaultLocale;
consoleFont = config.get ["i18n" "consoleFont"]; consoleFont = config.i18n.consoleFont;
consoleKeyMap = config.get ["i18n" "consoleKeyMap"]; consoleKeyMap = config.i18n.consoleKeyMap;
}) })
# Handles the maintenance/stalled event (single-user shell). # Handles the maintenance/stalled event (single-user shell).
@ -115,47 +114,47 @@ import ../upstart-jobs/gather.nix {
] ]
# DHCP client. # DHCP client.
++ optional ["networking" "useDHCP"] ++ optional config.networking.useDHCP
(import ../upstart-jobs/dhclient.nix { (import ../upstart-jobs/dhclient.nix {
inherit (pkgs) nettools dhcp lib; inherit (pkgs) nettools dhcp lib;
interfaces = config.get ["networking" "interfaces"]; interfaces = config.networking.interfaces;
}) })
# ifplugd daemon for monitoring Ethernet cables. # ifplugd daemon for monitoring Ethernet cables.
++ optional ["networking" "interfaceMonitor" "enable"] ++ optional config.networking.interfaceMonitor.enable
(import ../upstart-jobs/ifplugd.nix { (import ../upstart-jobs/ifplugd.nix {
inherit (pkgs) ifplugd writeScript bash; inherit (pkgs) ifplugd writeScript bash;
inherit config; inherit config;
}) })
# DHCP server. # DHCP server.
++ optional ["services" "dhcpd" "enable"] ++ optional config.services.dhcpd.enable
(import ../upstart-jobs/dhcpd.nix { (import ../upstart-jobs/dhcpd.nix {
inherit (pkgs) dhcp; inherit (pkgs) dhcp;
configFile = config.get ["services" "dhcpd" "configFile"]; configFile = config.services.dhcpd.configFile;
interfaces = config.get ["services" "dhcpd" "interfaces"]; interfaces = config.services.dhcpd.interfaces;
}) })
# SSH daemon. # SSH daemon.
++ optional ["services" "sshd" "enable"] ++ optional config.services.sshd.enable
(import ../upstart-jobs/sshd.nix { (import ../upstart-jobs/sshd.nix {
inherit (pkgs) writeText openssh glibc; inherit (pkgs) writeText openssh glibc;
inherit (pkgs.xorg) xauth; inherit (pkgs.xorg) xauth;
inherit nssModulesPath; inherit nssModulesPath;
forwardX11 = config.get ["services" "sshd" "forwardX11"]; forwardX11 = config.services.sshd.forwardX11;
allowSFTP = config.get ["services" "sshd" "allowSFTP"]; allowSFTP = config.services.sshd.allowSFTP;
}) })
# NTP daemon. # NTP daemon.
++ optional ["services" "ntp" "enable"] ++ optional config.services.ntp.enable
(import ../upstart-jobs/ntpd.nix { (import ../upstart-jobs/ntpd.nix {
inherit modprobe; inherit modprobe;
inherit (pkgs) ntp glibc writeText; inherit (pkgs) ntp glibc writeText;
servers = config.get ["services" "ntp" "servers"]; servers = config.services.ntp.servers;
}) })
# X server. # X server.
++ optional ["services" "xserver" "enable"] ++ optional config.services.xserver.enable
(import ../upstart-jobs/xserver.nix { (import ../upstart-jobs/xserver.nix {
inherit config; inherit config;
inherit (pkgs) writeText lib xterm slim xorg mesa inherit (pkgs) writeText lib xterm slim xorg mesa
@ -165,64 +164,64 @@ import ../upstart-jobs/gather.nix {
libX11 = pkgs.xlibs.libX11; libX11 = pkgs.xlibs.libX11;
libXext = pkgs.xlibs.libXext; libXext = pkgs.xlibs.libXext;
fontDirectories = import ../system/fonts.nix {inherit pkgs config;}; fontDirectories = import ../system/fonts.nix {inherit pkgs config;};
isClone = config.get ["services" "xserver" "isClone"]; isClone = config.services.xserver.isClone;
}) })
# Apache httpd. # Apache httpd.
++ optional ["services" "httpd" "enable"] ++ optional config.services.httpd.enable
(import ../upstart-jobs/httpd.nix { (import ../upstart-jobs/httpd.nix {
inherit config pkgs; inherit config pkgs;
inherit (pkgs) glibc; inherit (pkgs) glibc;
}) })
# Samba service. # Samba service.
++ optional ["services" "samba" "enable"] ++ optional config.services.samba.enable
(import ../upstart-jobs/samba.nix { (import ../upstart-jobs/samba.nix {
inherit pkgs; inherit pkgs;
inherit (pkgs) glibc samba; inherit (pkgs) glibc samba;
}) })
# CUPS (printing) daemon. # CUPS (printing) daemon.
++ optional ["services" "printing" "enable"] ++ optional config.services.printing.enable
(import ../upstart-jobs/cupsd.nix { (import ../upstart-jobs/cupsd.nix {
inherit (pkgs) writeText cups; inherit (pkgs) writeText cups;
}) })
# Gateway6 # Gateway6
++ optional ["services" "gw6c" "enable"] ++ optional config.services.gw6c.enable
(import ../upstart-jobs/gw6c.nix { (import ../upstart-jobs/gw6c.nix {
inherit config pkgs; inherit config pkgs;
}) })
# X Font Server # X Font Server
++ optional ["services" "xfs" "enable"] ++ optional config.services.xfs.enable
(import ../upstart-jobs/xfs.nix { (import ../upstart-jobs/xfs.nix {
inherit config pkgs; inherit config pkgs;
}) })
++ optional ["services" "ircdHybrid" "enable"] ++ optional config.services.ircdHybrid.enable
(import ../upstart-jobs/ircd-hybrid.nix { (import ../upstart-jobs/ircd-hybrid.nix {
inherit config pkgs; inherit config pkgs;
}) })
# ALSA sound support. # ALSA sound support.
++ optional ["sound" "enable"] ++ optional config.sound.enable
(import ../upstart-jobs/alsa.nix { (import ../upstart-jobs/alsa.nix {
inherit modprobe; inherit modprobe;
inherit (pkgs) alsaUtils; inherit (pkgs) alsaUtils;
}) })
# D-Bus system-wide daemon. # D-Bus system-wide daemon.
++ optional ["services" "dbus" "enable"] ++ optional config.services.dbus.enable
(import ../upstart-jobs/dbus.nix { (import ../upstart-jobs/dbus.nix {
inherit (pkgs) stdenv dbus; inherit (pkgs) stdenv dbus;
dbusServices = dbusServices =
pkgs.lib.optional (config.get ["services" "hal" "enable"]) pkgs.hal; pkgs.lib.optional (config.services.hal.enable) pkgs.hal;
}) })
# HAL daemon. # HAL daemon.
++ optional ["services" "hal" "enable"] ++ optional config.services.hal.enable
(import ../upstart-jobs/hal.nix { (import ../upstart-jobs/hal.nix {
inherit (pkgs) stdenv hal; inherit (pkgs) stdenv hal;
}) })
@ -243,11 +242,11 @@ import ../upstart-jobs/gather.nix {
inherit ttyNumber; inherit ttyNumber;
loginProgram = "${pkgs.pam_login}/bin/login"; loginProgram = "${pkgs.pam_login}/bin/login";
})) }))
(config.get ["services" "mingetty" "ttys"]) (config.services.mingetty.ttys)
) )
# Transparent TTY backgrounds. # Transparent TTY backgrounds.
++ optional ["services" "ttyBackgrounds" "enable"] ++ optional config.services.ttyBackgrounds.enable
(import ../upstart-jobs/tty-backgrounds.nix { (import ../upstart-jobs/tty-backgrounds.nix {
inherit (pkgs) stdenv splashutils; inherit (pkgs) stdenv splashutils;
@ -256,8 +255,8 @@ import ../upstart-jobs/gather.nix {
let let
specificThemes = specificThemes =
config.get ["services" "ttyBackgrounds" "defaultSpecificThemes"] config.services.ttyBackgrounds.defaultSpecificThemes
++ config.get ["services" "ttyBackgrounds" "specificThemes"]; ++ config.services.ttyBackgrounds.specificThemes;
overridenTTYs = map (x: x.tty) specificThemes; overridenTTYs = map (x: x.tty) specificThemes;
@ -270,14 +269,14 @@ import ../upstart-jobs/gather.nix {
in in
(map (ttyNumber: { (map (ttyNumber: {
tty = ttyNumber; tty = ttyNumber;
theme = config.get ["services" "ttyBackgrounds" "defaultTheme"]; theme = config.services.ttyBackgrounds.defaultTheme;
}) defaultTTYs) }) defaultTTYs)
++ specificThemes; ++ specificThemes;
}) })
# User-defined events. # User-defined events.
++ (map makeJob (config.get ["services" "extraJobs"])) ++ (map makeJob (config.services.extraJobs))
# For the built-in logd job. # For the built-in logd job.
++ [(makeJob { jobDrv = pkgs.upstart; })]; ++ [(makeJob { jobDrv = pkgs.upstart; })];

View File

@ -1,16 +1,16 @@
{config, pkgs}: {config, pkgs}:
let let
getCfg = option: config.get ["services" "gw6c" option]; cfg = config.services.gw6c;
procps = pkgs.procps; procps = pkgs.procps;
gw6cService = import ../services/gw6c { gw6cService = import ../services/gw6c {
inherit (pkgs) stdenv gw6c coreutils inherit (pkgs) stdenv gw6c coreutils
procps upstart iputils gnused procps upstart iputils gnused
gnugrep; gnugrep;
username = getCfg "username"; username = cfg.username;
password = getCfg "password"; password = cfg.password;
server = getCfg "server"; server = cfg.server;
keepAlive = getCfg "keepAlive"; keepAlive = cfg.keepAlive;
everPing = getCfg "everPing"; everPing = cfg.everPing;
}; };
in in
{ {

View File

@ -2,34 +2,30 @@
let let
getCfg = option: config.get ["services" "httpd" option]; cfg = config.services.httpd;
getCfgs = options: config.get (["services" "httpd"] ++ options); cfgSvn = cfg.subservices.subversion;
getCfgSvn = option: config.get ["services" "httpd" "subservices" "subversion" option];
getCfgsSvn = options: config.get (["services" "httpd" "subservices" "subversion"] ++ options);
optional = conf: subService: optional = pkgs.lib.optional;
if conf then [subService] else [];
hostName = getCfg "hostName"; hostName = cfg.hostName;
httpPort = getCfg "httpPort"; httpPort = cfg.httpPort;
httpsPort = getCfg "httpsPort"; httpsPort = cfg.httpsPort;
user = getCfg "user"; user = cfg.user;
group = getCfg "group"; group = cfg.group;
adminAddr = getCfg "adminAddr"; adminAddr = cfg.adminAddr;
logDir = getCfg "logDir"; logDir = cfg.logDir;
stateDir = getCfg "stateDir"; stateDir = cfg.stateDir;
enableSSL = false; enableSSL = false;
noUserDir = getCfg "noUserDir"; noUserDir = cfg.noUserDir;
extraDirectories = getCfg "extraDirectories"; extraDirectories = cfg.extraDirectories;
startingDependency = if (config.get [ "services" "gw6c" "enable" ]) startingDependency = if config.services.gw6c.enable then "gw6c" else "network-interfaces";
then "gw6c" else "network-interfaces";
webServer = import ../../services/apache-httpd { webServer = import ../../services/apache-httpd {
inherit (pkgs) apacheHttpd coreutils; inherit (pkgs) apacheHttpd coreutils;
stdenv = pkgs.stdenvNewSetupScript; stdenv = pkgs.stdenvNewSetupScript;
php = if getCfg "mod_php" then pkgs.php else null; php = if cfg.mod_php then pkgs.php else null;
inherit hostName httpPort httpsPort inherit hostName httpPort httpsPort
user group adminAddr logDir stateDir user group adminAddr logDir stateDir
@ -38,8 +34,8 @@ let
subServices = subServices =
# The Subversion subservice. # The Subversion subservice.
(optional (getCfgSvn "enable") ( (optional cfgSvn.enable (
let dataDir = getCfgSvn "dataDir"; in let dataDir = cfgSvn.dataDir; in
import ../../services/subversion ({ import ../../services/subversion ({
reposDir = dataDir + "/repos"; reposDir = dataDir + "/repos";
dbDir = dataDir + "/db"; dbDir = dataDir + "/db";
@ -55,17 +51,17 @@ let
else else
"http://" + hostName + ":" + (toString httpPort); "http://" + hostName + ":" + (toString httpPort);
notificationSender = getCfgSvn "notificationSender"; notificationSender = cfgSvn.notificationSender;
autoVersioning = getCfgSvn "autoVersioning"; autoVersioning = cfgSvn.autoVersioning;
userCreationDomain = getCfgSvn "userCreationDomain"; userCreationDomain = cfgSvn.userCreationDomain;
inherit pkgs; inherit pkgs;
} // } //
( if getCfgsSvn ["organization" "name"] != null then ( if cfgSvn.organization.name != null then
{ {
orgName = getCfgsSvn ["organization" "name"]; orgName = cfgSvn.organization.name;
orgLogoFile = getCfgsSvn ["organization" "logo"]; orgLogoFile = cfgSvn.organization.logo;
orgUrl = getCfgsSvn ["organization" "url"]; orgUrl = cfgSvn.organization.url;
} }
else else
# use the default from the subversion service # use the default from the subversion service
@ -76,12 +72,9 @@ let
) )
++ ++
(optional (getCfgs ["extraSubservices" "enable"]) (optional cfg.extraSubservices.enable
(map (service : service webServer pkgs) (map (service : service webServer pkgs) cfg.extraSubservices.services)
(getCfgs ["extraSubservices" "services"]) );
)
)
;
}; };
in in

View File

@ -29,7 +29,7 @@ start on network-interfaces/started
stop on network-interfaces/stop stop on network-interfaces/stop
respawn ${ifplugd}/sbin/ifplugd --no-daemon --no-startup --no-shutdown \\ respawn ${ifplugd}/sbin/ifplugd --no-daemon --no-startup --no-shutdown \\
${if config.get ["networking" "interfaceMonitor" "beep"] then "" else "--no-beep"} \\ ${if config.networking.interfaceMonitor.beep then "" else "--no-beep"} \\
--run ${plugScript}"; --run ${plugScript}";
} }

View File

@ -1,23 +1,22 @@
{config, pkgs}: {config, pkgs}:
let let
getCfg = option: config.get ["services" "ircdHybrid" option]; cfg = config.services.ircdHybrid;
ircdService = import ../services/ircd-hybrid { ircdService = import ../services/ircd-hybrid {
stdenv = pkgs.stdenvNewSetupScript; stdenv = pkgs.stdenvNewSetupScript;
inherit (pkgs) ircdHybrid coreutils inherit (pkgs) ircdHybrid coreutils
su iproute gnugrep procps; su iproute gnugrep procps;
serverName = getCfg "serverName"; serverName = cfg.serverName;
sid = getCfg "sid"; sid = cfg.sid;
description = getCfg "description"; description = cfg.description;
rsaKey = getCfg "rsaKey"; rsaKey = cfg.rsaKey;
certificate = getCfg "certificate"; certificate = cfg.certificate;
adminEmail = getCfg "adminEmail"; adminEmail = cfg.adminEmail;
extraIPs = getCfg "extraIPs"; extraIPs = cfg.extraIPs;
extraPort = getCfg "extraPort"; extraPort = cfg.extraPort;
gw6cEnabled = config.get ["services" "gw6c" "enable"]; gw6cEnabled = config.services.gw6c.enable;
}; };
startingDependency = if (config.get [ "services" "gw6c" "enable" ]) startingDependency = if config.services.gw6c.enable then "gw6c" else "network-interfaces";
then "gw6c" else "network-interfaces";
in in
{ {

View File

@ -3,8 +3,7 @@
}: }:
let let
configFile = ./xfs.conf; configFile = ./xfs.conf;
startingDependency = if (config.get [ "services" "gw6c" "enable" ]) startingDependency = if config.services.gw6c.enable then "gw6c" else "network-interfaces";
then "gw6c" else "network-interfaces";
in in
rec { rec {
name = "xfs"; name = "xfs";

View File

@ -23,8 +23,7 @@
let let
getCfg = option: config.get ["services" "xserver" option]; cfg = config.services.xserver;
getCfg2 = option: config.get (["services" "xserver"] ++ option);
optional = condition: x: if condition then [x] else []; optional = condition: x: if condition then [x] else [];
@ -34,11 +33,11 @@ let
#berylemerald #berylemerald
# Get a bunch of user settings. # Get a bunch of user settings.
videoDriver = getCfg "videoDriver"; videoDriver = cfg.videoDriver;
resolutions = map (res: "\"${toString res.x}x${toString res.y}\"") (getCfg "resolutions"); resolutions = map (res: "\"${toString res.x}x${toString res.y}\"") (cfg.resolutions);
sessionType = getCfg "sessionType"; sessionType = cfg.sessionType;
sessionStarter = getCfg "sessionStarter"; sessionStarter = cfg.sessionStarter;
renderingFlag = getCfg "renderingFlag"; renderingFlag = cfg.renderingFlag;
sessionCmd = sessionCmd =
@ -49,7 +48,7 @@ let
windowManager = windowManager =
let wm = getCfg "windowManager"; in let wm = cfg.windowManager; in
if wm != "" then wm else if wm != "" then wm else
if sessionType == "gnome" then "metacity" else if sessionType == "gnome" then "metacity" else
if sessionType == "kde" then "none" /* started by startkde */ else if sessionType == "kde" then "none" /* started by startkde */ else
@ -68,18 +67,18 @@ let
++ optional (videoDriver == "sis") xorg.xf86videosis ++ optional (videoDriver == "sis") xorg.xf86videosis
++ optional (videoDriver == "i810") xorg.xf86videoi810 ++ optional (videoDriver == "i810") xorg.xf86videoi810
++ optional (videoDriver == "intel") xorg.xf86videointel ++ optional (videoDriver == "intel") xorg.xf86videointel
++ (optional (getCfg "isSynaptics") [(synaptics+"/"+xorg.xorgserver) /*xorg.xf86inputevdev*/]); ++ (optional (cfg.isSynaptics) [(synaptics+"/"+xorg.xorgserver) /*xorg.xf86inputevdev*/]);
configFile = stdenv.mkDerivation { configFile = stdenv.mkDerivation {
name = "xserver.conf"; name = "xserver.conf";
src = ./xserver.conf; src = ./xserver.conf;
inherit fontDirectories videoDriver resolutions isClone; inherit fontDirectories videoDriver resolutions isClone;
synapticsInputDevice = (if getCfg "isSynaptics" then " synapticsInputDevice = (if cfg.isSynaptics then "
Section \"InputDevice\" Section \"InputDevice\"
Identifier \"Touchpad[0]\" Identifier \"Touchpad[0]\"
Driver \"synaptics\" Driver \"synaptics\"
Option \"Device\" \"${getCfg "devSynaptics"}\" Option \"Device\" \"${cfg.devSynaptics}\"
Option \"Protocol\" \"PS/2\" Option \"Protocol\" \"PS/2\"
Option \"LeftEdge\" \"1700\" Option \"LeftEdge\" \"1700\"
Option \"RightEdge\" \"5300\" Option \"RightEdge\" \"5300\"
@ -100,25 +99,25 @@ let
Option \"TapButton3\" \"3\" Option \"TapButton3\" \"3\"
EndSection " else ""); EndSection " else "");
xkbOptions = if (getCfg "xkbOptions") == "" then "" else xkbOptions = if (cfg.xkbOptions) == "" then "" else
" Option \"XkbOptions\" \"${getCfg "xkbOptions"}\""; " Option \"XkbOptions\" \"${cfg.xkbOptions}\"";
layout = getCfg "layout"; layout = cfg.layout;
corePointer = if getCfg "isSynaptics" then "Touchpad[0]" else "Mouse[0]"; corePointer = if cfg.isSynaptics then "Touchpad[0]" else "Mouse[0]";
internalAGPGART = internalAGPGART =
if (getCfg "useInternalAGPGART") == "yes" then if (cfg.useInternalAGPGART) == "yes" then
" Option \"UseInternalAGPGART\" \"yes\"" " Option \"UseInternalAGPGART\" \"yes\""
else if (getCfg "useInternalAGPGART") == "no" then else if (cfg.useInternalAGPGART) == "no" then
" Option \"UseInternalAGPGART\" \"no\"" " Option \"UseInternalAGPGART\" \"no\""
else " "; else " ";
extraDeviceConfig = getCfg "extraDeviceConfig"; extraDeviceConfig = cfg.extraDeviceConfig;
extraMonitorSettings = getCfg "extraMonitorSettings"; extraMonitorSettings = cfg.extraMonitorSettings;
extraModules = getCfg "extraModules"; extraModules = cfg.extraModules;
serverLayoutOptions = getCfg "serverLayoutOptions"; serverLayoutOptions = cfg.serverLayoutOptions;
defaultDepth = getCfg "defaultDepth"; defaultDepth = cfg.defaultDepth;
buildCommand = " buildCommand = "
buildCommand= # urgh, don't substitute this buildCommand= # urgh, don't substitute this
@ -197,7 +196,7 @@ let
fi fi
${if getCfg "startSSHAgent" then " ${if cfg.startSSHAgent then "
### Start the SSH agent. ### Start the SSH agent.
export SSH_ASKPASS=${x11_ssh_askpass}/libexec/x11-ssh-askpass export SSH_ASKPASS=${x11_ssh_askpass}/libexec/x11-ssh-askpass
eval $(${openssh}/bin/ssh-agent) eval $(${openssh}/bin/ssh-agent)
@ -299,7 +298,7 @@ let
"-config ${configFile}" "-config ${configFile}"
":${toString display}" "vt${toString tty}" ":${toString display}" "vt${toString tty}"
"-xkbdir" "${xkeyboard_config}/etc/X11/xkb" "-xkbdir" "${xkeyboard_config}/etc/X11/xkb"
] ++ (if ! config.get ["services" "xserver" "tcpEnable"] ] ++ (if ! config.services.xserver.tcpEnable
then ["-nolisten tcp"] else []); then ["-nolisten tcp"] else []);
@ -315,17 +314,16 @@ login_cmd exec ${stdenv.bash}/bin/sh ${clientScript}
# Unpack the SLiM theme, or use the default. # Unpack the SLiM theme, or use the default.
slimThemesDir = slimThemesDir =
let let
theme = getCfg2 ["slim" "theme"];
unpackedTheme = stdenv.mkDerivation { unpackedTheme = stdenv.mkDerivation {
name = "slim-theme"; name = "slim-theme";
buildCommand = " buildCommand = "
ensureDir $out ensureDir $out
cd $out cd $out
unpackFile ${theme} unpackFile ${cfg.slim.theme}
ln -s * default ln -s * default
"; ";
}; };
in if theme == null then "${slim}/share/slim/themes" else unpackedTheme; in if cfg.slim.theme == null then "${slim}/share/slim/themes" else unpackedTheme;
in in
@ -384,7 +382,7 @@ rec {
rm -f /var/run/opengl-driver rm -f /var/run/opengl-driver
${if videoDriver == "nvidia" ${if videoDriver == "nvidia"
then "ln -sf ${nvidiaDrivers} /var/run/opengl-driver" then "ln -sf ${nvidiaDrivers} /var/run/opengl-driver"
else if getCfg "driSupport" else if cfg.driSupport
then "ln -sf ${mesa} /var/run/opengl-driver" then "ln -sf ${mesa} /var/run/opengl-driver"
else "" else ""
} }
@ -401,7 +399,7 @@ rec {
${if videoDriver == "nvidia" ${if videoDriver == "nvidia"
then "env XORG_DRI_DRIVER_PATH=${nvidiaDrivers}/X11R6/lib/modules/drivers/" then "env XORG_DRI_DRIVER_PATH=${nvidiaDrivers}/X11R6/lib/modules/drivers/"
else if getCfg "driSupport" else if cfg.driSupport
then "env XORG_DRI_DRIVER_PATH=${mesa}/lib/modules/dri" then "env XORG_DRI_DRIVER_PATH=${mesa}/lib/modules/dri"
else "" else ""
} }