From d8232b77c7fe48b3796d59e6914373f2bd1bd91e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 8 Sep 2021 15:19:50 +0200 Subject: feeds: afew --- overlays/afew.nix | 12 ++++++++++++ user-profiles/feeds/module.nix | 32 +++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 overlays/afew.nix diff --git a/overlays/afew.nix b/overlays/afew.nix new file mode 100644 index 00000000..5075d678 --- /dev/null +++ b/overlays/afew.nix @@ -0,0 +1,12 @@ +final: prev: { + afew = prev.afew.overrideAttrs (oldAttrs: { + src = prev.fetchgit { + url = "https://github.com/gkleen/afew.git"; + rev = "7b96c73000152188bf8ec9168721f26f5bd01aa6"; + sha256 = "09pmfyxq2j0rqvdisahpxpskvxckksx6gq9axdc83ppkws25iprm"; + leaveDotGit = true; + }; + + nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [ final.git ]; + }); +} 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