From 2746d34fb7358358c44252fa7d1d98def5b7f8aa Mon Sep 17 00:00:00 2001 From: Louis Opter Date: Thu, 23 May 2024 10:18:08 -0700 Subject: [PATCH] mindforger: upgrade to 2.0.0 Pull MindForger's [fork][cmark-fork] of [cmark-gfm][cmark] alongside Mindforger and build it in `preBuild`. I am not sure to understand how mindforger could be built before that. The patches that were applied have all been upstreamed and could be removed. A patch for the Qt project file to use pkg-config to find hunspell was added. Don't forget to install dictionaries from `hunspellDicts` for this to be useful. This currently does not build on Darwin because some vendored transitive dependency, and I did not bother with that. Thanks to @FliegendeWurst for picking this PR up, and help with it. [cmark]: https://github.com/github/cmark-gfm [cmark-fork]: https://github.com/dvorka/cmark --- .../editors/mindforger/default.nix | 73 +++++++++++++------ .../mindforger/hunspell_pkgconfig.patch | 23 ++++++ .../editors/mindforger/paths.patch | 42 ----------- 3 files changed, 75 insertions(+), 63 deletions(-) create mode 100644 pkgs/applications/editors/mindforger/hunspell_pkgconfig.patch delete mode 100644 pkgs/applications/editors/mindforger/paths.patch diff --git a/pkgs/applications/editors/mindforger/default.nix b/pkgs/applications/editors/mindforger/default.nix index db4d65de7959..b113a0e10eac 100644 --- a/pkgs/applications/editors/mindforger/default.nix +++ b/pkgs/applications/editors/mindforger/default.nix @@ -1,37 +1,68 @@ { lib , stdenv -, cmark-gfm -, fetchurl -, fetchpatch +, cmake +, curl +, fetchFromGitHub +, hunspell +, pkg-config , qmake , qtbase , qtwebengine , wrapGAppsHook3 , wrapQtAppsHook }: - -stdenv.mkDerivation rec { - pname = "mindforger"; - version = "1.52.0"; - - src = fetchurl { - url = "https://github.com/dvorka/mindforger/releases/download/${version}/mindforger_${version}.tgz"; - sha256 = "1pghsw8kwvjhg3jpmjs0n892h2l0pm0cs6ymi8b23fwk0kfj67rd"; +let + version = "2.0.0"; + srcs = { + mindforger = fetchFromGitHub { + owner = "dvorka"; + repo = "mindforger"; + rev = version; + sha256 = "sha256-+8miV2xuQcaWGdWCEXPIg6EXjAHtgD9pX7Z8ZNhpMjA="; + }; + cmark-gfm = fetchFromGitHub { + owner = "dvorka"; + repo = "cmark"; + rev = "4ca8688093228c599432a87d7bd945804c573d51"; + sha256 = "sha256-0WiG8aot8mc0h1BKPgC924UKQrgunZvKKBy9bD7nhoQ="; + }; + mindforger-repository = fetchFromGitHub { + owner = "dvorka"; + repo = "mindforger-repository"; + rev = "ec81a27e5de6408bbcd3f6d7733a7c6f3b52e433"; + sha256 = "sha256-JGTP1He7G2Obmsav64Lf7BLHp8OTvPtg38VHsrEC36o="; + }; }; +in stdenv.mkDerivation { + pname = "mindforger"; + inherit version; - nativeBuildInputs = [ qmake wrapGAppsHook3 wrapQtAppsHook ]; - buildInputs = [ qtbase qtwebengine cmark-gfm ]; + src = srcs.mindforger; + + nativeBuildInputs = [ cmake pkg-config qmake wrapGAppsHook3 wrapQtAppsHook ]; + buildInputs = [ curl hunspell qtbase qtwebengine ]; + + # Disable the cmake hook (so we don't try to build MindForger with it), and + # build MindForger's internal fork of cmark-gfm ahead of MindForger itself. + # + # Moreover unpack the docs that are needed for the MacOS build. + postUnpack = '' + cp -TR ${srcs.cmark-gfm} $sourceRoot/deps/cmark-gfm + '' + lib.optionalString stdenv.hostPlatform.isDarwin '' + cp -TR ${srcs.mindforger-repository} $sourceRoot/doc + ''; + dontUseCmakeConfigure = true; + preBuild = ''( + mkdir deps/cmark-gfm/build && + cd deps/cmark-gfm/build && + cmake -DCMARK_TESTS=OFF -DCMARK_SHARED=OFF .. && + cmake --build . --parallel + )''; doCheck = true; patches = [ - # this makes the package relocatable - removes hardcoded references to /usr - ./paths.patch - # this fixes compilation with QtWebEngine - referencing a commit trying to upstream the change - see https://github.com/dvorka/mindforger/pull/1357 - (fetchpatch { - url = "https://github.com/dvorka/mindforger/commit/d28e2bade0278af1b5249953202810540969026a.diff"; - sha256 = "sha256-qHKQQNGSc3F9seaOHV0gzBQFFqcTXk91LpKrojjpAUw="; - }) + ./hunspell_pkgconfig.patch ]; postPatch = '' @@ -62,7 +93,7 @@ stdenv.mkDerivation rec { ''; homepage = "https://www.mindforger.com"; license = licenses.gpl2Plus; - platforms = platforms.all; + platforms = [ "aarch64-linux" "x86_64-linux" ]; maintainers = with maintainers; [ cyplo ]; mainProgram = "mindforger"; }; diff --git a/pkgs/applications/editors/mindforger/hunspell_pkgconfig.patch b/pkgs/applications/editors/mindforger/hunspell_pkgconfig.patch new file mode 100644 index 000000000000..babbf3e42589 --- /dev/null +++ b/pkgs/applications/editors/mindforger/hunspell_pkgconfig.patch @@ -0,0 +1,23 @@ +diff --git a/app/app.pro b/app/app.pro +index 89ff5c0b..9625ecd1 100644 +--- a/app/app.pro ++++ b/app/app.pro +@@ -159,12 +159,13 @@ macx { + + } else:unix { + # pkgconfig-based configuration does not work @ Ubuntu +- # CONFIG += link_pkgconfig +- # PKGCONFIG += hunspell ++ # but does on NixOS ++ CONFIG += link_pkgconfig ++ PKGCONFIG += hunspell + +- # hardcoded paths are (unfortunately) more robust: +- INCLUDEPATH += /usr/include/hunspell +- LIBS += -lhunspell ++ # Where hardcoded paths are (unfortunately) more robust^W^W^W^Wannoying: ++ # INCLUDEPATH += /usr/include/hunspell ++ # LIBS += -lhunspell + + HEADERS += \ + ./src/qt/spelling/dictionary_provider_hunspell.h \ diff --git a/pkgs/applications/editors/mindforger/paths.patch b/pkgs/applications/editors/mindforger/paths.patch deleted file mode 100644 index e9b9244f8dbd..000000000000 --- a/pkgs/applications/editors/mindforger/paths.patch +++ /dev/null @@ -1,42 +0,0 @@ -diff --git a/app/app.pro b/app/app.pro -index 29f9d9e..15fd2ff 100644 ---- a/app/app.pro -+++ b/app/app.pro -@@ -370,7 +370,7 @@ RESOURCES += \ - # See http://doc.qt.io/qt-5/qmake-advanced-usage.html - - binfile.files += mindforger --binfile.path = /usr/bin/ -+binfile.path = $$PREFIX/bin/ - INSTALLS += binfile - - # ######################################## -diff --git a/mindforger.pro b/mindforger.pro -index bd4f21d..6bb2dbc 100644 ---- a/mindforger.pro -+++ b/mindforger.pro -@@ -43,20 +43,20 @@ app.depends = lib - #IMPORTANT: binfile MUST be specified in app/app.pro (project next to/that builds binary) - - docfiles.files += doc/* --docfiles.path = /usr/share/doc/mindforger/ -+docfiles.path = $$PREFIX/share/doc/mindforger/ - INSTALLS += docfiles - - manfiles.files += man/* --manfiles.path = /usr/share/man/man1/ -+manfiles.path = $$PREFIX/share/man/man1/ - INSTALLS += manfiles - - iconfiles.files += app/resources/icons/* --iconfiles.path = /usr/share/icons/mindforger/ -+iconfiles.path = $$PREFIX/share/icons/mindforger/ - INSTALLS += iconfiles - - # experiment w/ file - shortcutfiles.files += app/resources/gnome-shell/mindforger.desktop --shortcutfiles.path = /usr/share/applications/ -+shortcutfiles.path = $$PREFIX/share/applications/ - INSTALLS += shortcutfiles - - # eof