@justinas @publicvoit Well unless you go down the #poetry2nix rabbit hole, using poetry+fhs is a natural convergence point I would say. You want to use the language's packaging tools, not #nix's for others to be able to work on it, too. poetry is widely used and works well. uv might replace it at some point. But as soon as you use anything serious (i.e. precompiled, think numpy, scipy, sklearn, pick your poison), you're f*cked on #NixOS. So you make an fhsUserEnv.

Dagster is an orchestration engine for data pipelines written in Python. In this configuration, I've subdued it into a reproducibly built, runnable Nix application with poetry2nix:

https://rossabaker.com/configs/dagster/

Next steps include a NixOS module and systemd service for production deployment.

#Dagster #Nix #Poetry2Nix

Ross A. Baker: Dagster

Dagster is an orchestrator for data pipelines. This configuration packages Dagster's OSS version with poetry2nix and makes it runnable from anywhere with Nix.

Oooh I just realized that #poetry2nix fixes the RPATHs in pre-compiled Python packages such as #numpy, #scipy, et al., so they just work! 🤯 For some reason I thought it just packaged the files up but it makes total sense that it also fixes binaries. Makes it even more useful! 💪

#nix #nixos

Slowly getting the hang of #poetry2nix (packages your  #pythonPoetry project with  #nix). Without a more solid understanding of the nix language and packaging in general, poetry2nix is just pain when Python packages do weird things (like dependency cycles all over the place wtf adafruit?). But now with my 10th or so attempt of rejecting and retrying poetry2nix again, I can package quite some projects of mine with it. 💪

#nix #NixOS

So close today! 😣

How do I give my #poetry2nix app a working #sudo?

propagatedBuildInputs = with pkgs; [ sudo ]; // produces this:

sudo: /nix/store/s2fqzzw2zqq613qmh9iv8am93ldmkdls-sudo-1.9.15p5/bin/sudo must be owned by uid 0 and have the setuid bit set

Hard-coding /run/wrappers/bin/sudo? Doesn't feel very #nix'y...

#nixos

@publicvoit I hit a wall with #poetry2nix on a more complex project (weird errors on the python-magic package 🤷), so I added another flake template to run your poetry project inside an FHS environment, which does less magic than poetry2nix and generally feels a bit more robust, as this is exactly what prebuilt Python packages expect. The downside is that one needs to manually specify the system dependencies...

https://gitlab.com/nobodyinperson/flakes/-/tree/main/poetryFHS

poetryFHS · main · Yann Büchau / ❄️ Nix Flake Templates · GitLab

Nix flake templates

GitLab

I have been struggling hard doing proper  #Python development on  #NixOS.

pip install'ed binary packages (numpy et. al) don't work (i.e. don't find system libraries like libz libstdc++ etc.), making scientific data analysis completely impossible. The workarounds (using the nixpkgs versions or setting LD_LIBRARY_PATH) are not viable.

With this #poetry2nix flake template (the clue is preferWheels=true) it seems I can finally work properly:

https://gitlab.com/nobodyinperson/flakes/-/tree/main/poetry2nix

#nix

poetry2nix · main · Yann Büchau / ❄️ Nix Flake Templates · GitLab

Nix flake templates

GitLab

Finally some success with #poetry2nix. Secret ingredient is `preferWheels=true`. This hack gets rids of all the build problems where poetry2nix does not know about each individual package's build system. Kinda dirty though, but at least this is workable.

I find it quite interesting, that it immediately makes 'nix run' run the entry point script I set up in poetry - without me configuring that explicitly. 👍

#nix #nixos #Python

@publicvoit Very nice article that also lists many pain points I am having as a fresh  #NixOS switcher. #Python environments are indeed clunky in my experience. I currently also settled on providing a pinned Python in a nix(-shell) environment, then using poetry (also tried Pipenv) to manage the venv. buildFHSUserEnv might be necessary to get rid of nasty library-not-found errors. #poetry2nix sounds like the solution, but hasn't worked for me yet.

I gave top billing to Devbox in my first newsletter, which is one of my favorite tools next to #Poetry2nix for making portable developer environments using #Nix. What's your favorite Nix project and why?

#Python