mirror of
https://github.com/Noratrieb/nixos.git
synced 2026-01-14 19:55:08 +01:00
cargo-bisect-rustc
This commit is contained in:
parent
e9e1711063
commit
b6ef4f0ddf
4 changed files with 124 additions and 1 deletions
71
custom-pkgs/cargo-bisect-rustc/0001-patchelf.patch
Normal file
71
custom-pkgs/cargo-bisect-rustc/0001-patchelf.patch
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
diff --git a/src/toolchains.rs b/src/toolchains.rs
|
||||||
|
index 16e68a0..5ce1c50 100644
|
||||||
|
--- a/src/toolchains.rs
|
||||||
|
+++ b/src/toolchains.rs
|
||||||
|
@@ -34,6 +34,8 @@ pub(crate) enum InstallError {
|
||||||
|
TempDir(#[source] io::Error),
|
||||||
|
#[error("Could not move tempdir into destination: {0}")]
|
||||||
|
Move(#[source] io::Error),
|
||||||
|
+ #[error("Could not patchelf")]
|
||||||
|
+ Patchelf(#[source] io::Error),
|
||||||
|
#[error("Could not run subcommand {cmd}: {err}")]
|
||||||
|
Subcommand {
|
||||||
|
cmd: String,
|
||||||
|
@@ -208,7 +210,9 @@ impl Toolchain {
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
- fs::rename(tmpdir.into_path(), dest).map_err(InstallError::Move)
|
||||||
|
+ fs::rename(tmpdir.into_path(), &dest).map_err(InstallError::Move)?;
|
||||||
|
+ nix_patchelf(dest).map_err(InstallError::Patchelf)?;
|
||||||
|
+ Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn remove(&self, dl_params: &DownloadParams) -> io::Result<()> {
|
||||||
|
@@ -542,3 +546,46 @@ fn download_tarball(
|
||||||
|
res => res,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+fn nix_patchelf(mut toolchain_path: PathBuf) -> Result<(), io::Error> {
|
||||||
|
+ toolchain_path.push("bin");
|
||||||
|
+
|
||||||
|
+ for entry in toolchain_path.read_dir()? {
|
||||||
|
+ let entry = entry?;
|
||||||
|
+ if !entry.file_type()?.is_file() {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ eprintln!(
|
||||||
|
+ "info: you seem to be running NixOS. Attempting to patch {}",
|
||||||
|
+ entry.path().to_str().unwrap()
|
||||||
|
+ );
|
||||||
|
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
|
||||||
|
+ .arg("--set-interpreter")
|
||||||
|
+ .arg("@dynamicLinker@")
|
||||||
|
+ .arg(entry.path())
|
||||||
|
+ .output();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ toolchain_path.pop();
|
||||||
|
+ toolchain_path.push("lib");
|
||||||
|
+
|
||||||
|
+ for entry in toolchain_path.read_dir()? {
|
||||||
|
+ let entry = entry?;
|
||||||
|
+ if !entry.file_type()?.is_file() {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ eprintln!(
|
||||||
|
+ "info: you seem to be running NixOS. Attempting to patch {}",
|
||||||
|
+ entry.path().to_str().unwrap()
|
||||||
|
+ );
|
||||||
|
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
|
||||||
|
+ .arg("--set-rpath")
|
||||||
|
+ .arg("@libPath@")
|
||||||
|
+ .arg(entry.path())
|
||||||
|
+ .output();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ Ok(())
|
||||||
|
+}
|
||||||
45
custom-pkgs/cargo-bisect-rustc/default.nix
Normal file
45
custom-pkgs/cargo-bisect-rustc/default.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
pkgs: pkgs.rustPlatform.buildRustPackage rec {
|
||||||
|
pname = "cargo-bisect-rustc";
|
||||||
|
version = "0.6.6";
|
||||||
|
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "rust-lang";
|
||||||
|
repo = "cargo-bisect-rustc";
|
||||||
|
rev = "v${version}";
|
||||||
|
hash = "sha256-i/MZslGbv72MZmd31SQFc2QdDRigs8edyN2/T5V5r4k=";
|
||||||
|
};
|
||||||
|
|
||||||
|
cargoHash = "sha256-dnR0V2MvW4Z3jtsjXSboCRFNb22fDGu01fC40N2Deho=";
|
||||||
|
|
||||||
|
patches =
|
||||||
|
let
|
||||||
|
patchelfPatch = pkgs.runCommand "0001-patchelf.patch"
|
||||||
|
{
|
||||||
|
CC = pkgs.stdenv.cc;
|
||||||
|
patchelf = pkgs.patchelf;
|
||||||
|
libPath = "$ORIGIN/../lib:${pkgs.lib.makeLibraryPath [ pkgs.zlib ]}";
|
||||||
|
}
|
||||||
|
''
|
||||||
|
export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
|
||||||
|
substitute ${./0001-patchelf.patch} $out \
|
||||||
|
--subst-var patchelf \
|
||||||
|
--subst-var dynamicLinker \
|
||||||
|
--subst-var libPath
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
pkgs.lib.optionals pkgs.stdenv.isLinux [ patchelfPatch ];
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [ pkg-config ];
|
||||||
|
buildInputs = with pkgs; [ openssl xz ];
|
||||||
|
|
||||||
|
PKG_CONFIG_PATH = "${pkgs.openssl}/lib";
|
||||||
|
|
||||||
|
# Tests access the network.
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
meta = with pkgs.lib; {
|
||||||
|
description = "Bisects rustc, either nightlies or CI artifacts";
|
||||||
|
homepage = "https://github.com/rust-lang/cargo-bisect-rustc";
|
||||||
|
license = licenses.mit;
|
||||||
|
};
|
||||||
|
}
|
||||||
3
custom-pkgs/default.nix
Normal file
3
custom-pkgs/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
pkgs: {
|
||||||
|
cargo-bisect-rustc = import ./cargo-bisect-rustc/default.nix pkgs;
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,10 @@
|
||||||
, config
|
, config
|
||||||
, pkgs
|
, pkgs
|
||||||
, ...
|
, ...
|
||||||
}: {
|
}:
|
||||||
|
let customPkgs = import ../custom-pkgs/default.nix pkgs;
|
||||||
|
in
|
||||||
|
{
|
||||||
# You can import other home-manager modules here
|
# You can import other home-manager modules here
|
||||||
imports = [
|
imports = [
|
||||||
# If you want to use home-manager modules from other flakes (such as nix-colors):
|
# If you want to use home-manager modules from other flakes (such as nix-colors):
|
||||||
|
|
@ -65,6 +68,7 @@
|
||||||
rustup-toolchain-install-master
|
rustup-toolchain-install-master
|
||||||
inferno
|
inferno
|
||||||
gh
|
gh
|
||||||
|
customPkgs.cargo-bisect-rustc
|
||||||
];
|
];
|
||||||
|
|
||||||
# Enable home-manager and git
|
# Enable home-manager and git
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue