Skip to content

Instantly share code, notes, and snippets.

@pokon548
Created October 30, 2023 09:20
Show Gist options
  • Save pokon548/7a5ca47d6007c70d453b865bdc91dd65 to your computer and use it in GitHub Desktop.
Save pokon548/7a5ca47d6007c70d453b865bdc91dd65 to your computer and use it in GitHub Desktop.
fixup! magic workaround for permission issue
{ lib, stdenv, fetchurl, appimageTools, makeWrapper, electron_25, autoPatchelfHook, coreutils, jq }:
stdenv.mkDerivation rec {
pname = "siyuan-note";
version = "2.10.12";
src = fetchurl {
url = "https://github.com/siyuan-note/siyuan/releases/download/v${version}/siyuan-${version}-linux.AppImage";
hash = "sha256-G5lofIIkmm0DJLGc6MqBuwckCkdPA8FLs0qFH9bEYeU=";
};
appimageContents = appimageTools.extractType2 {
name = "${pname}-${version}";
inherit src;
};
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
nativeBuildInputs = [ makeWrapper autoPatchelfHook ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/share/${pname} $out/share/applications
cp -a ${appimageContents}/{locales,resources} $out/share/${pname}
cp -a ${appimageContents}/siyuan.desktop $out/share/applications/${pname}.desktop
substituteInPlace $out/share/applications/${pname}.desktop \
--replace 'Exec=AppRun' 'Exec=${pname}'
runHook postInstall
'';
postFixup = ''
wrapProgram $out/share/siyuan-note/resources/kernel/SiYuan-Kernel \
--set PATH ${lib.makeBinPath [ coreutils jq ]}
sed -i '3i readarray arr < <(jq -r ".[]" ~/.config/siyuan/workspace.json)' "$out/share/siyuan-note/resources/kernel/SiYuan-Kernel"
sed -i '4i for i in $\{arr[@]}; do chmod -R +w $i; done' "$out/share/siyuan-note/resources/kernel/SiYuan-Kernel"
makeWrapper ${electron_25}/bin/electron $out/bin/${pname} \
--add-flags "$out/share/siyuan-note/resources/app \"\$@\"" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
'';
meta = with lib; {
homepage = "https://b3log.org/siyuan";
description = "A privacy-first, self-hosted, fully open source personal knowledge management software, written in typescript and golang.";
platforms = [ "x86_64-linux" ];
license = licenses.agpl3Only;
maintainers = with maintainers; [ abd-liac ];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment