siyuan: migrate to use pnpm and add missed kernel info

This commit is contained in:
TomaSajt 2024-06-06 20:07:37 +02:00
parent b9d0607ec1
commit b52c9d3125
No known key found for this signature in database
GPG Key ID: F011163C050122A1
2 changed files with 45 additions and 7781 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,34 @@
{
lib,
stdenv,
fetchFromGitHub,
buildGoModule,
buildNpmPackage,
substituteAll,
pandoc,
nodejs,
pnpm_9,
electron,
makeWrapper,
}:
buildNpmPackage rec {
let
pnpm = pnpm_9;
in
stdenv.mkDerivation (finalAttrs: {
pname = "siyuan";
version = "3.0.11";
src = fetchFromGitHub {
owner = "siyuan-note";
repo = "siyuan";
rev = "v${version}";
rev = "v${finalAttrs.version}";
hash = "sha256-s82g5os944us85V2TBnm+HNd37vVzNjaOJYrbBrgLSI=";
};
kernel = buildGoModule {
name = "${pname}-${version}-kernel";
inherit src;
sourceRoot = "${src.name}/kernel";
name = "${finalAttrs.pname}-${finalAttrs.version}-kernel";
inherit (finalAttrs) src;
sourceRoot = "${finalAttrs.src.name}/kernel";
vendorHash = "sha256-onZBrw0fDsjqXgQF06C40ArxNmsbFDIwD57fJ0jB0ls=";
patches = [
@ -40,24 +46,42 @@ buildNpmPackage rec {
substituteInPlace vendor/github.com/88250/gulu/file.go \
--replace-fail "os.Chmod(dest, sourceinfo.Mode())" "os.Chmod(dest, 0644)"
'';
# Set flags and tags as per upstream's Dockerfile
ldflags = [
"-s"
"-w"
"-X"
"github.com/siyuan-note/siyuan/kernel/util.Mode=prod"
];
tags = [ "fts5" ];
};
sourceRoot = "${src.name}/app";
nativeBuildInputs = [
nodejs
pnpm.configHook
makeWrapper
];
postPatch = ''
ln -s ${./package-lock.json} package-lock.json
# for some reason the default page is broken, use the redirection link automatically
substituteInPlace electron/main.js \
--replace-fail ' "/stage/build/app/index.html?v=" + new Date().getTime()' '"/stage/build/desktop"'
'';
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs)
pname
version
src
sourceRoot
;
hash = "sha256-9+4pAEka6+tymkh6calacjPbcJ++HuNTA6qBEAQ7zPg=";
};
npmDepsHash = "sha256-Yv/iOCyry3CNeKPxS206Y5y5mvzPU873PJdi0UQkVLs=";
sourceRoot = "${finalAttrs.src.name}/app";
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
npmBuildScript = "build:desktop";
buildPhase = ''
runHook preBuild
pnpm build
postBuild = ''
substituteInPlace electron-builder-linux.yml \
--replace-fail '- target: "AppImage"' "" \
--replace-fail '- target: "tar.gz"' '- target: "dir"'
@ -67,7 +91,9 @@ buildNpmPackage rec {
-e 1i'electronVersion: ${electron.version}' \
-i electron-builder-linux.yml
npm run dist-linux
pnpm run dist-linux
runHook postBuild
'';
installPhase = ''
@ -77,7 +103,7 @@ buildNpmPackage rec {
cp -r build/*-unpacked/{locales,resources{,.pak}} $out/share/siyuan
mkdir $out/share/siyuan/resources/kernel
ln -s ${kernel}/bin/kernel $out/share/siyuan/resources/kernel/SiYuan-Kernel
ln -s ${finalAttrs.kernel}/bin/kernel $out/share/siyuan/resources/kernel/SiYuan-Kernel
makeWrapper ${lib.getExe electron} $out/bin/siyuan \
--chdir $out/share/siyuan/resources \
@ -97,4 +123,4 @@ buildNpmPackage rec {
maintainers = with lib.maintainers; [ tomasajt ];
platforms = lib.platforms.linux;
};
}
})