From d8232b77c7fe48b3796d59e6914373f2bd1bd91e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 8 Sep 2021 15:19:50 +0200 Subject: feeds: afew --- user-profiles/feeds/module.nix | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'user-profiles/feeds') diff --git a/user-profiles/feeds/module.nix b/user-profiles/feeds/module.nix index 854083ee..da992b8c 100644 --- a/user-profiles/feeds/module.nix +++ b/user-profiles/feeds/module.nix @@ -5,7 +5,6 @@ with lib; let inherit (flakeInputs.home-manager.lib) hm; - configPath = "${config.xdg.configHome}/feeds/notmuchrc"; databasePath = "${config.xdg.dataHome}/feeds"; imm = @@ -131,6 +130,30 @@ let search = { exclude_tags = ["deleted"]; }; }; + configPath = pkgs.writeText "notmuchrc" (generators.toINI { mkKeyValue = mkIniKeyValue; } notmuchIni); + + afewConfigDir = pkgs.symlinkJoin { + name = "afew-config"; + paths = [ + (pkgs.writeTextDir "config" '' + [InboxFilter] + '') + ]; + }; + + notmuchHooksDir = + let + afewHook = pkgs.writeShellScript "afew" '' + exec -- ${pkgs.afew}/bin/afew -c ${afewConfigDir} -C ${configPath} --tag --new -vv + ''; + in pkgs.linkFarm "notmuch-hooks" [ + { name = "post-new"; + path = afewHook; + } + { name = "post-insert"; + path = afewHook; + } + ]; in { config = { home.packages = [ immWrapped ]; @@ -138,12 +161,6 @@ in { home.activation.createImm = hm.dag.entryAfter ["writeBoundary"] '' $DRY_RUN_CMD mkdir -p $VERBOSE_ARG ${config.xdg.configHome}/imm ''; - - xdg.configFile."feeds/notmuchrc".text = - let toIni = generators.toINI { mkKeyValue = mkIniKeyValue; }; - in '' - # Generated by Home Manager. - '' + toIni notmuchIni; home.activation.createFeedsDatabase = hm.dag.entryAfter ["linkGeneration" "writeBoundary"] '' $DRY_RUN_CMD mkdir -p -m 0750 $VERBOSE_ARG ${databasePath} @@ -155,6 +172,7 @@ in { fi NOTMUCH_CONFIG=${configPath} $DRY_RUN_CMD ${pkgs.notmuch}/bin/notmuch new $NOTMUCH_VERBOSE_ARG fi + $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG ${notmuchHooksDir} ${databasePath}/.notmuch/hooks ''; systemd.user.services."logrotate-imm" = { -- cgit v1.2.3