at 17.09-beta 2.7 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.quassel; 7 quassel = cfg.package; 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 package = mkOption { 27 type = types.package; 28 default = pkgs.quasselDaemon; 29 defaultText = "pkgs.quasselDaemon"; 30 description = '' 31 The package of the quassel daemon. 32 ''; 33 example = literalExample "pkgs.quasselDaemon"; 34 }; 35 36 interfaces = mkOption { 37 default = [ "127.0.0.1" ]; 38 description = '' 39 The interfaces the Quassel daemon will be listening to. If `[ 127.0.0.1 ]', 40 only clients on the local host can connect to it; if `[ 0.0.0.0 ]', clients 41 can access it from any network interface. 42 ''; 43 }; 44 45 portNumber = mkOption { 46 default = 4242; 47 description = '' 48 The port number the Quassel daemon will be listening to. 49 ''; 50 }; 51 52 dataDir = mkOption { 53 default = ''/home/${user}/.config/quassel-irc.org''; 54 description = '' 55 The directory holding configuration files, the SQlite database and the SSL Cert. 56 ''; 57 }; 58 59 user = mkOption { 60 default = null; 61 description = '' 62 The existing user the Quassel daemon should run as. If left empty, a default "quassel" user will be created. 63 ''; 64 }; 65 66 }; 67 68 }; 69 70 71 ###### implementation 72 73 config = mkIf cfg.enable { 74 75 users.extraUsers = mkIf (cfg.user == null) [ 76 { name = "quassel"; 77 description = "Quassel IRC client daemon"; 78 group = "quassel"; 79 uid = config.ids.uids.quassel; 80 }]; 81 82 users.extraGroups = mkIf (cfg.user == null) [ 83 { name = "quassel"; 84 gid = config.ids.gids.quassel; 85 }]; 86 87 systemd.services.quassel = 88 { description = "Quassel IRC client daemon"; 89 90 wantedBy = [ "multi-user.target" ]; 91 after = [ "network.target" ] ++ optional config.services.postgresql.enable "postgresql.service" 92 ++ optional config.services.mysql.enable "mysql.service"; 93 94 preStart = '' 95 mkdir -p ${cfg.dataDir} 96 chown ${user} ${cfg.dataDir} 97 ''; 98 99 serviceConfig = 100 { 101 ExecStart = "${quassel}/bin/quasselcore --listen=${concatStringsSep '','' cfg.interfaces} --port=${toString cfg.portNumber} --configdir=${cfg.dataDir}"; 102 User = user; 103 PermissionsStartOnly = true; 104 }; 105 }; 106 107 }; 108 109}