no description only meoww


it wouldn't be my problem if it weren't NixOS since c libs would be globally available so i could just use virtualenv and not care

stuff i want:

  • mutable virtualenv that i can install in editable mode into because i often work on multiple packages at once

  • some nixpkgs Python packages in my virtualenv because unfortunately native deps exist

  • negotiable, but i want to be able to just pip install stuff in my user profile for quick hacking. or at least have stuff like ipython etc. currently i use python.withPackages for this which breaks pip user install.

    mach-nix and the nixpkgs Python infrastructure gets me the latter but not the former afaik

It seems like you can't compose nixpkgs Python packages and virtualenv, which is extremely frustrating: virtualenvs can't use packages from nixpkgs as far as i can tell. The only way seems to be to use mach-nix or nixpkgs to provide the Python environment including dependencies and ignore both pip and virtualenv.

in haskell land (i used to say haskell deps are equally abysmal but i don't believe it anymore, haskell is less bad) it works like so: you use nix to acquire project deps, then while working on them locally you just stick your local hacking copies into cabal.project and they're not nix's problem until you release. https://jade.fyi/blog/nix-hls-for-deps/

or you can just get a standard cabal toolchain from Nix and ignore Nix modulo providing the necessary c libs as inputs to your shell (which will just work because pkg-config). i feel like this is a lot harder with python.


You must log in to comment.

in reply to @leftpaddotpy's post:

good enough to jiggle the bits in my memory: it seems to be PIP_PREFIX and PYTHONPATH that were used in the hacks i saw: https://matrix.ai/blog/developing-with-nix/

like, venv works as normal but you're fucked as soon as you want packages from nixpkgs along with your other packages. I guess what I want is "bundle these nix Python packages with my interpreter and install anything else mutably into this venv", which I think is what that does.

so here's what we did:

shell.nix

let
  pkgs = import <nixpkgs> {};
  pythonPackages = pkgs.python3Packages;
in
pkgs.mkShell rec {
  venvDir = "./.venv";
  buildInputs = with pythonPackages; [
    python
    venvShellHook
  ];

  postVenvCreation = ''
    unset SOURCE_DATE_EPOCH
    pip install -r requirements.txt
  '';

  postShellHook = ''
    unset SOURCE_DATE_EPOCH
  '';
}

yeah this is what happens when documentation maintainers neither set URL slugs by hand, nor have any explanation for contributors of what a URL slug is or how to pick a good one. we've dug into this aspect of the Nix docs before, and decided it wasn't worth our time.

glad you found it though!