From 205fbe972c620f27283a69a29e7e81e9d693a210 Mon Sep 17 00:00:00 2001 From: ettom <36895504+ettom@users.noreply.github.com> Date: Mon, 7 Mar 2022 00:52:52 +0200 Subject: [PATCH 1/3] maintainers: add ettom --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 6f3a6a7562f9..2de492236c13 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -4670,6 +4670,12 @@ githubId = 32169529; name = "Etienne Jean"; }; + ettom = { + email = "ettom22@hotmail.com"; + github = "ettom"; + githubId = 36895504; + name = "ettom"; + }; etu = { email = "elis@hirwing.se"; matrix = "@etu:semi.social"; From f163a047f593ab31a81e24fb68a72a162d39500a Mon Sep 17 00:00:00 2001 From: ettom <36895504+ettom@users.noreply.github.com> Date: Mon, 7 Mar 2022 00:53:33 +0200 Subject: [PATCH 2/3] zeyple: init at cc125b7 --- pkgs/misc/zeyple/default.nix | 27 +++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 pkgs/misc/zeyple/default.nix diff --git a/pkgs/misc/zeyple/default.nix b/pkgs/misc/zeyple/default.nix new file mode 100644 index 000000000000..a14996e1d7d1 --- /dev/null +++ b/pkgs/misc/zeyple/default.nix @@ -0,0 +1,27 @@ +{ lib, python3Packages, fetchFromGitHub }: + +python3Packages.buildPythonApplication rec { + pname = "zeyple"; + version = "unstable-2021-04-10"; + + format = "other"; + + src = fetchFromGitHub { + owner = "infertux"; + repo = "zeyple"; + rev = "cc125b7b44432542b227887fd7e2701f77fd8ca2"; + sha256 = "0r2d1drg2zvwmn3zg0qb32i9mh03r5di9q1yszx23r32rsax9mxh"; + }; + + propagatedBuildInputs = [ python3Packages.pygpgme ]; + installPhase = '' + install -Dm755 $src/zeyple/zeyple.py $out/bin/zeyple + ''; + + meta = with lib; { + description = "Utility program to automatically encrypt outgoing emails with GPG"; + homepage = "https://infertux.com/labs/zeyple/"; + maintainers = with maintainers; [ ettom ]; + license = licenses.agpl3Plus; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4537502abbe4..418c63d4e3eb 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -39596,6 +39596,8 @@ with pkgs; ymuse = callPackage ../applications/audio/ymuse { }; + zeyple = callPackage ../misc/zeyple { }; + zk = callPackage ../applications/office/zk { }; zktree = callPackage ../applications/misc/zktree { }; From a375b000a673b6b5bb80c43f5d561c67c9bd3cdc Mon Sep 17 00:00:00 2001 From: ettom <36895504+ettom@users.noreply.github.com> Date: Mon, 7 Mar 2022 01:56:05 +0200 Subject: [PATCH 3/3] nixos/zeyple: init --- nixos/modules/module-list.nix | 1 + nixos/modules/services/mail/zeyple.nix | 125 +++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 nixos/modules/services/mail/zeyple.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 1c976de0ef0e..e5686c5c63f1 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -564,6 +564,7 @@ ./services/mail/schleuder.nix ./services/mail/spamassassin.nix ./services/mail/sympa.nix + ./services/mail/zeyple.nix ./services/matrix/appservice-discord.nix ./services/matrix/appservice-irc.nix ./services/matrix/conduit.nix diff --git a/nixos/modules/services/mail/zeyple.nix b/nixos/modules/services/mail/zeyple.nix new file mode 100644 index 000000000000..e7f9ddd92dc2 --- /dev/null +++ b/nixos/modules/services/mail/zeyple.nix @@ -0,0 +1,125 @@ +{ config, pkgs, lib, ... }: + +with lib; +let + cfg = config.services.zeyple; + ini = pkgs.formats.ini { }; + + gpgHome = pkgs.runCommand "zeyple-gpg-home" { } '' + mkdir -p $out + for file in ${lib.concatStringsSep " " cfg.keys}; do + ${config.programs.gnupg.package}/bin/gpg --homedir="$out" --import "$file" + done + + # Remove socket files + rm -f $out/S.* + ''; +in { + options.services.zeyple = { + enable = mkEnableOption (lib.mdDoc "Zeyple, an utility program to automatically encrypt outgoing emails with GPG"); + + user = mkOption { + type = types.str; + default = "zeyple"; + description = lib.mdDoc '' + User to run Zeyple as. + + ::: {.note} + If left as the default value this user will automatically be created + on system activation, otherwise the sysadmin is responsible for + ensuring the user exists. + ::: + ''; + }; + + group = mkOption { + type = types.str; + default = "zeyple"; + description = lib.mdDoc '' + Group to use to run Zeyple. + + ::: {.note} + If left as the default value this group will automatically be created + on system activation, otherwise the sysadmin is responsible for + ensuring the user exists. + ::: + ''; + }; + + settings = mkOption { + type = ini.type; + default = { }; + description = lib.mdDoc '' + Zeyple configuration. refer to + + for details on supported values. + ''; + }; + + keys = mkOption { + type = with types; listOf path; + description = lib.mdDoc "List of public key files that will be imported by gpg."; + }; + + rotateLogs = mkOption { + type = types.bool; + default = true; + description = lib.mdDoc "Whether to enable rotation of log files."; + }; + }; + + config = mkIf cfg.enable { + users.groups = optionalAttrs (cfg.group == "zeyple") { "${cfg.group}" = { }; }; + users.users = optionalAttrs (cfg.user == "zeyple") { + "${cfg.user}" = { + isSystemUser = true; + group = cfg.group; + }; + }; + + services.zeyple.settings = { + zeyple = mapAttrs (name: mkDefault) { + log_file = "/var/log/zeyple/zeyple.log"; + force_encrypt = true; + }; + + gpg = mapAttrs (name: mkDefault) { home = "${gpgHome}"; }; + + relay = mapAttrs (name: mkDefault) { + host = "localhost"; + port = 10026; + }; + }; + + environment.etc."zeyple.conf".source = ini.generate "zeyple.conf" cfg.settings; + + systemd.tmpfiles.rules = [ "f '${cfg.settings.zeyple.log_file}' 0600 ${cfg.user} ${cfg.group} - -" ]; + services.logrotate = mkIf cfg.rotateLogs { + enable = true; + settings.zeyple = { + files = cfg.settings.zeyple.log_file; + frequency = "weekly"; + rotate = 5; + compress = true; + copytruncate = true; + }; + }; + + services.postfix.extraMasterConf = '' + zeyple unix - n n - - pipe + user=${cfg.user} argv=${pkgs.zeyple}/bin/zeyple ''${recipient} + + localhost:${toString cfg.settings.relay.port} inet n - n - 10 smtpd + -o content_filter= + -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks,no_milters + -o smtpd_helo_restrictions= + -o smtpd_client_restrictions= + -o smtpd_sender_restrictions= + -o smtpd_recipient_restrictions=permit_mynetworks,reject + -o mynetworks=127.0.0.0/8,[::1]/128 + -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128 + ''; + + services.postfix.extraConfig = "content_filter = zeyple"; + }; +}