fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
2.0 KiB79 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6  cfg = config.programs.rtx;
7  tomlFormat = pkgs.formats.toml { };
8in {
9  meta.maintainers = [ hm.maintainers.pedorich-n ];
10
11  options = {
12    programs.rtx = {
13      enable = mkEnableOption "RTX. Runtime Executor (asdf Rust clone)";
14
15      package = mkPackageOption pkgs "rtx" { };
16
17      enableBashIntegration = mkEnableOption "Bash Integration" // {
18        default = true;
19      };
20
21      enableZshIntegration = mkEnableOption "Zsh Integration" // {
22        default = true;
23      };
24
25      enableFishIntegration = mkEnableOption "Fish Integration" // {
26        default = true;
27      };
28
29      settings = mkOption {
30        type = tomlFormat.type;
31        default = { };
32        example = literalExpression ''
33          tools = {
34            node = "lts";
35            python = ["3.10" "3.11"];
36          };
37
38          settings = {
39            verbose = false;
40            experimental = false;
41          };
42        '';
43        description = ''
44          Settings written to {file}`$XDG_CONFIG_HOME/rtx/config.toml`.
45
46          See <https://github.com/jdxcode/rtx#global-config-configrtxconfigtoml>
47          for details on supported values.
48
49          ::: {.warning}
50          Modifying the `tools` section doesn't make RTX install them.
51          You have to manually run `rtx install` to install the tools.
52          :::
53        '';
54      };
55    };
56  };
57
58  config = mkIf cfg.enable {
59    home.packages = [ cfg.package ];
60
61    xdg.configFile."rtx/config.toml" = mkIf (cfg.settings != { }) {
62      source = tomlFormat.generate "rtx-settings" cfg.settings;
63    };
64
65    programs = {
66      bash.initExtra = mkIf cfg.enableBashIntegration ''
67        eval "$(${getExe cfg.package} activate bash)"
68      '';
69
70      zsh.initExtra = mkIf cfg.enableZshIntegration ''
71        eval "$(${getExe cfg.package} activate zsh)"
72      '';
73
74      fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
75        ${getExe cfg.package} activate fish | source
76      '';
77    };
78  };
79}