From 9f9d0e6402d32edf03576267b1607f66fe00b1f1 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Wed, 17 Dec 2025 12:58:45 +0000 Subject: [PATCH] brioche: init at 0.1.6 --- pkgs/by-name/br/brioche/fetchers.nix | 20 ++++++ pkgs/by-name/br/brioche/librusty_v8.nix | 13 ++++ pkgs/by-name/br/brioche/package.nix | 76 ++++++++++++++++++++++ pkgs/by-name/br/brioche/update-librusty.sh | 47 +++++++++++++ 4 files changed, 156 insertions(+) create mode 100644 pkgs/by-name/br/brioche/fetchers.nix create mode 100644 pkgs/by-name/br/brioche/librusty_v8.nix create mode 100644 pkgs/by-name/br/brioche/package.nix create mode 100755 pkgs/by-name/br/brioche/update-librusty.sh diff --git a/pkgs/by-name/br/brioche/fetchers.nix b/pkgs/by-name/br/brioche/fetchers.nix new file mode 100644 index 000000000000..41b800a6e63c --- /dev/null +++ b/pkgs/by-name/br/brioche/fetchers.nix @@ -0,0 +1,20 @@ +# not a stable interface, do not reference outside the windmill package but make a copy if you need +{ + lib, + stdenv, + fetchurl, +}: + +{ + fetchLibrustyV8 = + args: + fetchurl { + name = "librusty_v8-${args.version}"; + url = "https://github.com/denoland/rusty_v8/releases/download/v${args.version}/librusty_v8_release_${stdenv.hostPlatform.rust.rustcTarget}.a.gz"; + sha256 = args.shas.${stdenv.hostPlatform.system}; + meta = { + inherit (args) version; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + }; + }; +} diff --git a/pkgs/by-name/br/brioche/librusty_v8.nix b/pkgs/by-name/br/brioche/librusty_v8.nix new file mode 100644 index 000000000000..a3a91c5cc15a --- /dev/null +++ b/pkgs/by-name/br/brioche/librusty_v8.nix @@ -0,0 +1,13 @@ +# auto-generated file -- DO NOT EDIT! +{ fetchLibrustyV8 }: + +fetchLibrustyV8 { + version = "140.2.0"; + shas = { + # NOTE; Follows supported platforms of package (see meta.platforms attribute)! + x86_64-linux = "0xgkyjx4vhi001p8iv0wqjpal4nl0vj65fnhp5x8ckss6mhanymg"; + aarch64-linux = "1gal8sylc0k9x37m4lrlncmcfaxn5bdizgi9rhyfb9da9wi41n9f"; + x86_64-darwin = "0y117lgc1d90f3z285ljazacscs02mmk9b57h403ilgqfly8dzh7"; + aarch64-darwin = "106n64mrmwk0jzm8zy891kjjbxrr7yggj7m986pxinf8igvab7br"; + }; +} diff --git a/pkgs/by-name/br/brioche/package.nix b/pkgs/by-name/br/brioche/package.nix new file mode 100644 index 000000000000..3106d86f80fe --- /dev/null +++ b/pkgs/by-name/br/brioche/package.nix @@ -0,0 +1,76 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + pkg-config, + callPackage, + librusty_v8 ? ( + callPackage ./librusty_v8.nix { + inherit (callPackage ./fetchers.nix { }) fetchLibrustyV8; + } + ), + openssl, + tzdata, + versionCheckHook, + _experimental-update-script-combinators, + nix-update-script, +}: + +rustPlatform.buildRustPackage (finalAttrs: { + pname = "brioche"; + version = "0.1.6"; + + src = fetchFromGitHub { + owner = "brioche-dev"; + repo = "brioche"; + tag = "v${finalAttrs.version}"; + hash = "sha256-tMVBpFCTxesrkj7Z3huVD86baw1tYAtPdPAzYJzTCnA="; + }; + + cargoHash = "sha256-LPHJHS69oUvmTaYoMSINCcyYIHYMq++UCUMh9KrCm/0="; + + env = { + OPENSSL_NO_VENDOR = true; + RUSTY_V8_ARCHIVE = librusty_v8; + }; + + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = [ + openssl + ]; + + checkFlags = [ + # Require internet access + "--skip=test_bake_process" + ]; + + nativeCheckInputs = [ + # Otherwise, some tests fail with: + # Error: failed to find time zone `Etc/Unknown` since there is no time zone database configured at line 1 column 415 + tzdata + ]; + + nativeInstallCheckInputs = [ + versionCheckHook + ]; + versionCheckProgramArg = "--version"; + doInstallCheck = true; + + passthru.updateScript = _experimental-update-script-combinators.sequence [ + (nix-update-script { }) + ./update-librusty.sh + ]; + + meta = { + description = "Package manager for building and running complex software projects"; + homepage = "https://brioche.dev/"; + downloadPage = "https://github.com/brioche-dev/brioche"; + changelog = "https://github.com/brioche-dev/brioche/blob/${finalAttrs.src.tag}/CHANGELOG.md"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ GaetanLepage ]; + mainProgram = "brioche"; + }; +}) diff --git a/pkgs/by-name/br/brioche/update-librusty.sh b/pkgs/by-name/br/brioche/update-librusty.sh new file mode 100755 index 000000000000..0ba452c803f5 --- /dev/null +++ b/pkgs/by-name/br/brioche/update-librusty.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p gnugrep gnused nix jq +# shellcheck shell=bash + +set -eu -o pipefail + +echo "librusty_v8: UPDATING" + +# ASSUMES; The Cargo.lock file is located at /backend/Cargo.toml + +BRIOCHE_LATEST_VERSION=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} --silent --fail --location "https://api.github.com/repos/brioche-dev/brioche/releases/latest" | jq --raw-output .tag_name) +CARGO_LOCK=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} --silent --fail --location "https://github.com/brioche-dev/brioche/raw/$BRIOCHE_LATEST_VERSION/Cargo.lock") + +PACKAGE_DIR=$(dirname "$(readlink --canonicalize-existing "${BASH_SOURCE[0]}")") +OUTPUT_FILE="$PACKAGE_DIR/librusty_v8.nix" +NEW_VERSION=$(echo "$CARGO_LOCK" | grep --after-context 5 'name = "v8"' | grep 'version =' | sed -E 's/version = "//;s/"//') + +CURRENT_VERSION="" +if [ -f "$OUTPUT_FILE" ]; then + CURRENT_VERSION="$(grep 'version =' "$OUTPUT_FILE" | sed -E 's/version = "//;s/"//')" +fi + +if [ "$CURRENT_VERSION" == "$NEW_VERSION" ]; then + echo "No update needed, $CURRENT_VERSION is already latest" + exit 0 +fi + +TEMP_FILE="$OUTPUT_FILE.tmp" +cat >"$TEMP_FILE" <