diff --git a/modules/programs/nushell.nix b/modules/programs/nushell.nix index c31c6c65f..da01672b1 100644 --- a/modules/programs/nushell.nix +++ b/modules/programs/nushell.nix @@ -6,6 +6,11 @@ let cfg = config.programs.nushell; + configDir = if pkgs.stdenv.isDarwin then + "Library/Application Support/nushell" + else + "${config.xdg.configHome}/nushell"; + linesOrSource = name: types.submodule ({ config, ... }: { options = { @@ -110,16 +115,15 @@ in { config = mkIf cfg.enable { home.packages = [ cfg.package ]; - - xdg.configFile = mkMerge [ + home.file = mkMerge [ (mkIf (cfg.configFile != null || cfg.extraConfig != "") { - "nushell/config.nu".text = mkMerge [ + "${configDir}/config.nu".text = mkMerge [ (mkIf (cfg.configFile != null) cfg.configFile.text) cfg.extraConfig ]; }) (mkIf (cfg.envFile != null || cfg.extraEnv != "") { - "nushell/env.nu".text = mkMerge [ + "${configDir}/env.nu".text = mkMerge [ (mkIf (cfg.envFile != null) cfg.envFile.text) cfg.extraEnv ]; diff --git a/tests/modules/programs/nushell/example-settings.nix b/tests/modules/programs/nushell/example-settings.nix index d1eca3202..21d94a70a 100644 --- a/tests/modules/programs/nushell/example-settings.nix +++ b/tests/modules/programs/nushell/example-settings.nix @@ -1,4 +1,4 @@ -{ ... }: +{ pkgs, ... }: { programs.nushell = { @@ -19,12 +19,17 @@ test.stubs.nushell = { }; - nmt.script = '' + nmt.script = let + configDir = if pkgs.stdenv.isDarwin then + "home-files/Library/Application Support/nushell" + else + "home-files/.config/nushell"; + in '' assertFileContent \ - home-files/.config/nushell/config.nu \ + "${configDir}/config.nu" \ ${./config-expected.nu} assertFileContent \ - home-files/.config/nushell/env.nu \ + "${configDir}/env.nu" \ ${./env-expected.nu} ''; }