mise: add module

This adds the support for the mise program, the successor of rtx. This
commit therefore also removes the rtx module.
This commit is contained in:
Nikita Pedorich 2024-01-21 08:51:14 +01:00 committed by GitHub
parent 9b378afae7
commit 928f2528f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 222 additions and 170 deletions

View file

@ -1383,6 +1383,15 @@ in {
A new module is available: 'xdg.portal'.
'';
}
{
time = "2024-01-20T23:45:07+00:00";
message = ''
A new module is available: 'programs.mise'.
This module replaces 'programs.rtx', which has been removed.
'';
}
];
};
}

View file

@ -147,6 +147,7 @@ let
./programs/mcfly.nix
./programs/mercurial.nix
./programs/micro.nix
./programs/mise.nix
./programs/mpv.nix
./programs/mr.nix
./programs/msmtp.nix
@ -194,7 +195,6 @@ let
./programs/rofi-pass.nix
./programs/rofi.nix
./programs/rtorrent.nix
./programs/rtx.nix
./programs/ruff.nix
./programs/sagemath.nix
./programs/sapling.nix

111
modules/programs/mise.nix Normal file
View file

@ -0,0 +1,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
'';
};
};
}

View file

@ -1,79 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.rtx;
tomlFormat = pkgs.formats.toml { };
in {
meta.maintainers = [ hm.maintainers.pedorich-n ];
options = {
programs.rtx = {
enable = mkEnableOption "RTX. Runtime Executor (asdf Rust clone)";
package = mkPackageOption pkgs "rtx" { };
enableBashIntegration = mkEnableOption "Bash Integration" // {
default = true;
};
enableZshIntegration = mkEnableOption "Zsh Integration" // {
default = true;
};
enableFishIntegration = mkEnableOption "Fish Integration" // {
default = true;
};
settings = mkOption {
type = tomlFormat.type;
default = { };
example = literalExpression ''
tools = {
node = "lts";
python = ["3.10" "3.11"];
};
settings = {
verbose = false;
experimental = false;
};
'';
description = ''
Settings written to {file}`$XDG_CONFIG_HOME/rtx/config.toml`.
See <https://github.com/jdxcode/rtx#global-config-configrtxconfigtoml>
for details on supported values.
::: {.warning}
Modifying the `tools` section doesn't make RTX install them.
You have to manually run `rtx install` to install the tools.
:::
'';
};
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."rtx/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "rtx-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
'';
};
};
}

View file

