core/pkgs/build-support/rust/sysroot/update-lockfile.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
600 B
Bash
Raw Normal View History

2024-05-02 00:46:19 +00:00
#!/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"