|
1 | 1 | {
|
| 2 | + description = "Tag Studio Development Environment"; |
| 3 | + |
2 | 4 | inputs = {
|
3 | 5 | nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
4 | 6 |
|
5 | 7 | qt6Nixpkgs = {
|
6 |
| - # Commit bumping to qt6.6.3 |
7 |
| - url = "github:NixOS/nixpkgs/f862bd46d3020bcfe7195b3dad638329271b0524"; |
| 8 | + # Commit bumping to qt6.7.1 |
| 9 | + url = "github:NixOS/nixpkgs/47da0aee5616a063015f10ea593688646f2377e4"; |
8 | 10 | };
|
9 | 11 | };
|
10 | 12 |
|
|
15 | 17 | qt6Pkgs = qt6Nixpkgs.legacyPackages.x86_64-linux;
|
16 | 18 | in {
|
17 | 19 | devShells.x86_64-linux.default = pkgs.mkShell {
|
| 20 | + name = "Tag Studio Virtual Environment"; |
| 21 | + venvDir = "./.venv"; |
| 22 | + |
18 | 23 | LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
|
19 | 24 | pkgs.gcc-unwrapped
|
20 | 25 | pkgs.zlib
|
|
35 | 40 | qt6Pkgs.qt6.full
|
36 | 41 | qt6Pkgs.qt6.qtbase
|
37 | 42 | ];
|
| 43 | + |
38 | 44 | buildInputs = with pkgs; [
|
39 | 45 | cmake
|
40 | 46 | gdb
|
41 | 47 | zstd
|
42 |
| - python312Packages.pip |
43 | 48 | python312Full
|
44 |
| - python312Packages.virtualenv # run virtualenv . |
| 49 | + python312Packages.pip |
45 | 50 | python312Packages.pyusb # fixes the pyusb 'No backend available' when installed directly via pip
|
| 51 | + python312Packages.venvShellHook # Initializes a venv in $venvDir |
| 52 | + ruff # Ruff cannot be installed via pip |
| 53 | + mypy # MyPy cannot be installed via pip |
46 | 54 |
|
47 | 55 | libgcc
|
48 |
| - makeWrapper |
49 |
| - bashInteractive |
50 | 56 | glib
|
51 | 57 | libxkbcommon
|
52 | 58 | freetype
|
|
70 | 76 | # this is for the shellhook portion
|
71 | 77 | qt6Pkgs.qt6.wrapQtAppsHook
|
72 | 78 | ];
|
| 79 | + |
| 80 | + # Run after the virtual environment is created |
| 81 | + postVenvCreation = '' |
| 82 | + unset SOURCE_DATE_EPOCH |
| 83 | +
|
| 84 | + echo Installing dependencies into virtual environment |
| 85 | + pip install -r requirements.txt |
| 86 | + pip install -r requirements-dev.txt |
| 87 | + # Hacky solution to not fight with other dev deps |
| 88 | + # May show failure if skipped due to same version with nixpkgs |
| 89 | + pip uninstall -y mypy ruff |
| 90 | + ''; |
| 91 | + |
73 | 92 | # set the environment variables that Qt apps expect
|
74 |
| - shellHook = '' |
75 |
| - export QT_QPA_PLATFORM=wayland |
| 93 | + postShellHook = '' |
| 94 | + unset SOURCE_DATE_EPOCH |
| 95 | +
|
| 96 | + export QT_QPA_PLATFORM="wayland;xcb" |
76 | 97 | export LIBRARY_PATH=/usr/lib:/usr/lib64:$LIBRARY_PATH
|
77 | 98 | # export LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib/:/run/opengl-driver/lib/
|
78 | 99 | export QT_PLUGIN_PATH=${pkgs.qt6.qtbase}/${pkgs.qt6.qtbase.qtPluginPrefix}
|
79 | 100 | bashdir=$(mktemp -d)
|
80 | 101 | makeWrapper "$(type -p bash)" "$bashdir/bash" "''${qtWrapperArgs[@]}"
|
| 102 | +
|
| 103 | + echo Activating Virtual Environment |
| 104 | + source $venvDir/bin/activate |
| 105 | + export PYTHONPATH=$PWD/$venvDir/${pkgs.python312Full.sitePackages}:$PYTHONPATH |
| 106 | +
|
81 | 107 | exec "$bashdir/bash"
|
82 | 108 | '';
|
83 | 109 | };
|
|
0 commit comments