From 38fbd8909e6d4a8a36fda318c5feb8704da178d1 Mon Sep 17 00:00:00 2001 From: jaredmontoya <49511278+jaredmontoya@users.noreply.github.com> Date: Mon, 29 Sep 2025 10:59:12 +0200 Subject: [PATCH] dircolors: add nushell integration --- modules/programs/dircolors.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/programs/dircolors.nix b/modules/programs/dircolors.nix index fcbae1624..035355d0b 100644 --- a/modules/programs/dircolors.nix +++ b/modules/programs/dircolors.nix @@ -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; }) ] );