nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 nodejs,
5 fetchFromGitHub,
6 yarn-berry_4,
7 python3,
8 pkg-config,
9 libsecret,
10 rsync,
11 xcbuild,
12 buildPackages,
13 clang_20,
14}:
15
16stdenv.mkDerivation (finalAttrs: {
17 pname = "joplin-cli";
18 version = "3.5.1";
19
20 src = fetchFromGitHub {
21 owner = "laurent22";
22 repo = "joplin";
23 tag = "v${finalAttrs.version}";
24 postFetch = ''
25 # there's a file with a weird name that causes a hash mismatch on darwin
26 rm $out/packages/app-cli/tests/support/photo*
27 '';
28 hash = "sha256-NNtdY6ajMfcMWj/AIo+b2nhylBCqyOIwCepYx/ZNCBY=";
29 };
30
31 missingHashes = ./missing-hashes.json;
32
33 offlineCache = yarn-berry_4.fetchYarnBerryDeps {
34 inherit (finalAttrs) src missingHashes postPatch;
35 hash = "sha256-EGP/nnz4u6I0efTQu41lgmk0tuHpiavVKHRdiSYdEUs=";
36 };
37
38 nativeBuildInputs = [
39 nodejs
40 yarn-berry_4.yarn-berry-offline
41 yarn-berry_4.yarnBerryConfigHook
42 (python3.withPackages (ps: with ps; [ distutils ]))
43 pkg-config
44 libsecret
45 rsync
46 ]
47 ++ lib.optionals stdenv.hostPlatform.isDarwin [
48 xcbuild
49 buildPackages.cctools
50 clang_20 # clang_21 breaks keytar, sqlite
51 ];
52
53 buildInputs = [
54 nodejs
55 ];
56
57 env = {
58 # Disable scripts so that yarn doesn't immediately run them
59 # We want to patch them first
60 YARN_ENABLE_SCRIPTS = 0;
61 };
62
63 postPatch = ''
64 # Don't immediately build everything
65 sed -i '/postinstall/d' package.json
66 # Don't install onenote-converter subpackage deps
67 sed -i '/onenote-converter/d' packages/{lib,app-cli}/package.json
68 '';
69
70 buildPhase = ''
71 runHook preBuild
72
73 unset YARN_ENABLE_SCRIPTS
74
75 yarn config set enableInlineBuilds true
76
77 for node_modules in packages/*/node_modules; do
78 patchShebangs $node_modules
79 done
80
81 yarn workspaces focus root joplin
82 yarn workspaces foreach -Rptvi --from joplin run tsc
83 yarn workspaces foreach -Rtvi --from joplin run build
84
85 runHook postBuild
86 '';
87
88 installPhase = ''
89 runHook preInstall
90
91 # Remove dev dependencies
92 yarn workspaces focus --production root joplin
93
94 mkdir -p $out/lib/packages
95 mkdir $out/bin
96 mv packages/{app-cli,renderer,tools,utils,lib,htmlpack,turndown{,-plugin-gfm},fork-*} $out/lib/packages/
97 rm -rf $out/lib/packages/lib/node_modules/canvas
98
99 # Remove extra files
100 rm -rf $out/lib/packages/app-cli/{app/*.test.ts,*.md,.*ignore,tests/,tools/,*.js,*.json,*.sh}
101
102 # Link final binary
103 chmod +x $out/lib/packages/app-cli/app/main.js
104 ln -s $out/lib/packages/app-cli/app/main.js $out/bin/joplin
105 patchShebangs $out/bin/joplin
106
107 runHook postInstall
108 '';
109
110 updateScript = ./update.sh;
111
112 meta = {
113 changelog = "https://github.com/laurent22/joplin/releases/v${finalAttrs.version}";
114 description = "CLI client for Joplin";
115 homepage = "https://joplinapp.org/";
116 license = lib.licenses.agpl3Plus;
117 mainProgram = "joplin";
118 maintainers = with lib.maintainers; [ pyrox0 ];
119 };
120})