@ -101,6 +101,7 @@ in import nmtSrc {
./modules/programs/man
./modules/programs/mbsync
./modules/programs/micro
./modules/programs/mise
./modules/programs/mpv
./modules/programs/mu
./modules/programs/mujmap
@ -128,7 +129,6 @@ in import nmtSrc {
./modules/programs/readline
./modules/programs/rio
./modules/programs/ripgrep
./modules/programs/rtx
./modules/programs/ruff
./modules/programs/sagemath
./modules/programs/sapling

View file

@ -0,0 +1,16 @@
{ config, ... }: {
programs = {
mise = {
package = config.lib.test.mkStubPackage { name = "mise"; };
enable = true;
enableBashIntegration = true;
};
bash.enable = true;
};
nmt.script = ''
assertFileRegex home-files/.bashrc 'eval "$(/nix/store/.*mise.*/bin/mise activate bash)"'
'';
}

View file

@ -0,0 +1,45 @@
{ config, pkgs, ... }: {
programs = {
mise = {
package = config.lib.test.mkStubPackage { name = "mise"; };
enable = true;
globalConfig = {
tools = {
node = "lts";
python = [ "3.10" "3.11" ];
};
aliases = { my_custom_node = "20"; };
};
settings = {
verbose = false;
experimental = true;
disable_tools = [ "node" ];
};
};
};
nmt.script = ''
assertFileExists home-files/.config/mise/config.toml
assertPathExists home-files/.config/mise/settings.toml
assertFileContent home-files/.config/mise/config.toml ${
pkgs.writeText "mise.config.expected" ''
[aliases]
my_custom_node = "20"
[tools]
node = "lts"
python = ["3.10", "3.11"]
''
}
assertFileContent home-files/.config/mise/settings.toml ${
pkgs.writeText "mise.settings.expected" ''
disable_tools = ["node"]
experimental = true
verbose = false
''
}
'';
}

View file

@ -0,0 +1,13 @@
{ config, ... }: {
config = {
programs.mise = {
package = config.lib.test.mkStubPackage { name = "mise"; };
enable = true;
};
nmt.script = ''
assertPathNotExists home-files/.config/mise/config.toml
assertPathNotExists home-files/.config/mise/settings.toml
'';
};
}

View file

@ -0,0 +1,7 @@
{
mise-default-settings = ./default-settings.nix;
mise-custom-settings = ./custom-settings.nix;
mise-bash-integration = ./bash-integration.nix;
mise-zsh-integration = ./zsh-integration.nix;
mise-fish-integration = ./fish-integration.nix;
}

View file

@ -1,7 +1,7 @@
{ config, ... }: {
programs = {
rtx = {
package = config.lib.test.mkStubPackage { name = "rtx"; };
mise = {
package = config.lib.test.mkStubPackage { name = "mise"; };
enable = true;
enableFishIntegration = true;
};
@ -10,7 +10,7 @@
};
nmt.script = ''
assertFileRegex home-files/.config/fish/config.fish '/nix/store/.*rtx.*/bin/rtx activate fish | source'
assertFileRegex home-files/.config/fish/config.fish '/nix/store/.*mise.*/bin/mise activate fish | source'
'';
}

View file

@ -0,0 +1,16 @@
{ config, ... }: {
programs = {
mise = {
package = config.lib.test.mkStubPackage { name = "mise"; };
enable = true;
enableZshIntegration = true;
};
zsh.enable = true;
};
nmt.script = ''
assertFileRegex home-files/.zshrc 'eval "$(/nix/store/.*mise.*/bin/mise activate zsh)"'
'';
}

View file

@ -1,16 +0,0 @@
{ config, ... }: {
programs = {
rtx = {
package = config.lib.test.mkStubPackage { name = "rtx"; };
enable = true;
enableBashIntegration = true;
};
bash.enable = true;
};
nmt.script = ''
assertFileRegex home-files/.bashrc 'eval "$(/nix/store/.*rtx.*/bin/rtx activate bash)"'
'';
}

View file

@ -1,35 +0,0 @@
{ config, pkgs, ... }: {
programs = {
rtx = {
package = config.lib.test.mkStubPackage { name = "rtx"; };
enable = true;
settings = {
tools = {
node = "lts";
python = [ "3.10" "3.11" ];
};
settings = {
verbose = false;
experimental = false;
};
};
};
};
nmt.script = ''
assertFileExists home-files/.config/rtx/config.toml
assertFileContent home-files/.config/rtx/config.toml ${
pkgs.writeText "rtx.expected" ''
[settings]
experimental = false
verbose = false
[tools]
node = "lts"
python = ["3.10", "3.11"]
''
}
'';
}

View file

@ -1,12 +0,0 @@
{ config, ... }: {
config = {
programs.rtx = {
package = config.lib.test.mkStubPackage { name = "rtx"; };
enable = true;
};
nmt.script = ''
assertPathNotExists home-files/.config/rtx/config.toml
'';
};
}

View file

@ -1,7 +0,0 @@
{
rtx-default-settings = ./default-settings.nix;
rtx-custom-settings = ./custom-settings.nix;
rtx-bash-integration = ./bash-integration.nix;
rtx-zsh-integration = ./zsh-integration.nix;
rtx-fish-integration = ./fish-integration.nix;
}

View file

@ -1,16 +0,0 @@
{ config, ... }: {
programs = {
rtx = {
package = config.lib.test.mkStubPackage { name = "rtx"; };
enable = true;
enableZshIntegration = true;
};
zsh.enable = true;
};
nmt.script = ''
assertFileRegex home-files/.zshrc 'eval "$(/nix/store/.*rtx.*/bin/rtx activate zsh)"'
'';
}