Qt: Difference between revisions
Added a section for explicitly specifying development dependencies |
m Fix syntax error in example code for specifying explitit Qt dependencies |
||
| Line 32: | Line 32: | ||
However if fetching the entirety of <code>pkgs.qt6.full</code> is not appealing and you know which parts of Qt you need, your first instinct might be adding something like <code>pkgs.qt6.qtdeclarative</code> for creating QML-based Qt programs to <code>buildInputs</code>, '''however''' that will not work and you will get compile errors for missing libraries. <code>pkgs.qt6.full</code> is actually [https://github.com/NixOS/nixpkgs/blob/nixos-24.11/pkgs/development/libraries/qt-6/default.nix#L94-L144 creating an environment that contains all Qt libraries] that allows <code>qmake</code> and tools to find those libraries, so you must do the same and <code>pkgs.qt6.env</code> will help make one. For example: | However if fetching the entirety of <code>pkgs.qt6.full</code> is not appealing and you know which parts of Qt you need, your first instinct might be adding something like <code>pkgs.qt6.qtdeclarative</code> for creating QML-based Qt programs to <code>buildInputs</code>, '''however''' that will not work and you will get compile errors for missing libraries. <code>pkgs.qt6.full</code> is actually [https://github.com/NixOS/nixpkgs/blob/nixos-24.11/pkgs/development/libraries/qt-6/default.nix#L94-L144 creating an environment that contains all Qt libraries] that allows <code>qmake</code> and tools to find those libraries, so you must do the same and <code>pkgs.qt6.env</code> will help make one. For example: | ||
< | <syntaxhighlight lang="nix"> | ||
# shell.nix | # shell.nix | ||
{ pkgs ? import <nixpkgs> {} }: | { pkgs ? import <nixpkgs> {} }: | ||
| Line 38: | Line 38: | ||
# pkgs.qt6.env already includes pkgs.qt6.qtbase | # pkgs.qt6.env already includes pkgs.qt6.qtbase | ||
# And using `with` to prevent a lot of typing. | # And using `with` to prevent a lot of typing. | ||
qtEnv = with pkgs.qt6; env "qt-custom-${qtbase.version}" | qtEnv = with pkgs.qt6; env "qt-custom-${qtbase.version}" [ | ||
qtdeclarative | |||
]; | |||
in | in | ||
pkgs.mkShell { | pkgs.mkShell { | ||
| Line 53: | Line 51: | ||
]; | ]; | ||
} | } | ||
</ | </syntaxhighlight> | ||
== Packaging == | == Packaging == | ||