typora: fix (#362036)

This commit is contained in:
Aleksana 2024-12-08 12:01:03 +08:00 committed by GitHub
commit e90ab5481b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,6 +16,7 @@
, expat
, alsa-lib
, buildFHSEnv
, writeTextFile
}:
let
@ -60,6 +61,7 @@ let
pango
cairo
mesa
libGL
expat
libxkbcommon
]) ++ (with pkgs.xorg; [
@ -73,10 +75,35 @@ let
libxcb
]);
runScript = ''
Typora $*
Typora "$@"
'';
};
launchScript = writeTextFile {
name = "typora-launcher";
executable = true;
text = ''
#!${stdenv.shell}
# Configuration directory setup
XDG_CONFIG_HOME=''${XDG_CONFIG_HOME:-~/.config}
TYPORA_CONFIG_DIR="$XDG_CONFIG_HOME/Typora"
TYPORA_DICT_DIR="$TYPORA_CONFIG_DIR/typora-dictionaries"
# Create config directories with proper permissions
mkdir -p "$TYPORA_DICT_DIR"
chmod 755 "$TYPORA_CONFIG_DIR"
chmod 755 "$TYPORA_DICT_DIR"
# Read user flags if they exist
if [ -f "$XDG_CONFIG_HOME/typora-flags.conf" ]; then
TYPORA_USER_FLAGS="$(sed 's/#.*//' "$XDG_CONFIG_HOME/typora-flags.conf" | tr '\n' ' ')"
fi
exec ${typoraFHS}/bin/typora-fhs "$@" $TYPORA_USER_FLAGS
'';
};
in stdenv.mkDerivation {
inherit pname version;
@ -87,7 +114,7 @@ in stdenv.mkDerivation {
installPhase = ''
runHook preInstall
mkdir -p $out/bin
ln -s ${typoraFHS}/bin/typora-fhs $out/bin/typora
ln -s ${launchScript} $out/bin/typora
ln -s ${typoraBase}/share/ $out
runHook postInstall
'';