From b66ef28841319bf1a281bde4e97c82458839a483 Mon Sep 17 00:00:00 2001 From: Justin Humm Date: Mon, 20 Aug 2018 20:30:02 +0200 Subject: [PATCH 1/7] buildRustPackage, fetchcargo: optionally use vendor config from cargo-vendor By setting useRealVendorConfig explicitly to true, the actual (slightly modified) config generated by cargo-vendor is used. This solves a problem, where the static vendor config in pkgs/build-support/rust/default.nix would not sufficiently replace all crates Cargo is looking for. As useRealVendorConfig (and writeVendorConfig in fetchcargo) default to false, there should be no breakage in existing cargoSha256 hashes. Nethertheless, imho using this new feature should become standard. A possible deprecation path could be: - introduce this patch - set useRealVendorConfig explicitly to false whereever cargoSha256 is set but migration is not wanted yet. - after some time, let writeVendorConfig default to true - when useRealVendorConfig is true everywhere cargoSha256 is set and enough time is passed, `assert cargoVendorDir == null -> useRealVendorConfig;`, remove old behaviour - after some time, remove all appearences of useRealVendorConfig and the parameter itself --- doc/languages-frameworks/rust.section.md | 11 ++++++++- nixos/doc/manual/release-notes/rl-1809.xml | 21 +++++++++++++++++ pkgs/build-support/rust/default.nix | 26 ++++++++++++++++------ pkgs/build-support/rust/fetchcargo.nix | 10 +++++---- 4 files changed, 56 insertions(+), 12 deletions(-) diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md index 6588281878a0..737759fd8bd8 100644 --- a/doc/languages-frameworks/rust.section.md +++ b/doc/languages-frameworks/rust.section.md @@ -42,7 +42,8 @@ rustPlatform.buildRustPackage rec { sha256 = "0y5d1n6hkw85jb3rblcxqas2fp82h3nghssa4xqrhqnz25l799pj"; }; - cargoSha256 = "0q68qyl2h6i0qsz82z840myxlnjay8p1w5z7hfyr8fqp7wgwa9cx"; + cargoSha256 = "194lzn9xjkc041lmqnm676ydgbhn45xx9jhrhz6lzlg99yr6b880"; + useRealVendorConfig = true; meta = with stdenv.lib; { description = "A fast line-oriented regex search tool, similar to ag and ack"; @@ -64,6 +65,14 @@ When the `Cargo.lock`, provided by upstream, is not in sync with the added in `cargoPatches` will also be prepended to the patches in `patches` at build-time. +The `useRealVendorConfig` parameter tells cargo-vendor to include a Cargo +configuration file in the fetched dependencies. This will fix problems with +projects, where Crates are downloaded from non-crates.io sources. Please note, +that currently this parameter defaults to `false` only due to compatibility +reasons, as setting this to `true` requires a change in `cargoSha256`. +Eventually this distinction will be deprecated, so please always set +`useRealVendorConfig` to `true` and make sure to recompute the `cargoSha256`. + To install crates with nix there is also an experimental project called [nixcrates](https://github.com/fractalide/nixcrates). diff --git a/nixos/doc/manual/release-notes/rl-1809.xml b/nixos/doc/manual/release-notes/rl-1809.xml index 01421fc5dda7..dd04996925bb 100644 --- a/nixos/doc/manual/release-notes/rl-1809.xml +++ b/nixos/doc/manual/release-notes/rl-1809.xml @@ -551,6 +551,27 @@ inherit (pkgs.nixos { stdenv.buildPlatform, stdenv.hostPlatform, and stdenv.targetPlatform. + + + The buildRustPackage function got the new + argument useRealVendorConfig, currently + defaulting to false. Setting it to + true necessates the recomputation of the + cargoSha256 and fixes a problem with + dependencies, that were fetched from a non-crates.io source. + Eventually only the true behaviour will be kept, + so please set it explicitly to true and + recompute your cargoSha256, so that we can + migrate to the new behaviour and deprecate the option. + + + While recomputing cargoSha256, it is important + to first invalidate the hash (e.g. by changing a digit), so that + Nix actually rebuilds the fixed-output derivation. Otherwise this + could lead to hard to detect errors, where a package seemingly + builds on your computer, but breaks on others! + + diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 820989a76206..a2dc5df4d926 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -17,9 +17,15 @@ in , cargoBuildFlags ? [] , cargoVendorDir ? null +# This tells cargo-vendor to include a Cargo config file in the fixed-output +# derivation. This is desirable in every case, so please set it to true. +# Eventually this will default to true and even later this option and the old +# behaviour will be removed. +, useRealVendorConfig ? false , ... } @ args: assert cargoVendorDir == null -> cargoSha256 != "unset"; +assert cargoVendorDir != null -> !useRealVendorConfig; let cargoDeps = if cargoVendorDir == null @@ -27,6 +33,7 @@ let inherit name src srcs sourceRoot cargoUpdateHook; patches = cargoPatches; sha256 = cargoSha256; + writeVendorConfig = useRealVendorConfig; } else null; @@ -61,14 +68,19 @@ in stdenv.mkDerivation (args // { ${setupVendorDir} mkdir .cargo - cat >.cargo/config <<-EOF - [source.crates-io] - registry = 'https://github.com/rust-lang/crates.io-index' - replace-with = 'vendored-sources' + '' + (if useRealVendorConfig then '' + sed "s|directory = \".*\"|directory = \"$(pwd)/$cargoDepsCopy\"|g" \ + "$(pwd)/$cargoDepsCopy/.cargo/config" > .cargo/config + '' else '' + cat >.cargo/config <<-EOF + [source.crates-io] + registry = 'https://github.com/rust-lang/crates.io-index' + replace-with = 'vendored-sources' - [source.vendored-sources] - directory = '$(pwd)/$cargoDepsCopy' - EOF + [source.vendored-sources] + directory = '$(pwd)/$cargoDepsCopy' + EOF + '') + '' unset cargoDepsCopy diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix index 2670ed528640..2d8a36a30ace 100644 --- a/pkgs/build-support/rust/fetchcargo.nix +++ b/pkgs/build-support/rust/fetchcargo.nix @@ -1,5 +1,5 @@ { stdenv, cacert, git, rust, cargo-vendor }: -{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "" }: +{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "", writeVendorConfig ? false }: stdenv.mkDerivation { name = "${name}-vendor"; nativeBuildInputs = [ cacert cargo-vendor git rust.cargo ]; @@ -23,9 +23,11 @@ stdenv.mkDerivation { ${cargoUpdateHook} - cargo vendor - - cp -ar vendor $out + mkdir -p $out + cargo vendor $out > config + '' + stdenv.lib.optionalString writeVendorConfig '' + mkdir $out/.cargo + sed "s|directory = \".*\"|directory = \"./vendor\"|g" config > $out/.cargo/config ''; outputHashAlgo = "sha256"; From ccf72b853738cba2de2c4b22cfc1668792201bb3 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Sat, 8 Sep 2018 14:14:56 +0200 Subject: [PATCH 2/7] fetchcargo: normalise cargo config to ensure determinism --- .../rust/cargo-vendor-normalise.py | 32 +++++++++++++++++++ pkgs/build-support/rust/default.nix | 8 ++--- pkgs/build-support/rust/fetchcargo.nix | 13 ++++++-- 3 files changed, 47 insertions(+), 6 deletions(-) create mode 100755 pkgs/build-support/rust/cargo-vendor-normalise.py diff --git a/pkgs/build-support/rust/cargo-vendor-normalise.py b/pkgs/build-support/rust/cargo-vendor-normalise.py new file mode 100755 index 000000000000..194636968564 --- /dev/null +++ b/pkgs/build-support/rust/cargo-vendor-normalise.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import toml +import sys + +def escape(s): + return '"'+s.replace('"', r'\"').replace("\n", r"\n").replace("\\", "\\\\")+'"' + +data = toml.load(sys.stdin) + +assert list(data.keys()) == [ "source" ] + +# this value is non deterministic +data["source"]["vendored-sources"]["directory"] = "@vendor@" + +result = "" +inner = data["source"] +for source in sorted(inner.keys()): + result += '[source.{}]\n'.format(escape(source)) + if source == "vendored-sources": + result += '"directory" = "@vendor@"\n' + else: + for key in sorted(inner[source].keys()): + result += '{} = {}\n'.format(escape(key), escape(inner[source][key])) + result += "\n" + +real = toml.loads(result) +assert real == data, "output = {} while input = {}".format(real, data) + +print(result) + + diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index a2dc5df4d926..864e42c47619 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -1,7 +1,7 @@ -{ stdenv, cacert, git, rust, cargo-vendor }: +{ stdenv, cacert, git, rust, cargo-vendor, python3 }: let fetchcargo = import ./fetchcargo.nix { - inherit stdenv cacert git rust cargo-vendor; + inherit stdenv cacert git rust cargo-vendor python3; }; in { name, cargoSha256 ? "unset" @@ -69,8 +69,8 @@ in stdenv.mkDerivation (args // { mkdir .cargo '' + (if useRealVendorConfig then '' - sed "s|directory = \".*\"|directory = \"$(pwd)/$cargoDepsCopy\"|g" \ - "$(pwd)/$cargoDepsCopy/.cargo/config" > .cargo/config + substitute "$(pwd)/$cargoDepsCopy/.cargo/config" .cargo/config \ + --subst-var-by vendor "$(pwd)/$cargoDepsCopy" '' else '' cat >.cargo/config <<-EOF [source.crates-io] diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix index 2d8a36a30ace..f04988a7dc13 100644 --- a/pkgs/build-support/rust/fetchcargo.nix +++ b/pkgs/build-support/rust/fetchcargo.nix @@ -1,5 +1,14 @@ -{ stdenv, cacert, git, rust, cargo-vendor }: +{ stdenv, cacert, git, rust, cargo-vendor, python3 }: { name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "", writeVendorConfig ? false }: +let cargo-vendor-normalise = stdenv.mkDerivation { + name = "cargo-vendor-normalise"; + src = ./cargo-vendor-normalise.py; + unpackPhase = ":"; + installPhase = "install -D $src $out/bin/cargo-vendor-normalise"; + buildInputs = [ (python3.withPackages(ps: [ ps.toml ])) ]; + preferLocalBuild = true; +}; +in stdenv.mkDerivation { name = "${name}-vendor"; nativeBuildInputs = [ cacert cargo-vendor git rust.cargo ]; @@ -27,7 +36,7 @@ stdenv.mkDerivation { cargo vendor $out > config '' + stdenv.lib.optionalString writeVendorConfig '' mkdir $out/.cargo - sed "s|directory = \".*\"|directory = \"./vendor\"|g" config > $out/.cargo/config + < config ${cargo-vendor-normalise}/bin/cargo-vendor-normalise > $out/.cargo/config ''; outputHashAlgo = "sha256"; From f20b229aa19e92914aba7fe990201be730c07a10 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Sun, 9 Sep 2018 15:54:00 +0200 Subject: [PATCH 3/7] fectchcargo: don't break old sha256 --- doc/languages-frameworks/rust.section.md | 11 +------- nixos/doc/manual/release-notes/rl-1809.xml | 21 --------------- pkgs/build-support/rust/default.nix | 26 +++++-------------- .../rust/fetchcargo-default-config.toml | 7 +++++ pkgs/build-support/rust/fetchcargo.nix | 17 +++++++----- 5 files changed, 25 insertions(+), 57 deletions(-) create mode 100755 pkgs/build-support/rust/fetchcargo-default-config.toml diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md index 737759fd8bd8..6588281878a0 100644 --- a/doc/languages-frameworks/rust.section.md +++ b/doc/languages-frameworks/rust.section.md @@ -42,8 +42,7 @@ rustPlatform.buildRustPackage rec { sha256 = "0y5d1n6hkw85jb3rblcxqas2fp82h3nghssa4xqrhqnz25l799pj"; }; - cargoSha256 = "194lzn9xjkc041lmqnm676ydgbhn45xx9jhrhz6lzlg99yr6b880"; - useRealVendorConfig = true; + cargoSha256 = "0q68qyl2h6i0qsz82z840myxlnjay8p1w5z7hfyr8fqp7wgwa9cx"; meta = with stdenv.lib; { description = "A fast line-oriented regex search tool, similar to ag and ack"; @@ -65,14 +64,6 @@ When the `Cargo.lock`, provided by upstream, is not in sync with the added in `cargoPatches` will also be prepended to the patches in `patches` at build-time. -The `useRealVendorConfig` parameter tells cargo-vendor to include a Cargo -configuration file in the fetched dependencies. This will fix problems with -projects, where Crates are downloaded from non-crates.io sources. Please note, -that currently this parameter defaults to `false` only due to compatibility -reasons, as setting this to `true` requires a change in `cargoSha256`. -Eventually this distinction will be deprecated, so please always set -`useRealVendorConfig` to `true` and make sure to recompute the `cargoSha256`. - To install crates with nix there is also an experimental project called [nixcrates](https://github.com/fractalide/nixcrates). diff --git a/nixos/doc/manual/release-notes/rl-1809.xml b/nixos/doc/manual/release-notes/rl-1809.xml index dd04996925bb..01421fc5dda7 100644 --- a/nixos/doc/manual/release-notes/rl-1809.xml +++ b/nixos/doc/manual/release-notes/rl-1809.xml @@ -551,27 +551,6 @@ inherit (pkgs.nixos { stdenv.buildPlatform, stdenv.hostPlatform, and stdenv.targetPlatform. - - - The buildRustPackage function got the new - argument useRealVendorConfig, currently - defaulting to false. Setting it to - true necessates the recomputation of the - cargoSha256 and fixes a problem with - dependencies, that were fetched from a non-crates.io source. - Eventually only the true behaviour will be kept, - so please set it explicitly to true and - recompute your cargoSha256, so that we can - migrate to the new behaviour and deprecate the option. - - - While recomputing cargoSha256, it is important - to first invalidate the hash (e.g. by changing a digit), so that - Nix actually rebuilds the fixed-output derivation. Otherwise this - could lead to hard to detect errors, where a package seemingly - builds on your computer, but breaks on others! - - diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 864e42c47619..1d5de052f893 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -17,15 +17,9 @@ in , cargoBuildFlags ? [] , cargoVendorDir ? null -# This tells cargo-vendor to include a Cargo config file in the fixed-output -# derivation. This is desirable in every case, so please set it to true. -# Eventually this will default to true and even later this option and the old -# behaviour will be removed. -, useRealVendorConfig ? false , ... } @ args: assert cargoVendorDir == null -> cargoSha256 != "unset"; -assert cargoVendorDir != null -> !useRealVendorConfig; let cargoDeps = if cargoVendorDir == null @@ -33,7 +27,6 @@ let inherit name src srcs sourceRoot cargoUpdateHook; patches = cargoPatches; sha256 = cargoSha256; - writeVendorConfig = useRealVendorConfig; } else null; @@ -68,19 +61,12 @@ in stdenv.mkDerivation (args // { ${setupVendorDir} mkdir .cargo - '' + (if useRealVendorConfig then '' - substitute "$(pwd)/$cargoDepsCopy/.cargo/config" .cargo/config \ - --subst-var-by vendor "$(pwd)/$cargoDepsCopy" - '' else '' - cat >.cargo/config <<-EOF - [source.crates-io] - registry = 'https://github.com/rust-lang/crates.io-index' - replace-with = 'vendored-sources' - - [source.vendored-sources] - directory = '$(pwd)/$cargoDepsCopy' - EOF - '') + '' + config="$(pwd)/$cargoDepsCopy/.cargo/config"; + if [[ ! -e $config ]]; then + config=${./fetchcargo-default-config.toml}; + fi; + substitute $config .cargo/config \ + --subst-var-by vendor "$(pwd)/$cargoDepsCopy" unset cargoDepsCopy diff --git a/pkgs/build-support/rust/fetchcargo-default-config.toml b/pkgs/build-support/rust/fetchcargo-default-config.toml new file mode 100755 index 000000000000..dd8ebbc32d31 --- /dev/null +++ b/pkgs/build-support/rust/fetchcargo-default-config.toml @@ -0,0 +1,7 @@ +[source."crates-io"] +"replace-with" = "vendored-sources" + +[source."vendored-sources"] +"directory" = "@vendor@" + + diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix index f04988a7dc13..1a40a362d9b5 100644 --- a/pkgs/build-support/rust/fetchcargo.nix +++ b/pkgs/build-support/rust/fetchcargo.nix @@ -1,5 +1,4 @@ { stdenv, cacert, git, rust, cargo-vendor, python3 }: -{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "", writeVendorConfig ? false }: let cargo-vendor-normalise = stdenv.mkDerivation { name = "cargo-vendor-normalise"; src = ./cargo-vendor-normalise.py; @@ -9,9 +8,10 @@ let cargo-vendor-normalise = stdenv.mkDerivation { preferLocalBuild = true; }; in +{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "" }: stdenv.mkDerivation { 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; phases = "unpackPhase patchPhase installPhase"; @@ -33,10 +33,15 @@ stdenv.mkDerivation { ${cargoUpdateHook} mkdir -p $out - cargo vendor $out > config - '' + stdenv.lib.optionalString writeVendorConfig '' - mkdir $out/.cargo - < config ${cargo-vendor-normalise}/bin/cargo-vendor-normalise > $out/.cargo/config + cargo vendor $out | cargo-vendor-normalise > config + # 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"; From 7bfa20198afce7830ff2daccb4400f03c9f40e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 11 Sep 2018 21:49:16 +0100 Subject: [PATCH 4/7] fetchcargo: add type checking to cargo-vendor-normalise.py --- .../rust/cargo-vendor-normalise.py | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/pkgs/build-support/rust/cargo-vendor-normalise.py b/pkgs/build-support/rust/cargo-vendor-normalise.py index 194636968564..2d7a18957184 100755 --- a/pkgs/build-support/rust/cargo-vendor-normalise.py +++ b/pkgs/build-support/rust/cargo-vendor-normalise.py @@ -1,32 +1,41 @@ #!/usr/bin/env python -import toml import sys -def escape(s): - return '"'+s.replace('"', r'\"').replace("\n", r"\n").replace("\\", "\\\\")+'"' - -data = toml.load(sys.stdin) - -assert list(data.keys()) == [ "source" ] - -# this value is non deterministic -data["source"]["vendored-sources"]["directory"] = "@vendor@" - -result = "" -inner = data["source"] -for source in sorted(inner.keys()): - result += '[source.{}]\n'.format(escape(source)) - if source == "vendored-sources": - result += '"directory" = "@vendor@"\n' - else: - for key in sorted(inner[source].keys()): - result += '{} = {}\n'.format(escape(key), escape(inner[source][key])) - result += "\n" - -real = toml.loads(result) -assert real == data, "output = {} while input = {}".format(real, data) - -print(result) +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() From 33dab23255cedcf83fe1710a35b9b962f41406aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 11 Sep 2018 21:52:06 +0100 Subject: [PATCH 5/7] alacritty: switch back to upstream source Thanks to https://github.com/NixOS/nixpkgs/pull/46362 We can now support git dependencies! --- pkgs/applications/misc/alacritty/default.nix | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/misc/alacritty/default.nix b/pkgs/applications/misc/alacritty/default.nix index 4544ed1fba3b..98e93321265e 100644 --- a/pkgs/applications/misc/alacritty/default.nix +++ b/pkgs/applications/misc/alacritty/default.nix @@ -1,6 +1,6 @@ { stdenv, lib, - fetchgit, + fetchFromGitHub, rustPlatform, cmake, makeWrapper, @@ -51,18 +51,16 @@ let ]; in buildRustPackage rec { name = "alacritty-unstable-${version}"; - version = "2018-08-30"; + version = "2018-08-05"; - # At the moment we cannot handle git dependencies in buildRustPackage. - # This fork only replaces rust-fontconfig/libfontconfig with a git submodules. - src = fetchgit { - url = https://github.com/Mic92/alacritty.git; - rev = "rev-${version}"; - sha256 = "0izvg7dwwb763jc6gnmn47i5zrkxvmh3vssn6vzrrmqhd4j3msmf"; - fetchSubmodules = true; + src = fetchFromGitHub { + owner = "jwilm"; + repo = "alacritty"; + rev = "1adb5cb7fc05054197aa08e0d1fa957df94888ab"; + sha256 = "06rc7dy1vn59lc5hjh953h9lh0f39c0n0jmrz472mrya722fl2ab"; }; - cargoSha256 = "1ijgkwv9ij4haig1h6n2b9xbhp5vahy9vp1sx72wxaaj9476msjx"; + cargoSha256 = "0ms0248bb2lgbzcqks6i0qhn1gaiim3jf1kl17qw52c8an3rc652"; nativeBuildInputs = [ cmake From a3e1da17cb10327f1045e22f49dba1f959ac769e Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Tue, 11 Sep 2018 23:40:35 +0200 Subject: [PATCH 6/7] cargo-vendor-normalise: add a small install check --- pkgs/build-support/rust/fetchcargo.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix index 1a40a362d9b5..eb51e5c4ff9a 100644 --- a/pkgs/build-support/rust/fetchcargo.nix +++ b/pkgs/build-support/rust/fetchcargo.nix @@ -4,6 +4,13 @@ let cargo-vendor-normalise = stdenv.mkDerivation { src = ./cargo-vendor-normalise.py; unpackPhase = ":"; installPhase = "install -D $src $out/bin/cargo-vendor-normalise"; + 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 + ''; buildInputs = [ (python3.withPackages(ps: [ ps.toml ])) ]; preferLocalBuild = true; }; From 50578abfc5e42b47247c486bf845c310c2299d8d Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 17 Sep 2018 20:21:21 +0200 Subject: [PATCH 7/7] fetchcargo: Fix cargo-vendor-normalise for darwin --- pkgs/build-support/rust/fetchcargo.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix index eb51e5c4ff9a..9e77f8817b24 100644 --- a/pkgs/build-support/rust/fetchcargo.nix +++ b/pkgs/build-support/rust/fetchcargo.nix @@ -2,8 +2,11 @@ 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 @@ -11,7 +14,6 @@ let cargo-vendor-normalise = stdenv.mkDerivation { < $reference $out/bin/cargo-vendor-normalise > test; cmp test $reference ''; - buildInputs = [ (python3.withPackages(ps: [ ps.toml ])) ]; preferLocalBuild = true; }; in