forked from nikkuss/pkgs
fix(grimoire): electron 41 with sqlite3 patch
This commit is contained in:
@@ -9,14 +9,15 @@
|
||||
gnumake,
|
||||
pkg-config,
|
||||
makeWrapper,
|
||||
electron_40,
|
||||
electron_41,
|
||||
vpkmerge,
|
||||
sqlite,
|
||||
callPackage,
|
||||
makeDesktopItem,
|
||||
copyDesktopItems,
|
||||
}: let
|
||||
sources = callPackage ../../../../_sources/generated.nix {};
|
||||
}:
|
||||
let
|
||||
sources = callPackage ../../../../_sources/generated.nix { };
|
||||
|
||||
src = sources.grimoire.src;
|
||||
version = src.rev;
|
||||
@@ -32,114 +33,116 @@
|
||||
pnpmDeps = pnpm.fetchDeps {
|
||||
pname = "grimoire";
|
||||
inherit version src;
|
||||
fetcherVersion = 3;
|
||||
hash = "sha256-X7KLUag9HPHVit0l/tA3BxQZ2/Cj0A5KiG4Oevx2268=";
|
||||
fetcherVersion = 4;
|
||||
hash = "sha256-Mqvvemc3oDCiuY/UnDOc73P+dLqMEFnwQotodVhrPao=";
|
||||
# hash = lib.fakeHash;
|
||||
};
|
||||
|
||||
desktopItem = makeDesktopItem {
|
||||
name = "grimoire";
|
||||
exec = "grimoire %u";
|
||||
desktopName = "Grimoire";
|
||||
categories = ["Utility"];
|
||||
mimeTypes = ["x-scheme-handler/grimoire"];
|
||||
categories = [ "Utility" ];
|
||||
mimeTypes = [ "x-scheme-handler/grimoire" ];
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "grimoire";
|
||||
inherit version src;
|
||||
stdenv.mkDerivation {
|
||||
pname = "grimoire";
|
||||
inherit version src;
|
||||
|
||||
nativeBuildInputs = [
|
||||
nodejs_22
|
||||
pnpm
|
||||
pnpm.configHook
|
||||
python3
|
||||
gcc
|
||||
gnumake
|
||||
pkg-config
|
||||
makeWrapper
|
||||
electron_40
|
||||
copyDesktopItems
|
||||
];
|
||||
nativeBuildInputs = [
|
||||
nodejs_22
|
||||
pnpm
|
||||
pnpm.configHook
|
||||
python3
|
||||
gcc
|
||||
gnumake
|
||||
pkg-config
|
||||
makeWrapper
|
||||
electron_41
|
||||
copyDesktopItems
|
||||
];
|
||||
|
||||
desktopItems = [desktopItem];
|
||||
desktopItems = [ desktopItem ];
|
||||
|
||||
buildInputs = [
|
||||
sqlite
|
||||
];
|
||||
buildInputs = [
|
||||
sqlite
|
||||
];
|
||||
|
||||
inherit pnpmDeps;
|
||||
inherit pnpmDeps;
|
||||
|
||||
env = {
|
||||
GRIMOIRE_SOCIAL_BASE_URL = "https://grimoire-social.slusheliott.workers.dev";
|
||||
# electron-builder must not try to fetch an Electron binary over the
|
||||
# network; we hand it the Nix one via --config.electronDist below.
|
||||
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
||||
};
|
||||
env = {
|
||||
GRIMOIRE_SOCIAL_BASE_URL = "https://grimoire-social.slusheliott.workers.dev";
|
||||
# electron-builder must not try to fetch an Electron binary over the
|
||||
# network; we hand it the Nix one via --config.electronDist below.
|
||||
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
cp -r ${grimoire-social-src} ../grimoire-social
|
||||
chmod -R u+w ../grimoire-social
|
||||
postPatch = ''
|
||||
cp -r ${grimoire-social-src} ../grimoire-social
|
||||
chmod -R u+w ../grimoire-social
|
||||
|
||||
mkdir -p resources/vpkmerge
|
||||
cp ${vpkmerge}/bin/vpkmerge resources/vpkmerge/vpkmerge-linux-x86_64
|
||||
chmod +x resources/vpkmerge/vpkmerge-linux-x86_64
|
||||
'';
|
||||
mkdir -p resources/vpkmerge
|
||||
cp ${vpkmerge}/bin/vpkmerge resources/vpkmerge/vpkmerge-linux-x86_64
|
||||
chmod +x resources/vpkmerge/vpkmerge-linux-x86_64
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
mkdir -p ../grimoire-social/node_modules
|
||||
ln -sfn "$(realpath node_modules/zod)" ../grimoire-social/node_modules/zod
|
||||
mkdir -p ../grimoire-social/node_modules
|
||||
ln -sfn "$(realpath node_modules/zod)" ../grimoire-social/node_modules/zod
|
||||
|
||||
# Rebuild the better-sqlite3 native addon against the Electron ABI. We do
|
||||
# this ourselves (and disable electron-builder's own rebuild below) so no
|
||||
# network fetch of Electron headers is needed inside the sandbox.
|
||||
(
|
||||
cd node_modules/better-sqlite3
|
||||
HOME="$TMPDIR" node \
|
||||
"${nodejs_22}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" \
|
||||
rebuild \
|
||||
--nodedir="${electron_40.headers}"
|
||||
)
|
||||
# Rebuild the better-sqlite3 native addon against the Electron ABI. We do
|
||||
# this ourselves (and disable electron-builder's own rebuild below) so no
|
||||
# network fetch of Electron headers is needed inside the sandbox.
|
||||
(
|
||||
cd node_modules/better-sqlite3
|
||||
patch -p1 < ${./patches/better-sqlite3-thistogetthis.patch}
|
||||
HOME="$TMPDIR" node \
|
||||
"${nodejs_22}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" \
|
||||
rebuild \
|
||||
--nodedir="${electron_41.headers}"
|
||||
)
|
||||
|
||||
# Package the app the same way upstream CI does (release.yml):
|
||||
# `electron-vite build && electron-builder`. We stop at the unpacked
|
||||
# `--dir` output instead of building AppImage/deb installers, then wrap
|
||||
# the Nix Electron around the produced app.asar. Building through
|
||||
# electron-builder (rather than launching Electron on the raw dist/)
|
||||
# makes `app.isPackaged` true, which is what disables the dev-only
|
||||
# DevTools auto-open and the dev vpkmerge lookup path.
|
||||
export HOME="$TMPDIR"
|
||||
pnpm exec electron-vite build
|
||||
pnpm exec electron-builder --linux dir \
|
||||
--config.npmRebuild=false \
|
||||
--config.electronDist=${electron_40.dist} \
|
||||
--config.electronVersion=${electron_40.version}
|
||||
# Package the app the same way upstream CI does (release.yml):
|
||||
# `electron-vite build && electron-builder`. We stop at the unpacked
|
||||
# `--dir` output instead of building AppImage/deb installers, then wrap
|
||||
# the Nix Electron around the produced app.asar. Building through
|
||||
# electron-builder (rather than launching Electron on the raw dist/)
|
||||
# makes `app.isPackaged` true, which is what disables the dev-only
|
||||
# DevTools auto-open and the dev vpkmerge lookup path.
|
||||
export HOME="$TMPDIR"
|
||||
pnpm exec electron-vite build
|
||||
pnpm exec electron-builder --linux dir \
|
||||
--config.npmRebuild=false \
|
||||
--config.electronDist=${electron_41.dist} \
|
||||
--config.electronVersion=${electron_41.version}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/lib/grimoire
|
||||
# electron-builder emits the packaged app (app.asar, app.asar.unpacked,
|
||||
# and extraResources such as vpkmerge) under release/linux-unpacked/resources.
|
||||
cp -r release/linux-unpacked/resources $out/lib/grimoire/resources
|
||||
mkdir -p $out/lib/grimoire
|
||||
# electron-builder emits the packaged app (app.asar, app.asar.unpacked,
|
||||
# and extraResources such as vpkmerge) under release/linux-unpacked/resources.
|
||||
cp -r release/linux-unpacked/resources $out/lib/grimoire/resources
|
||||
|
||||
# Launch the Nix Electron against the packaged asar. process.resourcesPath
|
||||
# resolves to the directory holding app.asar, so the bundled vpkmerge at
|
||||
# resources/vpkmerge/ is found at runtime.
|
||||
mkdir -p $out/bin
|
||||
makeWrapper ${electron_40}/bin/electron $out/bin/grimoire \
|
||||
--add-flags "$out/lib/grimoire/resources/app.asar" \
|
||||
--set NODE_ENV production
|
||||
# Launch the Nix Electron against the packaged asar. process.resourcesPath
|
||||
# resolves to the directory holding app.asar, so the bundled vpkmerge at
|
||||
# resources/vpkmerge/ is found at runtime.
|
||||
mkdir -p $out/bin
|
||||
makeWrapper ${electron_41}/bin/electron $out/bin/grimoire \
|
||||
--add-flags "$out/lib/grimoire/resources/app.asar" \
|
||||
--set NODE_ENV production
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Grimoire — Electron-based mod manager";
|
||||
platforms = ["x86_64-linux"];
|
||||
};
|
||||
}
|
||||
meta = {
|
||||
description = "Grimoire — Electron-based mod manager";
|
||||
platforms = [ "x86_64-linux" ];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
--- a/src/util/macros.cpp 2026-07-20 13:25:03.226579751 +0100
|
||||
+++ b/src/util/macros.cpp 2026-07-20 13:25:43.980692531 +0100
|
||||
@@ -11,6 +11,19 @@
|
||||
#define GET_PROTOTYPE(obj) ((obj)->GetPrototype())
|
||||
#endif
|
||||
|
||||
+// PropertyCallbackInfo::This() and Holder() were removed; use HolderV2().
|
||||
+// Tracking bug for V8 API removals: http://crbug.com/333672197
|
||||
+// V8 head has since restored Holder() and deprecated HolderV2():
|
||||
+// https://chromium.googlesource.com/v8/v8/+/main/include/v8-function-callback.h
|
||||
+// V8_INLINE Local<Object> Holder() const;
|
||||
+// V8_DEPRECATE_SOON("Use Holder().")
|
||||
+// V8_INLINE Local<Object> HolderV2() const;
|
||||
+#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >= 13
|
||||
+#define PROPERTY_HOLDER(info) (info).HolderV2()
|
||||
+#else
|
||||
+#define PROPERTY_HOLDER(info) (info).This()
|
||||
+#endif
|
||||
+
|
||||
#define EasyIsolate v8::Isolate* isolate = v8::Isolate::GetCurrent()
|
||||
#define OnlyIsolate info.GetIsolate()
|
||||
#define OnlyContext isolate->GetCurrentContext()
|
||||
--- a/src/objects/database.cpp 2026-07-20 13:25:03.229579774 +0100
|
||||
+++ b/src/objects/database.cpp 2026-07-20 13:25:52.605028002 +0100
|
||||
@@ -408,10 +408,10 @@
|
||||
}
|
||||
|
||||
NODE_GETTER(Database::JS_open) {
|
||||
- info.GetReturnValue().Set(Unwrap<Database>(info.This())->open);
|
||||
+ info.GetReturnValue().Set(Unwrap<Database>(PROPERTY_HOLDER(info))->open);
|
||||
}
|
||||
|
||||
NODE_GETTER(Database::JS_inTransaction) {
|
||||
- Database* db = Unwrap<Database>(info.This());
|
||||
+ Database* db = Unwrap<Database>(PROPERTY_HOLDER(info));
|
||||
info.GetReturnValue().Set(db->open && !static_cast<bool>(sqlite3_get_autocommit(db->db_handle)));
|
||||
}
|
||||
--- a/src/objects/statement.cpp 2026-07-20 13:25:03.231579789 +0100
|
||||
+++ b/src/objects/statement.cpp 2026-07-20 13:25:52.606984847 +0100
|
||||
@@ -378,6 +378,6 @@
|
||||
}
|
||||
|
||||
NODE_GETTER(Statement::JS_busy) {
|
||||
- Statement* stmt = Unwrap<Statement>(info.This());
|
||||
+ Statement* stmt = Unwrap<Statement>(PROPERTY_HOLDER(info));
|
||||
info.GetReturnValue().Set(stmt->alive && stmt->locked);
|
||||
}
|
||||
Reference in New Issue
Block a user