2020-07-24 15:15:55 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.nushell;
|
|
|
|
|
2021-03-13 04:20:00 +00:00
|
|
|
tomlFormat = pkgs.formats.toml { };
|
2020-07-24 15:15:55 +00:00
|
|
|
|
2022-05-13 15:20:42 +00:00
|
|
|
linesOrSource = name:
|
|
|
|
types.submodule ({ config, ... }: {
|
|
|
|
options = {
|
|
|
|
text = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
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;
|
|
|
|
default = pkgs.writeTextFile {
|
|
|
|
inherit (config) text;
|
|
|
|
name = hm.strings.storeFileName name;
|
|
|
|
};
|
|
|
|
defaultText = literalExpression "file containing text";
|
|
|
|
description = ''
|
|
|
|
Path of the nushell <filename>${name}</filename> file to use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
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
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
2022-07-07 06:49:50 +00:00
|
|
|
xdg.configFile = mkMerge [
|
|
|
|
(mkIf (cfg.configFile != null) { "nushell/config.nu" = cfg.configFile; })
|
|
|
|
(mkIf (cfg.envFile != null) { "nushell/env.nu" = cfg.envFile; })
|
|
|
|
];
|
2020-07-24 15:15:55 +00:00
|
|
|
};
|
|
|
|
}
|