mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-01-29 06:10:51 +00:00
When using the nix flake to generate a development shell, the python virtual environment will now automatically be created and dependecies from both requirements.txt and requirements-dev.txt will be installed. This removes the need for using the setup script after entering the dev shell. Exec bash must be the last thing called, as any other commands past it will not get executed by the shell hook. Also removes some duplicate dependencies that I found.
107 lines
2.7 KiB
Nix
107 lines
2.7 KiB
Nix
{
|
|
description = "Tag Studio Development Environment";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
|
|
qt6Nixpkgs = {
|
|
# Commit bumping to qt6.6.3
|
|
url = "github:NixOS/nixpkgs/f862bd46d3020bcfe7195b3dad638329271b0524";
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixpkgs, qt6Nixpkgs }:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
|
|
|
qt6Pkgs = qt6Nixpkgs.legacyPackages.x86_64-linux;
|
|
in {
|
|
devShells.x86_64-linux.default = pkgs.mkShell {
|
|
name = "Tag Studio Virtual Environment";
|
|
venvDir = "./.venv";
|
|
|
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
|
|
pkgs.gcc-unwrapped
|
|
pkgs.zlib
|
|
pkgs.libglvnd
|
|
pkgs.glib
|
|
pkgs.stdenv.cc.cc
|
|
pkgs.fontconfig
|
|
pkgs.libxkbcommon
|
|
pkgs.xorg.libxcb
|
|
pkgs.freetype
|
|
pkgs.dbus
|
|
pkgs.zstd
|
|
# For PySide6 Multimedia
|
|
pkgs.libpulseaudio
|
|
pkgs.libkrb5
|
|
|
|
qt6Pkgs.qt6.qtwayland
|
|
qt6Pkgs.qt6.full
|
|
qt6Pkgs.qt6.qtbase
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
cmake
|
|
gdb
|
|
zstd
|
|
python312Full
|
|
python312Packages.pip
|
|
python312Packages.pyusb # fixes the pyusb 'No backend available' when installed directly via pip
|
|
python312Packages.venvShellHook # Initializes a venv in $venvDir
|
|
|
|
libgcc
|
|
glib
|
|
libxkbcommon
|
|
freetype
|
|
binutils
|
|
dbus
|
|
coreutils
|
|
libGL
|
|
libGLU
|
|
fontconfig
|
|
xorg.libxcb
|
|
|
|
# this is for the shellhook portion
|
|
makeWrapper
|
|
bashInteractive
|
|
] ++ [
|
|
qt6Pkgs.qt6.qtbase
|
|
qt6Pkgs.qt6.full
|
|
qt6Pkgs.qt6.qtwayland
|
|
qt6Pkgs.qtcreator
|
|
|
|
# this is for the shellhook portion
|
|
qt6Pkgs.qt6.wrapQtAppsHook
|
|
];
|
|
|
|
# Run after the virtual environment is created
|
|
postVenvCreation = ''
|
|
unset SOURCE_DATE_EPOCH
|
|
|
|
echo Installing dependencies into virtual environment
|
|
pip install -r requirements.txt
|
|
pip install -r requirements-dev.txt
|
|
'';
|
|
|
|
# set the environment variables that Qt apps expect
|
|
postShellHook = ''
|
|
unset SOURCE_DATE_EPOCH
|
|
|
|
export QT_QPA_PLATFORM=wayland
|
|
export LIBRARY_PATH=/usr/lib:/usr/lib64:$LIBRARY_PATH
|
|
# export LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib/:/run/opengl-driver/lib/
|
|
export QT_PLUGIN_PATH=${pkgs.qt6.qtbase}/${pkgs.qt6.qtbase.qtPluginPrefix}
|
|
bashdir=$(mktemp -d)
|
|
makeWrapper "$(type -p bash)" "$bashdir/bash" "''${qtWrapperArgs[@]}"
|
|
|
|
echo Activating Virtual Environment
|
|
source $venvDir/bin/activate
|
|
export PYTHONPATH=$PWD/$venvDir/${pkgs.python312Full.sitePackages}:$PYTHONPATH
|
|
|
|
exec "$bashdir/bash"
|
|
'';
|
|
};
|
|
};
|
|
}
|