From 8886a68edadb1d93c7101337f995ffce4b410ff2 Mon Sep 17 00:00:00 2001 From: Alejandro Angulo <5242883+alejandro-angulo@users.noreply.github.com> Date: Tue, 20 Aug 2024 05:17:35 -0700 Subject: [PATCH] fix(home-manager/lazygit): support darwin without XDG (#313) * fix(home-manager/lazygit): support darwin without XDG Lazygit would fail to load becase the wrong path was being generated to the configuration file on darwin systems when XDG wasn't enabled. * Refactored * fix(home-manager/lazygit): actually use xdg directory when it's enabled --------- Co-authored-by: seth --- modules/home-manager/lazygit.nix | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/home-manager/lazygit.nix b/modules/home-manager/lazygit.nix index 25153cb..527cffb 100644 --- a/modules/home-manager/lazygit.nix +++ b/modules/home-manager/lazygit.nix @@ -1,9 +1,26 @@ -{ config, lib, ... }: +{ + config, + lib, + pkgs, + ... +}: let inherit (lib) ctp; inherit (config.catppuccin) sources; + cfg = config.programs.lazygit.catppuccin; enable = cfg.enable && config.programs.lazygit.enable; + + # NOTE: On MacOS specifically, k9s expects its configuration to be in + # `~/Library/Application Support` when not using XDG + enableXdgConfig = !pkgs.stdenv.hostPlatform.isDarwin || config.xdg.enable; + + configDirectory = + if enableXdgConfig then + config.xdg.configHome + else + "${config.home.homeDirectory}/Library/Application Support"; + configFile = "${configDirectory}/lazygit/config.yml"; in { options.programs.lazygit.catppuccin = lib.ctp.mkCatppuccinOpt { name = "lazygit"; } // { @@ -12,6 +29,6 @@ in config.home.sessionVariables = lib.mkIf enable { # Ensure that the default config file is still sourced - LG_CONFIG_FILE = "${sources.lazygit}/themes-mergable/${cfg.flavor}/${cfg.accent}.yml,${config.xdg.configHome}/lazygit/config.yml"; + LG_CONFIG_FILE = "${sources.lazygit}/themes-mergable/${cfg.flavor}/${cfg.accent}.yml,${configFile}"; }; }