2023-10-09 19:29:22 +00:00
|
|
|
{ lib
|
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchNpmDeps
|
|
|
|
, npmHooks
|
|
|
|
, binaryen
|
|
|
|
, gzip
|
|
|
|
, nodejs
|
2024-01-13 08:15:51 +00:00
|
|
|
, rustc
|
2023-10-09 19:29:22 +00:00
|
|
|
, wasm-bindgen-cli
|
|
|
|
, wasm-pack
|
2024-09-19 14:19:46 +00:00
|
|
|
, fetchpatch
|
2023-10-09 19:29:22 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
wasm-bindgen-92 = wasm-bindgen-cli.override {
|
|
|
|
version = "0.2.92";
|
|
|
|
hash = "sha256-1VwY8vQy7soKEgbki4LD+v259751kKxSxmo/gqE6yV0=";
|
|
|
|
cargoHash = "sha256-aACJ+lYNEU8FFBs158G1/JG8sc6Rq080PeKCMnwdpH0=";
|
2023-10-09 19:29:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "pagefind";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "1.1.0";
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "cloudcannon";
|
|
|
|
repo = "pagefind";
|
|
|
|
rev = "refs/tags/v${version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-pcgcu9zylSTjj5rxNff+afFBWVpN5sGtlpadG1wb93M=";
|
2023-10-09 19:29:22 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
cargoPatches = [
|
|
|
|
(fetchpatch { # https://github.com/CloudCannon/pagefind/pull/680
|
|
|
|
name = "cargo-update-time.patch";
|
|
|
|
url = "https://github.com/CloudCannon/pagefind/commit/e6778572d225316803180db822f5cc12a936acd2.patch";
|
|
|
|
hash = "sha256-XHpHA1hPIe+wjDQ6LE9hn2jn3eMBOK9Yoo920jfH9do=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
cargoHash = "sha256-KWWln7QCRo02cOgHy5JNERGS0CvvgsPISwkTZeeNEkg=";
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
env.npmDeps_web_js = fetchNpmDeps {
|
|
|
|
name = "npm-deps-web-js";
|
|
|
|
src = "${src}/pagefind_web_js";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = "sha256-1gdVBCxxLEGFihIxoSSgxw/tMyVgwe7HFG/JjEfYVnQ=";
|
2023-10-09 19:29:22 +00:00
|
|
|
};
|
|
|
|
env.npmDeps_ui_default = fetchNpmDeps {
|
|
|
|
name = "npm-deps-ui-default";
|
|
|
|
src = "${src}/pagefind_ui/default";
|
|
|
|
hash = "sha256-voCs49JneWYE1W9U7aB6G13ypH6JqathVDeF58V57U8=";
|
|
|
|
};
|
|
|
|
env.npmDeps_ui_modular = fetchNpmDeps {
|
|
|
|
name = "npm-deps-ui-modular";
|
|
|
|
src = "${src}/pagefind_ui/modular";
|
|
|
|
hash = "sha256-O0RqZUsRFtByxMQdwNGNcN38Rh+sDqqNo9YlBcrnsF4=";
|
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
env.cargoDeps_web = rustPlatform.fetchCargoTarball {
|
|
|
|
name = "cargo-deps-web";
|
|
|
|
src = "${src}/pagefind_web/";
|
|
|
|
hash = "sha256-vDkVXyDePKgYTYE5ZTLLfOHwPYfgaqP9p5/fKCQQi0g=";
|
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# Tricky way to run npmConfigHook multiple times
|
|
|
|
(
|
|
|
|
local postPatchHooks=() # written to by npmConfigHook
|
|
|
|
source ${npmHooks.npmConfigHook}/nix-support/setup-hook
|
|
|
|
npmRoot=pagefind_web_js npmDeps=$npmDeps_web_js npmConfigHook
|
|
|
|
npmRoot=pagefind_ui/default npmDeps=$npmDeps_ui_default npmConfigHook
|
|
|
|
npmRoot=pagefind_ui/modular npmDeps=$npmDeps_ui_modular npmConfigHook
|
|
|
|
)
|
2024-04-21 15:54:59 +00:00
|
|
|
(
|
|
|
|
cd pagefind_web
|
|
|
|
cargoDeps=$cargoDeps_web cargoSetupPostUnpackHook
|
|
|
|
cargoDeps=$cargoDeps_web cargoSetupPostPatchHook
|
|
|
|
)
|
2023-10-09 19:29:22 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
binaryen
|
|
|
|
gzip
|
|
|
|
nodejs
|
2024-01-13 08:15:51 +00:00
|
|
|
rustc
|
|
|
|
rustc.llvmPackages.lld
|
2024-04-21 15:54:59 +00:00
|
|
|
wasm-bindgen-92
|
2023-10-09 19:29:22 +00:00
|
|
|
wasm-pack
|
|
|
|
];
|
|
|
|
|
|
|
|
# build wasm and js assets
|
|
|
|
# based on "test-and-build" in https://github.com/CloudCannon/pagefind/blob/main/.github/workflows/release.yml
|
|
|
|
preBuild = ''
|
|
|
|
export HOME=$(mktemp -d)
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
echo entering pagefind_web_js...
|
2023-10-09 19:29:22 +00:00
|
|
|
(
|
|
|
|
cd pagefind_web_js
|
|
|
|
npm run build-coupled
|
|
|
|
)
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
echo entering pagefind_web...
|
2023-10-09 19:29:22 +00:00
|
|
|
(
|
|
|
|
cd pagefind_web
|
|
|
|
bash ./local_build.sh
|
|
|
|
)
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
echo entering pagefind_ui/default...
|
2023-10-09 19:29:22 +00:00
|
|
|
(
|
|
|
|
cd pagefind_ui/default
|
|
|
|
npm run build
|
|
|
|
)
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
echo entering pagefind_ui/modular...
|
2023-10-09 19:29:22 +00:00
|
|
|
(
|
|
|
|
cd pagefind_ui/modular
|
|
|
|
npm run build
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildFeatures = [ "extended" ];
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Generate low-bandwidth search index for your static website";
|
|
|
|
homepage = "https://pagefind.app/";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ pbsds ];
|
|
|
|
platforms = platforms.unix;
|
2024-02-29 20:09:43 +00:00
|
|
|
mainProgram = "pagefind";
|
2023-10-09 19:29:22 +00:00
|
|
|
};
|
|
|
|
}
|