1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

dircolors: respect preferXdgDirectories if set

This commit is contained in:
Shaw Vrana 2024-07-10 16:29:41 -07:00
parent 1e22ef1518
commit 163e34933f

View file

@ -69,7 +69,8 @@ in {
};
};
config = mkIf cfg.enable {
config = mkIf cfg.enable (mkMerge [
{
# Add default settings from `dircolors --print-database`.
programs.dircolors.settings = {
RESET = mkDefault "0";
@ -202,7 +203,9 @@ in {
".spx" = mkDefault "00;36";
".xspf" = mkDefault "00;36";
};
}
(mkIf (!config.home.preferXdgDirectories) {
home.file.".dir_colors".text = concatStringsSep "\n" ([ ]
++ mapAttrsToList formatLine cfg.settings ++ [ "" ]
++ optional (cfg.extraConfig != "") cfg.extraConfig);
@ -219,5 +222,24 @@ in {
programs.zsh.initExtraBeforeCompInit = mkIf cfg.enableZshIntegration ''
eval $(${pkgs.coreutils}/bin/dircolors -b ~/.dir_colors)
'';
};
})
(mkIf config.home.preferXdgDirectories {
xdg.configFile.dir_colors.text = concatStringsSep "\n" ([ ]
++ mapAttrsToList formatLine cfg.settings ++ [ "" ]
++ optional (cfg.extraConfig != "") cfg.extraConfig);
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
eval $(${pkgs.coreutils}/bin/dircolors -b ${config.xdg.configHome}/dir_colors)
'';
programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
eval (${pkgs.coreutils}/bin/dircolors -c ${config.xdg.configHome}/dir_colors)
'';
# Set `LS_COLORS` before Oh My Zsh and `initExtra`.
programs.zsh.initExtraBeforeCompInit = mkIf cfg.enableZshIntegration ''
eval $(${pkgs.coreutils}/bin/dircolors -b ${config.xdg.configHome}/dir_colors)
'';
})
]);
}