NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.09k stars 14.14k forks source link

abricotine #148152

Closed schlichtanders closed 2 years ago

schlichtanders commented 2 years ago

Project description Abricotine is an open-source markdown editor built for desktop.

Desktop markdown editor with inline preview

Metadata

WolfangAukang commented 2 years ago

There is a set of issues with this application, unfortunately:

[
  [Error: EACCES: permission denied, mkdir '/home/bjorn/.config/Abricotine/app/dict/da_DK'] {
    errno: -13,
    code: 'EACCES',
    syscall: 'mkdir',
    path: '/home/bjorn/.config/Abricotine/app/dict/da_DK'
  },
  [Error: EACCES: permission denied, mkdir '/home/bjorn/.config/Abricotine/app/dict/de_DE'] {
    errno: -13,
    code: 'EACCES',
    syscall: 'mkdir',
    path: '/home/bjorn/.config/Abricotine/app/dict/de_DE'
  },
  [Error: EACCES: permission denied, mkdir '/home/bjorn/.config/Abricotine/app/dict/en_US'] {
    errno: -13,
    code: 'EACCES',
    syscall: 'mkdir',
    path: '/home/bjorn/.config/Abricotine/app/dict/en_US'
  },
  [Error: EACCES: permission denied, mkdir '/home/bjorn/.config/Abricotine/app/dict/es'] {
    errno: -13,
    code: 'EACCES',
    syscall: 'mkdir',
    path: '/home/bjorn/.config/Abricotine/app/dict/es'
  },
... (There is more)

And with that, you get the error

·> ./result/bin/abricotine
Error while loading localization data: Error: ENOENT: no such file or directory, open '/home/bjorn/.config/Abricotine/app/lang/en.json'

I can try to replicate the directories at the beginning, but who knows if that would work, plus it would make the process more cumbersome.

WolfangAukang commented 2 years ago

Regarding the permission issue, here are:

Let me explain what happens:

schlichtanders commented 2 years ago

Hi @WolfangAukang thank you very much for explaining the difficulty of the situation. Very impressive how a package can be setup such that it is impossible for it to be build on NixOS.

What would be the hacky workaround to at least try it out on NixOS (within an overlay or nix-shell or whatever)?

WolfangAukang commented 2 years ago

What would be the hacky workaround to at least try it out on NixOS (within an overlay or nix-shell or whatever)?

Right now, I've created this script that verifies if the config directory is not created:

set -euo pipefail

CONFIG_PATH="$HOME/.config/Abricotine"

if [ ! -d "$CONFIG_PATH" ]; then SOURCE_SUBPATH="/opt/abricotine/resources/app.asar.unpacked/default" mkdir -p "$CONFIG_PATH/app" cp -R "$1$SOURCE_SUBPATH/dict" "$CONFIG_PATH/app/dict" cp -R "$1$SOURCE_SUBPATH/lang" "$CONFIG_PATH/app/lang" cp -R "$1$SOURCE_SUBPATH/templates" "$CONFIG_PATH/app/templates" cp -R "$1$SOURCE_SUBPATH/themes" "$CONFIG_PATH/app/themes" chmod -R u+w "$CONFIG_PATH/app/" echo "Executed" else if [ ! -w "$CONFIG_PATH/app/dict" ]; then chmod -R u+w "$CONFIG_PATH/app/dict" fi if [ ! -w "$CONFIG_PATH/app/lang" ]; then chmod -R u+w "$CONFIG_PATH/app/lang" fi if [ ! -w "$CONFIG_PATH/app/templates" ]; then chmod -R u+w "$CONFIG_PATH/app/templates" fi if [ ! -w "$CONFIG_PATH/app/themes" ]; then chmod -R u+w "$CONFIG_PATH/app/themes" fi fi



The main idea is that when you create a wrapper around the original binary (`makeWrapper`), you can set an option to run a certain command before the application, like [here](https://github.com/NixOS/nixpkgs/blob/b25f4f082dfecfd79cefbec489c7fe585d136f78/pkgs/applications/networking/mailreaders/tutanota-desktop/default.nix#L48). As we definitely need to use Electron, `makeWrapper` is a must step for packaging this.

Now, the idea is connecting this script and run it before running Abricotine. That would solve the issue. Now it is checking the best way to do that.
WolfangAukang commented 2 years ago

Ready, I was able to package it. Let's see how it goes.

schlichtanders commented 2 years ago

Very impressive. Thank you so much @WolfangAukang

I looked over the code and am able to understand what is going on :). Still quite some steps away from my personal skills - I would wish to be able to package this myself at some time - the config script with set -euo pipefail is new to me (really good to know), the copyDesktopItems (nice one!), the electron runner, and some parts here and there. Looks very concise altogether.

Thank you. Looking forward to try abricotine and also I learned a lot.

WolfangAukang commented 2 years ago

@schlichtanders Unfortunately, Nixpkgs dropped support to Electron 6. As the application hasn't brought up newer versions, the only option would be asking the dev for newer versions and see if they can upgrade the support to a newer Electron version.

WolfangAukang commented 2 years ago

The developer decided to not continue with the project. I will close the PR as porting this wouldn't be accepted by the commiters, but in case someone decides to fork it and improve the Electron support, I can definitely port it.