/
mise.nix
111 lines (91 loc) · 2.78 KB
/
mise.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.mise;
tomlFormat = pkgs.formats.toml { };
in {
meta.maintainers = [ hm.maintainers.pedorich-n ];
imports = let
mkRemovedWarning = opt:
(mkRemovedOptionModule [ "programs" "rtx" opt ] ''
The `rtx` package has been replaced by `mise`, please switch over to
using the options under `programs.mise.*` instead.
'');
in map mkRemovedWarning [
"enable"
"package"
"enableBashIntegration"
"enableZshIntegration"
"enableFishIntegration"
"settings"
];
options = {
programs.mise = {
enable = mkEnableOption "mise";
package = mkPackageOption pkgs "mise" { };
enableBashIntegration = mkEnableOption "Bash Integration" // {
default = true;
};
enableZshIntegration = mkEnableOption "Zsh Integration" // {
default = true;
};
enableFishIntegration = mkEnableOption "Fish Integration" // {
default = true;
};
globalConfig = mkOption {
type = tomlFormat.type;
default = { };
example = literalExpression ''
tools = {
node = "lts";
python = ["3.10" "3.11"];
};
aliases = {
my_custom_node = "20";
};
'';
description = ''
Config written to {file}`$XDG_CONFIG_HOME/mise/config.toml`.
See <https://mise.jdx.dev/configuration.html#global-config-config-mise-config-toml>
for details on supported values.
'';
};
settings = mkOption {
type = tomlFormat.type;
default = { };
example = literalExpression ''
verbose = false;
experimental = false;
disable_tools = ["node"];
'';
description = ''
Settings written to {file}`$XDG_CONFIG_HOME/mise/settings.toml`.
See <https://mise.jdx.dev/configuration.html#settings-file-config-mise-settings-toml>
for details on supported values.
'';
};
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile = {
"mise/config.toml" = mkIf (cfg.globalConfig != { }) {
source = tomlFormat.generate "mise-config" cfg.globalConfig;
};
"mise/settings.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "mise-settings" cfg.settings;
};
};
programs = {
bash.initExtra = mkIf cfg.enableBashIntegration ''
eval "$(${getExe cfg.package} activate bash)"
'';
zsh.initExtra = mkIf cfg.enableZshIntegration ''
eval "$(${getExe cfg.package} activate zsh)"
'';
fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
${getExe cfg.package} activate fish | source
'';
};
};
}