From 19094e7d7baa724d5d3db19e69558ae389c89633 Mon Sep 17 00:00:00 2001 From: Moraxyc Date: Sat, 23 May 2026 06:32:23 -0700 Subject: [PATCH 1/3] siyuan: support darwin --- pkgs/by-name/si/siyuan/package.nix | 43 +++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/si/siyuan/package.nix b/pkgs/by-name/si/siyuan/package.nix index 6f3da143226b..2647e2cf6dd4 100644 --- a/pkgs/by-name/si/siyuan/package.nix +++ b/pkgs/by-name/si/siyuan/package.nix @@ -15,12 +15,15 @@ copyDesktopItems, nix-update-script, xdg-utils, + darwin, }: let platformIds = { "x86_64-linux" = "linux"; "aarch64-linux" = "linux-arm64"; + "x86_64-darwin" = "darwin"; + "aarch64-darwin" = "darwin-arm64"; }; platformId = platformIds.${stdenv.system} or (throw "Unsupported platform: ${stdenv.system}"); @@ -86,8 +89,13 @@ stdenv.mkDerivation (finalAttrs: { nodejs pnpmConfigHook pnpm_9 + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ makeWrapper copyDesktopItems + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + darwin.autoSignDarwinBinariesHook ]; pnpmDeps = fetchPnpmDeps { @@ -114,6 +122,9 @@ stdenv.mkDerivation (finalAttrs: { # link kernel into the correct starting place so that electron-builder can copy it to it's final location mkdir kernel-${platformId} ln -s ${finalAttrs.kernel}/bin/kernel kernel-${platformId}/SiYuan-Kernel + + cp -r ${electron.dist} electron-dist + chmod -R u+w electron-dist ''; buildPhase = '' @@ -121,19 +132,36 @@ stdenv.mkDerivation (finalAttrs: { pnpm build - npm exec electron-builder -- \ - --dir \ - --config electron-builder-${platformId}.yml \ - -c.electronDist=${electron.dist} \ - -c.electronVersion=${electron.version} + electronBuilderArgs=( + --dir + --config electron-builder-${platformId}.yml + -c.electronDist=electron-dist + -c.electronVersion=${electron.version} + -c.mac.identity=null + ) + + npm exec electron-builder -- "''${electronBuilderArgs[@]}" runHook postBuild ''; installPhase = '' runHook preInstall + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + mkdir -p $out/Applications $out/bin + cp -R build/mac*/*.app $out/Applications/SiYuan.app + + cat > $out/bin/siyuan << EOF + #!${stdenv.shell} + exec open -na "$out/Applications/SiYuan.app" --args "\$@" + EOF + chmod +x $out/bin/siyuan + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' mkdir -p $out/share/siyuan + cp -r build/*-unpacked/{locales,resources{,.pak}} $out/share/siyuan makeWrapper ${lib.getExe electron} $out/bin/siyuan \ @@ -145,11 +173,12 @@ stdenv.mkDerivation (finalAttrs: { --inherit-argv0 install -Dm644 src/assets/icon.svg $out/share/icons/hicolor/scalable/apps/siyuan.svg - + '' + + '' runHook postInstall ''; - desktopItems = [ desktopEntry ]; + desktopItems = lib.optionals stdenv.hostPlatform.isLinux [ desktopEntry ]; passthru = { inherit (finalAttrs.kernel) goModules; # this tricks nix-update into also updating the kernel goModules FOD From 982047257db8ec474f5c6175bc75126251e6f699 Mon Sep 17 00:00:00 2001 From: Moraxyc Date: Sat, 23 May 2026 06:34:22 -0700 Subject: [PATCH 2/3] siyuan: refactor --- pkgs/by-name/si/siyuan/package.nix | 54 ++++++++++++++---------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/pkgs/by-name/si/siyuan/package.nix b/pkgs/by-name/si/siyuan/package.nix index 2647e2cf6dd4..d1f89fc0c348 100644 --- a/pkgs/by-name/si/siyuan/package.nix +++ b/pkgs/by-name/si/siyuan/package.nix @@ -19,6 +19,10 @@ }: let + inherit (stdenv.hostPlatform) isLinux isDarwin system; + + pnpm = pnpm_9; + platformIds = { "x86_64-linux" = "linux"; "aarch64-linux" = "linux-arm64"; @@ -26,16 +30,7 @@ let "aarch64-darwin" = "darwin-arm64"; }; - platformId = platformIds.${stdenv.system} or (throw "Unsupported platform: ${stdenv.system}"); - - desktopEntry = makeDesktopItem { - name = "siyuan"; - desktopName = "SiYuan"; - comment = "Refactor your thinking"; - icon = "siyuan"; - exec = "siyuan %U"; - categories = [ "Utility" ]; - }; + platformId = platformIds.${system} or (throw "Unsupported platform: ${system}"); in stdenv.mkDerivation (finalAttrs: { pname = "siyuan"; @@ -72,9 +67,7 @@ stdenv.mkDerivation (finalAttrs: { # Set flags and tags as per upstream's Dockerfile ldflags = [ "-s" - "-w" - "-X" - "github.com/siyuan-note/siyuan/kernel/util.Mode=prod" + "-X 'github.com/siyuan-note/siyuan/kernel/util.Mode=prod'" ]; tags = [ "fts5" ]; }; @@ -88,13 +81,13 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ nodejs pnpmConfigHook - pnpm_9 + pnpm ] - ++ lib.optionals stdenv.hostPlatform.isLinux [ + ++ lib.optionals isLinux [ makeWrapper copyDesktopItems ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ + ++ lib.optionals isDarwin [ darwin.autoSignDarwinBinariesHook ]; @@ -106,7 +99,7 @@ stdenv.mkDerivation (finalAttrs: { sourceRoot postPatch ; - pnpm = pnpm_9; + inherit pnpm; fetcherVersion = 3; hash = "sha256-GAbP9H+c+JXymH0/vpeYOJrkkFJGVyKcpJYFeyRLSKc="; }; @@ -148,7 +141,7 @@ stdenv.mkDerivation (finalAttrs: { installPhase = '' runHook preInstall '' - + lib.optionalString stdenv.hostPlatform.isDarwin '' + + lib.optionalString isDarwin '' mkdir -p $out/Applications $out/bin cp -R build/mac*/*.app $out/Applications/SiYuan.app @@ -159,7 +152,7 @@ stdenv.mkDerivation (finalAttrs: { EOF chmod +x $out/bin/siyuan '' - + lib.optionalString stdenv.hostPlatform.isLinux '' + + lib.optionalString isLinux '' mkdir -p $out/share/siyuan cp -r build/*-unpacked/{locales,resources{,.pak}} $out/share/siyuan @@ -178,16 +171,21 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; - desktopItems = lib.optionals stdenv.hostPlatform.isLinux [ desktopEntry ]; + desktopItems = lib.optional isLinux (makeDesktopItem { + name = "siyuan"; + desktopName = "SiYuan"; + comment = "Refactor your thinking"; + icon = "siyuan"; + exec = "siyuan %U"; + categories = [ "Utility" ]; + }); - passthru = { - inherit (finalAttrs.kernel) goModules; # this tricks nix-update into also updating the kernel goModules FOD - updateScript = nix-update-script { - extraArgs = [ - "--version-regex" - "^v(\\d+\\.\\d+\\.\\d+)$" - ]; - }; + passthru.updateScript = nix-update-script { + extraArgs = [ + "--version-regex" + "^v(\\d+\\.\\d+\\.\\d+)$" + "--subpackage=kernel" + ]; }; meta = { From 062581ebdc8c71d5e1065aeb2005f9b19770fd32 Mon Sep 17 00:00:00 2001 From: Moraxyc Date: Sat, 23 May 2026 06:35:35 -0700 Subject: [PATCH 3/3] siyuan: switch to pnpm_10 --- pkgs/by-name/si/siyuan/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/si/siyuan/package.nix b/pkgs/by-name/si/siyuan/package.nix index d1f89fc0c348..88c6090f1809 100644 --- a/pkgs/by-name/si/siyuan/package.nix +++ b/pkgs/by-name/si/siyuan/package.nix @@ -6,7 +6,7 @@ replaceVars, pandoc, nodejs, - pnpm_9, + pnpm_10, fetchPnpmDeps, pnpmConfigHook, electron, @@ -21,7 +21,7 @@ let inherit (stdenv.hostPlatform) isLinux isDarwin system; - pnpm = pnpm_9; + pnpm = pnpm_10; platformIds = { "x86_64-linux" = "linux"; @@ -101,7 +101,7 @@ stdenv.mkDerivation (finalAttrs: { ; inherit pnpm; fetcherVersion = 3; - hash = "sha256-GAbP9H+c+JXymH0/vpeYOJrkkFJGVyKcpJYFeyRLSKc="; + hash = "sha256-M2Fdie0XK2Pck/fP7Djxb7XNAQXpJO2i2kSJrDj1G0E="; }; sourceRoot = "${finalAttrs.src.name}/app";