1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

dircolors: add nushell integration

This commit is contained in:
jaredmontoya 2025-09-29 10:59:12 +02:00 committed by Austin Horstman
parent 462363e248
commit 38fbd8909e

View file

@ -36,6 +36,8 @@ in
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; };
settings = mkOption {
type = with types; attrsOf str;
default = { };
@ -67,11 +69,13 @@ in
dircolorsPath =
if config.home.preferXdgDirectories then "${config.xdg.configHome}/dir_colors" else "~/.dir_colors";
dircolorsConfig = lib.concatStringsSep "\n" (
dircolorsConfigText = lib.concatStringsSep "\n" (
lib.mapAttrsToList formatLine cfg.settings
++ [ "" ]
++ lib.optional (cfg.extraConfig != "") cfg.extraConfig
);
dircolorsConfig = pkgs.writeText "dir_colors" dircolorsConfigText;
in
mkIf cfg.enable (
lib.mkMerge [
@ -223,12 +227,21 @@ in
eval $(${lib.getExe' cfg.package "dircolors"} -b ${dircolorsPath})
''
);
programs.nushell.extraEnv = mkIf cfg.enableNushellIntegration ''
source ${
pkgs.runCommand "dircolors.nu" { } ''
eval "$(${lib.getExe' cfg.package "dircolors"} -b ${dircolorsConfig})"
echo "export-env { \$env.LS_COLORS = \"$LS_COLORS\" }" >> $out
''
}
'';
}
(mkIf (!config.home.preferXdgDirectories) {
home.file.".dir_colors".text = dircolorsConfig;
home.file.".dir_colors".source = dircolorsConfig;
})
(mkIf config.home.preferXdgDirectories {
xdg.configFile.dir_colors.text = dircolorsConfig;
xdg.configFile.dir_colors.source = dircolorsConfig;
})
]
);