Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions pkgs/by-name/jo/joplin-desktop/buildPlugin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
lib,
fetchzip,
npm-lockfile-fix,
buildNpmPackage,

name,
url,
hash,
npmDepsHash,
patches ? [ ],
}:

buildNpmPackage {
inherit name npmDepsHash patches;

src = fetchzip {
inherit url hash;
postFetch = ''
# Add missing integrity and resolved fields
${lib.getExe npm-lockfile-fix} $out/package-lock.json
'';
};

postPatch = ''
sed -i '/preinstall/d' package.json
'';

npmBuildScript = "dist";

installPhase = ''
runHook preInstall

install -Dm444 -t $out publish/*.jpl

runHook postInstall
'';
}
44 changes: 44 additions & 0 deletions pkgs/by-name/jo/joplin-desktop/missing-hashes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"@img/sharp-darwin-arm64@npm:0.33.4": "41e5ad30a5460a34a468dedef1b317e19b9878c13cc8115f855cecb9486ebb6e1f7e2b6dd3f0f1112ea9cbe3c7cf7a0c18213d3bfa0da77877ba3587dbe075df",
"@img/sharp-darwin-x64@npm:0.33.4": "264d90ea0928b1b30678159944f48a987010ba5dfdc97dbada6714483fa0d393f971a2d7909ed7573982acf13efa03ab43b6f22e64a1fce7f106c37e899ae367",
"@img/sharp-libvips-darwin-arm64@npm:1.0.2": "fa84f3487058b1ddd7bd607205b4f3e89e10e6f1d21701a064e586aa6b60d009a763fd7e26e4a347430579db25a6a0c968044e3a1a38773bc265c6622d7c9eb9",
"@img/sharp-libvips-darwin-x64@npm:1.0.2": "87ebf2edd083abb711c712bf83a2ba81889591e74e09ebec95364db0d03f06f2d178a8937c432595dbf89a5abcb4fe819d8671813dfeb23585123e2fd087247a",
"@img/sharp-libvips-linux-arm64@npm:1.0.2": "1f36347235982e67a3031a8ea466391282ba679a70866613372d1c95b7c622c10cf5a06d204f9a01f07cf3f27d219181e2680d2c348115dc2bd67d0335346e73",
"@img/sharp-libvips-linux-arm@npm:1.0.2": "598757b81ac94a1b6d89a8b33544bd5487723aac2b4b3d51d40515cce8376377dfef69304c47586ffaf56bbbadecc6e0a39c5a3e8112cbc18cfc4e415f604e27",
"@img/sharp-libvips-linux-s390x@npm:1.0.2": "f5dffd83065707a7b23ab6327e795faf5659546733ae7fcfecdc78d6369699bc29a36b22a498a2e929a5bffc9ea5c6abe207c1ae2d310560eed8f036e1cbd9bd",
"@img/sharp-libvips-linux-x64@npm:1.0.2": "f0dffe9f28e90f32baa486c34303bd0640603c11ca21bdba505f510b1b6edabb6e3cfe7be533d23293bde4dadb94acaf19d1620feaae89a8a307dc20bd720ecf",
"@img/sharp-libvips-linuxmusl-arm64@npm:1.0.2": "4298fbcae47fd5b54b05264fe44c1162e83c0b4ecc2d8f7e93bccc87b33cb3153bd77374b5d2408f7d5840d23109be204744b6a223d351a992a370951ee4b38b",
"@img/sharp-libvips-linuxmusl-x64@npm:1.0.2": "d8dcd822d9aa2501817dc59b582ca56129d4c03e5bd6b54e3baafb9b98c38326c4319bd7c3dfa058f214bee7734b1b19f0790bba481913afe1e712d3f8720cfd",
"@img/sharp-linux-arm64@npm:0.33.4": "e73036fa178d157df200c8be1c4a3557fabbcc21e433293453e74fd25fbb8e35941dd95bbafa8262dfd1f0260aa84ee471d1bb6325b9711e0fff0569f368b8dd",
"@img/sharp-linux-arm@npm:0.33.4": "aaa6bcbdc9ec5b48fec662f97431d6da35f363531c80eabcccb0a91e50edad3a4ec9396d457e9ecd3048d0f3435146230b2a7209c8b1e88e81d155634c2ccb6e",
"@img/sharp-linux-s390x@npm:0.33.4": "721d102ab50da64543920d512c5d058ab13a63de7c1d908ed12455be5596b4a26c23c5a9f7219486e722fc91a8ed9ff6838af0567e03b2ba512677f302538903",
"@img/sharp-linux-x64@npm:0.33.4": "1bcc4fd398f2cddcf7164804685d7f050ace81a48e6769cf0f6b7eca5a41f28910c7bd943e89aa5267943a06983715e1d7ed5b7436827935dd4c2075ca34ce45",
"@img/sharp-linuxmusl-arm64@npm:0.33.4": "b9a2bd70e34a679798eebd9e7edca4775dade662316d697a6cfc91fe1b710bd717dd9b5bd71a6d67c3b8f6618b8ee607f15041f1b0014d8d2acde4fa867e8711",
"@img/sharp-linuxmusl-x64@npm:0.33.4": "7d711a3d62f59f77f0e6e97027ae75614fcba6c2b7cc6188a4496a9d0c72115a59e9ca252f6e37e19aee6436c4ec4d5fcd8303c2986d2abe7f2e90fb3fdf5210",
"@img/sharp-wasm32@npm:0.33.4": "683f5d53db1ff2e98605fd6281d1ef3afc3e4a710a1fcc8e74142229bd573636023268ae1c07060cbf57fe36c45a71380cfe2be48178aab119f24891c378fd22",
"@img/sharp-win32-ia32@npm:0.33.4": "f42be0d5a35d48cc44e468c30a0a372ff459574c4d06498280dca1a8c3f1bf495a9e5ff8ba303971cfc5ca9a4858bd0883abfec4eb80b137926beeed150f0e98",
"@img/sharp-win32-x64@npm:0.33.4": "b272f5cb6104485de228ce1569341b6a2065f0570dccd3725112f1f963d5be4ed1fc045b63ead3e94becf9778a579acad9e5cb4899ff9a8f0aef70b89e639784",
"@rollup/rollup-android-arm-eabi@npm:4.2.0": "0b0b4eee292d9e0a05b6295f68c42b980d3a896b966f212e2e0553ba79b893b8cbe590ad1e8bf2b0ab3bf5d6160e740499dc2e0618d24192acbe43c0177eb280",
"@rollup/rollup-android-arm64@npm:4.2.0": "2b32aaf04a4b4c4c1539146945f907cb4f0938411aa2f2f2dfb636ee00d4b9adb13affe288309ccf077584ee7a4b19ba6ecd9452c7235ce9a04b5f2dc504a04e",
"@rollup/rollup-darwin-arm64@npm:4.2.0": "129f66910043d72922b79278d8196952b0602b026f4e86244c81766af1ea79685f61d78432b3fd74e4a03317f16a45d1aaee5cfb7d5887ef643a5e005900a358",
"@rollup/rollup-darwin-x64@npm:4.2.0": "892365ee83ee4d34a675c23cab8d3e162f53c77e27fe251d5ae02f09299c3bcf603e1b3fd2d6d0b435c90eed35842d0b819c9fc5077e6dc91831507f0b7554b8",
"@rollup/rollup-linux-arm-gnueabihf@npm:4.2.0": "5d8b0aa6f9153eec2e3ac9eac3a398f4534764150f01543db666088785c9bbb98ea2b27e6152dc011dd3bcc862634acfd8be2af5edb4644012fe5767de6b8cab",
"@rollup/rollup-linux-arm64-gnu@npm:4.2.0": "96f119069ccdcca5aa4306dbd70e627018a2e3bf760cf14d57a269a60197436c5b8703d0495fa8e9226174b99ce3b01b983e0311cf00d9d27c18a1c784e23737",
"@rollup/rollup-linux-arm64-musl@npm:4.2.0": "2edd96e4e0d8acbd76bca3d1335a77f13bf1f0a6c9937f896c4bd2cf6a4f4d48cd0032ff9015415eafa15826b0f875cbac9b241b7679b229ddb462b88b896264",
"@rollup/rollup-linux-x64-gnu@npm:4.2.0": "9f773f683181763bd22b1df1d3de01086c4c4017c26fce2d9d1d5a37fe367bd98537d0826294742031f1782c8fbb9f55155e5439b02439551a8c087d4f2496f1",
"@rollup/rollup-linux-x64-musl@npm:4.2.0": "2fa80cc108abea8e6a8e773d2f3bc68b177b793aa4cdd280899ff9dec36f56b9a794b41fccbe9d41486e0894cd035382ecee9206cce12cb837aea3ba9c61c2e5",
"@rollup/rollup-win32-arm64-msvc@npm:4.2.0": "2c58fc0e633fb5fdd5e7966e3dd8cf0b575892e5b459f5e0a656e554db27a8997a161a6f484fff32b2ddb76f4c4fcac73783bd7ebb2afc98fa61cbf6496a8906",
"@rollup/rollup-win32-ia32-msvc@npm:4.2.0": "2a6347e67a9e025d21f3218992add7b1c4f2d06816236bf15d052a13c06ff8593b6bef7462ec8646db840348772f24c5c84fe7bc6b3580b6335e594fdf7c92ef",
"@rollup/rollup-win32-x64-msvc@npm:4.2.0": "c972900a6e81909e8d4b908f21dd967408098898e4f5ef865efdb6818bd7e7b3143846f92e662fa3f4b33cb3981819f9acc4d343417b5def926fffb634b9cd30",
"dmg-license@npm:1.0.11": "be760b0fc5bb36a31ad623597e8c883eee85a2a775107892354b1fb8fd11fba7bf6c2c0e96bb6c43a8f27a448bd4188d6073dbc4c0f53034f42f05660c4571ee",
"iconv-corefoundation@npm:1.1.7": "e9456c1ece923480330e2de94c214afa04ef28b72bc9e982ada8c2fdad270a0e6af99cccb303f87406dde84cbf82b807c73152252ecc90f54d89cdd1b0e7351e",
"lightningcss-darwin-arm64@npm:1.19.0": "82aec584a78c29575d2ec5b17787b36d98ef508e0f848929adf37f1899c83a05b55a84a80608c4a2138b14832b8d690b0d0968a4905f0cbc3ca6984d84ea6b9c",
"lightningcss-darwin-x64@npm:1.19.0": "07a3851a2498c3edd98a41829726bba565429e84666b44360197988f6e1b680433f696f7c9b3b7a90efc196e66c7077837a800ae0ba83896b002e1c4d013a837",
"lightningcss-linux-arm-gnueabihf@npm:1.19.0": "bade132cd6b4de48a1bba97543187fe0a8129af3da3b86a63bd3f9f4f089dfd849541968543672182b78883e83a694a4db19c1af5d1eabdb762ec457df016629",
"lightningcss-linux-arm64-gnu@npm:1.19.0": "e54088904bc884bea57330fb7a90110944f4b9e709154bc83a86e502a5eda0c58973b42ad3e273ce98eeb6d22bcf9d30cf65d38de9a420f93e5c97980cdd1870",
"lightningcss-linux-arm64-musl@npm:1.19.0": "3c0f993df610230c7f76134bfe7025e880b6ba89c5c086fe7916b4cb4008fbd787f9c8141a534e3ec8420cd5cd43d298481adc0f1325855ebf31e898ae73bf45",
"lightningcss-linux-x64-gnu@npm:1.19.0": "c0195bae2546ee5842b18ea6cfef199de36bac433866364df6f5e1f1c5f60d081de4647f10966337e540ae5ea8f4b6b8ad0e8d3ce020fb9c4fec8bdcce636ed6",
"lightningcss-linux-x64-musl@npm:1.19.0": "1f2995a52539c0315c5890dff8adbfef0fb35d63df67ec3128f5e1507c391b1ae51927e31c48f0af61e74dafaeea06658c403ee73b1a5418584910b14cc831ed",
"lightningcss-win32-x64-msvc@npm:1.19.0": "cee88f0a8873274525034a7a51d3cb082cb55627ed70a51e0b7183aa7271128de0188695f4f672a3f79101e06290bd1bd5b1408decfc36016176bd7f7edc130b",
"systeminformation@npm:5.21.15": "664d4821c23ab704c02fc020ac5c140849a415bdee4be8188256a6ef5d5f418b4373383636bfff94d10304e47b1765ba9c8bec04fd05ec81e7552e1e94593054"
}
285 changes: 213 additions & 72 deletions pkgs/by-name/jo/joplin-desktop/package.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,227 @@
{
lib,
stdenv,
appimageTools,
fetchurl,
nodejs,
makeDesktopItem,
copyDesktopItems,
makeWrapper,
_7zz,
fetchFromGitHub,
yarn-berry_3,
python3,
pkg-config,
pango,
cairo,
pixman,
libsecret,
electron_36,
xcbuild,
buildPackages,
callPackage,
runCommand,
libGL,
typescript,
}:

let
electron = electron_36;
yarn-berry = yarn-berry_3;

releaseData = lib.importJSON ./release-data.json;

buildPlugin = import ./buildPlugin.nix;

getPluginPatch =
src: id:
runCommand "${id}.diff" { } ''
patch="${src}/packages/default-plugins/plugin-patches/${id}.diff"

if [ -f "$patch" ]; then
cp "$patch" "$out"
else
# create an empty patch file if it doesn't exist – can't check this from Nix code without IFD
touch "$out"
fi
'';

getDefaultPlugins = map (callPackage buildPlugin);
in

stdenv.mkDerivation (finalAttrs: {
pname = "joplin-desktop";
inherit (releaseData) version;

inherit (stdenv.hostPlatform) system;
throwSystem = throw "Unsupported system: ${system}";
passthru.updateScript = ./update.py;

releaseData = lib.importJSON ./release-data.json;
src = fetchurl releaseData.${system} or throwSystem;
src = fetchFromGitHub {
owner = "laurent22";
repo = "joplin";
tag = "v${finalAttrs.version}";
postFetch = ''
# there's a file with a weird name that causes a hash mismatch on darwin
rm $out/packages/app-cli/tests/support/photo*
'';
inherit (releaseData) hash;
};

missingHashes = ./missing-hashes.json;

offlineCache = yarn-berry.fetchYarnBerryDeps {
inherit (finalAttrs) src missingHashes postPatch;
hash = releaseData.deps_hash;
};

appimageContents = appimageTools.extractType2 {
inherit pname version src;
# allows overriding to disable building the plugins
defaultPlugins = getDefaultPlugins (
lib.mapAttrsToList (
id: plugin:
plugin
// {
patches = [ (getPluginPatch finalAttrs.src id) ];
}
) releaseData.plugins
);

buildInputs = [
libGL
];

nativeBuildInputs = [
nodejs
yarn-berry.yarn-berry-offline
yarn-berry.yarnBerryConfigHook
typescript
(python3.withPackages (ps: with ps; [ distutils ]))
pkg-config
pango
cairo
pixman
libsecret
makeWrapper
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
xcbuild
buildPackages.cctools
]
++ lib.optionals stdenv.hostPlatform.isLinux [
copyDesktopItems
];

env = {
ELECTRON_SKIP_BINARY_DOWNLOAD = 1;

# Disable scripts for now, so that yarnBerryConfigHook does not try to build anything
# before we can patchShebangs additional paths (see buildPhase).
# https://github.com/NixOS/nixpkgs/blob/3cd051861c41df675cee20153bfd7befee120a98/pkgs/by-name/ya/yarn-berry/fetcher/yarn-berry-config-hook.sh#L83
YARN_ENABLE_SCRIPTS = 0;
};

postPatch = ''
# Don't automatically build everything
sed -i '/postinstall/d' package.json
# Don't install onenote-converter subpackage deps
sed -i '/onenote-converter/d' packages/{lib,app-desktop}/package.json
# Don't build the default plugins, would require networking. We build them separately.
sed -i "/'buildDefaultPlugins',/d" packages/app-desktop/gulpfile.ts
'';

buildPhase = ''
runHook preBuild

unset YARN_ENABLE_SCRIPTS

for node_modules in packages/*/node_modules; do
patchShebangs $node_modules
done

yarn config set enableInlineBuilds true

echo "installing yarn dependencies..."
yarn workspaces focus \
root \
@joplin/app-desktop

echo "building workspaces..."
yarn workspaces foreach -vi \
--topological-dev \
--recursive \
--from @joplin/app-desktop \
run build
yarn workspaces foreach -vi \
--parallel \
--recursive \
--from @joplin/app-desktop \
run tsc

# electronDist needs to be modifiable on Darwin
cp -r ${electron.dist} electronDist
chmod -R u+w electronDist
electronDist="$PWD/electronDist"

echo "bundling desktop application..."
cd packages/app-desktop

# copy over defaultPlugins
${lib.concatMapStringsSep "\n" (
plugin: "install -Dt ./build/defaultPlugins ${plugin}/*.jpl"
) finalAttrs.defaultPlugins}

# file is expected to be present for Linux build
mkdir dist && touch dist/AppImage

yarn run electronRebuild

yarn run electron-builder \
--dir \
-c.electronDist="$electronDist" \
-c.electronVersion=${electron.version} \
-c.mac.identity=null

runHook postBuild
'';

installPhase = ''
runHook preInstall

${lib.optionalString stdenv.hostPlatform.isLinux ''
outdir="$out/share/joplin-desktop"
mkdir -p "$outdir"

cp -r dist/*unpacked/* "$outdir"

for file in "$src/Assets/LinuxIcons"/*.png; do
resolution=$(basename "$file" .png)
install -Dm644 "$file" "$out/share/icons/hicolor/$resolution/apps/joplin.png"
done

makeWrapper "$outdir"/joplin $out/bin/joplin-desktop \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL ]}" \
--add-flags "--no-sandbox" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-wayland-ime --ozone-platform=wayland --enable-features=WaylandWindowDecorations}}" \
--inherit-argv0
''}

${lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/Applications
cp -r dist/mac*/Joplin.app $out/Applications
makeWrapper $out/Applications/Joplin.app/Contents/MacOS/Joplin $out/bin/joplin-desktop
''}

runHook postInstall
'';

desktopItems = [
(makeDesktopItem {
name = "joplin";
desktopName = "Joplin";
exec = "joplin-desktop %U";
icon = "joplin";
comment = "Joplin for Desktop";
categories = [ "Office" ];
startupWMClass = "@joplin/app-desktop";
mimeTypes = [ "x-scheme-handler/joplin" ];
})
];

meta = with lib; {
description = "Open source note taking and to-do application with synchronisation capabilities";
mainProgram = "joplin-desktop";
Expand All @@ -34,68 +235,8 @@ let
homepage = "https://joplinapp.org";
license = licenses.agpl3Plus;
maintainers = with maintainers; [
hugoreeves
qjoly
yajo
fugi
];
platforms = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
};

linux = appimageTools.wrapType2 {
inherit
pname
version
src
meta
;
nativeBuildInputs = [ makeWrapper ];

profile = ''
export LC_ALL=C.UTF-8
'';

extraInstallCommands = ''
wrapProgram $out/bin/joplin-desktop \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform=wayland --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}"
install -Dm644 ${appimageContents}/joplin.desktop $out/share/applications/joplin.desktop
install -Dm644 ${appimageContents}/joplin.png $out/share/pixmaps/joplin.png
substituteInPlace $out/share/applications/joplin.desktop \
--replace-fail 'Exec=AppRun' 'Exec=joplin-desktop'
'';

passthru.updateScript = ./update.py;
inherit (electron.meta) platforms;
};

darwin = stdenv.mkDerivation {
inherit
pname
version
src
meta
;

nativeBuildInputs = [ _7zz ];

unpackPhase = ''
runHook preUnpack
7zz x -x'!Joplin ${version}/Applications' -xr'!*:com.apple.cs.Code*' $src
runHook postUnpack
'';

sourceRoot = if stdenv.hostPlatform.isx86_64 then "Joplin ${version}" else ".";

installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -R Joplin.app $out/Applications
runHook postInstall
'';

passthru.updateScript = ./update.py;
};
in
if stdenv.hostPlatform.isDarwin then darwin else linux
})
Loading
Loading