1
0
Fork 0

Add pagefind via PR patches

This commit is contained in:
Tim Van Baak 2023-09-16 17:24:51 -07:00
parent d5104157ad
commit 75a860a95a
4 changed files with 311 additions and 1 deletions

View File

@ -3,7 +3,17 @@
outputs = { self, nixpkgs }: let outputs = { self, nixpkgs }: let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system}; patched = (import nixpkgs { inherit system; }).applyPatches {
name = "nixpkgs+247773";
src = nixpkgs;
patches = [
./patches/b6910512a0789390af9db312ee8f08665bd662ab.patch
./patches/f23952856444fe39fad622a0db9eae55cd0f6fe8.patch
./patches/095afd88c41f08cb37e9cd67429baaa8d02e2d6f.patch
];
};
pkgs = import patched { inherit system; };
#pkgs = nixpkgs.legacyPackages.${system};
pyenv = pkgs.python3.withPackages (pypkgs: [ pyenv = pkgs.python3.withPackages (pypkgs: [
pypkgs.markdown pypkgs.markdown
pypkgs.beautifulsoup4 pypkgs.beautifulsoup4
@ -15,6 +25,7 @@
pyenv pyenv
pkgs.entr pkgs.entr
pkgs.rsync pkgs.rsync
pkgs.pagefind
]; ];
}; };
}; };

View File

@ -0,0 +1,140 @@
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 { };

View File

