1{ lib
2, nix-update-script
3, rustPlatform
4, fetchFromGitHub
5, installShellFiles
6, stdenv
7, coreutils
8, bash
9, pkg-config
10, openssl
11, direnv
12, Security
13, SystemConfiguration
14}:
15
16rustPlatform.buildRustPackage rec {
17 pname = "rtx";
18 version = "2023.11.2";
19
20 src = fetchFromGitHub {
21 owner = "jdxcode";
22 repo = "rtx";
23 rev = "v${version}";
24 hash = "sha256-OdqHyxqufJJTfP7frjLKf5R0WNySDyZc7Sh0Mpdord0=";
25 };
26
27 cargoHash = "sha256-KOte3zmJllrMp6OaKuFtUsRjdRKlSAxdJp1iJEOPcF0=";
28
29 nativeBuildInputs = [ installShellFiles pkg-config ];
30 buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [ Security SystemConfiguration ];
31
32 postPatch = ''
33 patchShebangs --build ./test/data/plugins/**/bin/* ./src/fake_asdf.rs ./src/cli/reshim.rs
34
35 substituteInPlace ./src/env_diff.rs \
36 --replace '"bash"' '"${bash}/bin/bash"'
37
38 substituteInPlace ./src/cli/direnv/exec.rs \
39 --replace '"env"' '"${coreutils}/bin/env"' \
40 --replace 'cmd!("direnv"' 'cmd!("${direnv}/bin/direnv"'
41 '';
42
43 checkFlags = [
44 # Requires .git directory to be present
45 "--skip=cli::plugins::ls::tests::test_plugin_list_urls"
46 ];
47 cargoTestFlags = [ "--all-features" ];
48 # some tests access the same folders, don't test in parallel to avoid race conditions
49 dontUseCargoParallelTests = true;
50
51 postInstall = ''
52 installManPage ./man/man1/rtx.1
53
54 installShellCompletion \
55 --bash ./completions/rtx.bash \
56 --fish ./completions/rtx.fish \
57 --zsh ./completions/_rtx
58 '';
59
60 passthru = {
61 updateScript = nix-update-script { };
62 };
63
64 meta = {
65 homepage = "https://github.com/jdxcode/rtx";
66 description = "Polyglot runtime manager (asdf rust clone)";
67 changelog = "https://github.com/jdxcode/rtx/releases/tag/v${version}";
68 license = lib.licenses.mit;
69 maintainers = with lib.maintainers; [ konradmalik ];
70 mainProgram = "rtx";
71 };
72}