Browse Source

replace ifEnable by mkIf and mkThenElse.

svn path=/nixos/branches/fix-style/; revision=13382
nsd-state-dir
Nicolas Pierron 14 years ago
parent
commit
1236cf61f4
  1. 10
      upstart-jobs/alsa.nix
  2. 39
      upstart-jobs/avahi-daemon.nix
  3. 10
      upstart-jobs/dbus.nix
  4. 10
      upstart-jobs/disnix.nix
  5. 6
      upstart-jobs/gpm.nix
  6. 18
      upstart-jobs/hal.nix
  7. 23
      upstart-jobs/nagios/default.nix
  8. 21
      upstart-jobs/pcmcia.nix

10
upstart-jobs/alsa.nix

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

39
upstart-jobs/avahi-daemon.nix

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

10
upstart-jobs/dbus.nix

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

10
upstart-jobs/disnix.nix

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

6
upstart-jobs/gpm.nix

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

18
upstart-jobs/hal.nix

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

23
upstart-jobs/nagios/default.nix

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

21
upstart-jobs/pcmcia.nix

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