Merge pull request #46362 from symphorien/non-broken-fetchcargo
Non broken fetchcargo
This commit is contained in:
commit
8a94866817
|
@ -1,6 +1,6 @@
|
||||||
{ stdenv,
|
{ stdenv,
|
||||||
lib,
|
lib,
|
||||||
fetchgit,
|
fetchFromGitHub,
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
cmake,
|
cmake,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
|
@ -51,18 +51,16 @@ let
|
||||||
];
|
];
|
||||||
in buildRustPackage rec {
|
in buildRustPackage rec {
|
||||||
name = "alacritty-unstable-${version}";
|
name = "alacritty-unstable-${version}";
|
||||||
version = "2018-08-30";
|
version = "2018-08-05";
|
||||||
|
|
||||||
# At the moment we cannot handle git dependencies in buildRustPackage.
|
src = fetchFromGitHub {
|
||||||
# This fork only replaces rust-fontconfig/libfontconfig with a git submodules.
|
owner = "jwilm";
|
||||||
src = fetchgit {
|
repo = "alacritty";
|
||||||
url = https://github.com/Mic92/alacritty.git;
|
rev = "1adb5cb7fc05054197aa08e0d1fa957df94888ab";
|
||||||
rev = "rev-${version}";
|
sha256 = "06rc7dy1vn59lc5hjh953h9lh0f39c0n0jmrz472mrya722fl2ab";
|
||||||
sha256 = "0izvg7dwwb763jc6gnmn47i5zrkxvmh3vssn6vzrrmqhd4j3msmf";
|
|
||||||
fetchSubmodules = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
cargoSha256 = "1ijgkwv9ij4haig1h6n2b9xbhp5vahy9vp1sx72wxaaj9476msjx";
|
cargoSha256 = "0ms0248bb2lgbzcqks6i0qhn1gaiim3jf1kl17qw52c8an3rc652";
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
cmake
|
cmake
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import toml
|
||||||
|
|
||||||
|
|
||||||
|
def quote(s: str) -> str:
|
||||||
|
escaped = s.replace('"', r"\"").replace("\n", r"\n").replace("\\", "\\\\")
|
||||||
|
return '"{}"'.format(escaped)
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
data = toml.load(sys.stdin)
|
||||||
|
|
||||||
|
assert list(data.keys()) == ["source"]
|
||||||
|
|
||||||
|
# this value is non deterministic
|
||||||
|
data["source"]["vendored-sources"]["directory"] = "@vendor@"
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
inner = data["source"]
|
||||||
|
for source, attrs in sorted(inner.items()):
|
||||||
|
lines.append("[source.{}]".format(quote(source)))
|
||||||
|
if source == "vendored-sources":
|
||||||
|
lines.append('"directory" = "@vendor@"\n')
|
||||||
|
else:
|
||||||
|
for key, value in sorted(attrs.items()):
|
||||||
|
attr = "{} = {}".format(quote(key), quote(value))
|
||||||
|
lines.append(attr)
|
||||||
|
lines.append("")
|
||||||
|
|
||||||
|
result = "\n".join(lines)
|
||||||
|
real = toml.loads(result)
|
||||||
|
assert real == data, "output = {} while input = {}".format(real, data)
|
||||||
|
|
||||||
|
print(result)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
|
@ -1,7 +1,7 @@
|
||||||
{ stdenv, cacert, git, rust, cargo-vendor }:
|
{ stdenv, cacert, git, rust, cargo-vendor, python3 }:
|
||||||
let
|
let
|
||||||
fetchcargo = import ./fetchcargo.nix {
|
fetchcargo = import ./fetchcargo.nix {
|
||||||
inherit stdenv cacert git rust cargo-vendor;
|
inherit stdenv cacert git rust cargo-vendor python3;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{ name, cargoSha256 ? "unset"
|
{ name, cargoSha256 ? "unset"
|
||||||
|
@ -61,14 +61,12 @@ in stdenv.mkDerivation (args // {
|
||||||
${setupVendorDir}
|
${setupVendorDir}
|
||||||
|
|
||||||
mkdir .cargo
|
mkdir .cargo
|
||||||
cat >.cargo/config <<-EOF
|
config="$(pwd)/$cargoDepsCopy/.cargo/config";
|
||||||
[source.crates-io]
|
if [[ ! -e $config ]]; then
|
||||||
registry = 'https://github.com/rust-lang/crates.io-index'
|
config=${./fetchcargo-default-config.toml};
|
||||||
replace-with = 'vendored-sources'
|
fi;
|
||||||
|
substitute $config .cargo/config \
|
||||||
[source.vendored-sources]
|
--subst-var-by vendor "$(pwd)/$cargoDepsCopy"
|
||||||
directory = '$(pwd)/$cargoDepsCopy'
|
|
||||||
EOF
|
|
||||||
|
|
||||||
unset cargoDepsCopy
|
unset cargoDepsCopy
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
[source."crates-io"]
|
||||||
|
"replace-with" = "vendored-sources"
|
||||||
|
|
||||||
|
[source."vendored-sources"]
|
||||||
|
"directory" = "@vendor@"
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,26 @@
|
||||||
{ stdenv, cacert, git, rust, cargo-vendor }:
|
{ stdenv, cacert, git, rust, cargo-vendor, python3 }:
|
||||||
|
let cargo-vendor-normalise = stdenv.mkDerivation {
|
||||||
|
name = "cargo-vendor-normalise";
|
||||||
|
src = ./cargo-vendor-normalise.py;
|
||||||
|
nativeBuildInputs = [ python3.pkgs.wrapPython ];
|
||||||
|
unpackPhase = ":";
|
||||||
|
installPhase = "install -D $src $out/bin/cargo-vendor-normalise";
|
||||||
|
pythonPath = [ python3.pkgs.toml ];
|
||||||
|
postFixup = "wrapPythonPrograms";
|
||||||
|
doInstallCheck = true;
|
||||||
|
installCheckPhase = ''
|
||||||
|
# check that ./fetchcargo-default-config.toml is a fix point
|
||||||
|
reference=${./fetchcargo-default-config.toml}
|
||||||
|
< $reference $out/bin/cargo-vendor-normalise > test;
|
||||||
|
cmp test $reference
|
||||||
|
'';
|
||||||
|
preferLocalBuild = true;
|
||||||
|
};
|
||||||
|
in
|
||||||
{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "" }:
|
{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "" }:
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "${name}-vendor";
|
name = "${name}-vendor";
|
||||||
nativeBuildInputs = [ cacert cargo-vendor git rust.cargo ];
|
nativeBuildInputs = [ cacert cargo-vendor git cargo-vendor-normalise rust.cargo ];
|
||||||
inherit src srcs patches sourceRoot;
|
inherit src srcs patches sourceRoot;
|
||||||
|
|
||||||
phases = "unpackPhase patchPhase installPhase";
|
phases = "unpackPhase patchPhase installPhase";
|
||||||
|
@ -23,9 +41,16 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
${cargoUpdateHook}
|
${cargoUpdateHook}
|
||||||
|
|
||||||
cargo vendor
|
mkdir -p $out
|
||||||
|
cargo vendor $out | cargo-vendor-normalise > config
|
||||||
cp -ar vendor $out
|
# fetchcargo used to never keep the config output by cargo vendor
|
||||||
|
# and instead hardcode the config in ./fetchcargo-default-config.toml.
|
||||||
|
# This broke on packages needing git dependencies, so now we keep the config.
|
||||||
|
# But not to break old cargoSha256, if the previous behavior was enough,
|
||||||
|
# we don't store the config.
|
||||||
|
if ! cmp config ${./fetchcargo-default-config.toml} > /dev/null; then
|
||||||
|
install -Dt $out/.cargo config;
|
||||||
|
fi;
|
||||||
'';
|
'';
|
||||||
|
|
||||||
outputHashAlgo = "sha256";
|
outputHashAlgo = "sha256";
|
||||||
|
|
Loading…
Reference in New Issue