depot/third_party/nixpkgs/pkgs/build-support/rust/sysroot/update-lockfile.sh
Default email ce641f4048 Project import generated by Copybara.
GitOrigin-RevId: bc5d68306b40b8522ffb69ba6cff91898c2fbbff
2021-12-06 17:07:01 +01:00

27 lines
600 B
Bash
Executable file

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p python3 python3.pkgs.toml cargo
set -eu pipefile
HERE=$(readlink -e $(dirname "${BASH_SOURCE[0]}"))
NIXPKGS_ROOT="$HERE/../../../.."
# https://unix.stackexchange.com/a/84980/390173
tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'update-lockfile')
cd "$tempdir"
mkdir -p src
touch src/lib.rs
RUSTC_SRC=$(nix-build "${NIXPKGS_ROOT}" -A pkgs.rustPlatform.rustLibSrc --no-out-link)
ln -s $RUSTC_SRC/{core,alloc} ./
export RUSTC_SRC
python3 "$HERE/cargo.py"
export RUSTC_BOOTSTRAP=1
cargo generate-lockfile
cp Cargo.lock "$HERE"
rm -rf "$tempdir"