terrastruct / d2-obsidian

The official D2 plugin for Obsidian. D2 is a modern diagram scripting language thats turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
217 stars 12 forks source link

Flatpak support #44

Open eruizc-dev opened 11 months ago

eruizc-dev commented 11 months ago

Flatpak is a package manager that installs applications in a sandbox, which is great for developers as they can package their applications with their dependencies without having them missing or conflicting with the dependencies of other applications but for extensions it may be painful as there is no way for users to install d2 package inside the sandbox. Even tho it is possible to share directories with the sandbox, common binary locations like /bin or /usr/bin are blacklisted and cannot be shared from the host to the sandbox.

The solution would be to use flatpak-spawn and run flatpak spawn --host /usr/bin/d2 within the sandbox instead of plain d2, it would be nice if this plugin allowed in the settings to provide a custom executable instead of just the path. Looking at the code I didn't found any way to do that currently, but it could be achieved.

Workaround

In the meantime I copied the d2 executable into the sandbox with this command, however it will get removed the next time Obsidian gets updated.

sudo move /usr/bin/d2 /var/lib/flatpak/app/md.obsidian.Obsidian/current/active/files/bin