@ -0,0 +1,77 @@
From b6910512a0789390af9db312ee8f08665bd662ab Mon Sep 17 00:00:00 2001
From: Joe Neeman <joeneeman@gmail.com>
Date: Mon, 15 May 2023 12:36:46 -0500
Subject: [PATCH] wasm-bindgen-cli: 0.2.84 -> 0.2.87
Also allow overriding the version
---
.../tools/wasm-bindgen-cli/default.nix | 15 +++++++--------
pkgs/servers/ldap/lldap/default.nix | 8 +++++++-
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/pkgs/development/tools/wasm-bindgen-cli/default.nix b/pkgs/development/tools/wasm-bindgen-cli/default.nix
index ec336d422ab162..d7b6aba2a2a3a5 100644
--- a/pkgs/development/tools/wasm-bindgen-cli/default.nix
+++ b/pkgs/development/tools/wasm-bindgen-cli/default.nix
@@ -7,28 +7,27 @@
, stdenv
, curl
, Security
-, runCommand
+, version ? "0.2.87"
+, hash ? "sha256-0u9bl+FkXEK2b54n7/l9JOCtKo+pb42GF9E1EnAUQa0="
+, cargoHash ? "sha256-AsZBtE2qHJqQtuCt/wCAgOoxYMfvDh8IzBPAOkYSYko="
}:
rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
- version = "0.2.84";
+ inherit version hash cargoHash;
src = fetchCrate {
- inherit pname version;
- sha256 = "sha256-0rK+Yx4/Jy44Fw5VwJ3tG243ZsyOIBBehYU54XP/JGk=";
+ inherit pname version hash;
};
- cargoSha256 = "sha256-vcpxcRlW1OKoD64owFF6mkxSqmNrvY+y3Ckn5UwEQ50=";
-
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [ curl Security ];
nativeCheckInputs = [ nodejs ];
- # other tests require it to be ran in the wasm-bindgen monorepo
- cargoTestFlags = [ "--test=interface-types" ];
+ # tests require it to be ran in the wasm-bindgen monorepo
+ doCheck = false;
meta = with lib; {
homepage = "https://rustwasm.github.io/docs/wasm-bindgen/";
diff --git a/pkgs/servers/ldap/lldap/default.nix b/pkgs/servers/ldap/lldap/default.nix
index 1948ca015dda83..93bf09add84905 100644
--- a/pkgs/servers/ldap/lldap/default.nix
+++ b/pkgs/servers/ldap/lldap/default.nix
@@ -32,6 +32,12 @@ let
configureFlags = attrs.configureFlags ++ ["--set=build.docs=false"];
});
+ wasm-bindgen-84 = wasm-bindgen-cli.override {
+ version = "0.2.84";
+ hash = "sha256-0rK+Yx4/Jy44Fw5VwJ3tG243ZsyOIBBehYU54XP/JGk=";
+ cargoHash = "sha256-vcpxcRlW1OKoD64owFF6mkxSqmNrvY+y3Ckn5UwEQ50=";
+ };
+
commonDerivationAttrs = rec {
pname = "lldap";
version = "0.4.3";
@@ -65,7 +71,7 @@ let
pname = commonDerivationAttrs.pname + "-frontend";
nativeBuildInputs = [
- wasm-pack wasm-bindgen-cli binaryen which rustc-wasm rustc-wasm.llvmPackages.lld
+ wasm-pack wasm-bindgen-84 binaryen which rustc-wasm rustc-wasm.llvmPackages.lld
];
buildPhase = ''

View File

@ -0,0 +1,82 @@
From f23952856444fe39fad622a0db9eae55cd0f6fe8 Mon Sep 17 00:00:00 2001
From: Peder Bergebakken Sundt <pbsds@hotmail.com>
Date: Mon, 7 Aug 2023 19:00:05 +0200
Subject: [PATCH] rustc-wasm32: init at 1.70.0
---
pkgs/servers/ldap/lldap/default.nix | 20 ++------------------
pkgs/top-level/all-packages.nix | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/pkgs/servers/ldap/lldap/default.nix b/pkgs/servers/ldap/lldap/default.nix
index 44678a71db1ea..3527f33f060dc 100644
--- a/pkgs/servers/ldap/lldap/default.nix
+++ b/pkgs/servers/ldap/lldap/default.nix
@@ -7,6 +7,7 @@
, nixosTests
, rustPlatform
, rustc
+, rustc-wasm32
, stdenv
, wasm-bindgen-cli
, wasm-pack
@@ -15,23 +16,6 @@
let
- # replace with upstream wasm rustc, after resolution of
- # https://github.com/NixOS/nixpkgs/issues/89426
- rustc-wasm = (rustc.override {
- stdenv = stdenv.override {
- targetPlatform = stdenv.targetPlatform // {
- parsed = {
- cpu.name = "wasm32";
- vendor.name = "unknown";
- kernel.name = "unknown";
- abi.name = "unknown";
- };
- };
- };
- }).overrideAttrs (attrs: {
- configureFlags = attrs.configureFlags ++ ["--set=build.docs=false"];
- });
-
wasm-bindgen-84 = wasm-bindgen-cli.override {
version = "0.2.84";
hash = "sha256-0rK+Yx4/Jy44Fw5VwJ3tG243ZsyOIBBehYU54XP/JGk=";
@@ -71,7 +55,7 @@ let
pname = commonDerivationAttrs.pname + "-frontend";
nativeBuildInputs = [
- wasm-pack wasm-bindgen-84 binaryen which rustc-wasm rustc-wasm.llvmPackages.lld
+ wasm-pack wasm-bindgen-84 binaryen which rustc-wasm32 rustc-wasm32.llvmPackages.lld
];
buildPhase = ''
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index b9bb66eb682fa..8e9cddabc6fa3 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -16864,6 +16864,22 @@ with pkgs;
inherit (rustPackages) cargo cargo-auditable cargo-auditable-cargo-wrapper clippy rustc rustPlatform;
+ # https://github.com/NixOS/nixpkgs/issues/89426
+ rustc-wasm32 = (rustc.override {
+ stdenv = stdenv.override {
+ targetPlatform = stdenv.targetPlatform // {
+ parsed = {
+ cpu.name = "wasm32";
+ vendor.name = "unknown";
+ kernel.name = "unknown";
+ abi.name = "unknown";
+ };
+ };
+ };
+ }).overrideAttrs (old: {
+ configureFlags = old.configureFlags ++ ["--set=build.docs=false"];
+ });
+
makeRustPlatform = callPackage ../development/compilers/rust/make-rust-platform.nix { };
buildRustCrate = callPackage ../build-support/rust/build-rust-crate { };