Qt: Difference between revisions

Smudgebun (talk | contribs)
Added a warning for the deprecated Qt section
Phobos (talk | contribs)
m Updated grammar
 
Line 4: Line 4:
{{warning|With the deprecation of <code>qt5.full</code> & <code>qt6.full</code>, for 25.11 and up (see [https://github.com/NixOS/nixpkgs/blob/32b61ba4d9088ef926dd27065daad604ca6b58aa/pkgs/development/libraries/qt-6/default.nix#L152 change]) this recommendation is outdated. For now please primarily refer to the [[#Explicit Dependencies|Explicit Dependencies]] Section below.}}
{{warning|With the deprecation of <code>qt5.full</code> & <code>qt6.full</code>, for 25.11 and up (see [https://github.com/NixOS/nixpkgs/blob/32b61ba4d9088ef926dd27065daad604ca6b58aa/pkgs/development/libraries/qt-6/default.nix#L152 change]) this recommendation is outdated. For now please primarily refer to the [[#Explicit Dependencies|Explicit Dependencies]] Section below.}}


If you want to develop qt applications in nixos you have to use nix-shell or direnv.
To develop Qt applications in NixOS you may use nix-shell or direnv.
For using nix-shell just run this command in the terminal:
For using nix-shell just run this command in the terminal:


Line 24: Line 24:
</syntaxHighlight>
</syntaxHighlight>


Also create '''.envrc''' file and paste: <code>use_nix</code> into it.
Also, create '''.envrc''' file and paste: <code>use_nix</code> into it.
 
Happy qt coding :)


=== Explicit Dependencies ===
=== Explicit Dependencies ===


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:
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">
<syntaxhighlight lang="nix">