1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 quassel = pkgs.quasselDaemon_qt5;
7 cfg = config.services.quassel;
8 user = if cfg.user != null then cfg.user else "quassel";
9in
10
11{
12
13 ###### interface
14
15 options = {
16
17 services.quassel = {
18
19 enable = mkOption {
20 default = false;
21 description = ''
22 Whether to run the Quassel IRC client daemon.
23 '';
24 };
25
26 interface = mkOption {
27 default = "127.0.0.1";
28 description = ''
29 The interface the Quassel daemon will be listening to. If `127.0.0.1',
30 only clients on the local host can connect to it; if `0.0.0.0', clients
31 can access it from any network interface.
32 '';
33 };
34
35 portNumber = mkOption {
36 default = 4242;
37 description = ''
38 The port number the Quassel daemon will be listening to.
39 '';
40 };
41
42 dataDir = mkOption {
43 default = ''/home/${user}/.config/quassel-irc.org'';
44 description = ''
45 The directory holding configuration files, the SQlite database and the SSL Cert.
46 '';
47 };
48
49 user = mkOption {
50 default = null;
51 description = ''
52 The existing user the Quassel daemon should run as. If left empty, a default "quassel" user will be created.
53 '';
54 };
55
56 };
57
58 };
59
60
61 ###### implementation
62
63 config = mkIf cfg.enable {
64
65 users.extraUsers = mkIf (cfg.user == null) [
66 { name = "quassel";
67 description = "Quassel IRC client daemon";
68 group = "quassel";
69 uid = config.ids.uids.quassel;
70 }];
71
72 users.extraGroups = mkIf (cfg.user == null) [
73 { name = "quassel";
74 gid = config.ids.gids.quassel;
75 }];
76
77 systemd.services.quassel =
78 { description = "Quassel IRC client daemon";
79
80 wantedBy = [ "multi-user.target" ];
81 after = [ "network.target" ];
82
83 preStart = ''
84 mkdir -p ${cfg.dataDir}
85 chown ${user} ${cfg.dataDir}
86 '';
87
88 serviceConfig =
89 {
90 ExecStart = "${quassel}/bin/quasselcore --listen=${cfg.interface} --port=${toString cfg.portNumber} --configdir=${cfg.dataDir}";
91 User = user;
92 PermissionsStartOnly = true;
93 };
94 };
95
96 };
97
98}