diff --git a/system/options.nix b/system/options.nix index a5fea0b2632d..2e841e6c7b79 100644 --- a/system/options.nix +++ b/system/options.nix @@ -480,35 +480,6 @@ in }; - bitlbee = { - - enable = mkOption { - default = false; - description = '' - Whether to run the BitlBee IRC to other chat network gateway. - Running it allows you to access the MSN, Jabber, Yahoo! and ICQ chat - networks via an IRC client. - ''; - }; - - interface = mkOption { - default = "127.0.0.1"; - description = '' - The interface the BitlBee deamon will be listening to. If `127.0.0.1', - only clients on the local host can connect to it; if `0.0.0.0', clients - can access it from any network interface. - ''; - }; - - portNumber = mkOption { - default = 6667; - description = '' - Number of the port BitlBee will be listening to. - ''; - }; - - }; - gnunet = { enable = mkOption { @@ -1532,6 +1503,7 @@ in (import ../upstart-jobs/lshd.nix) # GNU lshd SSH2 deamon (TODO: does neither start nor generate seed file ?) (import ../upstart-jobs/ntpd.nix) (import ../upstart-jobs/portmap.nix) + (import ../upstart-jobs/bitlbee.nix) # nix (import ../upstart-jobs/nix.nix) # nix options and daemon diff --git a/upstart-jobs/bitlbee.nix b/upstart-jobs/bitlbee.nix index d9956230aa07..a1cc1a878613 100644 --- a/upstart-jobs/bitlbee.nix +++ b/upstart-jobs/bitlbee.nix @@ -1,40 +1,93 @@ -args: with args; +{pkgs, config, ...}: + +###### interface +let + inherit (pkgs.lib) mkOption mkIf; + + options = { + services = { + bitlbee = { + + enable = mkOption { + default = false; + description = '' + Whether to run the BitlBee IRC to other chat network gateway. + Running it allows you to access the MSN, Jabber, Yahoo! and ICQ chat + networks via an IRC client. + ''; + }; + + interface = mkOption { + default = "127.0.0.1"; + description = '' + The interface the BitlBee deamon will be listening to. If `127.0.0.1', + only clients on the local host can connect to it; if `0.0.0.0', clients + can access it from any network interface. + ''; + }; + + portNumber = mkOption { + default = 6667; + description = '' + Number of the port BitlBee will be listening to. + ''; + }; + + }; + }; + }; +in + +###### implementation let bitlbeeUid = (import ../system/ids.nix).uids.bitlbee; + inherit (config.services.bitlbee) portNumber interface; in -{ - name = "bitlbee"; - users = [ - { name = "bitlbee"; - uid = bitlbeeUid; - description = "BitlBee user"; - home = "/var/empty"; - } - ]; - - groups = [ - { name = "bitlbee"; - gid = (import ../system/ids.nix).gids.bitlbee; - } +mkIf config.services.bitlbee.enable { + + require = [ + options ]; - job = '' -description "BitlBee IRC to other chat networks gateway" + users = { + extraUsers = [ + { name = "bitlbee"; + uid = bitlbeeUid; + description = "BitlBee user"; + home = "/var/empty"; + } + ]; + + extraGroups = [ + { name = "bitlbee"; + gid = (import ../system/ids.nix).gids.bitlbee; + } + ]; + }; -start on network-interfaces/started -stop on network-interfaces/stop + services = { + extraJobs = [{ + name = "bitlbee"; -start script - if ! test -d /var/lib/bitlbee - then - mkdir -p /var/lib/bitlbee - fi -end script + job = '' + description "BitlBee IRC to other chat networks gateway" -respawn ${bitlbee}/sbin/bitlbee -F -p ${toString portNumber} \ - -i ${interface} -u bitlbee - ''; + start on network-interfaces/started + stop on network-interfaces/stop + + start script + if ! test -d /var/lib/bitlbee + then + mkdir -p /var/lib/bitlbee + fi + end script + + respawn ${pkgs.bitlbee}/sbin/bitlbee -F -p ${toString portNumber} \ + -i ${interface} -u bitlbee + ''; + }]; + }; } diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index 25426b16566a..79338c2c5982 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -231,12 +231,6 @@ let inherit config pkgs; }) - ++ optional config.services.bitlbee.enable - (import ../upstart-jobs/bitlbee.nix { - inherit (pkgs) bitlbee; - inherit (config.services.bitlbee) portNumber interface; - }) - # Postfix mail server. ++ optional config.services.postfix.enable (import ../upstart-jobs/postfix.nix {