nushell: add options 'extraConfig' and 'extraEnv'
(cherry picked from commit 4a12f304e0
)
This commit is contained in:
parent
f7641a3ff3
commit
73dbcfbca6
|
@ -6,14 +6,17 @@ let
|
||||||
|
|
||||||
cfg = config.programs.nushell;
|
cfg = config.programs.nushell;
|
||||||
|
|
||||||
tomlFormat = pkgs.formats.toml { };
|
|
||||||
|
|
||||||
linesOrSource = name:
|
linesOrSource = name:
|
||||||
types.submodule ({ config, ... }: {
|
types.submodule ({ config, ... }: {
|
||||||
options = {
|
options = {
|
||||||
text = mkOption {
|
text = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
default = if config.source != null then
|
||||||
|
builtins.readFile config.source
|
||||||
|
else
|
||||||
|
"";
|
||||||
|
defaultText = literalExpression
|
||||||
|
"if source is defined, the content of source, otherwise empty";
|
||||||
description = ''
|
description = ''
|
||||||
Text of the nushell <filename>${name}</filename> file.
|
Text of the nushell <filename>${name}</filename> file.
|
||||||
If unset then the source option will be preferred.
|
If unset then the source option will be preferred.
|
||||||
|
@ -22,18 +25,14 @@ let
|
||||||
|
|
||||||
source = mkOption {
|
source = mkOption {
|
||||||
type = types.nullOr types.path;
|
type = types.nullOr types.path;
|
||||||
default = pkgs.writeTextFile {
|
default = null;
|
||||||
inherit (config) text;
|
|
||||||
name = hm.strings.storeFileName name;
|
|
||||||
};
|
|
||||||
defaultText = literalExpression "file containing text";
|
|
||||||
description = ''
|
description = ''
|
||||||
Path of the nushell <filename>${name}</filename> file to use.
|
Path of the nushell <filename>${name}</filename> file to use.
|
||||||
|
If the text option is set, it will be preferred.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ maintainers.Philipp-M ];
|
meta.maintainers = [ maintainers.Philipp-M ];
|
||||||
|
|
||||||
|
@ -91,14 +90,40 @@ in {
|
||||||
See <link xlink:href="https://www.nushell.sh/book/configuration.html#configuration" /> for more information.
|
See <link xlink:href="https://www.nushell.sh/book/configuration.html#configuration" /> for more information.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extraConfig = mkOption {
|
||||||
|
type = types.lines;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
Additional configuration to add to the nushell configuration file.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraEnv = mkOption {
|
||||||
|
type = types.lines;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
Additional configuration to add to the nushell environment variables file.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
xdg.configFile = mkMerge [
|
xdg.configFile = mkMerge [
|
||||||
(mkIf (cfg.configFile != null) { "nushell/config.nu" = cfg.configFile; })
|
(mkIf (cfg.configFile != null || cfg.extraConfig != "") {
|
||||||
(mkIf (cfg.envFile != null) { "nushell/env.nu" = cfg.envFile; })
|
"nushell/config.nu".text = mkMerge [
|
||||||
|
(mkIf (cfg.configFile != null) cfg.configFile.text)
|
||||||
|
cfg.extraConfig
|
||||||
|
];
|
||||||
|
})
|
||||||
|
(mkIf (cfg.envFile != null || cfg.extraEnv != "") {
|
||||||
|
"nushell/env.nu".text = mkMerge [
|
||||||
|
(mkIf (cfg.envFile != null) cfg.envFile.text)
|
||||||
|
cfg.extraEnv
|
||||||
|
];
|
||||||
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,3 +3,4 @@ let $config = {
|
||||||
table_mode: rounded
|
table_mode: rounded
|
||||||
use_ls_colors: true
|
use_ls_colors: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
let-env FOO = 'BAR'
|
let-env FOO = 'BAR'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue