diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index 7138c5b30..649d73e1f 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -1047,6 +1047,14 @@ in
A new module is available: 'programs.ripgrep'.
'';
}
+
+ {
+ time = "2023-06-07T06:01:16+00:00";
+ message = ''
+ A new module is available: 'programs.rtx'.
+ '';
+ }
+
];
};
}
diff --git a/modules/modules.nix b/modules/modules.nix
index b79ca19a7..78c41a301 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -167,6 +167,7 @@ let
./programs/rofi-pass.nix
./programs/rofi.nix
./programs/rtorrent.nix
+ ./programs/rtx.nix
./programs/sagemath.nix
./programs/sbt.nix
./programs/scmpuff.nix
diff --git a/modules/programs/rtx.nix b/modules/programs/rtx.nix
new file mode 100644
index 000000000..bb1053335
--- /dev/null
+++ b/modules/programs/rtx.nix
@@ -0,0 +1,81 @@
+{ 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 $XDG_CONFIG_HOME/rtx/config.toml.
+
+ See
+ for details on supported values.
+
+
+
+ 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 c9a7d7458..c68856b92 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -116,6 +116,7 @@ import nmt {
./modules/programs/qutebrowser
./modules/programs/readline
./modules/programs/ripgrep
+ ./modules/programs/rtx
./modules/programs/sagemath
./modules/programs/sbt
./modules/programs/scmpuff
diff --git a/tests/modules/programs/rtx/bash-integration.nix b/tests/modules/programs/rtx/bash-integration.nix
new file mode 100644
index 000000000..3c05c25cb
--- /dev/null
+++ b/tests/modules/programs/rtx/bash-integration.nix
@@ -0,0 +1,16 @@
+{ 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
new file mode 100644
index 000000000..74c52f943
--- /dev/null
+++ b/tests/modules/programs/rtx/custom-settings.nix
@@ -0,0 +1,35 @@
+{ 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
new file mode 100644
index 000000000..c1a0e7ae5
--- /dev/null
+++ b/tests/modules/programs/rtx/default-settings.nix
@@ -0,0 +1,12 @@
+{ 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
new file mode 100644
index 000000000..250b5ec6f
--- /dev/null
+++ b/tests/modules/programs/rtx/default.nix
@@ -0,0 +1,7 @@
+{
+ 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/fish-integration.nix b/tests/modules/programs/rtx/fish-integration.nix
new file mode 100644
index 000000000..edc752bd2
--- /dev/null
+++ b/tests/modules/programs/rtx/fish-integration.nix
@@ -0,0 +1,16 @@
+{ config, ... }: {
+ programs = {
+ rtx = {
+ package = config.lib.test.mkStubPackage { name = "rtx"; };
+ enable = true;
+ enableFishIntegration = true;
+ };
+
+ fish.enable = true;
+ };
+
+ nmt.script = ''
+ assertFileRegex home-files/.config/fish/config.fish '/nix/store/.*rtx.*/bin/rtx activate fish | source'
+ '';
+}
+
diff --git a/tests/modules/programs/rtx/zsh-integration.nix b/tests/modules/programs/rtx/zsh-integration.nix
new file mode 100644
index 000000000..fcff308d0
--- /dev/null
+++ b/tests/modules/programs/rtx/zsh-integration.nix
@@ -0,0 +1,16 @@
+{ 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)"'
+ '';
+}
+