From aa03c8a429902dbaf15b3395f8cefc5a4b83f7f7 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Tue, 18 Apr 2023 11:57:55 -0300 Subject: [PATCH] bat: rebuild caches during activation Without this, themes configured through Home Manager are not found at runtime. --- modules/programs/bat.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/programs/bat.nix b/modules/programs/bat.nix index df2e49685..3488e4980 100644 --- a/modules/programs/bat.nix +++ b/modules/programs/bat.nix @@ -6,6 +6,8 @@ let cfg = config.programs.bat; + package = pkgs.bat; + toConfigFile = generators.toKeyValue { mkKeyValue = k: v: "--${k}=${lib.escapeShellArg v}"; listsAsDuplicateKeys = true; @@ -61,12 +63,17 @@ in { }; config = mkIf cfg.enable { - home.packages = [ pkgs.bat ] ++ cfg.extraPackages; + home.packages = [ package ] ++ cfg.extraPackages; xdg.configFile = mkMerge ([{ "bat/config" = mkIf (cfg.config != { }) { text = toConfigFile cfg.config; }; }] ++ flip mapAttrsToList cfg.themes (name: body: { "bat/themes/${name}.tmTheme" = { text = body; }; })); + + home.activation.batCache = hm.dag.entryAfter [ "linkGeneration" ] '' + $VERBOSE_ECHO "Rebuilding bat theme cache" + $DRY_RUN_CMD ${lib.getExe package} cache --build + ''; }; }