Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create and activate venv via Nix Flake #229

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

seakrueger
Copy link
Contributor

When running nix develop to generate a development shell, the python virtual environment will now automatically be created and dependencies from requirements.txt will be installed (and the venv will be activated). Effectively, this moves the setup portion of the TagStudio.sh to the flake and means the setup script for Linux/Mac is no longer needed when using nix. The README has been updated to reflect the new process of nix develop then python3 tagstudio/tag_studio.py.

The python virtualenvironment package has been replaced with venvShellHook, which creates a virtual environment in the directory specified by $venvDir (in this case ./.venv). This also gives the postVenvCreation hook, where pip install is then executed. The previous shellHook needed to be moved to postShellHook to execute after the venv is created. unset SOURCE_DATE_EPOCH is probably not necessary, but is to solve a potential issue between pip and nix and appears in a lot of python flake examples.

@seakrueger
Copy link
Contributor Author

seakrueger commented May 30, 2024

This was finished prior to #149 being merged, which appears to have added a dep for libpulse and currently prevents the program from starting successfully via the flake. I'll create pr to fix that (and some other dep issues) soon, but this was bad timing on my part. Converting to draft

@seakrueger seakrueger marked this pull request as draft May 30, 2024 22:38
@CyanVoxel CyanVoxel added the Type: Installation Installing, building, and/or launching the program label May 31, 2024
@seakrueger
Copy link
Contributor Author

Now based on #244

@xarvex
Copy link
Member

xarvex commented Jun 6, 2024

Same as my comment on #224, I've will follow up as soon as I've done a proper test and review, thank you!

@CyanVoxel
Copy link
Member

Just a heads up, the instructions for running/building from source have been moved from the README to CONTRIBUTING.md

@seakrueger
Copy link
Contributor Author

seakrueger commented Jun 11, 2024

Currently, everything related to the actual creation of the venv works. The main blocker I'm on right now is mypy always fails with [import-not-found] for all third-party libraries, I don't know if that's something fixable or a fundamental broken-on-nix problem.

@seakrueger seakrueger marked this pull request as ready for review June 11, 2024 00:26
@xarvex
Copy link
Member

xarvex commented Jun 11, 2024

Thanks for the hard work on this. I'll see if I can figure something out myself for mypy.

@xarvex
Copy link
Member

xarvex commented Jun 16, 2024

Really couldn't figure out a way to get mypy to function without using from nixpkgs repos. For now the versions are the same as in the requirements-dev.txt but will have to see what this might mean when they drift apart.

@yedpodtrzitko
Copy link
Collaborator

Really couldn't figure out a way to get mypy to function without using from nixpkgs repos. For now the versions are the same as in the requirements-dev.txt but will have to see what this might mean when they drift apart.

I have no experience with NixOS, so sorry if I'm missing something obvious, but why is installation of requirements-dev.txt needed in first place? The dependencies are meant for developers, and in such case you will be most likely cloning the git repo instead of installing it via package manager, no?

@xarvex
Copy link
Member

xarvex commented Jun 16, 2024

Really couldn't figure out a way to get mypy to function without using from nixpkgs repos. For now the versions are the same as in the requirements-dev.txt but will have to see what this might mean when they drift apart.

I have no experience with NixOS, so sorry if I'm missing something obvious, but why is installation of requirements-dev.txt needed in first place? The dependencies are meant for developers, and in such case you will be most likely cloning the git repo instead of installing it via package manager, no?

This is a dev shell for developers to use, on NixOS you cannot just clone a repo and expect that to work and libraries don't exist the same as on a traditional distribution. This dev shell provides the utilities and libraries needed for a working development environment to use on TagStudio.
Building and running is something I will cook up at some point for NixOS, which as well needs to be handled in this flake.

seakrueger and others added 6 commits June 17, 2024 13:05
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.
Mostly as a fallback for xserver.
Moves the previous updated blurb from the README to the new CONTRIBUTING
file. Also reworks some wording to link to the Flake nix wiki page for
nix users who haven't enable flakes yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Installation Installing, building, and/or launching the program
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants