dovecot fixes

This commit is contained in:
Rouven Seifert 2024-06-21 14:46:36 +02:00
parent ef50b987a4
commit fe1add7e9d
Signed by: rouven.seifert
GPG key ID: B95E8FE6B11C4D09
4 changed files with 83 additions and 85 deletions

View file

@ -3,9 +3,7 @@
"course-management": { "course-management": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": [ "nixpkgs": "nixpkgs",
"nixpkgs"
],
"poetry2nix": "poetry2nix" "poetry2nix": "poetry2nix"
}, },
"locked": { "locked": {
@ -145,11 +143,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1716170277, "lastModified": 1718507237,
"narHash": "sha256-fCAiox/TuzWGVaAz16PxrR4Jtf9lN5dwWL2W74DS0yI=", "narHash": "sha256-xBEWCxWeRpWQggFFp8ugJCDa63cOJsVvx71R9F0Eowg=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nix-index-database", "repo": "nix-index-database",
"rev": "e0638db3db43b582512a7de8c0f8363a162842b9", "rev": "6af2c5e58c20311276f59d247341cafeebfcb6f4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -160,27 +158,27 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1718208800, "lastModified": 1701253981,
"narHash": "sha256-US1tAChvPxT52RV8GksWZS415tTS7PV42KTc2PNDBmc=", "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "cc54fb41d13736e92229c21627ea4f22199fee6b", "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixos-24.05", "ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1716061101, "lastModified": 1718478900,
"narHash": "sha256-H0eCta7ahEgloGIwE/ihkyGstOGu+kQwAiHvwVoXaA0=", "narHash": "sha256-v43N1gZLcGkhg3PdcrKUNIZ1L0FBzB2JqhIYEyKAHEs=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "e7cc61784ddf51c81487637b3031a6dd2d6673a2", "rev": "c884223af91820615a6146af1ae1fea25c107005",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -192,11 +190,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1716509168, "lastModified": 1718714799,
"narHash": "sha256-4zSIhSRRIoEBwjbPm3YiGtbd8HDWzFxJjw5DYSDy1n8=", "narHash": "sha256-FUZpz9rg3gL8NVPKbqU8ei1VkPLsTIfAJ2fdAf5qjak=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "bfb7a882678e518398ce9a31a881538679f6f092", "rev": "c00d587b1a1afbf200b1d8f0b0e4ba9deb1c7f0e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -207,6 +205,22 @@
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": {
"lastModified": 1718835956,
"narHash": "sha256-wM9v2yIxClRYsGHut5vHICZTK7xdrUGfrLkXvSuv6s4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "dd457de7e08c6d06789b1f5b88fc9327f4d96309",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1682134069, "lastModified": 1682134069,
"narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=", "narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=",
@ -271,7 +285,7 @@
"ese-manual": "ese-manual", "ese-manual": "ese-manual",
"kpp": "kpp", "kpp": "kpp",
"nix-index-database": "nix-index-database", "nix-index-database": "nix-index-database",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs_2",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"print-interface": "print-interface", "print-interface": "print-interface",
"sops-nix": "sops-nix", "sops-nix": "sops-nix",
@ -286,11 +300,11 @@
"nixpkgs-stable": "nixpkgs-stable" "nixpkgs-stable": "nixpkgs-stable"
}, },
"locked": { "locked": {
"lastModified": 1716400300, "lastModified": 1718506969,
"narHash": "sha256-0lMkIk9h3AzOHs1dCL9RXvvN4PM8VBKb+cyGsqOKa4c=", "narHash": "sha256-Pm9I/BMQHbsucdWf6y9G3xBZh3TMlThGo4KBbeoeczg=",
"owner": "Mic92", "owner": "Mic92",
"repo": "sops-nix", "repo": "sops-nix",
"rev": "b549832718b8946e875c016a4785d204fcfc2e53", "rev": "797ce4c1f45a85df6dd3d9abdc53f2691bea9251",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -383,7 +397,7 @@
"vscode-server": { "vscode-server": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_3", "flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_3"
}, },
"locked": { "locked": {
"lastModified": 1713958148, "lastModified": 1713958148,

View file

@ -18,7 +18,7 @@
course-management = { course-management = {
url = "github:fsr/course-management"; url = "github:fsr/course-management";
inputs.nixpkgs.follows = "nixpkgs"; # inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = outputs =

View file

@ -22,15 +22,15 @@ in
services.forgejo = { services.forgejo = {
enable = true; enable = true;
package = pkgs.forgejo.overrideAttrs (_old: { # package = pkgs.forgejo.overrideAttrs (_old: {
patches = [ # # patches = [
# migration fix # # # migration fix
(pkgs.fetchpatch { # # (pkgs.fetchpatch {
url = "https://codeberg.org/forgejo/forgejo/commit/ae463c7c559e02975ce5e758d8780def978eebee.patch"; # # url = "https://codeberg.org/forgejo/forgejo/commit/ae463c7c559e02975ce5e758d8780def978eebee.patch";
hash = "sha256-cOXPvkLS0n+ynSBTrmEtumZ2PYBeCZmxPpFktqkw6Fo="; # # hash = "sha256-cOXPvkLS0n+ynSBTrmEtumZ2PYBeCZmxPpFktqkw6Fo=";
}) # # })
]; # # ];
}); # });
user = gitUser; user = gitUser;
group = gitUser; group = gitUser;
lfs.enable = true; lfs.enable = true;

View file

@ -1,4 +1,4 @@
{ config, pkgs, ... }: { lib, config, pkgs, ... }:
let let
hostname = "mail.${config.networking.domain}"; hostname = "mail.${config.networking.domain}";
dovecot-ldap-args = pkgs.writeText "ldap-args" '' dovecot-ldap-args = pkgs.writeText "ldap-args" ''
@ -20,35 +20,6 @@ in
4190 # Managesieve 4190 # Managesieve
]; ];
sops.secrets."dovecot_ldap_search".owner = config.services.dovecot2.user; sops.secrets."dovecot_ldap_search".owner = config.services.dovecot2.user;
environment.etc = {
"dovecot/sieve-pipe/sa-learn-spam.sh" = {
text = ''
#!/bin/sh
${pkgs.rspamd}/bin/rspamc learn_spam
'';
mode = "0555";
};
"dovecot/sieve-pipe/sa-learn-ham.sh" = {
text = ''
#!/bin/sh
${pkgs.rspamd}/bin/rspamc learn_ham
'';
mode = "0555";
};
"dovecot/sieve/report-spam.sieve" = {
source = ./report-spam.sieve;
user = "dovecot2";
group = "dovecot2";
mode = "0544";
};
"dovecot/sieve/report-ham.sieve" = {
source = ./report-ham.sieve;
user = "dovecot2";
group = "dovecot2";
mode = "0544";
};
};
services.dovecot2 = { services.dovecot2 = {
enable = true; enable = true;
enableImap = true; enableImap = true;
@ -100,17 +71,45 @@ in
# set to satisfy the sieveScripts check, will be overridden by userdb lookups anyways # set to satisfy the sieveScripts check, will be overridden by userdb lookups anyways
mailUser = "vmail"; mailUser = "vmail";
mailGroup = "vmail"; mailGroup = "vmail";
sieve.scripts = { sieve = {
before = pkgs.writeText "spam.sieve" '' # just pot something in here to prevent empty strings
require "fileinto"; extensions = [ "notify" ];
pipeBins = map lib.getExe [
(pkgs.writeShellScriptBin "learn-ham.sh" "exec ${pkgs.rspamd}/bin/rspamc learn_ham")
(pkgs.writeShellScriptBin "learn-spam.sh" "exec ${pkgs.rspamd}/bin/rspamc learn_spam")
];
plugins = [
"sieve_imapsieve"
"sieve_extprograms"
];
scripts = {
before = pkgs.writeText "spam.sieve" ''
require "fileinto";
if anyof( if anyof(
header :contains "x-spam-flag" "yes", header :contains "x-spam-flag" "yes",
header :contains "X-Spam-Status" "Yes"){ header :contains "X-Spam-Status" "Yes"){
fileinto "Spam"; fileinto "Spam";
} }
''; '';
};
}; };
imapsieve.mailbox = [
{
# Spam: From elsewhere to Spam folder or flag changed in Spam folder
name = "Spam";
causes = [ "COPY" "APPEND" "FLAG" ];
before = ./report-spam.sieve;
}
{
# From Junk folder to elsewhere
name = "*";
from = "Spam";
causes = [ "COPY" ];
before = ./report-ham.sieve;
}
];
extraConfig = '' extraConfig = ''
auth_username_format = %Ln auth_username_format = %Ln
passdb { passdb {
@ -151,21 +150,6 @@ in
plugin { plugin {
sieve_plugins = sieve_imapsieve sieve_extprograms
sieve_global_extensions = +vnd.dovecot.pipe
sieve_pipe_bin_dir = /etc/dovecot/sieve-pipe
# Spam: From elsewhere to Spam folder or flag changed in Spam folder
imapsieve_mailbox1_name = Spam
imapsieve_mailbox1_causes = COPY APPEND FLAG
imapsieve_mailbox1_before = file:/etc/dovecot/sieve/report-spam.sieve
# Ham: From Spam folder to elsewhere
imapsieve_mailbox2_name = *
imapsieve_mailbox2_from = Spam
imapsieve_mailbox2_causes = COPY
imapsieve_mailbox2_before = file:/etc/dovecot/sieve/report-ham.sieve
# https://doc.dovecot.org/configuration_manual/plugins/listescape_plugin/ # https://doc.dovecot.org/configuration_manual/plugins/listescape_plugin/
listescape_char = "\\" listescape_char = "\\"
} }