Skip to content

Comments

joplin-desktop: build from source#417048

Merged
r-vdp merged 1 commit intoNixOS:masterfrom
fugidev:joplin-desktop
Aug 31, 2025
Merged

joplin-desktop: build from source#417048
r-vdp merged 1 commit intoNixOS:masterfrom
fugidev:joplin-desktop

Conversation

@fugidev
Copy link
Member

@fugidev fugidev commented Jun 15, 2025

Motivation: Upstream doesn't provide binaries for aarch64-linux.

Part of #296939

I took inspiration from the respective packages on AUR and Flathub, which are also source builds.

Unfortunately, building this package is currently broken on Darwin with sandbox = true due to #415328 and #416077 (merged). Otherwise it does build and work. But because of this, I'd keep the bin package for now and automatically fall back to it on Darwin, to not cause any issues on existing user setups. (Any opinions on this are very welcome.)

On Linux, the included "Backup" plugin doesn't load for some reason. The AUR package has the same issue and it has been reported, see JackGruber/joplin-plugin-backup#92. It works on the flatpak tho, and on this package's Darwin build as well.
Edit: fixed

More usage testing is greatly appreciated, as well as any other reviews and comments. :)

@yajo you seem to be the only active maintainer of the current package, do you want to be added as maintainer here?

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@fugidev fugidev force-pushed the joplin-desktop branch 2 times, most recently from d4b3a30 to a160497 Compare June 16, 2025 14:11
@fugidev
Copy link
Member Author

fugidev commented Jun 17, 2025

I reworked the plugin building to remove IFDs

@nix-owners nix-owners bot requested review from HugoReeves and qjoly June 17, 2025 12:56
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 8.has: documentation This PR adds or changes documentation labels Jun 17, 2025
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 18, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is simpler:

Suggested change
rev = "refs/tags/v${finalAttrs.version}";
tag = "v${finalAttrs.version}";

Copy link
Member Author

@fugidev fugidev Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but it causes an error in nix-prefetch in the update script for some reason:

fetchFromGitHub requires one of either `rev` or `tag` to be provided (not both)

As a workaround rev = null can be added, or extending the nix-prefetch flags with --rev --expr null.

I thought the way I did it would be the simplest, but if using tag is much preferred then I can of course add one of these workarounds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you make sure to add tag and remove rev? If so, nix-prefetch shouldn't fail.

Otherwise you can leave it as it is. It was just a suggestion based on code review, but if it is problematic then don't worry :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I did. Must be a bug in nix-prefetch

@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 20, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Jun 20, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 25, 2025
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 26, 2025
@fugidev
Copy link
Member Author

fugidev commented Jun 26, 2025

rebased and updated to 3.3.13

@fugidev
Copy link
Member Author

fugidev commented Jun 30, 2025

I refactored buildPlugin.nix as suggested by @yajo.

@yajo
Copy link
Contributor

yajo commented Jul 1, 2025

I tested the app but got this:

image

Clicking restart in safe mode an launching again didn't help.

I'm not sure if this is actually a failure from the new build or from some configuration with local plugins...

@fugidev
Copy link
Member Author

fugidev commented Jul 1, 2025

I'm not sure if this is actually a failure from the new build or from some configuration with local plugins...

Seems like you are running joplin-desktop 2.14.17 there for some reason, not this one

Copy link
Contributor

@yajo yajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I tested the wrong PR. Now it worked!

About dialog provided this info FWIW

Joplin 3.3.13 (prod, linux)

Device: linux, 13th Gen Intel(R) Core(TM) i7-1360P
ID del Cliente: e7cf469d82bd47648320bf15c5040be8
Versión de la Sincronización: 3
Versión del Perfil: 47
Llavero Soportado: No
Alternative instance ID: -

Automatic Backlinks to note: 3.0.3
Freehand Drawing: 3.0.1
Link Graph UI: 1.5.0
Note Tabs: 1.4.0
Outline: 1.5.13
Quick Links: 1.3.2
Rich Markdown: 0.15.0
Toggle Editor Menu & Keyboard Shortcut: 1.0.1

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Jul 2, 2025
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 29, 2025
@fugidev
Copy link
Member Author

fugidev commented Aug 29, 2025

