introducing a patch to not create a python venv when using the nix flake
fix: nix flake - don't build python venv #58
@ddogfoodd Thanks for the PR! But, I feel like we should find a better solution for this. Would it be possible to detect that we're on Nix, and if so, set a variable that would prevent the creation of the pip environment? For an example of what I envision this looking look, you can see here for how I currently handle this with macOS.
Also, do you mind explaining why the behavior of creating a python venv isn't desirable for Nix (I'm not saying that I disagree with you - I'm just not very familiar with Nix, so I'm genuinely not sure as to why)?
AFAIK nix (including flakes) is sandboxed i.e. offline during build by default.
Required dependencies have to be fetched before the build. Usually this means fetching the source code and importing other nix packages.
I believe the flake currently fails, because the build.sh is run which then tries to upgrade pip and install lxml while offline. We don't even need to, as the flake already imports lxml as a nix derivation / package.
Python venvs can bring further pain on NixOS, when python packages assume required C libraries in a certain location, while nix keeps them somewhere in the nix-store. This shouldn't apply here but is another reason to just skip the venv as long as we don't need it.
I agree and would have done it differently if I knew how. Apparently, we can check for the existence of /etc/NIXOS to detect NixOS, but that would't work on other OS using the nix package manager (https://discourse.nixos.org/t/detect-that-bash-script-is-running-under-nixos/11402/6). Is $OSTYPE a darwin thing or do we set it?
I assume we can set an environment variable during the flakes buildPhase, then skip the venv part if it is set.
Will try later.
ba5e5bc702
to 49e9ea6be6
Environment variable works, wasn't too sure about the naming. How about this?
LGTM, thanks!
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?