buck2: include prelude source in .prelude passthru

Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2023-08-13 23:19:01 -05:00
parent e85b6933d5
commit 6e287913f7
3 changed files with 29 additions and 2 deletions

View File

@ -30,13 +30,24 @@ let
aarch64-linux = "aarch64-unknown-linux-musl";
}."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
allHashes = builtins.fromJSON (builtins.readFile ./hashes.json);
# our version of buck2; this should be a git tag
buck2-version = "2023-08-01";
src =
let
allHashes = builtins.fromJSON (builtins.readFile ./hashes.json);
hash = allHashes."${stdenv.hostPlatform.system}";
url = "https://github.com/facebook/buck2/releases/download/${buck2-version}/buck2-${suffix}.zst";
in fetchurl { inherit url hash; };
# compatible version of buck2 prelude; a git revision in the buck2-prelude repository
buck2-prelude = "acf49faaa61fd6ad9facd9e1418eed514bbb2ec8";
prelude-src =
let
hash = allHashes."_prelude";
url = "https://github.com/facebook/buck2-prelude/archive/${buck2-prelude}.tar.gz";
in fetchurl { inherit url hash; };
in
stdenv.mkDerivation rec {
pname = "buck2";
@ -58,6 +69,8 @@ stdenv.mkDerivation rec {
'';
passthru = {
prelude = prelude-src;
updateScript = ./update.sh;
tests = testers.testVersion {
package = buck2;

View File

@ -1,4 +1,5 @@
{ "_comment": "@generated by pkgs/development/tools/build-managers/buck2/update.sh"
, "_prelude": "sha256-SkCsVymQL/i8tUvKoLVtOQRYRm3zuF+WOFnbCggQwes="
, "x86_64-linux": "sha256-wZULK2FPZ4GtQ5MMQmgfmtbMHJ7sPbue2RdVY0dmRuE="
, "x86_64-darwin": "sha256-FmayArw2gswKjAEv0AzpFZNiXNx3GmJnPwH9g+Y/BGU="
, "aarch64-linux": "sha256-3M1dRIFU0CwoVCbmq3oghhz51wW37melzt9hdIHqzzY="

View File

@ -9,7 +9,11 @@ VERSION=$(curl -s https://api.github.com/repos/facebook/buck2/releases \
(select ((.prerelease == true) and (.name != "latest"))) |
first
) | .name')
PRELUDE_HASH=$(curl -sLo - "https://github.com/facebook/buck2/releases/download/${VERSION}/prelude_hash")
PRELUDE_DL_URL="https://github.com/facebook/buck2-prelude/archive/${PRELUDE_HASH}.tar.gz"
echo "Latest buck2 prerelease: $VERSION"
echo "Compatible buck2-prelude hash: $PRELUDE_HASH"
ARCHS=(
"x86_64-linux:x86_64-unknown-linux-musl"
@ -22,7 +26,12 @@ NFILE=pkgs/development/tools/build-managers/buck2/default.nix
HFILE=pkgs/development/tools/build-managers/buck2/hashes.json
rm -f "$HFILE" && touch "$HFILE"
PRELUDE_SHA256HASH="$(nix-prefetch-url --type sha256 "$PRELUDE_DL_URL")"
PRELUDE_SRIHASH="$(nix hash to-sri --type sha256 "$PRELUDE_SHA256HASH")"
printf "{ \"_comment\": \"@generated by pkgs/development/tools/build-managers/buck2/update.sh\"\n" >> "$HFILE"
printf ", \"_prelude\": \"$PRELUDE_SRIHASH\"\n" >> "$HFILE"
for arch in "${ARCHS[@]}"; do
IFS=: read -r arch_name arch_target <<< "$arch"
sha256hash="$(nix-prefetch-url --type sha256 "https://github.com/facebook/buck2/releases/download/${VERSION}/buck2-${arch_target}.zst")"
@ -35,4 +44,8 @@ sed -i \
's/buck2-version\s*=\s*".*";/buck2-version = "'"$VERSION"'";/' \
"$NFILE"
echo "Done; wrote $HFILE and updated version"
sed -i \
's/buck2-prelude\s*=\s*".*";/buck2-prelude = "'"$PRELUDE_HASH"'";/' \
"$NFILE"
echo "Done; wrote $HFILE and updated version in $NFILE."