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

nushell: add options 'extraConfig' and 'extraEnv'

This commit is contained in:
Philipp Mildenberger 2022-10-23 19:11:21 +02:00 committed by Robert Helgesson
parent e999dfe7cb
commit 4a12f304e0
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 38 additions and 11 deletions

View file

@ -6,14 +6,17 @@ let
cfg = config.programs.nushell;
tomlFormat = pkgs.formats.toml { };
linesOrSource = name:
types.submodule ({ config, ... }: {
options = {
text = mkOption {
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 = ''
Text of the nushell <filename>${name}</filename> file.
If unset then the source option will be preferred.
@ -22,18 +25,14 @@ let
source = mkOption {
type = types.nullOr types.path;
default = pkgs.writeTextFile {
inherit (config) text;
name = hm.strings.storeFileName name;
};
defaultText = literalExpression "file containing text";
default = null;
description = ''
Path of the nushell <filename>${name}</filename> file to use.
If the text option is set, it will be preferred.
'';
};
};
});
in {
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.
'';
};
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 {
home.packages = [ cfg.package ];
xdg.configFile = mkMerge [
(mkIf (cfg.configFile != null) { "nushell/config.nu" = cfg.configFile; })
(mkIf (cfg.envFile != null) { "nushell/env.nu" = cfg.envFile; })
(mkIf (cfg.configFile != null || cfg.extraConfig != "") {
"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
];
})
];
};
}

View file

@ -3,3 +3,4 @@ let $config = {
table_mode: rounded
use_ls_colors: true
}

View file

@ -1 +1,2 @@
let-env FOO = 'BAR'