at 23.11-pre 2.6 kB view raw
1{ config, lib, pkgs, ... }: 2 3let 4 inherit (lib) mkEnableOption mkIf mkOption types; 5 inherit (pkgs) solanum util-linux; 6 cfg = config.services.solanum; 7 8 configFile = pkgs.writeText "solanum.conf" cfg.config; 9in 10 11{ 12 13 ###### interface 14 15 options = { 16 17 services.solanum = { 18 19 enable = mkEnableOption (lib.mdDoc "Solanum IRC daemon"); 20 21 config = mkOption { 22 type = types.str; 23 default = '' 24 serverinfo { 25 name = "irc.example.com"; 26 sid = "1ix"; 27 description = "irc!"; 28 29 vhost = "0.0.0.0"; 30 vhost6 = "::"; 31 }; 32 33 listen { 34 host = "0.0.0.0"; 35 port = 6667; 36 }; 37 38 auth { 39 user = "*@*"; 40 class = "users"; 41 flags = exceed_limit; 42 }; 43 channel { 44 default_split_user_count = 0; 45 }; 46 ''; 47 description = lib.mdDoc '' 48 Solanum IRC daemon configuration file. 49 check <https://github.com/solanum-ircd/solanum/blob/main/doc/reference.conf> for all options. 50 ''; 51 }; 52 53 openFilesLimit = mkOption { 54 type = types.int; 55 default = 1024; 56 description = lib.mdDoc '' 57 Maximum number of open files. Limits the clients and server connections. 58 ''; 59 }; 60 61 motd = mkOption { 62 type = types.nullOr types.lines; 63 default = null; 64 description = lib.mdDoc '' 65 Solanum MOTD text. 66 67 Solanum will read its MOTD from `/etc/solanum/ircd.motd`. 68 If set, the value of this option will be written to this path. 69 ''; 70 }; 71 72 }; 73 74 }; 75 76 77 ###### implementation 78 79 config = mkIf cfg.enable (lib.mkMerge [ 80 { 81 82 environment.etc."solanum/ircd.conf".source = configFile; 83 84 systemd.services.solanum = { 85 description = "Solanum IRC daemon"; 86 after = [ "network.target" ]; 87 wantedBy = [ "multi-user.target" ]; 88 reloadIfChanged = true; 89 restartTriggers = [ 90 configFile 91 ]; 92 serviceConfig = { 93 ExecStart = "${solanum}/bin/solanum -foreground -logfile /dev/stdout -configfile /etc/solanum/ircd.conf -pidfile /run/solanum/ircd.pid"; 94 ExecReload = "${util-linux}/bin/kill -HUP $MAINPID"; 95 DynamicUser = true; 96 User = "solanum"; 97 StateDirectory = "solanum"; 98 RuntimeDirectory = "solanum"; 99 LimitNOFILE = "${toString cfg.openFilesLimit}"; 100 }; 101 }; 102 103 } 104 105 (mkIf (cfg.motd != null) { 106 environment.etc."solanum/ircd.motd".text = cfg.motd; 107 }) 108 ]); 109}