4f0dadbf38
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
--argstr baseRev b32a094368
result/bin/apply-formatting $NIXPKGS_PATH
151 lines
4.2 KiB
Nix
151 lines
4.2 KiB
Nix
{
|
|
stdenv,
|
|
lib,
|
|
runCommand,
|
|
patchelf,
|
|
fetchFromGitHub,
|
|
rustPlatform,
|
|
makeBinaryWrapper,
|
|
pkg-config,
|
|
openssl,
|
|
curl,
|
|
zlib,
|
|
Security,
|
|
CoreServices,
|
|
libiconv,
|
|
xz,
|
|
}:
|
|
|
|
let
|
|
libPath = lib.makeLibraryPath [
|
|
zlib # libz.so.1
|
|
];
|
|
in
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
pname = "rustup";
|
|
version = "1.27.1";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "rust-lang";
|
|
repo = "rustup";
|
|
rev = version;
|
|
sha256 = "sha256-BehkJTEIbZHaM+ABaWN/grl9pX75lPqyBj1q1Kt273M=";
|
|
};
|
|
|
|
cargoHash = "sha256-iQoMPV97V9WJqT+qVtNpQtW5g+Jyl+U2uA+JEoRYTQA=";
|
|
|
|
nativeBuildInputs = [
|
|
makeBinaryWrapper
|
|
pkg-config
|
|
];
|
|
|
|
buildInputs =
|
|
[
|
|
(curl.override { inherit openssl; })
|
|
zlib
|
|
]
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
CoreServices
|
|
Security
|
|
libiconv
|
|
xz
|
|
];
|
|
|
|
buildFeatures = [ "no-self-update" ];
|
|
|
|
checkFeatures = [ "test" ];
|
|
|
|
patches = lib.optionals stdenv.hostPlatform.isLinux [
|
|
(runCommand "0001-dynamically-patchelf-binaries.patch"
|
|
{
|
|
CC = stdenv.cc;
|
|
patchelf = patchelf;
|
|
libPath = "${libPath}";
|
|
}
|
|
''
|
|
export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
|
|
substitute ${./0001-dynamically-patchelf-binaries.patch} $out \
|
|
--subst-var patchelf \
|
|
--subst-var dynamicLinker \
|
|
--subst-var libPath
|
|
''
|
|
)
|
|
];
|
|
|
|
# Random tests fail nondeterministically on macOS.
|
|
# TODO: Investigate this.
|
|
doCheck = !stdenv.hostPlatform.isDarwin;
|
|
|
|
# skip failing tests
|
|
checkFlags = [
|
|
# auto-self-update mode is set to 'disable' for nix rustup
|
|
"--skip=suite::cli_exact::check_updates_none"
|
|
"--skip=suite::cli_exact::check_updates_some"
|
|
"--skip=suite::cli_exact::check_updates_with_update"
|
|
# rustup-init is not used in nix rustup
|
|
"--skip=suite::cli_ui::rustup_init_ui_doc_text_tests"
|
|
];
|
|
|
|
postInstall = ''
|
|
pushd $out/bin
|
|
mv rustup-init rustup
|
|
binlinks=(
|
|
cargo rustc rustdoc rust-gdb rust-lldb rls rustfmt cargo-fmt
|
|
cargo-clippy clippy-driver cargo-miri rust-gdbgui rust-analyzer
|
|
)
|
|
for link in ''${binlinks[@]}; do
|
|
ln -s rustup $link
|
|
done
|
|
popd
|
|
|
|
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}
|
|
|
|
# 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"
|
|
|
|
# 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"
|
|
|
|
# add a wrapper script for ld.lld
|
|
mkdir -p $out/nix-support
|
|
substituteAll ${../../../../../pkgs/build-support/wrapper-common/utils.bash} $out/nix-support/utils.bash
|
|
substituteAll ${../../../../../pkgs/build-support/wrapper-common/darwin-sdk-setup.bash} $out/nix-support/darwin-sdk-setup.bash
|
|
substituteAll ${../../../../../pkgs/build-support/bintools-wrapper/add-flags.sh} $out/nix-support/add-flags.sh
|
|
substituteAll ${../../../../../pkgs/build-support/bintools-wrapper/add-hardening.sh} $out/nix-support/add-hardening.sh
|
|
export prog='$PROG'
|
|
export use_response_file_by_default=0
|
|
substituteAll ${../../../../../pkgs/build-support/bintools-wrapper/ld-wrapper.sh} $out/nix-support/ld-wrapper.sh
|
|
chmod +x $out/nix-support/ld-wrapper.sh
|
|
'';
|
|
|
|
env = lib.optionalAttrs (pname == "rustup") {
|
|
inherit (stdenv.cc.bintools)
|
|
expandResponseParams
|
|
shell
|
|
suffixSalt
|
|
wrapperName
|
|
coreutils_bin
|
|
;
|
|
hardening_unsupported_flags = "";
|
|
};
|
|
|
|
meta = with lib; {
|
|
description = "Rust toolchain installer";
|
|
homepage = "https://www.rustup.rs/";
|
|
license = with licenses; [
|
|
asl20 # or
|
|
mit
|
|
];
|
|
maintainers = [ maintainers.mic92 ];
|
|
};
|
|
}
|