diff --git a/doc/manual/development.xml b/doc/manual/development.xml index 017a0f007fab..0b02c7f60c6c 100644 --- a/doc/manual/development.xml +++ b/doc/manual/development.xml @@ -150,7 +150,7 @@ $ nixos-rebuild switch -I /my/sources definitions. This conditional values can be distinguished in two categories. The condition which are local to the current configuration and conditions which are dependent on others configurations. Local - properties are mkIf, mkAlways + properties are mkIf and mkAssert. Global properties are mkOverride, mkDefault and mkOrder. @@ -158,12 +158,7 @@ $ nixos-rebuild switch -I /my/sources mkIf is used to remove the option definitions which are below it if the condition is evaluated to false. mkAssert expects the condition to be evaluated - to true otherwise it raises an error message. mkAlways - is used to ignore all the mkIf - and mkAssert which have been made - previously. mkAlways and mkAssert - are often used together to set an option value and to ensure that it has - not been masked by another one. + to true otherwise it raises an error message. mkOverride is used to mask previous definitions if the current value has a lower mask number. The mask value is 100 (default) @@ -223,14 +218,6 @@ let locatedb = "/var/cache/locatedb"; logfile = "/var/log/updatedb"; cmd =''root updatedb --localuser=nobody --output=${locatedb} > ${logfile}''; - - mkCheck = x: - mkIf cfg.enable ( - mkAssert config.services.cron.enable '' - The cron daemon is not enabled, required by services.locate.enable. - '' - x - ) in { @@ -260,9 +247,9 @@ in }; }; - config = mkCheck { + config = mkIf cfg.enable { services.cron = { - enable = mkAlways cfg.enable; + enable = true; systemCronJobs = "${cfg.period} root ${cmd}"; }; }; diff --git a/modules/config/pulseaudio.nix b/modules/config/pulseaudio.nix index 71bf0081e4eb..5dffd9d3afba 100644 --- a/modules/config/pulseaudio.nix +++ b/modules/config/pulseaudio.nix @@ -28,64 +28,65 @@ let cfg = config.hardware.pulseaudio; in }; - config = mkIf cfg.enable { + config = mkMerge + [ # Create pulse/client.conf even if PulseAudio is disabled so + # that we can disable the autospawn feature in programs that + # are built with PulseAudio support (like KDE). + { environment.etc = singleton + { target = "pulse/client.conf"; + source = pkgs.writeText "client.conf" + '' + autospawn=${if cfg.enable then "yes" else "no"} + ${optionalString cfg.enable '' + daemon-binary=${cfg.package}/bin/pulseaudio + ''} + ''; + }; + } - environment.systemPackages = - [ cfg.package ]; + (mkIf cfg.enable { - environment.etc = mkAlways ( - [ # Create pulse/client.conf even if PulseAudio is disabled so - # that we can disable the autospawn feature in programs that - # are built with PulseAudio support (like KDE). - { target = "pulse/client.conf"; - source = pkgs.writeText "client.conf" - '' - autospawn=${if cfg.enable then "yes" else "no"} - ${optionalString cfg.enable '' - daemon-binary=${cfg.package}/bin/pulseaudio - ''} - ''; - } + environment.systemPackages = [ cfg.package ]; - ] ++ optionals cfg.enable - [ # Write an /etc/asound.conf that causes all ALSA applications to - # be re-routed to the PulseAudio server through ALSA's Pulse - # plugin. - { target = "asound.conf"; - source = pkgs.writeText "asound.conf" - '' - pcm_type.pulse { - lib ${pkgs.alsaPlugins}/lib/alsa-lib/libasound_module_pcm_pulse.so - } + environment.etc = + [ # Write an /etc/asound.conf that causes all ALSA applications to + # be re-routed to the PulseAudio server through ALSA's Pulse + # plugin. + { target = "asound.conf"; + source = pkgs.writeText "asound.conf" + '' + pcm_type.pulse { + lib ${pkgs.alsaPlugins}/lib/alsa-lib/libasound_module_pcm_pulse.so + } - pcm.!default { - type pulse - hint.description "Default Audio Device (via PulseAudio)" - } + pcm.!default { + type pulse + hint.description "Default Audio Device (via PulseAudio)" + } - ctl_type.pulse { - lib ${pkgs.alsaPlugins}/lib/alsa-lib/libasound_module_ctl_pulse.so - } + ctl_type.pulse { + lib ${pkgs.alsaPlugins}/lib/alsa-lib/libasound_module_ctl_pulse.so + } - ctl.!default { - type pulse - } - ''; - } + ctl.!default { + type pulse + } + ''; + } - { target = "pulse/default.pa"; - source = "${cfg.package}/etc/pulse/default.pa"; - } + { target = "pulse/default.pa"; + source = "${cfg.package}/etc/pulse/default.pa"; + } - { target = "pulse/system.pa"; - source = "${cfg.package}/etc/pulse/system.pa"; - } + { target = "pulse/system.pa"; + source = "${cfg.package}/etc/pulse/system.pa"; + } + ]; - ]); + # Allow PulseAudio to get realtime priority using rtkit. + security.rtkit.enable = true; - # Allow PulseAudio to get realtime priority using rtkit. - security.rtkit.enable = true; - - }; + }) + ]; } diff --git a/modules/services/network-filesystems/samba.nix b/modules/services/network-filesystems/samba.nix index 2cf4e8c11ff0..93c07df7cc60 100644 --- a/modules/services/network-filesystems/samba.nix +++ b/modules/services/network-filesystems/samba.nix @@ -154,23 +154,23 @@ in defaultShare = { enable = mkOption { - description = "Whether to share /home/smbd as 'default'."; - default = false; - }; + description = "Whether to share /home/smbd as 'default'."; + default = false; + }; writeable = mkOption { - description = "Whether to allow write access to default share."; - default = false; - }; + description = "Whether to allow write access to default share."; + default = false; + }; guest = mkOption { - description = "Whether to allow guest access to default share."; - default = true; - }; + description = "Whether to allow guest access to default share."; + default = true; + }; }; securityType = mkOption { description = "Samba security type"; - default = "user"; - example = "share"; + default = "user"; + example = "share"; }; }; @@ -180,43 +180,45 @@ in ###### implementation - config = mkIf config.services.samba.enable { + config = mkMerge + [ { # Always provide a smb.conf to shut up programs like smbclient and smbspool. + environment.etc = singleton + { source = + if cfg.enable then configFile + else pkgs.writeText "smb-dummy.conf" "# Samba is disabled."; + target = "samba/smb.conf"; + }; + } - users.extraUsers = singleton - { name = user; - description = "Samba service user"; - group = group; - }; + (mkIf config.services.samba.enable { + users.extraUsers = singleton + { name = user; + description = "Samba service user"; + group = group; + }; - users.extraGroups = singleton - { name = group; - }; + users.extraGroups = singleton + { name = group; + }; - # always provide a smb.conf to shut up programs like smbclient and smbspool. - environment.etc = mkAlways (singleton - { source = - if cfg.enable then configFile - else pkgs.writeText "smb-dummy.conf" "# Samba is disabled."; - target = "samba/smb.conf"; - }); - # Dummy job to start the real Samba daemons (nmbd, smbd, winbindd). - jobs.sambaControl = - { name = "samba"; - description = "Samba server"; + # Dummy job to start the real Samba daemons (nmbd, smbd, winbindd). + jobs.sambaControl = + { name = "samba"; + description = "Samba server"; - startOn = "started network-interfaces"; - stopOn = "stopping network-interfaces"; + startOn = "started network-interfaces"; + stopOn = "stopping network-interfaces"; - preStart = setupScript; - }; + preStart = setupScript; + }; - jobs.nmbd = daemonJob "nmbd" "-D"; + jobs.nmbd = daemonJob "nmbd" "-D"; - jobs.smbd = daemonJob "smbd" "-D"; + jobs.smbd = daemonJob "smbd" "-D"; - jobs.winbindd = daemonJob "winbindd" "-D"; - - }; + jobs.winbindd = daemonJob "winbindd" "-D"; + }) + ]; }