summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/solanum.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2021-05-25 09:50:26 +0200
committermakefu <github@syntax-fehler.de>2021-05-25 09:50:26 +0200
commitc9a67885666bc85e0c5340d78c38cde279a1eac1 (patch)
tree188062a30af7e1bf654068f80472f956af934cd3 /krebs/3modules/solanum.nix
parentba58fde0957b5801322ba30e82efd0575d9a7b7b (diff)
parentb1437a3b1761a58cfa8d601c20da0a0f13e3d795 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'krebs/3modules/solanum.nix')
-rw-r--r--krebs/3modules/solanum.nix104
1 files changed, 104 insertions, 0 deletions
diff --git a/krebs/3modules/solanum.nix b/krebs/3modules/solanum.nix
new file mode 100644
index 000000000..9094d1003
--- /dev/null
+++ b/krebs/3modules/solanum.nix
@@ -0,0 +1,104 @@
+{ config, lib, pkgs, ... }:
+
+let
+ inherit (lib) mkEnableOption mkIf mkOption singleton types;
+ inherit (pkgs) coreutils solanum;
+ cfg = config.krebs.solanum;
+
+ configFile = pkgs.writeText "solanum.conf" ''
+ ${cfg.config}
+ '';
+in
+
+{
+
+ ###### interface
+
+ options = {
+
+ krebs.solanum = {
+
+ enable = mkEnableOption "Solanum IRC daemon";
+
+ config = mkOption {
+ type = types.str;
+ description = ''
+ Solanum IRC daemon configuration file.
+ '';
+ };
+
+ statedir = mkOption {
+ type = types.path;
+ default = "/var/lib/solanum";
+ description = ''
+ Location of the state directory of solanum.
+ '';
+ };
+
+ user = mkOption {
+ type = types.str;
+ default = "ircd";
+ description = ''
+ Solanum IRC daemon user.
+ '';
+ };
+
+ group = mkOption {
+ type = types.str;
+ default = "ircd";
+ description = ''
+ Solanum IRC daemon group.
+ '';
+ };
+
+ motd = mkOption {
+ type = types.nullOr types.lines;
+ default = null;
+ description = ''
+ Solanum MOTD text.
+
+ Solanum will read its MOTD from /etc/solanum/ircd.motd .
+ If set, the value of this option will be written to this path.
+ '';
+ };
+
+ };
+
+ };
+
+
+ ###### implementation
+
+ config = mkIf cfg.enable (lib.mkMerge [
+ {
+ users.users.${cfg.user} = {
+ description = "Solanum IRC daemon user";
+ uid = config.ids.uids.ircd;
+ group = cfg.group;
+ };
+
+ users.groups.${cfg.group} = {
+ gid = config.ids.gids.ircd;
+ };
+
+ systemd.tmpfiles.rules = [
+ "d ${cfg.statedir} - ${cfg.user} ${cfg.group} - -"
+ ];
+
+ systemd.services.solanum = {
+ description = "Solanum IRC daemon";
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ ExecStart = "${solanum}/bin/solanum -foreground -logfile /dev/stdout -configfile ${configFile} -pidfile ${cfg.statedir}/ircd.pid";
+ Group = cfg.group;
+ User = cfg.user;
+ };
+ };
+
+ }
+
+ (mkIf (cfg.motd != null) {
+ environment.etc."solanum/ircd.motd".text = cfg.motd;
+ })
+ ]);
+}