Rebased and updated to v3.4.6 (Note: that's actually a pre-release, but was updated to in #436033).

This required switching to yarn-berry_4 and some other minor changes.

Build tested on aarch64-linux and aarch64-darwin.

@r-vdp if the size of the vendored yarn.lock is an issue, we could instead store and apply the diff? That would be ~500KB, down from 1.6MB. Or we could try pruning it in the FOD and see if it breaks down the road.

@r-vdp
Copy link
Contributor

r-vdp commented Aug 29, 2025

Yeah, the only thing that's keeping me from merging this, is indeed the size of the vendored lock file.

Both of those options sound like they would improve the situation, but I don't know yarn enough to make the call on which approach would be better here.

@fugidev
Copy link
Member Author

fugidev commented Aug 29, 2025

I changed it to store only the diff 👍
This way, I'm confident that it won't break ^^

@yuyuyureka
Copy link
Contributor

fetchYarnBerryDeps should only download the tgz files and never try to compile anything or run build scripts of the dependencies. Your code mentions something about "would require unneccessary complexity to fix". Does that mean that with the original lockfile is broken with fetchYarnBerryDeps?
Otherwise, I wouldn't see the problem with fetching the dependencies for the entire workspace, and then only building a subset of the workspace.

@fugidev
Copy link
Member Author

fugidev commented Aug 30, 2025

@yuyuyureka the issue is not with fetchYarnBerryDeps, that works just fine (I see where the confusion may come from; I only meant to specify the offlineCache's size difference for a rough idea on what portion of the deps is unnecessary).

yarn install is the step where some deps are apparently built from source, like sqlite (required for the desktop app) but also e.g. wasm-pack (which is not). And that would, afaict, require adding additional buildInputs (or otherwise workarounds) in order to not fail. Unless I've missed something ^^'

Edit: I'm taking another look at yarn workspaces focus. I couldn't get that to work before but maybe I've missed something (or it could be different with yarn 4).

@fugidev
Copy link
Member Author

fugidev commented Aug 30, 2025

I got it working! No vendoring a modified lockfile needed anymore. I'm much happier with this.

For some reason I'm getting a hash mismatch for src on darwin now, that is very weird...

Edit: hash mismatch is resolved

@fugidev
Copy link
Member Author

fugidev commented Aug 31, 2025

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 417048
Commit: 84cecfdf3cff39a731636cb201f2a167a5c223c4 (subsequent changes)
Merge: 39a7c5b823bdf782fc6edd7dae084eaadc324a9e

Logs: https://github.com/fugidev/nixpkgs-review-gha/actions/runs/17356630392


x86_64-linux

✅ 1 package built:
  • joplin-desktop

aarch64-linux

✅ 1 package built:
  • joplin-desktop

x86_64-darwin (sandbox = relaxed)

✅ 1 package built:
  • joplin-desktop

aarch64-darwin (sandbox = relaxed)

✅ 1 package built:
  • joplin-desktop

@fugidev fugidev requested review from r-vdp and yuyuyureka August 31, 2025 12:12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rev = "refs/tags/v${finalAttrs.version}";
tag = "v${finalAttrs.version}";

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #417048 (comment)
What would be preferred in your opinion?

Copy link
Contributor

@r-vdp r-vdp Aug 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't see that comment, sorry. The tag attribute is preferred because it avoids git getting confused when the repo contains a commit whose commit hash has the tag as a prefix, or a branch with the same name. And the refs/tags/ is also rather verbose.
So I would opt to add rev = null with a comment to explain why it is needed for now.

Copy link
Member Author

@fugidev fugidev Aug 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rev = null in the derivation didn't work for some reason (it did back then). So I've added the workaround in the update script. Seems more fitting anyway when I think about it, since it's only relevant there.

Copy link
Contributor

@r-vdp r-vdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all your effort on this!

@r-vdp r-vdp merged commit bc6b16b into NixOS:master Aug 31, 2025
29 of 31 checks passed
@fugidev
Copy link
Member Author

fugidev commented Aug 31, 2025

Thank you and everyone else for reviewing and helping get this over the finish line! :)

@fugidev fugidev deleted the joplin-desktop branch September 1, 2025 08:13
@HHR2020
Copy link
Contributor

HHR2020 commented Sep 5, 2025

This pr makes my joplin scale 4x when NIXOS_OZONE_WL is set.

picture

@fugidev
Copy link
Member Author

fugidev commented Sep 5, 2025

@HHR2020 it scales correctly and just the same with or without NIXOS_OZONE_WL set for me (1.5x scale on sway). You should create an issue, maybe others have the same problem?

@ajs124
Copy link
Member

ajs124 commented Sep 24, 2025

This seems to have introduced a runtime dependency on nodejs. Is there any way to avoid this?

@fugidev
Copy link
Member Author

fugidev commented Sep 24, 2025

This seems to have introduced a runtime dependency on nodejs. Is there any way to avoid this?

Can you elaborate what you mean by that? And is that not the case for other (source-built) Electron applications? I can look into it if you give me some pointers :)

