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;
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
];

View file

@ -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}
'';
}