1
0
Fork 0
www/patches/095afd88c41f08cb37e9cd67429...

141 lines
3.8 KiB
Diff

From 095afd88c41f08cb37e9cd67429baaa8d02e2d6f Mon Sep 17 00:00:00 2001
From: Peder Bergebakken Sundt <pbsds@hotmail.com>
Date: Tue, 4 Jul 2023 02:07:17 +0200
Subject: [PATCH] pagefind: init at 1.0.2
---
pkgs/applications/misc/pagefind/default.nix | 110 ++++++++++++++++++++
pkgs/top-level/all-packages.nix | 2 +
2 files changed, 112 insertions(+)
create mode 100644 pkgs/applications/misc/pagefind/default.nix
diff --git a/pkgs/applications/misc/pagefind/default.nix b/pkgs/applications/misc/pagefind/default.nix
new file mode 100644
index 0000000000000..02bbd2e95e9b9
--- /dev/null
+++ b/pkgs/applications/misc/pagefind/default.nix
@@ -0,0 +1,110 @@
+{ lib
+, callPackage
+, rustPlatform
+, fetchFromGitHub
+, fetchNpmDeps
+, npmHooks
+, binaryen
+, gzip
+, nodejs
+, rustc-wasm32
+, wasm-bindgen-cli
+, wasm-pack
+}:
+
+let
+
+ wasm-bindgen-84 = wasm-bindgen-cli.override {
+ version = "0.2.84";
+ hash = "sha256-0rK+Yx4/Jy44Fw5VwJ3tG243ZsyOIBBehYU54XP/JGk=";
+ cargoHash = "sha256-vcpxcRlW1OKoD64owFF6mkxSqmNrvY+y3Ckn5UwEQ50=";
+ };
+
+in
+
+rustPlatform.buildRustPackage rec {
+ pname = "pagefind";
+ version = "1.0.2";
+
+ src = fetchFromGitHub {
+ owner = "cloudcannon";
+ repo = "pagefind";
+ rev = "refs/tags/v${version}";
+ hash = "sha256-hTEDTl9cjIwMkSzH0coRQwx9cXfx9W/dYLNV2ES+qA0=";
+ };
+
+ cargoHash = "sha256-J6gU4kT8callfy+4ecHPPAdMtj4xZ6qP1dNxaPzJNuc=";
+
+ env.npmDeps_web_js = fetchNpmDeps {
+ name = "npm-deps-web-js";
+ src = "${src}/pagefind_web_js";
+ hash = "sha256-pGE4lUFZ4dA++8kBklcMBoaN/1Z92dfOzQKhukbuEyc=";
+ };
+ 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=";
+ };
+
+ 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
+ )
+ '';
+
+ nativeBuildInputs = [
+ binaryen
+ gzip
+ nodejs
+ rustc-wasm32
+ rustc-wasm32.llvmPackages.lld
+ wasm-bindgen-84
+ 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 = ''
+ (
+ cd pagefind_web_js
+ npm run build-coupled
+ )
+
+ (
+ cd pagefind_web
+ export HOME=$(mktemp -d)
+ export RUSTFLAGS="-C linker=lld"
+ bash ./local_build.sh
+ )
+
+ (
+ cd pagefind_ui/default
+ npm run build
+ )
+
+ (
+ 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;
+ };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 8e9cddabc6fa3..bf3d6fec5ab2a 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -11534,6 +11534,8 @@ with pkgs;
PageEdit = libsForQt5.callPackage ../applications/office/PageEdit { };
+ pagefind = libsForQt5.callPackage ../applications/misc/pagefind { };
+
paging-calculator = callPackage ../development/tools/paging-calculator { };
pagmo2 = callPackage ../development/libraries/pagmo2 { };