From b3b243193228967cbef529a7e032f4d248594ca2 Mon Sep 17 00:00:00 2001 From: Sebastian Hagen Date: Thu, 25 May 2017 22:28:50 +0100 Subject: [PATCH] charybdis service: add option to configure MOTD (#25512) Read MOTD files from /etc/charybdis. --- .../modules/services/networking/charybdis.nix | 76 +++++++++++-------- pkgs/servers/irc/charybdis/default.nix | 1 + 2 files changed, 46 insertions(+), 31 deletions(-) diff --git a/nixos/modules/services/networking/charybdis.nix b/nixos/modules/services/networking/charybdis.nix index 2f7d006b8816..c354ec61fe23 100644 --- a/nixos/modules/services/networking/charybdis.nix +++ b/nixos/modules/services/networking/charybdis.nix @@ -51,6 +51,17 @@ in ''; }; + motd = mkOption { + type = types.nullOr types.lines; + default = null; + description = '' + Charybdis MOTD text. + + Charybdis will read its MOTD from /etc/charybdis/ircd.motd . + If set, the value of this option will be written to this path. + ''; + }; + }; }; @@ -58,39 +69,42 @@ in ###### implementation - config = mkIf cfg.enable { - - users.extraUsers = singleton { - name = cfg.user; - description = "Charybdis IRC daemon user"; - uid = config.ids.uids.ircd; - group = cfg.group; - }; - - users.extraGroups = singleton { - name = cfg.group; - gid = config.ids.gids.ircd; - }; - - systemd.services.charybdis = { - description = "Charybdis IRC daemon"; - wantedBy = [ "multi-user.target" ]; - environment = { - BANDB_DBPATH = "${cfg.statedir}/ban.db"; + config = mkIf cfg.enable (lib.mkMerge [ + { + users.extraUsers = singleton { + name = cfg.user; + description = "Charybdis IRC daemon user"; + uid = config.ids.uids.ircd; + group = cfg.group; }; - serviceConfig = { - ExecStart = "${charybdis}/bin/charybdis-ircd -foreground -logfile /dev/stdout -configfile ${configFile}"; - Group = cfg.group; - User = cfg.user; - PermissionsStartOnly = true; # preStart needs to run with root permissions + + users.extraGroups = singleton { + name = cfg.group; + gid = config.ids.gids.ircd; }; - preStart = '' - ${coreutils}/bin/mkdir -p ${cfg.statedir} - ${coreutils}/bin/chown ${cfg.user}:${cfg.group} ${cfg.statedir} - ''; - }; - - }; + systemd.services.charybdis = { + description = "Charybdis IRC daemon"; + wantedBy = [ "multi-user.target" ]; + environment = { + BANDB_DBPATH = "${cfg.statedir}/ban.db"; + }; + serviceConfig = { + ExecStart = "${charybdis}/bin/charybdis-ircd -foreground -logfile /dev/stdout -configfile ${configFile}"; + Group = cfg.group; + User = cfg.user; + PermissionsStartOnly = true; # preStart needs to run with root permissions + }; + preStart = '' + ${coreutils}/bin/mkdir -p ${cfg.statedir} + ${coreutils}/bin/chown ${cfg.user}:${cfg.group} ${cfg.statedir} + ''; + }; + } + + (mkIf (cfg.motd != null) { + environment.etc."charybdis/ircd.motd".text = cfg.motd; + }) + ]); } diff --git a/pkgs/servers/irc/charybdis/default.nix b/pkgs/servers/irc/charybdis/default.nix index 46e4b755e5c3..f63fecb66c88 100644 --- a/pkgs/servers/irc/charybdis/default.nix +++ b/pkgs/servers/irc/charybdis/default.nix @@ -19,6 +19,7 @@ stdenv.mkDerivation rec { "--enable-ipv6" "--enable-openssl=${openssl.dev}" "--with-program-prefix=charybdis-" + "--sysconfdir=/etc/charybdis" ]; buildInputs = [ bison flex openssl ];