Merge pull request #309460 from r-ryantm/auto-update/home-manager
[NixPkgs.git] / pkgs / build-support / rust / sysroot / update-lockfile.sh
blobd0596d1e5a623adb391c3838a5f02cb907440d6c
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p python3 python3.pkgs.toml cargo
4 set -eu pipefile
6 HERE=$(readlink -e $(dirname "${BASH_SOURCE[0]}"))
7 NIXPKGS_ROOT="$HERE/../../../.."
9 # https://unix.stackexchange.com/a/84980/390173
10 tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'update-lockfile')
11 cd "$tempdir"
12 mkdir -p src
13 touch src/lib.rs
15 RUSTC_SRC=$(nix-build "${NIXPKGS_ROOT}" -A pkgs.rustPlatform.rustLibSrc --no-out-link)
17 ln -s $RUSTC_SRC/{core,alloc} ./
19 export RUSTC_SRC
20 python3 "$HERE/cargo.py"
22 export RUSTC_BOOTSTRAP=1
23 cargo generate-lockfile
25 cp Cargo.lock "$HERE"
27 rm -rf "$tempdir"