summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 40e09a0a9cc55249ed2da758df5a89360e83b6f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
  description = "Qt for Python development environment (PySide6, nixos-26.05)";

  inputs = {
    nixpkgs.url = "github:Nixos/nixpkgs/nixos-26.05";
  };

  outputs =
    { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};

      python = pkgs.python3.withPackages (
        p: with p; [
          pyside6
        ]
      );
    in
    {
      formatter.${system} = pkgs.nixfmt;

      devShells.${system}.default = pkgs.mkShell {
        packages = [
          python
          pkgs.qt6.qttools # designer, linguist, assistant
          pkgs.qt6.qtdoc # offline documentation for Assistant
        ];

        # Platform plugins are found automatically (compiled-in store
        # paths), but QML imports are NOT: without this export, any
        # "import QtQuick" fails with "module is not installed".
        shellHook = ''
          # uic/rcc (with Python codegen via -g python) live in libexec,
          # not bin, so they are not on PATH by default.
          export PATH=${pkgs.qt6.qtbase}/libexec:$PATH
          export QML_IMPORT_PATH=${pkgs.qt6.qtdeclarative}/lib/qt-6/qml
          export QML2_IMPORT_PATH=$QML_IMPORT_PATH
          export QT_DOCS=${pkgs.qt6.qtdoc}/share/doc
          echo "PySide6 $(python -c 'import PySide6; print(PySide6.__version__)') sur Python $(python -V | cut -d' ' -f2)"
          echo "Exemples dans ./examples — voir README.md"
        '';
      };
    };
}