1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-26 15:41:40 +00:00

* 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
label linux
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;
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;

View file

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

View file

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

View file

@ -5,4 +5,4 @@ stdenv.mkDerivation {
builder = ./builder.sh;
setuidWrapper = ./setuid-wrapper.c;
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.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
# 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;};
@ -27,7 +29,7 @@ rec {
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
@ -53,8 +55,8 @@ rec {
inherit (pkgsStatic) utillinux;
inherit (pkgsDiet) udev;
e2fsprogs = pkgs.e2fsprogsDiet;
devicemapper = if config.get ["boot" "initrd" "lvm"] then pkgs.devicemapperStatic else null;
lvm2 = if config.get ["boot" "initrd" "lvm"] then pkgs.lvm2Static else null;
devicemapper = if config.boot.initrd.lvm then pkgs.devicemapperStatic else null;
lvm2 = if config.boot.initrd.lvm then pkgs.lvm2Static else null;
allowedReferences = []; # prevent accidents like glibc being included in the initrd
}
"
@ -76,12 +78,12 @@ rec {
inherit (pkgs) substituteAll;
inherit (pkgsDiet) module_init_tools;
inherit extraUtils;
autoDetectRootDevice = config.get ["boot" "autoDetectRootDevice"];
autoDetectRootDevice = config.boot.autoDetectRootDevice;
fileSystems =
pkgs.lib.filter
(fs: fs.mountPoint == "/" || (fs ? neededForBoot && fs.neededForBoot))
(config.get ["fileSystems"]);
rootLabel = config.get ["boot" "rootLabel"];
(config.fileSystems);
rootLabel = config.boot.rootLabel;
inherit stage2Init;
modulesDir = modulesClosure;
modules = rootModules;
@ -98,7 +100,7 @@ rec {
{ object = bootStage1;
symlink = "/init";
}
] ++ (if config.get ["boot" "initrd" "enableSplashScreen"] then [
] ++ (if config.boot.initrd.enableSplashScreen then [
{ object = pkgs.runCommand "splashutils" {} "
ensureDir $out/bin
cp ${pkgs.splashutils}/bin/splash_helper $out/bin
@ -108,7 +110,7 @@ rec {
}
{ object = import ../helpers/unpack-theme.nix {
inherit (pkgs) stdenv;
theme = config.get ["services" "ttyBackgrounds" "defaultTheme"];
theme = config.services.ttyBackgrounds.defaultTheme;
};
symlink = "/etc/splash";
}
@ -120,7 +122,7 @@ rec {
nixosInstall = import ../installer/nixos-install.nix {
inherit (pkgs) perl runCommand substituteAll;
inherit nix;
nixpkgsURL = config.get ["installer" "nixpkgsURL"];
nixpkgsURL = config.installer.nixpkgsURL;
};
nixosRebuild = import ../installer/nixos-rebuild.nix {
@ -134,7 +136,7 @@ rec {
# NSS modules. Hacky!
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 ":"
(map (mod: mod + "/lib") nssModules));
@ -228,11 +230,11 @@ rec {
nixosCheckout
setuidWrapper
]
++ pkgs.lib.optional (config.get ["security" "sudo" "enable"]) pkgs.sudo
++ pkgs.lib.optional (config.get ["networking" "defaultMailServer" "directDelivery"]) pkgs.ssmtp
++ pkgs.lib.optional (config.security.sudo.enable) pkgs.sudo
++ pkgs.lib.optional (config.networking.defaultMailServer.directDelivery) pkgs.ssmtp
++ pkgs.lib.concatLists (map (job: job.extraPath) upstartJobs.jobs)
++ (config.get ["environment" "extraPackages"]) pkgs
++ pkgs.lib.optional (config.get ["fonts" "enableFontDir"]) fontDir;
++ (config.environment.extraPackages) pkgs
++ pkgs.lib.optional (config.fonts.enableFontDir) fontDir;
# We don't want to put all of `startPath' and `path' in $PATH, since
@ -261,12 +263,12 @@ rec {
isExecutable = true;
inherit etc wrapperDir systemPath modprobe defaultShell kernel;
readOnlyRoot = config.get ["boot" "readOnlyRoot"];
hostName = config.get ["networking" "hostName"];
readOnlyRoot = config.boot.readOnlyRoot;
hostName = config.networking.hostName;
setuidPrograms =
config.get ["security" "setuidPrograms"] ++
config.get ["security" "extraSetuidPrograms"] ++
pkgs.lib.optional (config.get ["security" "sudo" "enable"]) "sudo";
config.security.setuidPrograms ++
config.security.extraSetuidPrograms ++
pkgs.lib.optional (config.security.sudo.enable) "sudo";
inherit (usersGroups) createUsersGroups usersList groupsList;
@ -286,7 +288,7 @@ rec {
inherit (pkgs) substituteAll writeText coreutils
utillinux udev upstart;
inherit kernel activateConfiguration;
readOnlyRoot = config.get ["boot" "readOnlyRoot"];
readOnlyRoot = config.boot.readOnlyRoot;
upstartPath = [
pkgs.coreutils
pkgs.findutils
@ -294,7 +296,7 @@ rec {
pkgs.gnused
pkgs.upstart
];
bootLocal = config.get ["boot" "localCommands"];
bootLocal = config.boot.localCommands;
};
@ -305,8 +307,8 @@ rec {
isExecutable = true;
inherit (pkgs) bash;
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
copyKernels = config.get ["boot" "copyKernels"];
extraGrubEntries = config.get ["boot" "extraGrubEntries"];
copyKernels = config.boot.copyKernels;
extraGrubEntries = config.boot.extraGrubEntries;
};
@ -320,10 +322,10 @@ rec {
builder = ./system.sh;
switchToConfiguration = ./switch-to-configuration.sh;
inherit (pkgs) grub coreutils gnused gnugrep diffutils findutils upstart;
grubDevice = config.get ["boot" "grubDevice"];
grubDevice = config.boot.grubDevice;
kernelParams =
(config.get ["boot" "kernelParams"]) ++
(config.get ["boot" "extraKernelParams"]);
(config.boot.kernelParams) ++
(config.boot.extraKernelParams);
inherit bootStage2;
inherit activateConfiguration;
inherit grubMenuBuilder;
@ -340,7 +342,7 @@ rec {
pkgs.diffutils
pkgs.upstart # for initctl
];
configurationName = config.get ["boot" "configurationName"];
configurationName = config.boot.configurationName;
}) (pkgs.getConfig ["checkConfigurationOptions"] false)
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));
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;
};
optional = option: service:
if config.get option then [(makeJob service)] else [];
optional = cond: service: pkgs.lib.optional cond (makeJob service);
requiredTTYs =
(config.get ["services" "mingetty" "ttys"])
(config.services.mingetty.ttys)
++ [10] /* !!! sync with syslog.conf */ ;
in
@ -30,11 +29,11 @@ import ../upstart-jobs/gather.nix {
inherit (pkgs) stdenv writeText substituteAll udev procps;
inherit (pkgs.lib) cleanSource;
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 =
pkgs.lib.optional (config.get ["services" "hal" "enable"]) pkgs.hal;
pkgs.lib.optional (config.services.hal.enable) pkgs.hal;
})
# Makes LVM logical volumes available.
@ -52,30 +51,30 @@ import ../upstart-jobs/gather.nix {
# Hardware scan; loads modules for PCI devices.
(import ../upstart-jobs/hardware-scan.nix {
inherit modprobe;
doHardwareScan = config.get ["boot" "hardwareScan"];
kernelModules = config.get ["boot" "kernelModules"];
doHardwareScan = config.boot.hardwareScan;
kernelModules = config.boot.kernelModules;
})
# Mount file systems.
(import ../upstart-jobs/filesystems.nix {
inherit (pkgs) utillinux e2fsprogs;
fileSystems = config.get ["fileSystems"];
fileSystems = config.fileSystems;
})
# Swapping.
(import ../upstart-jobs/swap.nix {
inherit (pkgs) utillinux library;
swapDevices = config.get ["swapDevices"];
swapDevices = config.swapDevices;
})
# Network interfaces.
(import ../upstart-jobs/network-interfaces.nix {
inherit modprobe;
inherit (pkgs) nettools wirelesstools bash writeText;
nameservers = config.get ["networking" "nameservers"];
defaultGateway = config.get ["networking" "defaultGateway"];
interfaces = config.get ["networking" "interfaces"];
localCommands = config.get ["networking" "localCommands"];
nameservers = config.networking.nameservers;
defaultGateway = config.networking.defaultGateway;
interfaces = config.networking.interfaces;
localCommands = config.networking.localCommands;
})
# Nix daemon - required for multi-user Nix.
@ -99,9 +98,9 @@ import ../upstart-jobs/gather.nix {
(import ../upstart-jobs/kbd.nix {
inherit (pkgs) glibc kbd gzip;
ttyNumbers = requiredTTYs;
defaultLocale = config.get ["i18n" "defaultLocale"];
consoleFont = config.get ["i18n" "consoleFont"];
consoleKeyMap = config.get ["i18n" "consoleKeyMap"];
defaultLocale = config.i18n.defaultLocale;
consoleFont = config.i18n.consoleFont;
consoleKeyMap = config.i18n.consoleKeyMap;
})
# Handles the maintenance/stalled event (single-user shell).
@ -115,47 +114,47 @@ import ../upstart-jobs/gather.nix {
]
# DHCP client.
++ optional ["networking" "useDHCP"]
++ optional config.networking.useDHCP
(import ../upstart-jobs/dhclient.nix {
inherit (pkgs) nettools dhcp lib;
interfaces = config.get ["networking" "interfaces"];
interfaces = config.networking.interfaces;
})
# ifplugd daemon for monitoring Ethernet cables.
++ optional ["networking" "interfaceMonitor" "enable"]
++ optional config.networking.interfaceMonitor.enable
(import ../upstart-jobs/ifplugd.nix {
inherit (pkgs) ifplugd writeScript bash;
inherit config;
})
# DHCP server.
++ optional ["services" "dhcpd" "enable"]
++ optional config.services.dhcpd.enable
(import ../upstart-jobs/dhcpd.nix {
inherit (pkgs) dhcp;
configFile = config.get ["services" "dhcpd" "configFile"];
interfaces = config.get ["services" "dhcpd" "interfaces"];
configFile = config.services.dhcpd.configFile;
interfaces = config.services.dhcpd.interfaces;
})
# SSH daemon.
++ optional ["services" "sshd" "enable"]
++ optional config.services.sshd.enable
(import ../upstart-jobs/sshd.nix {
inherit (pkgs) writeText openssh glibc;
inherit (pkgs.xorg) xauth;
inherit nssModulesPath;
forwardX11 = config.get ["services" "sshd" "forwardX11"];
allowSFTP = config.get ["services" "sshd" "allowSFTP"];
forwardX11 = config.services.sshd.forwardX11;
allowSFTP = config.services.sshd.allowSFTP;
})
# NTP daemon.
++ optional ["services" "ntp" "enable"]
++ optional config.services.ntp.enable
(import ../upstart-jobs/ntpd.nix {
inherit modprobe;
inherit (pkgs) ntp glibc writeText;
servers = config.get ["services" "ntp" "servers"];
servers = config.services.ntp.servers;
})
# X server.
++ optional ["services" "xserver" "enable"]
++ optional config.services.xserver.enable
(import ../upstart-jobs/xserver.nix {
inherit config;
inherit (pkgs) writeText lib xterm slim xorg mesa
@ -165,64 +164,64 @@ import ../upstart-jobs/gather.nix {
libX11 = pkgs.xlibs.libX11;
libXext = pkgs.xlibs.libXext;
fontDirectories = import ../system/fonts.nix {inherit pkgs config;};
isClone = config.get ["services" "xserver" "isClone"];
isClone = config.services.xserver.isClone;
})
# Apache httpd.
++ optional ["services" "httpd" "enable"]
++ optional config.services.httpd.enable
(import ../upstart-jobs/httpd.nix {
inherit config pkgs;
inherit (pkgs) glibc;
})
# Samba service.
++ optional ["services" "samba" "enable"]
++ optional config.services.samba.enable
(import ../upstart-jobs/samba.nix {
inherit pkgs;
inherit (pkgs) glibc samba;
})
# CUPS (printing) daemon.
++ optional ["services" "printing" "enable"]
++ optional config.services.printing.enable
(import ../upstart-jobs/cupsd.nix {
inherit (pkgs) writeText cups;
})
# Gateway6
++ optional ["services" "gw6c" "enable"]
++ optional config.services.gw6c.enable
(import ../upstart-jobs/gw6c.nix {
inherit config pkgs;
})
# X Font Server
++ optional ["services" "xfs" "enable"]
++ optional config.services.xfs.enable
(import ../upstart-jobs/xfs.nix {
inherit config pkgs;
})
++ optional ["services" "ircdHybrid" "enable"]
++ optional config.services.ircdHybrid.enable
(import ../upstart-jobs/ircd-hybrid.nix {
inherit config pkgs;
})
# ALSA sound support.
++ optional ["sound" "enable"]
++ optional config.sound.enable
(import ../upstart-jobs/alsa.nix {
inherit modprobe;
inherit (pkgs) alsaUtils;
})
# D-Bus system-wide daemon.
++ optional ["services" "dbus" "enable"]
++ optional config.services.dbus.enable
(import ../upstart-jobs/dbus.nix {
inherit (pkgs) stdenv dbus;
dbusServices =
pkgs.lib.optional (config.get ["services" "hal" "enable"]) pkgs.hal;
pkgs.lib.optional (config.services.hal.enable) pkgs.hal;
})
# HAL daemon.
++ optional ["services" "hal" "enable"]
++ optional config.services.hal.enable
(import ../upstart-jobs/hal.nix {
inherit (pkgs) stdenv hal;
})
@ -243,11 +242,11 @@ import ../upstart-jobs/gather.nix {
inherit ttyNumber;
loginProgram = "${pkgs.pam_login}/bin/login";
}))
(config.get ["services" "mingetty" "ttys"])
(config.services.mingetty.ttys)
)
# Transparent TTY backgrounds.
++ optional ["services" "ttyBackgrounds" "enable"]
++ optional config.services.ttyBackgrounds.enable
(import ../upstart-jobs/tty-backgrounds.nix {
inherit (pkgs) stdenv splashutils;
@ -256,8 +255,8 @@ import ../upstart-jobs/gather.nix {
let
specificThemes =
config.get ["services" "ttyBackgrounds" "defaultSpecificThemes"]
++ config.get ["services" "ttyBackgrounds" "specificThemes"];
config.services.ttyBackgrounds.defaultSpecificThemes
++ config.services.ttyBackgrounds.specificThemes;
overridenTTYs = map (x: x.tty) specificThemes;
@ -270,14 +269,14 @@ import ../upstart-jobs/gather.nix {
in
(map (ttyNumber: {
tty = ttyNumber;
theme = config.get ["services" "ttyBackgrounds" "defaultTheme"];
theme = config.services.ttyBackgrounds.defaultTheme;
}) defaultTTYs)
++ specificThemes;
})
# User-defined events.
++ (map makeJob (config.get ["services" "extraJobs"]))
++ (map makeJob (config.services.extraJobs))
# For the built-in logd job.
++ [(makeJob { jobDrv = pkgs.upstart; })];

View file

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

View file

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

View file

@ -29,7 +29,7 @@ start on network-interfaces/started
stop on network-interfaces/stop
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}";
}

View file

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

View file

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

View file

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