From 4af26d582cb50dc5c200bc1674944cec4821ceb5 Mon Sep 17 00:00:00 2001 From: Pascal Wittmann Date: Fri, 29 Mar 2013 10:28:54 +0100 Subject: [PATCH 1/4] Bitlbee: updated for systemd; added more options like AuthMode --- modules/services/networking/bitlbee.nix | 98 +++++++++++++++++++------ 1 file changed, 77 insertions(+), 21 deletions(-) diff --git a/modules/services/networking/bitlbee.nix b/modules/services/networking/bitlbee.nix index ffc1dcbad4b..2f67fe5f1e3 100644 --- a/modules/services/networking/bitlbee.nix +++ b/modules/services/networking/bitlbee.nix @@ -4,9 +4,13 @@ with pkgs.lib; let + cfg = config.services.bitlbee; bitlbeeUid = config.ids.uids.bitlbee; - inherit (config.services.bitlbee) portNumber interface; + authModeCheck = v: + v == "Open" || + v == "Closed" || + v == "Registered"; in @@ -43,6 +47,45 @@ in ''; }; + user = mkOption { + default = "bitlbee"; + description = '' + The user that executes the BitlBee daemon. + ''; + }; + + authMode = mkOption { + default = "Open"; + check = authModeCheck; + description = '' + The following authentication modes are available: + Open -- Accept connections from anyone, use NickServ for user authentication. + Closed -- Require authorization (using the PASS command during login) before allowing the user to connect at all. + Registered -- Only allow registered users to use this server; this disables the register- and the account command until the user identifies himself. + ''; + }; + + configDir = mkOption { + default = "/var/lib/bitlbee"; + description = '' + Specifyies the directory that stores all the per-user configuration files. + ''; + }; + + extraSettings = mkOption { + default = ""; + description = '' + Will be inserted in the Settings section of the config file. + ''; + }; + + extraDefaults = mkOption { + default = ""; + description = '' + Will be inserted in the Default section of the config file. + ''; + }; + }; }; @@ -53,41 +96,54 @@ in config = mkIf config.services.bitlbee.enable { users.extraUsers = singleton - { name = "bitlbee"; + { name = "${cfg.user}"; uid = bitlbeeUid; description = "BitlBee user"; home = "/var/empty"; }; users.extraGroups = singleton - { name = "bitlbee"; + { name = "${cfg.user}"; gid = config.ids.gids.bitlbee; }; - jobs.bitlbee = + systemd.services.bitlbee = { description = "BitlBee IRC to other chat networks gateway"; - name = "bitlbee"; - - startOn = "ip-up"; - - preStart = + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + preStart = '' - if ! test -d /var/lib/bitlbee - then - mkdir -p /var/lib/bitlbee - chown bitlbee:bitlbee /var/lib/bitlbee - fi - ''; - - exec = - '' - ${pkgs.bitlbee}/sbin/bitlbee -F -p ${toString portNumber} \ - -i ${interface} -u bitlbee - ''; + if ! test -d ${cfg.configDir} + then + mkdir -p ${cfg.configDir} + chown ${cfg.user}:${cfg.user} ${cfg.configDir} + chmod 750 ${cfg.configDir} + fi + ''; + serviceConfig.ExecStart = "${pkgs.bitlbee}/sbin/bitlbee -F -n -c /etc/bitlbee.conf"; }; environment.systemPackages = [ pkgs.bitlbee ]; + environment.etc = + [ + { source = pkgs.writeText "bitlbee.conf" + '' + [settings] + RunMode = Daemon + User = ${cfg.user} + DaemonInterface = ${cfg.interface} + DaemonPort = ${toString cfg.portNumber} + AuthMode = ${cfg.authMode} + ConfigDir = ${cfg.configDir} + ${cfg.extraSettings} + [defaults] + ${cfg.extraDefaults} + ''; + target = "bitlbee.conf"; + } + ]; + }; } From e33af285671d595adaaa259987c9ce13c00bdf17 Mon Sep 17 00:00:00 2001 From: Pascal Wittmann Date: Fri, 29 Mar 2013 12:37:06 +0100 Subject: [PATCH 2/4] Bitlbee: hardcode username and configdir; homedir == configdir --- modules/services/networking/bitlbee.nix | 33 ++++--------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/modules/services/networking/bitlbee.nix b/modules/services/networking/bitlbee.nix index 2f67fe5f1e3..44434d7ed8c 100644 --- a/modules/services/networking/bitlbee.nix +++ b/modules/services/networking/bitlbee.nix @@ -47,13 +47,6 @@ in ''; }; - user = mkOption { - default = "bitlbee"; - description = '' - The user that executes the BitlBee daemon. - ''; - }; - authMode = mkOption { default = "Open"; check = authModeCheck; @@ -65,13 +58,6 @@ in ''; }; - configDir = mkOption { - default = "/var/lib/bitlbee"; - description = '' - Specifyies the directory that stores all the per-user configuration files. - ''; - }; - extraSettings = mkOption { default = ""; description = '' @@ -96,14 +82,14 @@ in config = mkIf config.services.bitlbee.enable { users.extraUsers = singleton - { name = "${cfg.user}"; + { name = "bitlbee"; uid = bitlbeeUid; description = "BitlBee user"; - home = "/var/empty"; + home = "/var/lib/bitlbee"; }; users.extraGroups = singleton - { name = "${cfg.user}"; + { name = "bitlbee"; gid = config.ids.gids.bitlbee; }; @@ -111,15 +97,6 @@ in { description = "BitlBee IRC to other chat networks gateway"; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; - preStart = - '' - if ! test -d ${cfg.configDir} - then - mkdir -p ${cfg.configDir} - chown ${cfg.user}:${cfg.user} ${cfg.configDir} - chmod 750 ${cfg.configDir} - fi - ''; serviceConfig.ExecStart = "${pkgs.bitlbee}/sbin/bitlbee -F -n -c /etc/bitlbee.conf"; }; @@ -131,11 +108,11 @@ in '' [settings] RunMode = Daemon - User = ${cfg.user} + User = bitlbee + ConfigDir = /var/lib/bitlbee DaemonInterface = ${cfg.interface} DaemonPort = ${toString cfg.portNumber} AuthMode = ${cfg.authMode} - ConfigDir = ${cfg.configDir} ${cfg.extraSettings} [defaults] ${cfg.extraDefaults} From 8d0a7cb6d24900a6c8f8001a6da0029f89179c8c Mon Sep 17 00:00:00 2001 From: Pascal Wittmann Date: Fri, 29 Mar 2013 12:51:47 +0100 Subject: [PATCH 3/4] Bitlbee: tabs to spaces --- modules/services/networking/bitlbee.nix | 102 ++++++++++++------------ 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/modules/services/networking/bitlbee.nix b/modules/services/networking/bitlbee.nix index 44434d7ed8c..6f2778f669c 100644 --- a/modules/services/networking/bitlbee.nix +++ b/modules/services/networking/bitlbee.nix @@ -23,104 +23,102 @@ in 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. - ''; + 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. - ''; + 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. - ''; + default = 6667; + description = '' + Number of the port BitlBee will be listening to. + ''; }; authMode = mkOption { - default = "Open"; - check = authModeCheck; - description = '' - The following authentication modes are available: - Open -- Accept connections from anyone, use NickServ for user authentication. - Closed -- Require authorization (using the PASS command during login) before allowing the user to connect at all. - Registered -- Only allow registered users to use this server; this disables the register- and the account command until the user identifies himself. - ''; + default = "Open"; + check = authModeCheck; + description = '' + The following authentication modes are available: + Open -- Accept connections from anyone, use NickServ for user authentication. + Closed -- Require authorization (using the PASS command during login) before allowing the user to connect at all. + Registered -- Only allow registered users to use this server; this disables the register- and the account command until the user identifies himself. + ''; }; extraSettings = mkOption { - default = ""; - description = '' - Will be inserted in the Settings section of the config file. - ''; + default = ""; + description = '' + Will be inserted in the Settings section of the config file. + ''; }; extraDefaults = mkOption { - default = ""; - description = '' - Will be inserted in the Default section of the config file. - ''; + default = ""; + description = '' + Will be inserted in the Default section of the config file. + ''; }; }; }; - ###### implementation config = mkIf config.services.bitlbee.enable { users.extraUsers = singleton { name = "bitlbee"; - uid = bitlbeeUid; - description = "BitlBee user"; - home = "/var/lib/bitlbee"; + uid = bitlbeeUid; + description = "BitlBee user"; + home = "/var/lib/bitlbee"; }; users.extraGroups = singleton { name = "bitlbee"; - gid = config.ids.gids.bitlbee; + gid = config.ids.gids.bitlbee; }; systemd.services.bitlbee = { description = "BitlBee IRC to other chat networks gateway"; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; - serviceConfig.ExecStart = "${pkgs.bitlbee}/sbin/bitlbee -F -n -c /etc/bitlbee.conf"; + serviceConfig.ExecStart = "${pkgs.bitlbee}/sbin/bitlbee -F -n -c /etc/bitlbee.conf"; }; environment.systemPackages = [ pkgs.bitlbee ]; environment.etc = [ - { source = pkgs.writeText "bitlbee.conf" - '' - [settings] - RunMode = Daemon - User = bitlbee - ConfigDir = /var/lib/bitlbee - DaemonInterface = ${cfg.interface} - DaemonPort = ${toString cfg.portNumber} - AuthMode = ${cfg.authMode} - ${cfg.extraSettings} - [defaults] - ${cfg.extraDefaults} - ''; + { source = pkgs.writeText "bitlbee.conf" + '' + [settings] + RunMode = Daemon + User = bitlbee + ConfigDir = /var/lib/bitlbee + DaemonInterface = ${cfg.interface} + DaemonPort = ${toString cfg.portNumber} + AuthMode = ${cfg.authMode} + ${cfg.extraSettings} + [defaults] + ${cfg.extraDefaults} + ''; target = "bitlbee.conf"; } ]; - }; } From c4b3b719176567b0bae32ee405c3ae570016fa62 Mon Sep 17 00:00:00 2001 From: Pascal Wittmann Date: Mon, 1 Apr 2013 23:26:36 +0200 Subject: [PATCH 4/4] Bitlbee: create homedir; do not use /etc/bitlbee.conf --- modules/services/networking/bitlbee.nix | 37 ++++++++++++------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/modules/services/networking/bitlbee.nix b/modules/services/networking/bitlbee.nix index 6f2778f669c..82e875f5aae 100644 --- a/modules/services/networking/bitlbee.nix +++ b/modules/services/networking/bitlbee.nix @@ -12,6 +12,21 @@ let v == "Closed" || v == "Registered"; + bitlbeeConfig = pkgs.writeText "bitlbee.conf" + '' + [settings] + RunMode = Daemon + User = bitlbee + ConfigDir = /var/lib/bitlbee + DaemonInterface = ${cfg.interface} + DaemonPort = ${toString cfg.portNumber} + AuthMode = ${cfg.authMode} + ${cfg.extraSettings} + + [defaults] + ${cfg.extraDefaults} + ''; + in { @@ -85,6 +100,7 @@ in uid = bitlbeeUid; description = "BitlBee user"; home = "/var/lib/bitlbee"; + createHome = true; }; users.extraGroups = singleton @@ -96,29 +112,12 @@ in { description = "BitlBee IRC to other chat networks gateway"; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; - serviceConfig.ExecStart = "${pkgs.bitlbee}/sbin/bitlbee -F -n -c /etc/bitlbee.conf"; + serviceConfig.User = "bitlbee"; + serviceConfig.ExecStart = "${pkgs.bitlbee}/sbin/bitlbee -F -n -c ${bitlbeeConfig}"; }; environment.systemPackages = [ pkgs.bitlbee ]; - environment.etc = - [ - { source = pkgs.writeText "bitlbee.conf" - '' - [settings] - RunMode = Daemon - User = bitlbee - ConfigDir = /var/lib/bitlbee - DaemonInterface = ${cfg.interface} - DaemonPort = ${toString cfg.portNumber} - AuthMode = ${cfg.authMode} - ${cfg.extraSettings} - [defaults] - ${cfg.extraDefaults} - ''; - target = "bitlbee.conf"; - } - ]; }; }