9 cfg = config.services.bitlbee;
10 bitlbeeUid = config.ids.uids.bitlbee;
12 bitlbeePkg = pkgs.bitlbee.override {
13 enableLibPurple = cfg.libpurple_plugins != [ ];
14 enablePam = cfg.authBackend == "pam";
17 bitlbeeConfig = pkgs.writeText "bitlbee.conf" ''
20 ConfigDir = ${cfg.configDir}
21 DaemonInterface = ${cfg.interface}
22 DaemonPort = ${toString cfg.portNumber}
23 AuthMode = ${cfg.authMode}
24 AuthBackend = ${cfg.authBackend}
25 Plugindir = ${pkgs.bitlbee-plugins cfg.plugins}/lib/bitlbee
26 ${lib.optionalString (cfg.hostName != "") "HostName = ${cfg.hostName}"}
27 ${lib.optionalString (cfg.protocols != "") "Protocols = ${cfg.protocols}"}
34 purple_plugin_path = lib.concatMapStringsSep ":" (
35 plugin: "${plugin}/lib/pidgin/:${plugin}/lib/purple-2/"
36 ) cfg.libpurple_plugins;
48 enable = lib.mkOption {
49 type = lib.types.bool;
52 Whether to run the BitlBee IRC to other chat network gateway.
53 Running it allows you to access the MSN, Jabber, Yahoo! and ICQ chat
54 networks via an IRC client.
58 interface = lib.mkOption {
60 default = "127.0.0.1";
62 The interface the BitlBee daemon will be listening to. If `127.0.0.1`,
63 only clients on the local host can connect to it; if `0.0.0.0`, clients
64 can access it from any network interface.
68 portNumber = lib.mkOption {
70 type = lib.types.port;
72 Number of the port BitlBee will be listening to.
76 authBackend = lib.mkOption {
78 type = lib.types.enum [
83 How users are authenticated
84 storage -- save passwords internally
85 pam -- Linux PAM authentication
89 authMode = lib.mkOption {
91 type = lib.types.enum [
97 The following authentication modes are available:
98 Open -- Accept connections from anyone, use NickServ for user authentication.
99 Closed -- Require authorization (using the PASS command during login) before allowing the user to connect at all.
100 Registered -- Only allow registered users to use this server; this disables the register- and the account command until the user identifies himself.
104 hostName = lib.mkOption {
106 type = lib.types.str;
108 Normally, BitlBee gets a hostname using getsockname(). If you have a nicer
109 alias for your BitlBee daemon, you can set it here and BitlBee will identify
110 itself with that name instead.
114 plugins = lib.mkOption {
115 type = lib.types.listOf lib.types.package;
117 example = lib.literalExpression "[ pkgs.bitlbee-facebook ]";
119 The list of bitlbee plugins to install.
123 libpurple_plugins = lib.mkOption {
124 type = lib.types.listOf lib.types.package;
126 example = lib.literalExpression "[ pkgs.purple-matrix ]";
128 The list of libpurple plugins to install.
132 configDir = lib.mkOption {
133 default = "/var/lib/bitlbee";
134 type = lib.types.path;
136 Specify an alternative directory to store all the per-user configuration
141 protocols = lib.mkOption {
143 type = lib.types.str;
145 This option allows to remove the support of protocol, even if compiled
146 in. If nothing is given, there are no restrictions.
150 extraSettings = lib.mkOption {
152 type = lib.types.lines;
154 Will be inserted in the Settings section of the config file.
158 extraDefaults = lib.mkOption {
160 type = lib.types.lines;
162 Will be inserted in the Default section of the config file.
170 ###### implementation
172 config = lib.mkMerge [
173 (lib.mkIf config.services.bitlbee.enable {
174 systemd.services.bitlbee = {
175 environment.PURPLE_PLUGIN_PATH = purple_plugin_path;
176 description = "BitlBee IRC to other chat networks gateway";
177 after = [ "network.target" ];
178 wantedBy = [ "multi-user.target" ];
182 StateDirectory = "bitlbee";
183 ReadWritePaths = [ cfg.configDir ];
184 ExecStart = "${bitlbeePkg}/sbin/bitlbee -F -n -c ${bitlbeeConfig}";
188 environment.systemPackages = [ bitlbeePkg ];
191 (lib.mkIf (config.services.bitlbee.authBackend == "pam") {
192 security.pam.services.bitlbee = { };