1 { config, lib, pkgs, ... }:
7 cfg = config.services.bitlbee;
8 bitlbeeUid = config.ids.uids.bitlbee;
10 bitlbeePkg = pkgs.bitlbee.override {
11 enableLibPurple = cfg.libpurple_plugins != [];
12 enablePam = cfg.authBackend == "pam";
15 bitlbeeConfig = pkgs.writeText "bitlbee.conf"
19 ConfigDir = ${cfg.configDir}
20 DaemonInterface = ${cfg.interface}
21 DaemonPort = ${toString cfg.portNumber}
22 AuthMode = ${cfg.authMode}
23 AuthBackend = ${cfg.authBackend}
24 Plugindir = ${pkgs.bitlbee-plugins cfg.plugins}/lib/bitlbee
25 ${lib.optionalString (cfg.hostName != "") "HostName = ${cfg.hostName}"}
26 ${lib.optionalString (cfg.protocols != "") "Protocols = ${cfg.protocols}"}
34 lib.concatMapStringsSep ":"
35 (plugin: "${plugin}/lib/pidgin/:${plugin}/lib/purple-2/")
52 description = lib.mdDoc ''
53 Whether to run the BitlBee IRC to other chat network gateway.
54 Running it allows you to access the MSN, Jabber, Yahoo! and ICQ chat
55 networks via an IRC client.
59 interface = mkOption {
61 default = "127.0.0.1";
62 description = lib.mdDoc ''
63 The interface the BitlBee deamon will be listening to. If `127.0.0.1`,
64 only clients on the local host can connect to it; if `0.0.0.0`, clients
65 can access it from any network interface.
69 portNumber = mkOption {
72 description = lib.mdDoc ''
73 Number of the port BitlBee will be listening to.
77 authBackend = mkOption {
79 type = types.enum [ "storage" "pam" ];
80 description = lib.mdDoc ''
81 How users are authenticated
82 storage -- save passwords internally
83 pam -- Linux PAM authentication
89 type = types.enum [ "Open" "Closed" "Registered" ];
90 description = lib.mdDoc ''
91 The following authentication modes are available:
92 Open -- Accept connections from anyone, use NickServ for user authentication.
93 Closed -- Require authorization (using the PASS command during login) before allowing the user to connect at all.
94 Registered -- Only allow registered users to use this server; this disables the register- and the account command until the user identifies himself.
101 description = lib.mdDoc ''
102 Normally, BitlBee gets a hostname using getsockname(). If you have a nicer
103 alias for your BitlBee daemon, you can set it here and BitlBee will identify
104 itself with that name instead.
109 type = types.listOf types.package;
111 example = literalExpression "[ pkgs.bitlbee-facebook ]";
112 description = lib.mdDoc ''
113 The list of bitlbee plugins to install.
117 libpurple_plugins = mkOption {
118 type = types.listOf types.package;
120 example = literalExpression "[ pkgs.purple-matrix ]";
121 description = lib.mdDoc ''
122 The list of libpurple plugins to install.
126 configDir = mkOption {
127 default = "/var/lib/bitlbee";
129 description = lib.mdDoc ''
130 Specify an alternative directory to store all the per-user configuration
135 protocols = mkOption {
138 description = lib.mdDoc ''
139 This option allows to remove the support of protocol, even if compiled
140 in. If nothing is given, there are no restrictions.
144 extraSettings = mkOption {
147 description = lib.mdDoc ''
148 Will be inserted in the Settings section of the config file.
152 extraDefaults = mkOption {
155 description = lib.mdDoc ''
156 Will be inserted in the Default section of the config file.
164 ###### implementation
167 (mkIf config.services.bitlbee.enable {
168 systemd.services.bitlbee = {
169 environment.PURPLE_PLUGIN_PATH = purple_plugin_path;
170 description = "BitlBee IRC to other chat networks gateway";
171 after = [ "network.target" ];
172 wantedBy = [ "multi-user.target" ];
176 StateDirectory = "bitlbee";
177 ReadWritePaths = [ cfg.configDir ];
178 ExecStart = "${bitlbeePkg}/sbin/bitlbee -F -n -c ${bitlbeeConfig}";
182 environment.systemPackages = [ bitlbeePkg ];
185 (mkIf (config.services.bitlbee.authBackend == "pam") {
186 security.pam.services.bitlbee = {};