about summary refs log tree commit diff
path: root/modules/services/audio
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2009-10-12 16:36:19 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2009-10-12 16:36:19 +0000
commite91d882a946fc736f62235296e77c139cee7d9b3 (patch)
treee220488319f0cc28aafb01ca26809429eeaf7f82 /modules/services/audio
parent4a78ef25e73da292d060a2afde0c00980a22b2ac (diff)
downloadnixlib-e91d882a946fc736f62235296e77c139cee7d9b3.tar
nixlib-e91d882a946fc736f62235296e77c139cee7d9b3.tar.gz
nixlib-e91d882a946fc736f62235296e77c139cee7d9b3.tar.bz2
nixlib-e91d882a946fc736f62235296e77c139cee7d9b3.tar.lz
nixlib-e91d882a946fc736f62235296e77c139cee7d9b3.tar.xz
nixlib-e91d882a946fc736f62235296e77c139cee7d9b3.tar.zst
nixlib-e91d882a946fc736f62235296e77c139cee7d9b3.zip
* Converted modules that were still using the old (concrete syntax)
  style of declaring Upstart jobs.  While at it, converted them to the
  current NixOS module style and improved some option descriptions.
  Hopefully I didn't break too much :-)

svn path=/nixos/trunk/; revision=17761
Diffstat (limited to 'modules/services/audio')
-rw-r--r--modules/services/audio/pulseaudio.nix117
1 files changed, 58 insertions, 59 deletions
diff --git a/modules/services/audio/pulseaudio.nix b/modules/services/audio/pulseaudio.nix
index 7b71571337fa..d322c6b51ea1 100644
--- a/modules/services/audio/pulseaudio.nix
+++ b/modules/services/audio/pulseaudio.nix
@@ -1,89 +1,88 @@
-{pkgs, config, ...}:
+{ config, pkgs, ... }:
+
+with pkgs.lib;
 
-###### interface
 let
-  inherit (pkgs.lib) mkOption mkIf;
 
   uid = config.ids.uids.pulseaudio;
   gid = config.ids.gids.pulseaudio;
 
+in
+
+{
+
+  ###### interface
+
   options = {
-    services = {
-      pulseaudio = {
-        enable = mkOption {
-          default = false;
-          description = ''
-            Whether to enable the PulseAudio system-wide audio server.
-            Note that the documentation recommends running PulseAudio
-            daemons per-user rather than system-wide on desktop machines.
-          '';
-        };
-
-        logLevel = mkOption {
-          default = "notice";
-          example = "debug";
-          description = ''
-            A string denoting the log level: one of
-            <literal>error</literal>, <literal>warn</literal>,
-            <literal>notice</literal>, <literal>info</literal>,
-            or <literal>debug</literal>.
-          '';
-        };
+  
+    services.pulseaudio = {
+    
+      enable = mkOption {
+        default = false;
+        description = ''
+          Whether to enable the PulseAudio system-wide audio server.
+          Note that the documentation recommends running PulseAudio
+          daemons per-user rather than system-wide on desktop machines.
+        '';
       };
+
+      logLevel = mkOption {
+        default = "notice";
+        example = "debug";
+        description = ''
+          A string denoting the log level: one of
+          <literal>error</literal>, <literal>warn</literal>,
+          <literal>notice</literal>, <literal>info</literal>,
+          or <literal>debug</literal>.
+        '';
+      };
+
     };
+    
   };
-in
-
-###### implementation
+  
 
+  ###### implementation
 
-mkIf config.services.pulseaudio.enable {
-  require = [
-    options
-  ];
+  config = mkIf config.services.pulseaudio.enable {
 
-  environment = {
-    systemPackages = [pkgs.pulseaudio];
-  };
+    environment.systemPackages = [ pkgs.pulseaudio ];
 
-  users = {
-    extraUsers = [
+    users.extraUsers = singleton
       { name = "pulse";
         # For some reason, PulseAudio wants UID == GID.
         uid = assert uid == gid; uid;
         group = "pulse";
         description = "PulseAudio system-wide daemon";
         home = "/var/run/pulse";
-      }
-    ];
+      };
 
-    extraGroups = [
+    users.extraGroups = singleton
       { name = "pulse";
         inherit gid;
-      }
-    ];
-  };
+      };
 
-  services = {
-    extraJobs = [{
-      name = "pulseaudio";
+    jobAttrs.pulseaudio =
+      { description = "PulseAudio system-wide server";
 
-      job = ''
-        description "PulseAudio system-wide server"
+        startOn = "startup";
+        stopOn = "shutdown";
 
-        start on startup
-        stop on shutdown
+        preStart =
+          ''
+            test -d /var/run/pulse ||			\
+            ( mkdir -p --mode 755 /var/run/pulse &&	\
+              chown pulse:pulse /var/run/pulse )
+          '';
 
-        start script
-          test -d /var/run/pulse ||			\
-          ( mkdir -p --mode 755 /var/run/pulse &&	\
-            chown pulse:pulse /var/run/pulse )
-        end script
+        exec =
+          ''
+            ${pkgs.pulseaudio}/bin/pulseaudio           \
+              --system --daemonize                      \
+              --log-level="${config.services.pulseaudio.logLevel}"
+          '';
+      };
 
-        respawn ${pkgs.pulseaudio}/bin/pulseaudio               \
-          --system --daemonize                                  \
-          --log-level="${config.services.pulseaudio.logLevel}"
-      '';
-    }];
   };
+  
 }