at 15.09-beta 4.1 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.bitlbee; 8 bitlbeeUid = config.ids.uids.bitlbee; 9 10 authModeCheck = v: 11 v == "Open" || 12 v == "Closed" || 13 v == "Registered"; 14 15 bitlbeeConfig = pkgs.writeText "bitlbee.conf" 16 '' 17 [settings] 18 RunMode = Daemon 19 User = bitlbee 20 ConfigDir = ${cfg.configDir} 21 DaemonInterface = ${cfg.interface} 22 DaemonPort = ${toString cfg.portNumber} 23 AuthMode = ${cfg.authMode} 24 ${lib.optionalString (cfg.hostName != "") "HostName = ${cfg.hostName}"} 25 ${lib.optionalString (cfg.protocols != "") "Protocols = ${cfg.protocols}"} 26 ${cfg.extraSettings} 27 28 [defaults] 29 ${cfg.extraDefaults} 30 ''; 31 32in 33 34{ 35 36 ###### interface 37 38 options = { 39 40 services.bitlbee = { 41 42 enable = mkOption { 43 default = false; 44 description = '' 45 Whether to run the BitlBee IRC to other chat network gateway. 46 Running it allows you to access the MSN, Jabber, Yahoo! and ICQ chat 47 networks via an IRC client. 48 ''; 49 }; 50 51 interface = mkOption { 52 default = "127.0.0.1"; 53 description = '' 54 The interface the BitlBee deamon will be listening to. If `127.0.0.1', 55 only clients on the local host can connect to it; if `0.0.0.0', clients 56 can access it from any network interface. 57 ''; 58 }; 59 60 portNumber = mkOption { 61 default = 6667; 62 description = '' 63 Number of the port BitlBee will be listening to. 64 ''; 65 }; 66 67 authMode = mkOption { 68 default = "Open"; 69 type = types.addCheck types.str authModeCheck; 70 description = '' 71 The following authentication modes are available: 72 Open -- Accept connections from anyone, use NickServ for user authentication. 73 Closed -- Require authorization (using the PASS command during login) before allowing the user to connect at all. 74 Registered -- Only allow registered users to use this server; this disables the register- and the account command until the user identifies himself. 75 ''; 76 }; 77 78 hostName = mkOption { 79 default = ""; 80 type = types.str; 81 description = '' 82 Normally, BitlBee gets a hostname using getsockname(). If you have a nicer 83 alias for your BitlBee daemon, you can set it here and BitlBee will identify 84 itself with that name instead. 85 ''; 86 }; 87 88 configDir = mkOption { 89 default = "/var/lib/bitlbee"; 90 type = types.path; 91 description = '' 92 Specify an alternative directory to store all the per-user configuration 93 files. 94 ''; 95 }; 96 97 protocols = mkOption { 98 default = ""; 99 type = types.str; 100 description = '' 101 This option allows to remove the support of protocol, even if compiled 102 in. If nothing is given, there are no restrictions. 103 ''; 104 }; 105 106 extraSettings = mkOption { 107 default = ""; 108 description = '' 109 Will be inserted in the Settings section of the config file. 110 ''; 111 }; 112 113 extraDefaults = mkOption { 114 default = ""; 115 description = '' 116 Will be inserted in the Default section of the config file. 117 ''; 118 }; 119 120 }; 121 122 }; 123 124 ###### implementation 125 126 config = mkIf config.services.bitlbee.enable { 127 128 users.extraUsers = singleton 129 { name = "bitlbee"; 130 uid = bitlbeeUid; 131 description = "BitlBee user"; 132 home = "/var/lib/bitlbee"; 133 createHome = true; 134 }; 135 136 users.extraGroups = singleton 137 { name = "bitlbee"; 138 gid = config.ids.gids.bitlbee; 139 }; 140 141 systemd.services.bitlbee = 142 { description = "BitlBee IRC to other chat networks gateway"; 143 after = [ "network.target" ]; 144 wantedBy = [ "multi-user.target" ]; 145 serviceConfig.User = "bitlbee"; 146 serviceConfig.ExecStart = "${pkgs.bitlbee}/sbin/bitlbee -F -n -c ${bitlbeeConfig}"; 147 }; 148 149 environment.systemPackages = [ pkgs.bitlbee ]; 150 151 }; 152 153}