1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-19 17:49:45 +01:00

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.
This commit is contained in:
David Armstrong Lewis 2022-11-23 15:37:08 -08:00 committed by Robert Helgesson
parent e7eba9cc46
commit b44f56dfcd
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 17 additions and 8 deletions

View file

@ -6,6 +6,11 @@ let
cfg = config.programs.nushell; cfg = config.programs.nushell;
configDir = if pkgs.stdenv.isDarwin then
"Library/Application Support/nushell"
else
"${config.xdg.configHome}/nushell";
linesOrSource = name: linesOrSource = name:
types.submodule ({ config, ... }: { types.submodule ({ config, ... }: {
options = { options = {
@ -110,16 +115,15 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
home.file = mkMerge [
xdg.configFile = mkMerge [
(mkIf (cfg.configFile != null || cfg.extraConfig != "") { (mkIf (cfg.configFile != null || cfg.extraConfig != "") {
"nushell/config.nu".text = mkMerge [ "${configDir}/config.nu".text = mkMerge [
(mkIf (cfg.configFile != null) cfg.configFile.text) (mkIf (cfg.configFile != null) cfg.configFile.text)
cfg.extraConfig cfg.extraConfig
]; ];
}) })
(mkIf (cfg.envFile != null || cfg.extraEnv != "") { (mkIf (cfg.envFile != null || cfg.extraEnv != "") {
"nushell/env.nu".text = mkMerge [ "${configDir}/env.nu".text = mkMerge [
(mkIf (cfg.envFile != null) cfg.envFile.text) (mkIf (cfg.envFile != null) cfg.envFile.text)
cfg.extraEnv cfg.extraEnv
]; ];

View file

@ -1,4 +1,4 @@
{ ... }: { pkgs, ... }:
{ {
programs.nushell = { programs.nushell = {
@ -19,12 +19,17 @@
test.stubs.nushell = { }; 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 \ assertFileContent \
home-files/.config/nushell/config.nu \ "${configDir}/config.nu" \
${./config-expected.nu} ${./config-expected.nu}
assertFileContent \ assertFileContent \
home-files/.config/nushell/env.nu \ "${configDir}/env.nu" \
${./env-expected.nu} ${./env-expected.nu}
''; '';
} }