Qmake not found when trying to build Qt5 app

I’ve qt5.full installed (see How to get libsForQt5.qt5.qmake installed without qt5.full?) and am trying to build QOwnNotes locally.

I’ve downloaded the default.nix.

@totoroot@fosstodon.org:

omega@neptun /e/n/a/qownnotes (main) [1]> which qmake
/run/current-system/sw/bin/qmake

omega@neptun /e/n/a/qownnotes (main)> nix-build -E '((import <nixpkgs> {}).callPackage (import ./default.nix) { })'
error: evaluation aborted with the following error message: 'Function called without required argument "qmake" at /etc/nixos/apps/qownnotes/default.nix:4, did you mean "bmake", "cmake" or "imake"?'

Any suggestions what I’m doing wrong?

Sorry, I initially misunderstood what you were trying to do.

You have to call libsForQt5's callPackage:

nix-build -E '((import <nixpkgs> {}).libsForQt5.callPackage (import ./default.nix) { })'

You can also build it using a local nixpkgs clone (for me at ~/dev/nixpkgs):

nix-build ~/dev/nixpkgs -A qownnotes

This makes Nix look up the top-level name qownnotes and evaluate the expression which is defined here.

1 Like

Thank you very much, @totoroot, that helped a lot! I didn’t know libsForQt5 had it’s own callPackage!

Do you keep a local clone of the nixpkgs git repo (with all its Gigabytes of commits)? Or do you keep a shallow clone of the repo? Do you also keep your own fork for pull requests?

Glad that helped! Let me know if you run into any other issues.

Yes, I do. I don’t mind because disk space is relatively cheap nowadays, it saves bandwidth (I’ve only got 80/20 MBit/s) and speeds some things up while working on nixpkgs issues and PRs.

1 Like

Thank you very much!

@totoroot, did you have any look building qownnotes for Qt6? nixpkgs seems to be lacking a package for core5compat… And I can’t find anything about anyone using or needing the module…

Not yet, but I’ve got some time today and can try building it with Qt6 :slight_smile:

I came this far.

#
# QOwnNotes Qt6 build
#
# build command:
# nix-build -E '((import <nixpkgs> {}).qt6.callPackage (import ./default.qt6.nix) { })'
#
# TODO: qtcore5compat is still missing
#

{ lib
, stdenv
, fetchurl
, qmake
, qttools
, qtbase
, qtdeclarative
, qtsvg
, qtwayland
, qtwebsockets
, makeWrapper
, wrapQtAppsHook
}:

let
  pname = "qownnotes";
  appname = "QOwnNotes";
  version = "23.4.6";
in
stdenv.mkDerivation {
  inherit pname appname version;

  src = fetchurl {
    url = "https://download.tuxfamily.org/${pname}/src/${pname}-${version}.tar.xz";
    sha256 = "sha256-lfQkY/B+mv+hUeAfmZkZ2BHq7MjR0MUVNPjk5QCGisE=";
  };

  nativeBuildInputs = [
    qmake
    qttools
    wrapQtAppsHook
  ] ++ lib.optionals stdenv.isDarwin [ makeWrapper ];

  buildInputs = [
    qtbase
    qtdeclarative
    qtsvg
    qtwebsockets
  ] ++ lib.optionals stdenv.isLinux [ qtwayland ];

  postInstall =
  # Create a lowercase symlink for Linux
  lib.optionalString stdenv.isLinux ''
    ln -s $out/bin/${appname} $out/bin/${pname}
  ''
  # Wrap application for macOS as lowercase binary
  + lib.optionalString stdenv.isDarwin ''
    mkdir -p $out/Applications
    mv $out/bin/${appname}.app $out/Applications
    makeWrapper $out/Applications/${appname}.app/Contents/MacOS/${appname} $out/bin/${pname}
  '';

  meta = with lib; {
    description = "Plain-text file notepad and todo-list manager with markdown support and Nextcloud/ownCloud integration";
    homepage = "https://www.qownnotes.org/";
    changelog = "https://www.qownnotes.org/changelog.html";
    downloadPage = "https://github.com/pbek/QOwnNotes/releases/tag/v${version}";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ pbek ];
    platforms = platforms.unix;
  };
}

I already finished building it. Was a lot easier than expected. I’ll push my changes later, open a PR and ping you for testing

Awesome! I wonder what you did with core5compat :wink: