From fe282930f4ae23b47b2cfd4217afe082169511c5 Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Sat, 19 Apr 2025 12:08:38 +0300 Subject: [PATCH 1/8] rustup: remove `with lib;` --- pkgs/development/tools/rust/rustup/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/tools/rust/rustup/default.nix b/pkgs/development/tools/rust/rustup/default.nix index 649497629329..b18c1144a608 100644 --- a/pkgs/development/tools/rust/rustup/default.nix +++ b/pkgs/development/tools/rust/rustup/default.nix @@ -139,13 +139,15 @@ rustPlatform.buildRustPackage rec { hardening_unsupported_flags = ""; }; - meta = with lib; { + meta = { description = "Rust toolchain installer"; homepage = "https://www.rustup.rs/"; - license = with licenses; [ + license = with lib.licenses; [ asl20 # or mit ]; - maintainers = [ maintainers.mic92 ]; + maintainers = with lib.maintainers; [ + mic92 + ]; }; } From d3d46e19967bd3151db680489d6120c701123987 Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Sat, 19 Apr 2025 12:11:57 +0300 Subject: [PATCH 2/8] rustup: use `tag` and `hash` in the fetcher --- pkgs/development/tools/rust/rustup/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/rust/rustup/default.nix b/pkgs/development/tools/rust/rustup/default.nix index b18c1144a608..f988fe25a84e 100644 --- a/pkgs/development/tools/rust/rustup/default.nix +++ b/pkgs/development/tools/rust/rustup/default.nix @@ -29,8 +29,8 @@ rustPlatform.buildRustPackage rec { src = fetchFromGitHub { owner = "rust-lang"; repo = "rustup"; - rev = version; - sha256 = "sha256-BehkJTEIbZHaM+ABaWN/grl9pX75lPqyBj1q1Kt273M="; + tag = version; + hash = "sha256-BehkJTEIbZHaM+ABaWN/grl9pX75lPqyBj1q1Kt273M="; }; useFetchCargoVendor = true; From ded7bd6eec578aefff82593dea3f11f716b76e5b Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Sat, 19 Apr 2025 12:22:15 +0300 Subject: [PATCH 3/8] rustup: replace `rec` with `finalAttrs` --- pkgs/development/tools/rust/rustup/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/tools/rust/rustup/default.nix b/pkgs/development/tools/rust/rustup/default.nix index f988fe25a84e..9990e931b02b 100644 --- a/pkgs/development/tools/rust/rustup/default.nix +++ b/pkgs/development/tools/rust/rustup/default.nix @@ -22,14 +22,14 @@ let ]; in -rustPlatform.buildRustPackage rec { +rustPlatform.buildRustPackage (finalAttrs: { pname = "rustup"; version = "1.27.1"; src = fetchFromGitHub { owner = "rust-lang"; repo = "rustup"; - tag = version; + tag = finalAttrs.version; hash = "sha256-BehkJTEIbZHaM+ABaWN/grl9pX75lPqyBj1q1Kt273M="; }; @@ -128,7 +128,7 @@ rustPlatform.buildRustPackage rec { chmod +x $out/nix-support/ld-wrapper.sh ''; - env = lib.optionalAttrs (pname == "rustup") { + env = lib.optionalAttrs (finalAttrs.pname == "rustup") { inherit (stdenv.cc.bintools) expandResponseParams shell @@ -150,4 +150,4 @@ rustPlatform.buildRustPackage rec { mic92 ]; }; -} +}) From 5562972b27f7f8b45e34ddf5e636c62bfdafc438 Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Sat, 19 Apr 2025 12:26:46 +0300 Subject: [PATCH 4/8] rustup: remove unused override, use both curl and openssl - the override did nothing to curl - openssl was implicitly linked against (due to being in curl's pkgconfig file) - and I put openssl before curl, so only it could be overridden --- pkgs/development/tools/rust/rustup/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/tools/rust/rustup/default.nix b/pkgs/development/tools/rust/rustup/default.nix index 9990e931b02b..0ed4ba8d8c63 100644 --- a/pkgs/development/tools/rust/rustup/default.nix +++ b/pkgs/development/tools/rust/rustup/default.nix @@ -43,7 +43,8 @@ rustPlatform.buildRustPackage (finalAttrs: { buildInputs = [ - (curl.override { inherit openssl; }) + openssl + curl zlib ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ From bbad8bd32cca452db6c91829520b61691e363def Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Sat, 19 Apr 2025 12:45:48 +0300 Subject: [PATCH 5/8] rustup: allow generating completions in cross-building --- .../development/tools/rust/rustup/default.nix | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/pkgs/development/tools/rust/rustup/default.nix b/pkgs/development/tools/rust/rustup/default.nix index 0ed4ba8d8c63..022c78799cdb 100644 --- a/pkgs/development/tools/rust/rustup/default.nix +++ b/pkgs/development/tools/rust/rustup/default.nix @@ -9,11 +9,13 @@ pkg-config, openssl, curl, + installShellFiles, zlib, Security, CoreServices, libiconv, xz, + buildPackages, }: let @@ -39,6 +41,7 @@ rustPlatform.buildRustPackage (finalAttrs: { nativeBuildInputs = [ makeBinaryWrapper pkg-config + installShellFiles ]; buildInputs = @@ -107,15 +110,24 @@ rustPlatform.buildRustPackage (finalAttrs: { export HOME=$(mktemp -d) mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions} - # generate completion scripts for rustup - $out/bin/rustup completions bash rustup > "$out/share/bash-completion/completions/rustup" - $out/bin/rustup completions fish rustup > "$out/share/fish/vendor_completions.d/rustup.fish" - $out/bin/rustup completions zsh rustup > "$out/share/zsh/site-functions/_rustup" + ${lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ( + let + emulator = stdenv.hostPlatform.emulator buildPackages; + in + '' + # generate completion scripts for rustup + installShellCompletion --cmd rustup \ + --bash <(${emulator} $out/bin/rustup completions bash rustup) \ + --fish <(${emulator} $out/bin/rustup completions fish rustup) \ + --zsh <(${emulator} $out/bin/rustup completions zsh rustup) - # generate completion scripts for cargo - # Note: fish completion script is not supported. - $out/bin/rustup completions bash cargo > "$out/share/bash-completion/completions/cargo" - $out/bin/rustup completions zsh cargo > "$out/share/zsh/site-functions/_cargo" + # generate completion scripts for cargo + # Note: fish completion script is not supported. + installShellCompletion --cmd cargo \ + --bash <(${emulator} $out/bin/rustup completions bash cargo) \ + --zsh <(${emulator} $out/bin/rustup completions zsh cargo) + '' + )} # add a wrapper script for ld.lld mkdir -p $out/nix-support From 8201236c73b26eefbea2e820549ceb540c3fc647 Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Sat, 19 Apr 2025 12:50:56 +0300 Subject: [PATCH 6/8] rustup: use `writableTmpDirAsHomeHook` --- pkgs/development/tools/rust/rustup/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/tools/rust/rustup/default.nix b/pkgs/development/tools/rust/rustup/default.nix index 022c78799cdb..47486900ff96 100644 --- a/pkgs/development/tools/rust/rustup/default.nix +++ b/pkgs/development/tools/rust/rustup/default.nix @@ -9,6 +9,7 @@ pkg-config, openssl, curl, + writableTmpDirAsHomeHook, installShellFiles, zlib, Security, @@ -41,6 +42,7 @@ rustPlatform.buildRustPackage (finalAttrs: { nativeBuildInputs = [ makeBinaryWrapper pkg-config + writableTmpDirAsHomeHook installShellFiles ]; @@ -107,7 +109,6 @@ rustPlatform.buildRustPackage (finalAttrs: { wrapProgram $out/bin/rustup --prefix "LD_LIBRARY_PATH" : "${libPath}" # tries to create .rustup - export HOME=$(mktemp -d) mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions} ${lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ( From 3de1a5cf5908a37b3ad4af8e177b6a83c772b0ba Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Sat, 19 Apr 2025 14:53:24 +0300 Subject: [PATCH 7/8] rustup: remove unnecessary conditions for some envvars --- pkgs/development/tools/rust/rustup/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/tools/rust/rustup/default.nix b/pkgs/development/tools/rust/rustup/default.nix index 47486900ff96..3d33a608dac3 100644 --- a/pkgs/development/tools/rust/rustup/default.nix +++ b/pkgs/development/tools/rust/rustup/default.nix @@ -142,7 +142,7 @@ rustPlatform.buildRustPackage (finalAttrs: { chmod +x $out/nix-support/ld-wrapper.sh ''; - env = lib.optionalAttrs (finalAttrs.pname == "rustup") { + env = { inherit (stdenv.cc.bintools) expandResponseParams shell From c244ac2560dda2572370adf5cdaea74d93a718cd Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Sun, 20 Apr 2025 11:31:12 +0300 Subject: [PATCH 8/8] rustup: set `meta.mainProgram = "rustup"` --- pkgs/development/tools/rust/rustup/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/tools/rust/rustup/default.nix b/pkgs/development/tools/rust/rustup/default.nix index 3d33a608dac3..089a4a728c24 100644 --- a/pkgs/development/tools/rust/rustup/default.nix +++ b/pkgs/development/tools/rust/rustup/default.nix @@ -163,5 +163,6 @@ rustPlatform.buildRustPackage (finalAttrs: { maintainers = with lib.maintainers; [ mic92 ]; + mainProgram = "rustup"; }; })