diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 942aa3eb..24f3b0e3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,10 +64,10 @@ _Learn more about setting up a virtual environment [here](https://docs.python.or - Run the "TagStudio.sh" script and the program should launch! (Make sure that the script is marked as executable if on Linux). Note that launching from the script from outside of a terminal will not launch a terminal window with any debug or crash information. If you wish to see this information, just launch the shell script directly from your terminal with `./TagStudio.sh`. - - **NixOS** (TagStudio.sh) + - **NixOS** (Nix Flake) > [!WARNING] > Support for NixOS is still a work in progress. - - Use the provided `flake.nix` file to create and enter a working environment by running `nix develop`. Then, run the `TagStudio.sh` script. + - Use the provided [Flake](https://nixos.wiki/wiki/Flakes) to create and enter a working environment by running `nix develop`. Then, run the program via `python3 tagstudio/tag_studio.py` from the root directory. - **Any** (No Scripts) diff --git a/flake.lock b/flake.lock index e6a43b0b..f83ab58f 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1717602782, - "narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=", + "lastModified": 1718318537, + "narHash": "sha256-4Zu0RYRcAY/VWuu6awwq4opuiD//ahpc2aFHg2CWqFY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6", + "rev": "e9ee548d90ff586a6471b4ae80ae9cfcbceb3420", "type": "github" }, "original": { @@ -18,17 +18,17 @@ }, "qt6Nixpkgs": { "locked": { - "lastModified": 1711460435, - "narHash": "sha256-Qb/J9NFk2Qemg7vTl8EDCto6p3Uf/GGORkGhTQJLj9U=", + "lastModified": 1716287118, + "narHash": "sha256-iUTrXABmJAkPRhwPB8GEP7k52OWHVSRtMzlKQ2kIrz4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f862bd46d3020bcfe7195b3dad638329271b0524", + "rev": "47da0aee5616a063015f10ea593688646f2377e4", "type": "github" }, "original": { "owner": "NixOS", "repo": "nixpkgs", - "rev": "f862bd46d3020bcfe7195b3dad638329271b0524", + "rev": "47da0aee5616a063015f10ea593688646f2377e4", "type": "github" } }, diff --git a/flake.nix b/flake.nix index dbe54de5..69adee17 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,12 @@ { + 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"; + # Commit bumping to qt6.7.1 + url = "github:NixOS/nixpkgs/47da0aee5616a063015f10ea593688646f2377e4"; }; }; @@ -15,6 +17,9 @@ 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 @@ -35,18 +40,19 @@ qt6Pkgs.qt6.full qt6Pkgs.qt6.qtbase ]; + buildInputs = with pkgs; [ cmake gdb zstd - python312Packages.pip python312Full - python312Packages.virtualenv # run virtualenv . + python312Packages.pip python312Packages.pyusb # fixes the pyusb 'No backend available' when installed directly via pip + python312Packages.venvShellHook # Initializes a venv in $venvDir + ruff # Ruff cannot be installed via pip + mypy # MyPy cannot be installed via pip libgcc - makeWrapper - bashInteractive glib libxkbcommon freetype @@ -70,14 +76,34 @@ # 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 + # Hacky solution to not fight with other dev deps + # May show failure if skipped due to same version with nixpkgs + pip uninstall -y mypy ruff + ''; + # set the environment variables that Qt apps expect - shellHook = '' - export QT_QPA_PLATFORM=wayland + postShellHook = '' + unset SOURCE_DATE_EPOCH + + export QT_QPA_PLATFORM="wayland;xcb" 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" ''; };