2020-07-24 15:15:55 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.nushell;
|
|
|
|
|
2022-11-23 23:37:08 +00:00
|
|
|
configDir = if pkgs.stdenv.isDarwin then
|
|
|
|
"Library/Application Support/nushell"
|
|
|
|
else
|
|
|
|
"${config.xdg.configHome}/nushell";
|
|
|
|
|
2022-05-13 15:20:42 +00:00
|
|
|
linesOrSource = name:
|
|
|
|
types.submodule ({ config, ... }: {
|
|
|
|
options = {
|
|
|
|
text = mkOption {
|
|
|
|
type = types.lines;
|
2022-10-23 17:11:21 +00:00
|
|
|
default = if config.source != null then
|
|
|
|
builtins.readFile config.source
|
|
|
|
else
|
|
|
|
"";
|
|
|
|
defaultText = literalExpression
|
|
|
|
"if source is defined, the content of source, otherwise empty";
|
2022-05-13 15:20:42 +00:00
|
|
|
description = ''
|
|
|
|
Text of the nushell <filename>${name}</filename> file.
|
|
|
|
If unset then the source option will be preferred.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
source = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
2022-10-23 17:11:21 +00:00
|
|
|
default = null;
|
2022-05-13 15:20:42 +00:00
|
|
|
description = ''
|
|
|
|
Path of the nushell <filename>${name}</filename> file to use.
|
2022-10-23 17:11:21 +00:00
|
|
|
If the text option is set, it will be preferred.
|
2022-05-13 15:20:42 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
2020-07-24 15:15:55 +00:00
|
|
|
in {
|
|
|
|
meta.maintainers = [ maintainers.Philipp-M ];
|
|
|
|
|
2022-05-13 15:20:42 +00:00
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule [ "programs" "nushell" "settings" ] ''
|
|
|
|
Please use
|
|
|
|
|
|
|
|
'programs.nushell.configFile' and 'programs.nushell.envFile'
|
|
|
|
|
|
|
|
instead.
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2020-07-24 15:15:55 +00:00
|
|
|
options.programs.nushell = {
|
|
|
|
enable = mkEnableOption "nushell";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.nushell;
|
2021-10-09 09:14:08 +00:00
|
|
|
defaultText = literalExpression "pkgs.nushell";
|
2020-07-24 15:15:55 +00:00
|
|
|
description = "The package to use for nushell.";
|
|
|
|
};
|
|
|
|
|
2022-05-13 15:20:42 +00:00
|
|
|
configFile = mkOption {
|
2022-07-07 06:49:50 +00:00
|
|
|
type = types.nullOr (linesOrSource "config.nu");
|
|
|
|
default = null;
|
2021-10-09 09:14:08 +00:00
|
|
|
example = literalExpression ''
|
2022-05-13 15:20:42 +00:00
|
|
|
{ text = '''
|
|
|
|
let $config = {
|
|
|
|
filesize_metric: false
|
|
|
|
table_mode: rounded
|
|
|
|
use_ls_colors: true
|
|
|
|
}
|
|
|
|
''';
|
2020-07-24 15:15:55 +00:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
2022-05-13 15:20:42 +00:00
|
|
|
The configuration file to be used for nushell.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See <link xlink:href="https://www.nushell.sh/book/configuration.html#configuration" /> for more information.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
envFile = mkOption {
|
2022-07-07 06:49:50 +00:00
|
|
|
type = types.nullOr (linesOrSource "env.nu");
|
|
|
|
default = null;
|
2022-05-13 15:20:42 +00:00
|
|
|
example = ''
|
|
|
|
let-env FOO = 'BAR'
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
The environment variables file to be used for nushell.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See <link xlink:href="https://www.nushell.sh/book/configuration.html#configuration" /> for more information.
|
2020-07-24 15:15:55 +00:00
|
|
|
'';
|
|
|
|
};
|
2022-10-23 17:11:21 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
2020-07-24 15:15:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ cfg.package ];
|
2022-11-23 23:37:08 +00:00
|
|
|
home.file = mkMerge [
|
2022-10-23 17:11:21 +00:00
|
|
|
(mkIf (cfg.configFile != null || cfg.extraConfig != "") {
|
2022-11-23 23:37:08 +00:00
|
|
|
"${configDir}/config.nu".text = mkMerge [
|
2022-10-23 17:11:21 +00:00
|
|
|
(mkIf (cfg.configFile != null) cfg.configFile.text)
|
|
|
|
cfg.extraConfig
|
|
|
|
];
|
|
|
|
})
|
|
|
|
(mkIf (cfg.envFile != null || cfg.extraEnv != "") {
|
2022-11-23 23:37:08 +00:00
|
|
|
"${configDir}/env.nu".text = mkMerge [
|
2022-10-23 17:11:21 +00:00
|
|
|
(mkIf (cfg.envFile != null) cfg.envFile.text)
|
|
|
|
cfg.extraEnv
|
|
|
|
];
|
|
|
|
})
|
2022-07-07 06:49:50 +00:00
|
|
|
];
|
2020-07-24 15:15:55 +00:00
|
|
|
};
|
|
|
|
}
|