aboutsummaryrefslogtreecommitdiff
path: root/release.nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-04-03 20:06:26 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-04-03 20:14:34 +0200
commit5e7ccdc9e3ddd61dc85e20c898001345bfb497a5 (patch)
treed2cd4296120c559117a8c626a7dc38e2a2aedd48 /release.nix
parent63fa92605b2b0a8a6d948a27e1d331cc46b199bd (diff)
Publish a tarball containing the crates we depend on
This is needed since we no longer produce a source tarball. (cherry picked from commit bf70a047a0b2da606f65a88f13ce2994065cd9c4)
Diffstat (limited to 'release.nix')
-rw-r--r--release.nix94
1 files changed, 53 insertions, 41 deletions
diff --git a/release.nix b/release.nix
index 9b591229a..65b035957 100644
--- a/release.nix
+++ b/release.nix
@@ -12,52 +12,64 @@ let
builtins.readFile ./.version
+ (if officialRelease then "" else "pre${toString nix.revCount}_${nix.shortRev}");
- jobs = rec {
-
- # Create a "vendor" directory that contains the crates listed in
- # Cargo.lock. This allows Nix to be built without network access.
- vendoredCrates =
- let
- lockFile = builtins.fromTOML (builtins.readFile nix-rust/Cargo.lock);
-
- files = map (pkg: import <nix/fetchurl.nix> {
- url = "https://crates.io/api/v1/crates/${pkg.name}/${pkg.version}/download";
- sha256 = lockFile.metadata."checksum ${pkg.name} ${pkg.version} (registry+https://github.com/rust-lang/crates.io-index)";
- }) (builtins.filter (pkg: pkg.source or "" == "registry+https://github.com/rust-lang/crates.io-index") lockFile.package);
-
- in pkgs.runCommand "cargo-vendor-dir" {}
- ''
- mkdir -p $out/vendor
-
- cat > $out/vendor/config <<EOF
- [source.crates-io]
- replace-with = "vendored-sources"
-
- [source.vendored-sources]
- directory = "vendor"
- EOF
-
- ${toString (builtins.map (file: ''
- mkdir $out/vendor/tmp
- tar xvf ${file} -C $out/vendor/tmp
- dir=$(echo $out/vendor/tmp/*)
+ # Create a "vendor" directory that contains the crates listed in
+ # Cargo.lock. This allows Nix to be built without network access.
+ vendoredCrates' =
+ let
+ lockFile = builtins.fromTOML (builtins.readFile nix-rust/Cargo.lock);
+
+ files = map (pkg: import <nix/fetchurl.nix> {
+ url = "https://crates.io/api/v1/crates/${pkg.name}/${pkg.version}/download";
+ sha256 = lockFile.metadata."checksum ${pkg.name} ${pkg.version} (registry+https://github.com/rust-lang/crates.io-index)";
+ }) (builtins.filter (pkg: pkg.source or "" == "registry+https://github.com/rust-lang/crates.io-index") lockFile.package);
+
+ in pkgs.runCommand "cargo-vendor-dir" {}
+ ''
+ mkdir -p $out/vendor
+
+ cat > $out/vendor/config <<EOF
+ [source.crates-io]
+ replace-with = "vendored-sources"
+
+ [source.vendored-sources]
+ directory = "vendor"
+ EOF
+
+ ${toString (builtins.map (file: ''
+ mkdir $out/vendor/tmp
+ tar xvf ${file} -C $out/vendor/tmp
+ dir=$(echo $out/vendor/tmp/*)
+
+ # Add just enough metadata to keep Cargo happy.
+ printf '{"files":{},"package":"${file.outputHash}"}' > "$dir/.cargo-checksum.json"
+
+ # Clean up some cruft from the winapi crates. FIXME: find
+ # a way to remove winapi* from our dependencies.
+ if [[ $dir =~ /winapi ]]; then
+ find $dir -name "*.a" -print0 | xargs -0 rm -f --
+ fi
- # Add just enough metadata to keep Cargo happy.
- printf '{"files":{},"package":"${file.outputHash}"}' > "$dir/.cargo-checksum.json"
+ mv "$dir" $out/vendor/
- # Clean up some cruft from the winapi crates. FIXME: find
- # a way to remove winapi* from our dependencies.
- if [[ $dir =~ /winapi ]]; then
- find $dir -name "*.a" -print0 | xargs -0 rm -f --
- fi
+ rm -rf $out/vendor/tmp
+ '') files)}
+ '';
- mv "$dir" $out/vendor/
+ jobs = rec {
- rm -rf $out/vendor/tmp
- '') files)}
+ vendoredCrates =
+ with pkgs;
+ runCommand "vendored-crates" {}
+ ''
+ mkdir -p $out/nix-support
+ name=nix-vendored-crates-${version}
+ fn=$out/$name.tar.xz
+ tar cvfJ $fn -C ${vendoredCrates'} vendor \
+ --owner=0 --group=0 --mode=u+rw,uga+r \
+ --transform "s,vendor,$name,"
+ echo "file crates-tarball $fn" >> $out/nix-support/hydra-build-products
'';
-
build = pkgs.lib.genAttrs systems (system:
let pkgs = import nixpkgs { inherit system; }; in
@@ -89,7 +101,7 @@ let
patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
''}
- ln -sfn ${vendoredCrates}/vendor/ nix-rust/vendor
+ ln -sfn ${vendoredCrates'}/vendor/ nix-rust/vendor
(cd perl; autoreconf --install --force --verbose)
'';