Qt: Difference between revisions

imported>Bryanhonof
No edit summary
imported>Tobias.bora
No edit summary
Line 50: Line 50:
myapp = callPackage ./build/myapp/default.nix { } # Will complain it wasn't called with qtbase, etc.
myapp = callPackage ./build/myapp/default.nix { } # Will complain it wasn't called with qtbase, etc.
myapp = libsForQt5.callPackage ./build/myapp/default.nix { } # Should work
myapp = libsForQt5.callPackage ./build/myapp/default.nix { } # Should work
</syntaxHighlight>
== Projects using python (e.g. PyQt5) ==
It's possible to package a program that uses internally python and Qt (like PyQt5) by providing a python executable with the appropriate libraries like that <code>myPython = python3.withPackages (pkgs: with pkgs; [ pyqt5 ]);</code>. `<code>wrapQtAppsHook</code>` even seems  to be optional when using `mkderivation` (at least this program can be run without) since anyway it does not patch scripts.
<syntaxHighlight lang=nix>
{ mkDerivation,
  lib,
  stdenv,
  fetchFromGitHub,
  jack2,
  which,
  python3,
  qtbase,
  qttools,
  wrapQtAppsHook,
  liblo,
  git,
}:
let
  myPython = python3.withPackages (pkgs: with pkgs; [ pyqt5 liblo pyliblo pyxdg ]);
in
mkDerivation rec {
  pname = "RaySession";
  version = "0.11.1";
  src = fetchFromGitHub {
    owner = "Houston4444";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-EbDBuOcF0JQq/LOrakb040Yfrpdi3FOB1iczQTeXBkc=";
  };
  # This patch is required to be able to create a new session, but not a problem to compile and start the program
  # patches = [ ./copy_template_writable.patch ];
  # Otherwise lrelease-qt is not found:
  postPatch = ''
  substituteInPlace Makefile \
    --replace "lrelease-qt4" "${qttools.dev}/bin/lrelease" \
    --replace '$(DESTDIR)/' '$(DESTDIR)$(PREFIX)' # Otherwise problem with installing manual etc...
  '';
  nativeBuildInputs = [
    myPython
    wrapQtAppsHook # Not really useful since it will not pack scripts. And actually it seems that it's not required?
    which
    qttools
  ];
  propagatedBuildInputs = [ myPython qtbase jack2 git ];
  # Prefix must be set correctly due to sed -i "s?X-PREFIX-X?$(PREFIX)?"
  makeFlags = [ "PREFIX=$(out)" ]; # prefix does not work since due to line "install -d $(DESTDIR)/etc/xdg/"
}
</syntaxHighlight>
Call it with
<syntaxHighlight>
{ pkgs ? import <nixpkgs> {} }:
pkgs.libsForQt5.callPackage ./derivation.nix {}
</syntaxHighlight>
</syntaxHighlight>