From cac64a1afc53cf67891174acb24b45859050fbc1 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 18 May 2021 17:46:33 +0200 Subject: WIP solanum --- krebs/2configs/ircd.nix | 4 +- krebs/3modules/charybdis.nix | 109 --------------------- krebs/3modules/default.nix | 2 +- krebs/3modules/solanum.nix | 107 ++++++++++++++++++++ krebs/5pkgs/simple/solanum/default.nix | 62 ++++++++++++ .../5pkgs/simple/solanum/dont-create-logdir.patch | 14 +++ 6 files changed, 187 insertions(+), 111 deletions(-) delete mode 100644 krebs/3modules/charybdis.nix create mode 100644 krebs/3modules/solanum.nix create mode 100644 krebs/5pkgs/simple/solanum/default.nix create mode 100644 krebs/5pkgs/simple/solanum/dont-create-logdir.patch diff --git a/krebs/2configs/ircd.nix b/krebs/2configs/ircd.nix index 3ef2e7d2b..05e1bc69c 100644 --- a/krebs/2configs/ircd.nix +++ b/krebs/2configs/ircd.nix @@ -5,9 +5,11 @@ 6667 6669 ]; + systemd.services.solanum.serviceConfig.LimitNOFILE = 16384; systemd.services.charybdis.serviceConfig.LimitNOFILE = 16384; - krebs.charybdis = { + # services.charybdis = { + krebs.solanum = { enable = true; motd = '' hello diff --git a/krebs/3modules/charybdis.nix b/krebs/3modules/charybdis.nix deleted file mode 100644 index 038d79dd0..000000000 --- a/krebs/3modules/charybdis.nix +++ /dev/null @@ -1,109 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - inherit (lib) mkEnableOption mkIf mkOption singleton types; - inherit (pkgs) coreutils charybdis; - cfg = config.krebs.charybdis; - - configFile = pkgs.writeText "charybdis.conf" '' - ${cfg.config} - ''; -in - -{ - - ###### interface - - options = { - - krebs.charybdis = { - - enable = mkEnableOption "Charybdis IRC daemon"; - - config = mkOption { - type = types.str; - description = '' - Charybdis IRC daemon configuration file. - ''; - }; - - statedir = mkOption { - type = types.str; - default = "/var/lib/charybdis"; - description = '' - Location of the state directory of charybdis. - ''; - }; - - user = mkOption { - type = types.str; - default = "ircd"; - description = '' - Charybdis IRC daemon user. - ''; - }; - - group = mkOption { - type = types.str; - default = "ircd"; - description = '' - Charybdis IRC daemon group. - ''; - }; - - 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. - ''; - }; - - }; - - }; - - - ###### implementation - - config = mkIf cfg.enable (lib.mkMerge [ - { - users.users.${cfg.user} = { - description = "Charybdis IRC daemon user"; - uid = config.ids.uids.ircd; - group = cfg.group; - }; - - users.groups.${cfg.group} = { - 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"; - }; - serviceConfig = { - ExecStart = "${charybdis}/bin/charybdis -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/krebs/3modules/default.nix b/krebs/3modules/default.nix index 85d27459b..e75afad1d 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -17,7 +17,6 @@ let ./buildbot/slave.nix ./build.nix ./cachecache.nix - ./charybdis.nix ./ci.nix ./current.nix ./dns.nix @@ -52,6 +51,7 @@ let ./secret.nix ./setuid.nix ./shadow.nix + ./solanum.nix ./sync-containers.nix ./tinc.nix ./tinc_graphs.nix diff --git a/krebs/3modules/solanum.nix b/krebs/3modules/solanum.nix new file mode 100644 index 000000000..1d084dd4d --- /dev/null +++ b/krebs/3modules/solanum.nix @@ -0,0 +1,107 @@ +{ 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" ]; + environment = { + BANDB_DBPATH = "${cfg.statedir}/ban.db"; + }; + serviceConfig = { + ExecStart = "${solanum}/bin/solanum -foreground -logfile /dev/stdout -configfile ${configFile}"; + Group = cfg.group; + User = cfg.user; + }; + }; + + } + + (mkIf (cfg.motd != null) { + environment.etc."solanum/ircd.motd".text = cfg.motd; + }) + ]); +} diff --git a/krebs/5pkgs/simple/solanum/default.nix b/krebs/5pkgs/simple/solanum/default.nix new file mode 100644 index 000000000..1d39526ed --- /dev/null +++ b/krebs/5pkgs/simple/solanum/default.nix @@ -0,0 +1,62 @@ +{ lib, stdenv +, fetchFromGitHub +, autoreconfHook +, pkg-config +, bison +, flex +, openssl +, sqlite +, lksctp-tools +}: + +stdenv.mkDerivation rec { + pname = "solanum"; + version = "unstable-2020-12-14"; + + src = fetchFromGitHub { + owner = "solanum-ircd"; + repo = pname; + rev = "551e5a146eab4948ce4a57d87a7f671f2d7cc02d"; + sha256 = "14cd2cb04w6nwck7q49jw5zvifkzhkmblwhjfskc2nxcdb5x3l96"; + }; + + patches = [ + ./dont-create-logdir.patch + ]; + + configureFlags = [ + "--enable-epoll" + "--enable-ipv6" + "--enable-openssl=${openssl.dev}" + "--with-program-prefix=solanum-" + "--localstatedir=/var/lib/solanum" + "--with-rundir=/run/solanum" + "--with-logdir=/var/log/solanum" + ] ++ lib.optionals (stdenv.isLinux) [ + "--enable-sctp=${lksctp-tools.out}/lib" + ]; + + nativeBuildInputs = [ + autoreconfHook + bison + flex + pkg-config + ]; + + buildInputs = [ + openssl + sqlite + ]; + + doCheck = !stdenv.isDarwin; + + enableParallelBuilding = true; + + meta = with lib; { + description = "An IRCd for unified networks"; + homepage = "https://github.com/solanum-ircd/solanum"; + license = licenses.gpl2Only; + maintainers = with maintainers; [ hexa ]; + platforms = platforms.unix; + }; +} diff --git a/krebs/5pkgs/simple/solanum/dont-create-logdir.patch b/krebs/5pkgs/simple/solanum/dont-create-logdir.patch new file mode 100644 index 000000000..e348dd7b8 --- /dev/null +++ b/krebs/5pkgs/simple/solanum/dont-create-logdir.patch @@ -0,0 +1,14 @@ +diff --git a/Makefile.am b/Makefile.am +index 19e7b396..21093521 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -35,9 +35,6 @@ include/serno.h: + echo '#define DATECODE 0UL' >>include/serno.h; \ + fi + +-install-data-hook: +- test -d ${DESTDIR}${logdir} || mkdir -p ${DESTDIR}${logdir} +- + install-exec-hook: + rm -f ${DESTDIR}${libdir}/*.la + rm -f ${DESTDIR}${moduledir}/*.la -- cgit v1.2.3