From d17141524da9bb2557064763b3a5bd1f57dbc2bb Mon Sep 17 00:00:00 2001 From: Nikita Pedorich Date: Sun, 21 Jan 2024 08:51:14 +0100 Subject: [PATCH] mise: add module This adds the support for the mise program, the successor of rtx. This commit therefore also removes the rtx module. --- modules/misc/news.nix | 9 ++ modules/modules.nix | 2 +- modules/programs/mise.nix | 111 ++++++++++++++++++ modules/programs/rtx.nix | 79 ------------- tests/default.nix | 2 +- .../programs/mise/bash-integration.nix | 16 +++ .../modules/programs/mise/custom-settings.nix | 45 +++++++ .../programs/mise/default-settings.nix | 13 ++ tests/modules/programs/mise/default.nix | 7 ++ .../{rtx => mise}/fish-integration.nix | 6 +- .../modules/programs/mise/zsh-integration.nix | 16 +++ .../modules/programs/rtx/bash-integration.nix | 16 --- .../modules/programs/rtx/custom-settings.nix | 35 ------ .../modules/programs/rtx/default-settings.nix | 12 -- tests/modules/programs/rtx/default.nix | 7 -- .../modules/programs/rtx/zsh-integration.nix | 16 --- 16 files changed, 222 insertions(+), 170 deletions(-) create mode 100644 modules/programs/mise.nix delete mode 100644 modules/programs/rtx.nix create mode 100644 tests/modules/programs/mise/bash-integration.nix create mode 100644 tests/modules/programs/mise/custom-settings.nix create mode 100644 tests/modules/programs/mise/default-settings.nix create mode 100644 tests/modules/programs/mise/default.nix rename tests/modules/programs/{rtx => mise}/fish-integration.nix (63%) create mode 100644 tests/modules/programs/mise/zsh-integration.nix delete mode 100644 tests/modules/programs/rtx/bash-integration.nix delete mode 100644 tests/modules/programs/rtx/custom-settings.nix delete mode 100644 tests/modules/programs/rtx/default-settings.nix delete mode 100644 tests/modules/programs/rtx/default.nix delete mode 100644 tests/modules/programs/rtx/zsh-integration.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index ed6d1546b..e24ed4728 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -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. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 314dfdb8d..d557dc1b3 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -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 diff --git a/modules/programs/mise.nix b/modules/programs/mise.nix new file mode 100644 index 000000000..404f1bf9c --- /dev/null +++ b/modules/programs/mise.nix @@ -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 + 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 + 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 + ''; + }; + }; +} diff --git a/modules/programs/rtx.nix b/modules/programs/rtx.nix deleted file mode 100644 index 5fa9b5631..000000000 --- a/modules/programs/rtx.nix +++ /dev/null @@ -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 - 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 - ''; - }; - }; -} diff --git a/tests/default.nix b/tests/default.nix index b9874d8b5..17e78d914 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -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 diff --git a/tests/modules/programs/mise/bash-integration.nix b/tests/modules/programs/mise/bash-integration.nix new file mode 100644 index 000000000..552db2ffa --- /dev/null +++ b/tests/modules/programs/mise/bash-integration.nix @@ -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)"' + ''; +} + diff --git a/tests/modules/programs/mise/custom-settings.nix b/tests/modules/programs/mise/custom-settings.nix new file mode 100644 index 000000000..8f99e790a --- /dev/null +++ b/tests/modules/programs/mise/custom-settings.nix @@ -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 + '' + } + ''; +} diff --git a/tests/modules/programs/mise/default-settings.nix b/tests/modules/programs/mise/default-settings.nix new file mode 100644 index 000000000..de59e6297 --- /dev/null +++ b/tests/modules/programs/mise/default-settings.nix @@ -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 + ''; + }; +} diff --git a/tests/modules/programs/mise/default.nix b/tests/modules/programs/mise/default.nix new file mode 100644 index 000000000..511082a12 --- /dev/null +++ b/tests/modules/programs/mise/default.nix @@ -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; +} diff --git a/tests/modules/programs/rtx/fish-integration.nix b/tests/modules/programs/mise/fish-integration.nix similarity index 63% rename from tests/modules/programs/rtx/fish-integration.nix rename to tests/modules/programs/mise/fish-integration.nix index edc752bd2..cb5891931 100644 --- a/tests/modules/programs/rtx/fish-integration.nix +++ b/tests/modules/programs/mise/fish-integration.nix @@ -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' ''; } diff --git a/tests/modules/programs/mise/zsh-integration.nix b/tests/modules/programs/mise/zsh-integration.nix new file mode 100644 index 000000000..d9b2cdd90 --- /dev/null +++ b/tests/modules/programs/mise/zsh-integration.nix @@ -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)"' + ''; +} + diff --git a/tests/modules/programs/rtx/bash-integration.nix b/tests/modules/programs/rtx/bash-integration.nix deleted file mode 100644 index 3c05c25cb..000000000 --- a/tests/modules/programs/rtx/bash-integration.nix +++ /dev/null @@ -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)"' - ''; -} - diff --git a/tests/modules/programs/rtx/custom-settings.nix b/tests/modules/programs/rtx/custom-settings.nix deleted file mode 100644 index 74c52f943..000000000 --- a/tests/modules/programs/rtx/custom-settings.nix +++ /dev/null @@ -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"] - '' - } - ''; -} diff --git a/tests/modules/programs/rtx/default-settings.nix b/tests/modules/programs/rtx/default-settings.nix deleted file mode 100644 index c1a0e7ae5..000000000 --- a/tests/modules/programs/rtx/default-settings.nix +++ /dev/null @@ -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 - ''; - }; -} diff --git a/tests/modules/programs/rtx/default.nix b/tests/modules/programs/rtx/default.nix deleted file mode 100644 index 250b5ec6f..000000000 --- a/tests/modules/programs/rtx/default.nix +++ /dev/null @@ -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; -} diff --git a/tests/modules/programs/rtx/zsh-integration.nix b/tests/modules/programs/rtx/zsh-integration.nix deleted file mode 100644 index fcff308d0..000000000 --- a/tests/modules/programs/rtx/zsh-integration.nix +++ /dev/null @@ -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)"' - ''; -} -