Qt: Difference between revisions

Phobos (talk | contribs)
m Updated grammar
Aura (talk | contribs)
m Added nix lang on some code hightlight
 
Line 13: Line 13:
For using direnv, create a '''shell.nix''' file in the root of your project and paste these lines into it:
For using direnv, create a '''shell.nix''' file in the root of your project and paste these lines into it:


<syntaxHighlight lang=nix>
<syntaxhighlight lang="nix"># shell.nix
# shell.nix
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import <nixpkgs> {} }:
   pkgs.mkShell {
   pkgs.mkShell {
Line 21: Line 20:
       pkgs.qtcreator
       pkgs.qtcreator
     ];
     ];
}
}</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.
Line 30: Line 28:
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"># shell.nix
# shell.nix
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import <nixpkgs> {} }:
let
let
Line 48: Line 45:
       pkgs.qtcreator
       pkgs.qtcreator
     ];
     ];
}
}</syntaxhighlight>
</syntaxhighlight>


== Packaging ==
== Packaging ==
Line 138: Line 134:


For actual python applications, you may also use something like that (to test) :
For actual python applications, you may also use something like that (to test) :
<syntaxHighlight>
<syntaxHighlight lang=nix>
python3.pkgs.buildPythonApplication {
python3.pkgs.buildPythonApplication {
   pname = "blabla";
   pname = "blabla";