2024-05-15 15:35:15 +00:00
|
|
|
{
|
|
|
|
lib,
|
2024-07-27 06:49:29 +00:00
|
|
|
stdenv,
|
2024-05-15 15:35:15 +00:00
|
|
|
fetchFromGitHub,
|
2024-09-26 11:04:55 +00:00
|
|
|
buildGo123Module,
|
2024-05-15 15:35:15 +00:00
|
|
|
substituteAll,
|
|
|
|
pandoc,
|
2024-07-27 06:49:29 +00:00
|
|
|
nodejs,
|
|
|
|
pnpm_9,
|
2024-05-15 15:35:15 +00:00
|
|
|
electron,
|
2024-07-27 06:49:29 +00:00
|
|
|
makeWrapper,
|
2024-09-19 14:19:46 +00:00
|
|
|
makeDesktopItem,
|
|
|
|
copyDesktopItems,
|
2024-09-26 11:04:55 +00:00
|
|
|
nix-update-script,
|
2024-05-15 15:35:15 +00:00
|
|
|
}:
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
let
|
|
|
|
pnpm = pnpm_9;
|
|
|
|
|
|
|
|
platformIds = {
|
|
|
|
"x86_64-linux" = "linux";
|
|
|
|
"aarch64-linux" = "linux-arm64";
|
|
|
|
};
|
|
|
|
|
|
|
|
platformId = platformIds.${stdenv.system} or (throw "Unsupported platform: ${stdenv.system}");
|
2024-09-19 14:19:46 +00:00
|
|
|
|
|
|
|
desktopEntry = makeDesktopItem {
|
|
|
|
name = "siyuan";
|
|
|
|
desktopName = "SiYuan";
|
|
|
|
comment = "Refactor your thinking";
|
|
|
|
icon = "siyuan";
|
|
|
|
exec = "siyuan %U";
|
|
|
|
categories = [ "Utility" ];
|
|
|
|
};
|
2024-07-27 06:49:29 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2024-05-15 15:35:15 +00:00
|
|
|
pname = "siyuan";
|
2024-09-26 11:04:55 +00:00
|
|
|
version = "3.1.6";
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "siyuan-note";
|
|
|
|
repo = "siyuan";
|
2024-07-27 06:49:29 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
2024-09-26 11:04:55 +00:00
|
|
|
hash = "sha256-xGxZ6xu8R/JoW4X+drEv943y1jah4ZijHB+RNN6hxig=";
|
2024-05-15 15:35:15 +00:00
|
|
|
};
|
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
kernel = buildGo123Module {
|
2024-07-27 06:49:29 +00:00
|
|
|
name = "${finalAttrs.pname}-${finalAttrs.version}-kernel";
|
|
|
|
inherit (finalAttrs) src;
|
|
|
|
sourceRoot = "${finalAttrs.src.name}/kernel";
|
2024-09-26 11:04:55 +00:00
|
|
|
vendorHash = "sha256-I57T4/J0pL8/GISi22H1lpE1gkduNXdINvuo+F3YnAs=";
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
(substituteAll {
|
|
|
|
src = ./set-pandoc-path.patch;
|
|
|
|
pandoc_path = lib.getExe pandoc;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
# this patch makes it so that file permissions are not kept when copying files using the gulu package
|
|
|
|
# this fixes a problem where it was copying files from the store and keeping their permissions
|
|
|
|
# hopefully this doesn't break other functionality
|
|
|
|
modPostBuild = ''
|
|
|
|
chmod +w vendor/github.com/88250/gulu
|
|
|
|
substituteInPlace vendor/github.com/88250/gulu/file.go \
|
|
|
|
--replace-fail "os.Chmod(dest, sourceinfo.Mode())" "os.Chmod(dest, 0644)"
|
|
|
|
'';
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
# Set flags and tags as per upstream's Dockerfile
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
|
|
|
"-X"
|
|
|
|
"github.com/siyuan-note/siyuan/kernel/util.Mode=prod"
|
|
|
|
];
|
|
|
|
tags = [ "fts5" ];
|
|
|
|
};
|
2024-05-15 15:35:15 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
nodejs
|
|
|
|
pnpm.configHook
|
|
|
|
makeWrapper
|
2024-09-19 14:19:46 +00:00
|
|
|
copyDesktopItems
|
2024-07-27 06:49:29 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
pnpmDeps = pnpm.fetchDeps {
|
|
|
|
inherit (finalAttrs)
|
|
|
|
pname
|
|
|
|
version
|
|
|
|
src
|
|
|
|
sourceRoot
|
|
|
|
;
|
2024-09-26 11:04:55 +00:00
|
|
|
hash = "sha256-3PdmCbaZZjnTCSpBcvG7nP+zTGamoY/ZXjay7c8Zx5w=";
|
2024-07-27 06:49:29 +00:00
|
|
|
};
|
2024-05-15 15:35:15 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
sourceRoot = "${finalAttrs.src.name}/app";
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
|
|
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
postConfigure = ''
|
|
|
|
# remove prebuilt pandoc archives
|
|
|
|
rm -r pandoc
|
|
|
|
|
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2024-05-15 15:35:15 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
pnpm build
|
2024-05-15 15:35:15 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
npm exec electron-builder -- \
|
|
|
|
--dir \
|
|
|
|
--config electron-builder-${platformId}.yml \
|
2024-09-19 14:19:46 +00:00
|
|
|
-c.electronDist=${electron.dist} \
|
2024-07-27 06:49:29 +00:00
|
|
|
-c.electronVersion=${electron.version}
|
2024-05-15 15:35:15 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
runHook postBuild
|
2024-05-15 15:35:15 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/share/siyuan
|
|
|
|
cp -r build/*-unpacked/{locales,resources{,.pak}} $out/share/siyuan
|
|
|
|
|
|
|
|
makeWrapper ${lib.getExe electron} $out/bin/siyuan \
|
|
|
|
--chdir $out/share/siyuan/resources \
|
|
|
|
--add-flags $out/share/siyuan/resources/app \
|
|
|
|
--set ELECTRON_FORCE_IS_PACKAGED 1 \
|
2024-09-19 14:19:46 +00:00
|
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime}}" \
|
2024-05-15 15:35:15 +00:00
|
|
|
--inherit-argv0
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
install -Dm644 src/assets/icon.svg $out/share/icons/hicolor/scalable/apps/siyuan.svg
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
desktopItems = [ desktopEntry ];
|
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
passthru = {
|
|
|
|
inherit (finalAttrs.kernel) goModules; # this tricks nix-update into also updating the kernel goModules FOD
|
|
|
|
updateScript = nix-update-script { };
|
|
|
|
};
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
meta = {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Privacy-first personal knowledge management system that supports complete offline usage, as well as end-to-end encrypted data sync";
|
2024-05-15 15:35:15 +00:00
|
|
|
homepage = "https://b3log.org/siyuan/";
|
|
|
|
license = lib.licenses.agpl3Plus;
|
|
|
|
mainProgram = "siyuan";
|
|
|
|
maintainers = with lib.maintainers; [ tomasajt ];
|
2024-07-27 06:49:29 +00:00
|
|
|
platforms = lib.attrNames platformIds;
|
2024-05-15 15:35:15 +00:00
|
|
|
};
|
2024-07-27 06:49:29 +00:00
|
|
|
})
|