I am using NixOS having EXWM as my window manager and home-manager for my home configuration, as well as for my python environment (I use python3.withPackages).
I am commonly making use of regular programming via org-babel/ob-ipython. I have a single python package that I use to collect common functions for import in my org files.
This worked amazingly well under Arch Linux, where I just “installed” that python package using “python setup.py develop” and could access it from anywhere. Now with NixOS, I feel a couple of hurdles to maintain this convenient workflow and am looking either for a solution to it, or to alternative workflows with similar benefits (i.e. access to up-to-date python package code from within org-mode within the need to reinstall my python package after each change).
The documentation here, states that nix is capable of installing a package in develop mode under these given circumstances:
If we create a shell.nix file which calls buildPythonPackage , and if src is a local source, and if the local source has a setup.py , then development mode is activated.
So this is what I tried in my home-manager’s home.nix, however, since it is not a shell.nix, my package is installed in a static fashion, and changes to it are only noticed from within ipython/org-babel after switching my environment using home-manager switch.
Can anyone think of a solution on how to get my workflow (EXWM + org-babel/ob-ipython + development package) running or do have suggestions for a similar working workflow?
Generally, I don’t try to have a global python install. Instead I have per directory nix-shell’s which allow for me to switch contexts quickly (this can be paired with direnv to make this fairly transparent).
Thanks for the video. It indeed exactly contains what I am interested in. In fact, the code that I used above is analog to one of your examples.
The pythonImportsCheck = ["mypkg"]; check is very useful and does NOT fail for me neither during nix-build nor when running nix-shell.
Also, when looking at my PYTHON_PATH variable, my package is indeed its first element and contains an egg-link to the correct directory:
[nix-shell:~/Projects/mypkg]$ ls /run/user/1000/tmp.UkbEtlgEE0/lib/python3.7/site-packages # got this directory from PYTHON_PATH
[nix-shell:~/Projects/mypkg]$ cat /run/user/1000/tmp.UkbEtlgEE0/lib/python3.7/site-packages/mypkg.egg-link
/home/moritz/Projects/mypkg/src contains the main-package mypkg, which I want to be able to import.
Unfortunately, although the paths look good, when I spin up a python shell and try to import mypkg it does not find it. It’s especially weird, since the pythonImportsCheck passed…
For now, I’ll try to nix-build an environment that contains a python virtualenv (I only saw a way to do it with nix-shell so far…), although, I’d really like to understand what is going wrong.