git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #47603 from Mic92/bitlbee

nixos/bitlbee: add pam option

commitb9e7935eff113ee3ba75310a78a7cea2a39b8aba authorPascal Wittmann <mail@pascal-wittmann.de> dateThu 4 Oct 2018, 12:48 (8 years ago) parent4569dd7d334c1c
2 files changed+40−19
nixos/modules/services/networking/bitlbee.nix+28−13 pkgs/applications/networking/instant-messengers/bitlbee/default.nix+12−6
nixos/modules/services/networking/bitlbee.nix+28−13
@@ -7,9 +7,10 @@ let
77 cfg = config.services.bitlbee;
88 bitlbeeUid = config.ids.uids.bitlbee;
99
10− bitlbeePkg = if cfg.libpurple_plugins == []
11− then pkgs.bitlbee
12− else pkgs.bitlbee.override { enableLibPurple = true; };
10+ bitlbeePkg = pkgs.bitlbee.override {
11+ enableLibPurple = cfg.libpurple_plugins != [];
12+ enablePam = cfg.authBackend == "pam";
13+ };
1314
1415 bitlbeeConfig = pkgs.writeText "bitlbee.conf"
1516 ''
@@ -20,6 +21,7 @@ let
2021 DaemonInterface = ${cfg.interface}
2122 DaemonPort = ${toString cfg.portNumber}
2223 AuthMode = ${cfg.authMode}
24+ AuthBackend = ${cfg.authBackend}
2325 Plugindir = ${pkgs.bitlbee-plugins cfg.plugins}/lib/bitlbee
2426 ${lib.optionalString (cfg.hostName != "") "HostName = ${cfg.hostName}"}
2527 ${lib.optionalString (cfg.protocols != "") "Protocols = ${cfg.protocols}"}
@@ -70,6 +72,16 @@ in
7072 '';
7173 };
7274
75+ authBackend = mkOption {
76+ default = "storage";
77+ type = types.enum [ "storage" "pam" ];
78+ description = ''
79+ How users are authenticated
80+ storage -- save passwords internally
81+ pam -- Linux PAM authentication
82+ '';
83+ };
84+
7385 authMode = mkOption {
7486 default = "Open";
7587 type = types.enum [ "Open" "Closed" "Registered" ];
@@ -147,23 +159,22 @@ in
147159
148160 ###### implementation
149161
150− config = mkIf config.services.bitlbee.enable {
151−
152− users.users = singleton
153− { name = "bitlbee";
162+ config = mkMerge [
163+ (mkIf config.services.bitlbee.enable {
164+ users.users = singleton {
165+ name = "bitlbee";
154166 uid = bitlbeeUid;
155167 description = "BitlBee user";
156168 home = "/var/lib/bitlbee";
157169 createHome = true;
158170 };
159171
160− users.groups = singleton
161− { name = "bitlbee";
172+ users.groups = singleton {
173+ name = "bitlbee";
162174 gid = config.ids.gids.bitlbee;
163175 };
164176
165− systemd.services.bitlbee =
166− {
177+ systemd.services.bitlbee = {
167178 environment.PURPLE_PLUGIN_PATH = purple_plugin_path;
168179 description = "BitlBee IRC to other chat networks gateway";
169180 after = [ "network.target" ];
@@ -172,8 +183,12 @@ in
172183 serviceConfig.ExecStart = "${bitlbeePkg}/sbin/bitlbee -F -n -c ${bitlbeeConfig}";
173184 };
174185
175− environment.systemPackages = [ bitlbeePkg ];
186+ environment.systemPackages = [ bitlbeePkg ];
176187
177− };
188+ })
189+ (mkIf (config.services.bitlbee.authBackend == "pam") {
190+ security.pam.services.bitlbee = {};
191+ })
192+ ];
178193
179194}
pkgs/applications/networking/instant-messengers/bitlbee/default.nix+12−6
@@ -1,5 +1,7 @@
1−{ fetchurl, stdenv, gnutls, glib, pkgconfig, check, libotr, python,
2−enableLibPurple ? false, pidgin ? null }:
1+{ fetchurl, stdenv, gnutls, glib, pkgconfig, check, libotr, python
2+, enableLibPurple ? false, pidgin ? null
3+, enablePam ? false, pam ? null
4+}:
35
46with stdenv.lib;
57stdenv.mkDerivation rec {
@@ -13,19 +15,23 @@ stdenv.mkDerivation rec {
1315 nativeBuildInputs = [ pkgconfig ] ++ optional doCheck check;
1416
1517 buildInputs = [ gnutls glib libotr python ]
16− ++ optional enableLibPurple pidgin;
18+ ++ optional enableLibPurple pidgin
19+ ++ optional enablePam pam;
1720
1821 configureFlags = [
19− "--gcov=1"
2022 "--otr=1"
2123 "--ssl=gnutls"
2224 "--pidfile=/var/lib/bitlbee/bitlbee.pid"
23− ]
24− ++ optional enableLibPurple "--purple=1";
25+ ] ++ optional enableLibPurple "--purple=1"
26+ ++ optional enablePam "--pam=1";
2527
2628 installTargets = [ "install" "install-dev" ];
2729
2830 doCheck = !enableLibPurple; # Checks fail with libpurple for some reason
31+ checkPhase = ''
32+ # check flags set VERBOSE=y which breaks the build due overriding a command
33+ make check
34+ '';
2935
3036 enableParallelBuilding = true;
3137