Commit 466e57cb authored by Peder Bergebakken Sundt's avatar Peder Bergebakken Sundt
Browse files
parent b827e50a
Loading
Loading
Loading
Loading
+23 −8
Original line number Diff line number Diff line
@@ -14,26 +14,26 @@

let

  wasm-bindgen-84 = wasm-bindgen-cli.override {
    version = "0.2.84";
    hash = "sha256-0rK+Yx4/Jy44Fw5VwJ3tG243ZsyOIBBehYU54XP/JGk=";
    cargoHash = "sha256-vcpxcRlW1OKoD64owFF6mkxSqmNrvY+y3Ckn5UwEQ50=";
  wasm-bindgen-92 = wasm-bindgen-cli.override {
    version = "0.2.92";
    hash = "sha256-1VwY8vQy7soKEgbki4LD+v259751kKxSxmo/gqE6yV0=";
    cargoHash = "sha256-aACJ+lYNEU8FFBs158G1/JG8sc6Rq080PeKCMnwdpH0=";
  };

in

rustPlatform.buildRustPackage rec {
  pname = "pagefind";
  version = "1.0.4";
  version = "1.1.0";

  src = fetchFromGitHub {
    owner = "cloudcannon";
    repo = "pagefind";
    rev = "refs/tags/v${version}";
    hash = "sha256-IN+l5Wq89tjppE0xCcvczQSkJc1CLymEFeieJhvQQ54=";
    hash = "sha256-pcgcu9zylSTjj5rxNff+afFBWVpN5sGtlpadG1wb93M=";
  };

  cargoHash = "sha256-T7DBuqfpqaEmu9iItnFYsJVnEFxG1r9uXEkfqJp1mD8=";
  cargoHash = "sha256-E4gjG5GrVWkMKgjQiAvEiSy2/tx/yHKe+5isveMZ9tU=";

  env.npmDeps_web_js = fetchNpmDeps {
    name = "npm-deps-web-js";
@@ -50,6 +50,11 @@ rustPlatform.buildRustPackage rec {
    src = "${src}/pagefind_ui/modular";
    hash = "sha256-O0RqZUsRFtByxMQdwNGNcN38Rh+sDqqNo9YlBcrnsF4=";
  };
  env.cargoDeps_web = rustPlatform.fetchCargoTarball {
    name = "cargo-deps-web";
    src = "${src}/pagefind_web/";
    hash = "sha256-vDkVXyDePKgYTYE5ZTLLfOHwPYfgaqP9p5/fKCQQi0g=";
  };

  postPatch = ''
    # Tricky way to run npmConfigHook multiple times
@@ -60,6 +65,11 @@ rustPlatform.buildRustPackage rec {
      npmRoot=pagefind_ui/default npmDeps=$npmDeps_ui_default npmConfigHook
      npmRoot=pagefind_ui/modular npmDeps=$npmDeps_ui_modular npmConfigHook
    )
    (
      cd pagefind_web
      cargoDeps=$cargoDeps_web cargoSetupPostUnpackHook
      cargoDeps=$cargoDeps_web cargoSetupPostPatchHook
    )
  '';

  nativeBuildInputs = [
@@ -68,7 +78,7 @@ rustPlatform.buildRustPackage rec {
    nodejs
    rustc
    rustc.llvmPackages.lld
    wasm-bindgen-84
    wasm-bindgen-92
    wasm-pack
  ];

@@ -76,22 +86,27 @@ rustPlatform.buildRustPackage rec {
  # based on "test-and-build" in https://github.com/CloudCannon/pagefind/blob/main/.github/workflows/release.yml
  preBuild = ''
    export HOME=$(mktemp -d)

    echo entering pagefind_web_js...
    (
      cd pagefind_web_js
      npm run build-coupled
    )

    echo entering pagefind_web...
    (
      cd pagefind_web
      export RUSTFLAGS="-C linker=lld"
      bash ./local_build.sh
    )

    echo entering pagefind_ui/default...
    (
      cd pagefind_ui/default
      npm run build
    )

    echo entering pagefind_ui/modular...
    (
      cd pagefind_ui/modular
      npm run build