Commit 9f9d0e64 authored by Gaetan Lepage's avatar Gaetan Lepage
Browse files

brioche: init at 0.1.6

parent e2e5baad
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
# 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 ];
      };
    };
}
+13 −0
Original line number Diff line number Diff line
# 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";
  };
}
+76 −0
Original line number Diff line number Diff line
{
  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";
  };
})
+47 −0
Original line number Diff line number Diff line
#!/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 <REPO>/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" <<EOF
# auto-generated file -- DO NOT EDIT!
{ fetchLibrustyV8 }:

fetchLibrustyV8 {
  version = "$NEW_VERSION";
  shas = {
    # NOTE; Follows supported platforms of package (see meta.platforms attribute)!
    x86_64-linux = "$(nix-prefetch-url --type sha256 https://github.com/denoland/rusty_v8/releases/download/v"$NEW_VERSION"/librusty_v8_release_x86_64-unknown-linux-gnu.a.gz)";
    aarch64-linux = "$(nix-prefetch-url --type sha256 https://github.com/denoland/rusty_v8/releases/download/v"$NEW_VERSION"/librusty_v8_release_aarch64-unknown-linux-gnu.a.gz)";
    x86_64-darwin = "$(nix-prefetch-url --type sha256 https://github.com/denoland/rusty_v8/releases/download/v"$NEW_VERSION"/librusty_v8_release_x86_64-apple-darwin.a.gz)";
    aarch64-darwin = "$(nix-prefetch-url --type sha256 https://github.com/denoland/rusty_v8/releases/download/v"$NEW_VERSION"/librusty_v8_release_aarch64-apple-darwin.a.gz)";
  };
}
EOF

mv "$TEMP_FILE" "$OUTPUT_FILE"

echo "librusty_v8: UPDATE DONE"