1 { config, lib, options, pkgs, ... }:
6 cfg = config.services.quassel;
7 opt = options.services.quassel;
9 user = if cfg.user != null then cfg.user else "quassel";
20 enable = mkEnableOption (lib.mdDoc "the Quassel IRC client daemon");
22 certificateFile = mkOption {
23 type = types.nullOr types.str;
25 description = lib.mdDoc ''
26 Path to the certificate used for SSL connections with clients.
30 requireSSL = mkOption {
33 description = lib.mdDoc ''
34 Require SSL for connections from clients.
40 default = pkgs.quasselDaemon;
41 defaultText = literalExpression "pkgs.quasselDaemon";
42 description = lib.mdDoc ''
43 The package of the quassel daemon.
47 interfaces = mkOption {
48 type = types.listOf types.str;
49 default = [ "127.0.0.1" ];
50 description = lib.mdDoc ''
51 The interfaces the Quassel daemon will be listening to. If `[ 127.0.0.1 ]`,
52 only clients on the local host can connect to it; if `[ 0.0.0.0 ]`, clients
53 can access it from any network interface.
57 portNumber = mkOption {
60 description = lib.mdDoc ''
61 The port number the Quassel daemon will be listening to.
66 default = "/home/${user}/.config/quassel-irc.org";
67 defaultText = literalExpression ''
68 "/home/''${config.${opt.user}}/.config/quassel-irc.org"
71 description = lib.mdDoc ''
72 The directory holding configuration files, the SQlite database and the SSL Cert.
78 type = types.nullOr types.str;
79 description = lib.mdDoc ''
80 The existing user the Quassel daemon should run as. If left empty, a default "quassel" user will be created.
91 config = mkIf cfg.enable {
93 { assertion = cfg.requireSSL -> cfg.certificateFile != null;
94 message = "Quassel needs a certificate file in order to require SSL";
97 users.users = optionalAttrs (cfg.user == null) {
100 description = "Quassel IRC client daemon";
102 uid = config.ids.uids.quassel;
106 users.groups = optionalAttrs (cfg.user == null) {
109 gid = config.ids.gids.quassel;
113 systemd.tmpfiles.rules = [
114 "d '${cfg.dataDir}' - ${user} - - -"
117 systemd.services.quassel =
118 { description = "Quassel IRC client daemon";
120 wantedBy = [ "multi-user.target" ];
121 after = [ "network.target" ] ++ optional config.services.postgresql.enable "postgresql.service"
122 ++ optional config.services.mysql.enable "mysql.service";
126 ExecStart = concatStringsSep " " ([
127 "${quassel}/bin/quasselcore"
128 "--listen=${concatStringsSep "," cfg.interfaces}"
129 "--port=${toString cfg.portNumber}"
130 "--configdir=${cfg.dataDir}"
131 ] ++ optional cfg.requireSSL "--require-ssl"
132 ++ optional (cfg.certificateFile != null) "--ssl-cert=${cfg.certificateFile}");