From f9ebf2368831abe823fc4e36bf85ca5f676676ff Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Tue, 5 Aug 2025 02:02:19 +0200 Subject: [PATCH] feat(accounts/mail): implement afew filters management --- flake.lock | 6 +++--- modules/home-manager/accounts/email/default.nix | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 3176169..114cf11 100644 --- a/flake.lock +++ b/flake.lock @@ -61,10 +61,10 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1754265461, - "narHash": "sha256-qVA40ypUxsQR+kpzgqrsS2JrdwS6CI7JQcvpLjc+nlg=", + "lastModified": 1754351405, + "narHash": "sha256-q7KxXc9P60DAf2iUNXF42tUGkZErd0n59JuFxUMimlo=", "ref": "main", - "rev": "7ce0411fc0c480211951ef58b263c5eb72579681", + "rev": "cc10d2bdfb86551b7781041a1583388370da82cc", "shallow": true, "type": "git", "url": "ssh://git@git.epha.se:24422/ephase/nix-private.git" diff --git a/modules/home-manager/accounts/email/default.nix b/modules/home-manager/accounts/email/default.nix index 11b7bcc..af9d1b1 100644 --- a/modules/home-manager/accounts/email/default.nix +++ b/modules/home-manager/accounts/email/default.nix @@ -63,7 +63,14 @@ in v.afew.mailMover else {} ) cfg.accountConfigs); - in { + mailFilterRules = lib.flatten ( + lib.attrsets.mapAttrsToList ( + n: v: + if lib.hasAttrByPath ["afew" "filters"] v then + v.afew.filters + else [] + ) cfg.accountConfigs); + in { enable = true; extraConfig = '' [FolderNameFilter] @@ -79,6 +86,7 @@ in [ArchiveSentMailsFilter] sent_tag = sent [InboxFilter] + ${lib.concatImapStrings (p: e: "\n\n[Filter.${toString p}]\n ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n} = ${v}") e)}") mailFilterRules} ''; }; programs.neomutt = let