@ajs124
Copy link
Member

ajs124 commented Sep 25, 2025

What I mean is that this package depends on the nodejs package, which has quite a large closure size.
This isn't normal, no. nodejs should just be a build-time dependency.

If we compare the following:

$ nix-store -q --tree /nix/store/46xgz72mr2ppk40sd9crn9jcpsqbc31g-element-desktop-1.11.112|grep nodejs
[nothing]

with

$ nix-store -q --tree /nix/store/03fmf4hyy77s28kyfn6ak09dsp70jism-joplin-desktop-3.4.12|grep nodejs                                                                                                    
├───/nix/store/1x276grqkqal97vbf7xrna218jr2kv84-nodejs-22.19.0-source
├───/nix/store/r4557ald6zn4dzmvgh8na9vwnwzgrjgc-nodejs-22.19.0
│   └───/nix/store/r4557ald6zn4dzmvgh8na9vwnwzgrjgc-nodejs-22.19.0 [...]
$ nix path-info --recursive --closure-size --human-readable /nix/store/1x276grqkqal97vbf7xrna218jr2kv84-nodejs-22.19.0-source
/nix/store/1x276grqkqal97vbf7xrna218jr2kv84-nodejs-22.19.0-source        474.3M
$ nix path-info --recursive --closure-size --human-readable /nix/store/r4557ald6zn4dzmvgh8na9vwnwzgrjgc-nodejs-22.19.0
[…]
/nix/store/r4557ald6zn4dzmvgh8na9vwnwzgrjgc-nodejs-22.19.0               208.2M

This is likely because something in the build references this, but I'd assume/hope this isn't actually needed at runtime.

@fugidev
Copy link
Member Author

fugidev commented Sep 27, 2025

This is due to shebangs and other references to nodejs in the node_modules inside app.asar:

$ grep -lr /nix/store/r4557ald6zn4dzmvgh8na9vwnwzgrjgc-nodejs-22.19.0 
node_modules/rimraf/bin.js
node_modules/tar/node_modules/mkdirp/bin/cmd.js
node_modules/make-dir/node_modules/semver/bin/semver.js
node_modules/node-addon-api/tools/conversion.js
node_modules/prebuild-install/bin.js
node_modules/mkdirp/bin/cmd.js
node_modules/color-support/bin.js
node_modules/rc/cli.js
node_modules/glob/dist/esm/bin.mjs
node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp
node_modules/which/bin/node-which
node_modules/nopt/bin/nopt.js
node_modules/semver/bin/semver.js
node_modules/sqlite3/node_modules/node-gyp/bin/node-gyp.js
node_modules/sqlite3/build-tmp-napi-v6/Makefile
node_modules/sqlite3/build-tmp-napi-v6/config.gypi

$ grep -lr /nix/store/1x276grqkqal97vbf7xrna218jr2kv84-nodejs-22.19.0-source 
node_modules/sqlite3/build-tmp-napi-v6/Makefile
node_modules/sqlite3/build-tmp-napi-v6/config.gypi

I'm looking into if it's possible to eliminate those. The AppImage ships those as well, but does seem to work fine without nodejs after all.

@fugidev
Copy link
Member Author

fugidev commented Sep 27, 2025

I'm not really getting anywhere, and I can't really spare more time to sink into this at the moment. Best I can tell you so far is that nodejs (and patching the shebangs that reference it) is required for building keytar during dependency installation. It looks like element-desktop builds keytar using nix and symlinks it into node_modules. I could not easily get the same to work for joplin-desktop, but maybe that way it could be avoided to pull in nodejs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

8.has: documentation This PR adds or changes documentation 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.