mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
nushell: expose config dir location as option
This commit is contained in:
parent
b47ea12ff4
commit
363007f129
3 changed files with 56 additions and 11 deletions
|
|
@ -9,12 +9,6 @@ let
|
||||||
inherit (lib.hm.nushell) isNushellInline toNushell;
|
inherit (lib.hm.nushell) isNushellInline toNushell;
|
||||||
cfg = config.programs.nushell;
|
cfg = config.programs.nushell;
|
||||||
|
|
||||||
configDir =
|
|
||||||
if pkgs.stdenv.isDarwin && !config.xdg.enable then
|
|
||||||
"Library/Application Support/nushell"
|
|
||||||
else
|
|
||||||
"${config.xdg.configHome}/nushell";
|
|
||||||
|
|
||||||
linesOrSource =
|
linesOrSource =
|
||||||
name:
|
name:
|
||||||
types.submodule (
|
types.submodule (
|
||||||
|
|
@ -54,6 +48,24 @@ in
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "nushell" { nullable = true; };
|
package = lib.mkPackageOption pkgs "nushell" { nullable = true; };
|
||||||
|
|
||||||
|
configDir = lib.mkOption {
|
||||||
|
type = types.either types.str types.path;
|
||||||
|
default =
|
||||||
|
if pkgs.stdenv.isDarwin && !config.xdg.enable then
|
||||||
|
"Library/Application Support/nushell"
|
||||||
|
else
|
||||||
|
"${config.xdg.configHome}/nushell";
|
||||||
|
defaultText = lib.literalExpression ''
|
||||||
|
if pkgs.stdenv.isDarwin && !config.xdg.enable then
|
||||||
|
"Library/Application Support/nushell"
|
||||||
|
else
|
||||||
|
"''${config.xdg.configHome}/nushell";
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
Location of the nushell config directory. This directory contains the {file}`config.nu`, {file}`env.nu`, and {file}`login.nu` files, as well as history and plugin files.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
configFile = lib.mkOption {
|
configFile = lib.mkOption {
|
||||||
type = types.nullOr (linesOrSource "config.nu");
|
type = types.nullOr (linesOrSource "config.nu");
|
||||||
default = null;
|
default = null;
|
||||||
|
|
@ -224,7 +236,7 @@ in
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
lib.mkIf writeConfig {
|
lib.mkIf writeConfig {
|
||||||
"${configDir}/config.nu".text = lib.mkMerge [
|
"${cfg.configDir}/config.nu".text = lib.mkMerge [
|
||||||
(
|
(
|
||||||
let
|
let
|
||||||
hasEnvVars = cfg.environmentVariables != { };
|
hasEnvVars = cfg.environmentVariables != { };
|
||||||
|
|
@ -265,13 +277,13 @@ in
|
||||||
)
|
)
|
||||||
|
|
||||||
(lib.mkIf (cfg.envFile != null || cfg.extraEnv != "") {
|
(lib.mkIf (cfg.envFile != null || cfg.extraEnv != "") {
|
||||||
"${configDir}/env.nu".text = lib.mkMerge [
|
"${cfg.configDir}/env.nu".text = lib.mkMerge [
|
||||||
(lib.mkIf (cfg.envFile != null) cfg.envFile.text)
|
(lib.mkIf (cfg.envFile != null) cfg.envFile.text)
|
||||||
cfg.extraEnv
|
cfg.extraEnv
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
(lib.mkIf (cfg.loginFile != null || cfg.extraLogin != "") {
|
(lib.mkIf (cfg.loginFile != null || cfg.extraLogin != "") {
|
||||||
"${configDir}/login.nu".text = lib.mkMerge [
|
"${cfg.configDir}/login.nu".text = lib.mkMerge [
|
||||||
(lib.mkIf (cfg.loginFile != null) cfg.loginFile.text)
|
(lib.mkIf (cfg.loginFile != null) cfg.loginFile.text)
|
||||||
cfg.extraLogin
|
cfg.extraLogin
|
||||||
];
|
];
|
||||||
|
|
@ -289,7 +301,7 @@ in
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
lib.mkIf ((cfg.package != null) && (cfg.plugins != [ ])) {
|
lib.mkIf ((cfg.package != null) && (cfg.plugins != [ ])) {
|
||||||
"${configDir}/plugin.msgpackz".source = "${msgPackz}/plugin.msgpackz";
|
"${cfg.configDir}/plugin.msgpackz".source = "${msgPackz}/plugin.msgpackz";
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
|
||||||
30
tests/modules/programs/nushell/config-dir.nix
Normal file
30
tests/modules/programs/nushell/config-dir.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
programs.nushell = {
|
||||||
|
enable = true;
|
||||||
|
configDir = "${config.xdg.configHome}/nushell-alt-path";
|
||||||
|
extraConfig = ''
|
||||||
|
# extra config
|
||||||
|
'';
|
||||||
|
extraEnv = ''
|
||||||
|
# extra env
|
||||||
|
'';
|
||||||
|
extraLogin = ''
|
||||||
|
# extra login
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertDirectoryExists home-files/.config/nushell-alt-path
|
||||||
|
|
||||||
|
assertFileExists home-files/.config/nushell-alt-path/config.nu
|
||||||
|
assertFileRegex home-files/.config/nushell-alt-path/config.nu '# extra config'
|
||||||
|
|
||||||
|
assertFileExists home-files/.config/nushell-alt-path/env.nu
|
||||||
|
assertFileRegex home-files/.config/nushell-alt-path/env.nu "# extra env"
|
||||||
|
|
||||||
|
assertFileExists home-files/.config/nushell-alt-path/login.nu
|
||||||
|
assertFileRegex home-files/.config/nushell-alt-path/login.nu '# extra login'
|
||||||
|
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -1 +1,4 @@
|
||||||
{ nushell-example-settings = ./example-settings.nix; }
|
{
|
||||||
|
nushell-example-settings = ./example-settings.nix;
|
||||||
|
nushell-config-dir = ./config-dir.nix;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue