From b44f56dfcdc5eabbc5be9094c1db1251fb761483 Mon Sep 17 00:00:00 2001 From: David Armstrong Lewis <6754950+davidarmstronglewis@users.noreply.github.com> Date: Wed, 23 Nov 2022 15:37:08 -0800 Subject: [PATCH] nushell: support darwin config file locations Previously the nushell module did not differentiate between Linux and Darwin when deciding where to place config files, whereas nushell does. This commit fixes that. --- modules/programs/nushell.nix | 12 ++++++++---- tests/modules/programs/nushell/example-settings.nix | 13 +++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) 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} ''; }