Patch clippy-driver

This commit is contained in:
oxalica 2021-04-17 01:18:51 +08:00
parent 22e1be7777
commit dab9470d41
No known key found for this signature in database
GPG Key ID: CED392DE0C483D00

View File

@ -175,7 +175,7 @@ let
in in
map (tuple: { name = tuple.name; src = (getFetchUrl pkgs tuple.name tuple.target stdenv fetchurl); }) pkgsTuplesToInstall; map (tuple: { name = tuple.name; src = (getFetchUrl pkgs tuple.name tuple.target stdenv fetchurl); }) pkgsTuplesToInstall;
mkComponent = { pname, version, src }: mkComponent = { pname, version, src, rustc /* clippy depends on rustc */ }:
self.stdenv.mkDerivation { self.stdenv.mkDerivation {
inherit pname version src; inherit pname version src;
@ -227,6 +227,12 @@ let
done < <(find "$dir" -type f -print0) done < <(find "$dir" -type f -print0)
} }
setInterpreter $out setInterpreter $out
'' + super.lib.optionalString (pname == "clippy-preview") ''
if [[ -e "$out/bin/clippy-driver" ]]; then
patchelf \
--set-rpath "${rustc}/lib:${super.lib.makeLibraryPath [ self.zlib ]}:$out/lib" \
"$out/bin/clippy-driver" || true
fi
''; '';
postFixup = '' postFixup = ''
@ -395,6 +401,9 @@ let
pname = name; pname = name;
inherit (manifest) version; inherit (manifest) version;
inherit src; inherit src;
# The component name is `rust`.
# clippy-driver will be patched to $out/lib without touching this.
rustc = null;
})) namesAndSrcs; })) namesAndSrcs;
} }
) { ) {
@ -415,6 +424,8 @@ let
sha256 = xz_hash; sha256 = xz_hash;
fetchurl = self.fetchurl; fetchurl = self.fetchurl;
}; };
rustc = componentSet.rustc.${target} or
(throw "clippy depends on rustc, which is not available");
} }
) pkg.target ) pkg.target
) (removeAttrs manifest.pkg ["rust"]) // ) (removeAttrs manifest.pkg ["rust"]) //
@ -490,7 +501,7 @@ let
target ? super.rust.toRustTarget self.stdenv.targetPlatform target ? super.rust.toRustTarget self.stdenv.targetPlatform
}: let }: let
shortRev = builtins.substring 0 7 rev; shortRev = builtins.substring 0 7 rev;
components' = super.lib.mapAttrsToList (compName: hash: mkComponent { components' = super.lib.mapAttrs (compName: hash: mkComponent {
pname = compName; pname = compName;
version = shortRev; version = shortRev;
src = self.fetchurl { src = self.fetchurl {
@ -499,12 +510,13 @@ let
else "https://ci-artifacts.rust-lang.org/rustc-builds/${rev}/${compName}-nightly-${target}.tar.xz"; else "https://ci-artifacts.rust-lang.org/rustc-builds/${rev}/${compName}-nightly-${target}.tar.xz";
inherit hash; inherit hash;
}; };
rustc = components'.rustc or (throw "rustc is required for clippy");
}) components; }) components;
in in
aggregateComponents { aggregateComponents {
inherit pname; inherit pname;
version = shortRev; version = shortRev;
components = components'; components = builtins.attrValues components';
}; };
in { in {