replace ifEnable by mkIf and mkThenElse.

svn path=/nixos/branches/fix-style/; revision=13382
This commit is contained in:
Nicolas Pierron 2008-11-23 01:29:25 +00:00
parent 205a7431ac
commit 1236cf61f4
8 changed files with 70 additions and 67 deletions

View file

@ -22,7 +22,7 @@ in
###### implementation ###### implementation
let let
ifEnable = pkgs.lib.ifEnable config.sound.enable; inherit (pkgs.lib) mkIf;
# dangerous ! # dangerous !
modprobe = config.system.sbin.modprobe; modprobe = config.system.sbin.modprobe;
@ -70,7 +70,7 @@ let
}; };
in in
{ mkIf config.sound.enable {
require = [ require = [
(import ../upstart-jobs/default.nix) # config.services.extraJobs (import ../upstart-jobs/default.nix) # config.services.extraJobs
# (import ../system/user.nix) # users.* # (import ../system/user.nix) # users.*
@ -79,14 +79,14 @@ in
]; ];
environment = { environment = {
extraPackages = ifEnable [alsaUtils]; extraPackages = [alsaUtils];
}; };
users = { users = {
extraGroups = ifEnable [group]; extraGroups = [group];
}; };
services = { services = {
extraJobs = ifEnable [job]; extraJobs = [job];
}; };
} }

View file

@ -73,7 +73,7 @@ in
###### implementation ###### implementation
let let
cfg = config.services.avahi; cfg = config.services.avahi;
ifEnable = pkgs.lib.ifEnable cfg.enable; inherit (pkgs.lib) mkIf mkThenElse;
inherit (pkgs) avahi writeText lib; inherit (pkgs) avahi writeText lib;
@ -118,7 +118,7 @@ let
}; };
in in
{ mkIf cfg.enable {
require = [ require = [
(import ../upstart-jobs/default.nix) # config.services.extraJobs (import ../upstart-jobs/default.nix) # config.services.extraJobs
# (import ../system/?) # system.nssModules # (import ../system/?) # system.nssModules
@ -131,34 +131,37 @@ in
]; ];
system = { system = {
nssModules = ifEnable (pkgs.lib.optional nssModules = pkgs.lib.optional cfg.nssmdns pkgs.nssmdns;
cfg.nssmdns pkgs.nssmdns
);
}; };
environment = { environment = {
extraPackages = ifEnable [avahi]; extraPackages = [avahi];
# Name Service Switch configuration file. Required by the C library. # Name Service Switch configuration file. Required by the C library.
etc = [{ etc = mkIf cfg.nssmdns (mkThenElse {
source = if cfg.nssmdns thenPart = [{
then (assert cfg.enable; ../etc/nsswitch-mdns.conf) source = ../etc/nsswitch-mdns.conf;
else ../etc/nsswitch.conf;
target = "nsswitch.conf"; target = "nsswitch.conf";
}]; }];
elsePart = [{
source = ../etc/nsswitch.conf;
target = "nsswitch.conf";
}];
});
}; };
users = { users = {
extraUsers = ifEnable [user]; extraUsers = [user];
extraGroups = ifEnable [group]; extraGroups = [group];
}; };
services = { services = {
extraJobs = ifEnable [job]; extraJobs = [job];
dbus = { dbus = {
enable = cfg.enable; enable = true;
services = ifEnable [avahi]; services = [avahi];
}; };
}; };
} }

View file

@ -31,8 +31,8 @@ in
###### implementation ###### implementation
let let
cfg = config.services.dbus; cfg = config.services.dbus;
ifEnable = pkgs.lib.ifEnable cfg.enable;
services = cfg.services; services = cfg.services;
inherit (pkgs.lib) mkIf;
inherit (pkgs) stdenv dbus; inherit (pkgs) stdenv dbus;
@ -91,7 +91,7 @@ let
in in
{ mkIf cfg.enable {
require = [ require = [
(import ../upstart-jobs/default.nix) # config.services.extraJobs (import ../upstart-jobs/default.nix) # config.services.extraJobs
# (import ../system/user.nix) # users.* # (import ../system/user.nix) # users.*
@ -100,14 +100,14 @@ in
]; ];
environment = { environment = {
extraPackages = ifEnable [dbus.daemon dbus.tools]; extraPackages = [dbus.daemon dbus.tools];
}; };
users = { users = {
extraUsers = ifEnable [user]; extraUsers = [user];
}; };
services = { services = {
extraJobs = ifEnable [job]; extraJobs = [job];
}; };
} }

View file

@ -30,7 +30,7 @@ in
###### implementation ###### implementation
let let
cfg = config.services.disnix; cfg = config.services.disnix;
ifEnable = pkgs.lib.ifEnable cfg.enable; inherit (pkgs.lib) mkIf;
job = { job = {
name = "disnix"; name = "disnix";
@ -51,7 +51,7 @@ let
}; };
in in
{ mkIf cfg.enable {
require = [ require = [
(import ../upstart-jobs/default.nix) (import ../upstart-jobs/default.nix)
(import ../upstart-jobs/dbus.nix) # services.dbus.* (import ../upstart-jobs/dbus.nix) # services.dbus.*
@ -59,11 +59,11 @@ in
]; ];
services = { services = {
extraJobs = ifEnable [job]; extraJobs = [job];
dbus = { dbus = {
enable = cfg.enable; enable = true;
services = ifEnable [pkgs.disnix]; services = [pkgs.disnix];
}; };
}; };
} }

View file

@ -27,7 +27,7 @@ in
###### implementation ###### implementation
let let
cfg = config.services.gpm; cfg = config.services.gpm;
ifEnable = pkgs.lib.ifEnable cfg.enable; inherit (pkgs.lib) mkIf;
gpm = pkgs.gpm; gpm = pkgs.gpm;
gpmBin = "${gpm}/sbin/gpm"; gpmBin = "${gpm}/sbin/gpm";
@ -45,7 +45,7 @@ let
}; };
in in
{ mkIf cfg.enable {
require = [ require = [
(import ../upstart-jobs/default.nix) # config.services.extraJobs (import ../upstart-jobs/default.nix) # config.services.extraJobs
# /etc/security/console.perms (should be generated ?) # /etc/security/console.perms (should be generated ?)
@ -53,6 +53,6 @@ in
]; ];
services = { services = {
extraJobs = ifEnable [job]; extraJobs = [job];
}; };
} }

View file

@ -22,7 +22,7 @@ in
###### implementation ###### implementation
let let
cfg = config.services.hal; cfg = config.services.hal;
ifEnable = pkgs.lib.ifEnable cfg.enable; inherit (pkgs.lib) mkIf;
inherit (pkgs) hal; inherit (pkgs) hal;
@ -61,7 +61,7 @@ let
}; };
in in
{ mkIf cfg.enable {
require = [ require = [
(import ../upstart-jobs/default.nix) # config.services.extraJobs (import ../upstart-jobs/default.nix) # config.services.extraJobs
# (import ../system/user.nix) # users.* # (import ../system/user.nix) # users.*
@ -72,24 +72,24 @@ in
]; ];
environment = { environment = {
extraPackages = ifEnable [hal]; extraPackages = [hal];
}; };
users = { users = {
extraUsers = ifEnable [user]; extraUsers = [user];
extraGroups = ifEnable [group]; extraGroups = [group];
}; };
services = { services = {
extraJobs = ifEnable [job]; extraJobs = [job];
udev = { udev = {
addUdevPkgs = ifEnable [hal]; addUdevPkgs = [hal];
}; };
dbus = { dbus = {
enable = cfg.enable; enable = true;
services = ifEnable [hal]; services = [hal];
}; };
}; };
} }

View file

@ -59,6 +59,7 @@ in
###### implementation ###### implementation
let let
cfg = config.services.nagios; cfg = config.services.nagios;
inherit (pkgs.lib) mkIf mkThenElse;
nagiosUser = "nagios"; nagiosUser = "nagios";
nagiosGroup = "nogroup"; nagiosGroup = "nogroup";
@ -170,11 +171,9 @@ let
end script end script
"; ";
}; };
ifEnable = pkgs.lib.ifEnable cfg.enable;
in in
{ mkIf cfg.enable {
require = [ require = [
(import ../../upstart-jobs/default.nix) # config.services.extraJobs (import ../../upstart-jobs/default.nix) # config.services.extraJobs
# (import ../../system/user.nix) # users = { .. } # (import ../../system/user.nix) # users = { .. }
@ -187,27 +186,27 @@ in
environment = { environment = {
# This isn't needed, it's just so that the user can type "nagiostats # This isn't needed, it's just so that the user can type "nagiostats
# -c /etc/nagios.cfg". # -c /etc/nagios.cfg".
etc = ifEnable [ etc = [
{ source = nagiosCfgFile; { source = nagiosCfgFile;
target = "nagios.cfg"; target = "nagios.cfg";
} }
]; ];
extraPackages = ifEnable [pkgs.nagios]; extraPackages = [pkgs.nagios];
}; };
users = { users = {
extraUsers = ifEnable [user]; extraUsers = [user];
}; };
services = { services = {
extraJobs = ifEnable [job]; extraJobs = [job];
httpd = { httpd = mkIf cfg.enableWebInterface {
extraConfig = # ifEnable does not handle strings yet. extraConfig = mkThenElse {
if cfg.enable && cfg.enableWebInterface thenPart = extraHttpdConfig;
then extraHttpdConfig elsePart = "";
else ""; };
}; };
}; };
} }

View file

@ -38,31 +38,32 @@ in
###### implementation ###### implementation
let let
ifEnable = arg: inherit (pkgs.lib) mkIf;
if config.hardware.pcmcia.enable then arg
else if builtins.isList arg then []
else if builtins.isAttrs arg then {}
else null;
pcmciaUtils = pkgs.pcmciaUtils.passthru.function { pcmciaUtils = pkgs.pcmciaUtils.passthru.function {
inherit (config.hardware.pcmcia) firmware config; inherit (config.hardware.pcmcia) firmware config;
}; };
in in
{
require = options; mkIf config.hardware.pcmcia.enable {
require = [
# (import ../upstart-jobs/udev.nix)
# (import ?) # config.environment.extraPackages
options
];
boot = { boot = {
kernelModules = ifEnable [ "pcmcia" ]; kernelModules = [ "pcmcia" ];
}; };
services = { services = {
udev = { udev = {
addUdevPkgs = ifEnable [ pcmciaUtils ]; addUdevPkgs = [ pcmciaUtils ];
}; };
}; };
environment = { environment = {
extraPackages = ifEnable [ pcmciaUtils ]; extraPackages = [ pcmciaUtils ];
}; };
} }