Add mlmmj package and nixos module.

authored by Edward Tjörnhammar and committed by Michael Raskin 1615be91 c0da615c

+154
+2
nixos/modules/misc/ids.nix
··· 142 142 gdm = 132; 143 143 dhcpd = 133; 144 144 siproxd = 134; 145 + mlmmj = 135; 145 146 146 147 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! 147 148 ··· 258 259 gdm = 132; 259 260 tss = 133; 260 261 siproxd = 134; 262 + mlmmj = 135; 261 263 262 264 # When adding a gid, make sure it doesn't match an existing uid. And don't use gids above 399! 263 265
+1
nixos/modules/module-list.nix
··· 142 142 ./services/mail/dovecot.nix 143 143 ./services/mail/freepops.nix 144 144 ./services/mail/mail.nix 145 + ./services/mail/mlmmj.nix 145 146 ./services/mail/opensmtpd.nix 146 147 ./services/mail/postfix.nix 147 148 ./services/mail/spamassassin.nix
+128
nixos/modules/services/mail/mlmmj.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + 7 + cfg = config.services.mlmmj; 8 + stateDir = "/var/lib/mlmmj"; 9 + spoolDir = "/var/spool/mlmmj"; 10 + listDir = domain: list: "${spoolDir}/${domain}/${list}"; 11 + listCtl = domain: list: "${listDir domain list}/control"; 12 + transport = domain: list: "${domain}--${list}@local.list.mlmmj mlmmj:${domain}/${list}"; 13 + virtual = domain: list: "${list}@${domain} ${domain}--${list}@local.list.mlmmj"; 14 + alias = domain: list: "${list}: \"|${pkgs.mlmmj}/mlmmj-receive -L ${listDir domain list}/\""; 15 + subjectPrefix = list: "[${list}]"; 16 + listAddress = domain: list: "${list}@${domain}"; 17 + customHeaders = list: domain: [ "List-Id: ${list}" "Reply-To: ${list}@${domain}" ]; 18 + footer = domain: list: "To unsubscribe send a mail to ${list}+unsubscribe@${domain}"; 19 + createList = d: l: '' 20 + ${pkgs.coreutils}/bin/mkdir -p ${listCtl d l} 21 + echo ${listAddress d l} > ${listCtl d l}/listadress 22 + echo "${lib.concatStringsSep "\n" (customHeaders d l)}" > ${listCtl d l}/customheaders 23 + echo ${footer d l} > ${listCtl d l}/footer 24 + echo ${subjectPrefix l} > ${listCtl d l}/prefix 25 + ''; 26 + in 27 + 28 + { 29 + 30 + ###### interface 31 + 32 + options = { 33 + 34 + services.mlmmj = { 35 + 36 + enable = mkOption { 37 + type = types.bool; 38 + default = false; 39 + description = "Enable mlmmj"; 40 + }; 41 + 42 + user = mkOption { 43 + type = types.str; 44 + default = "mlmmj"; 45 + description = "mailinglist local user"; 46 + }; 47 + 48 + group = mkOption { 49 + type = types.str; 50 + default = "mlmmj"; 51 + description = "mailinglist local group"; 52 + }; 53 + 54 + listDomain = mkOption { 55 + type = types.str; 56 + default = "localhost"; 57 + description = "Set the mailing list domain"; 58 + }; 59 + 60 + mailLists = mkOption { 61 + type = types.listOf types.str; 62 + default = []; 63 + description = "The collection of hosted maillists"; 64 + }; 65 + 66 + }; 67 + 68 + }; 69 + 70 + ###### implementation 71 + 72 + config = mkIf cfg.enable { 73 + 74 + users.extraUsers = singleton { 75 + name = cfg.user; 76 + description = "mlmmj user"; 77 + home = stateDir; 78 + createHome = true; 79 + uid = config.ids.uids.mlmmj; 80 + group = cfg.group; 81 + useDefaultShell = true; 82 + }; 83 + 84 + users.extraGroups = singleton { 85 + name = cfg.group; 86 + gid = config.ids.gids.mlmmj; 87 + }; 88 + 89 + services.postfix = { 90 + enable = true; 91 + recipientDelimiter= "+"; 92 + extraMasterConf = '' 93 + mlmmj unix - n n - - pipe flags=ORhu user=mlmmj argv=${pkgs.mlmmj}/bin/mlmmj-recieve -F -L ${spoolDir}/$nextHop 94 + ''; 95 + 96 + extraAliases = concatMapStrings (alias cfg.listDomain) cfg.mailLists; 97 + 98 + extraConfig = '' 99 + transport = hash:${stateDir}/transports 100 + virtual = hash:${stateDir}/virtuals 101 + ''; 102 + }; 103 + 104 + environment.systemPackages = [ pkgs.mlmmj ]; 105 + 106 + system.activationScripts.mlmmj = '' 107 + ${pkgs.coreutils}/bin/mkdir -p ${stateDir} ${spoolDir}/${cfg.listDomain} 108 + ${pkgs.coreutils}/bin/chown -R ${cfg.user}:${cfg.group} ${spoolDir} 109 + ${lib.concatMapStrings (createList cfg.listDomain) cfg.mailLists} 110 + echo ${lib.concatMapStrings (virtual cfg.listDomain) cfg.mailLists} > ${stateDir}/virtuals 111 + echo ${cfg.listDomain} mailman: > ${stateDir}/transports 112 + echo ${lib.concatMapStrings (transport cfg.listDomain) cfg.mailLists} >> ${stateDir}/transports 113 + ''; 114 + 115 + systemd.services."mlmmj-maintd" = { 116 + description = "mlmmj maintenance daemon"; 117 + wantedBy = [ "multi-user.target" ]; 118 + 119 + serviceConfig = { 120 + User = cfg.user; 121 + Group = cfg.group; 122 + ExecStart = "${pkgs.mlmmj}/bin/mlmmj-maintd -F -d ${spoolDir}/${cfg.listDomain}"; 123 + }; 124 + }; 125 + 126 + }; 127 + 128 + }
+21
pkgs/servers/mail/mlmmj/default.nix
··· 1 + { stdenv, fetchurl, pkgconfig }: 2 + 3 + stdenv.mkDerivation rec { 4 + 5 + name = "mlmmj-${version}"; 6 + version = "1.2.18.1"; 7 + 8 + src = fetchurl { 9 + url = "http://mlmmj.org/releases/${name}.tar.gz"; 10 + sha256 = "336b6b20a6d7f0dcdc7445ecea0fe4bdacee241f624fcc710b4341780f35e383"; 11 + }; 12 + 13 + meta = with stdenv.lib; { 14 + homepage = http://mlmmj.org; 15 + description = "Mailing List Management Made Joyful"; 16 + maintainers = [ maintainers.edwtjo ]; 17 + platforms = platforms.linux; 18 + license = licenses.mit; 19 + }; 20 + 21 + }
+2
pkgs/top-level/all-packages.nix
··· 6853 6853 6854 6854 miniHttpd = callPackage ../servers/http/mini-httpd {}; 6855 6855 6856 + mlmmj = callPackage ../servers/mail/mlmmj { }; 6857 + 6856 6858 myserver = callPackage ../servers/http/myserver { }; 6857 6859 6858 6860 nginx = callPackage ../servers/http/nginx {