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