News for hackers. Stuff that matters.
Re:Building Go Programs with Nix Flakes by aidenn0 on Wednesday December 14, 2022 @11:46AM (#33986127)
Now if only there were a reliable way to do this with Python programs with a requirements.txt.

Last time I tried (maybe 2 months ago on NixOS 22.05), I found several different tools that claimed to be able to do this and they all failed in various ways; some failed quickly, others took a long time to fail. I ended up using my brain as an SAT solver and manually copying in nix expressions from older versions of nixpkgs that matched versions of the python libs that were needed.

Re:Building Go Programs with Nix Flakes by theptip on Wednesday December 14, 2022 @12:47PM (#33986969)
Does https://pypi.org/project/pypi2nix/ work?

Now that pip supports pinning with a sha (I say “now that”, this was added years ago but it wasn’t always thus), it seems it should be trivial to map onto the Nix model.

I have been working with poetry and playing with poetry2nix so haven’t tried raw pip requirements files with Nix.

Re:Building Go Programs with Nix Flakes by aidenn0 on Wednesday December 14, 2022 @04:10PM (#33990609)
If I were a better engineer, I'd have recorded a list of all the things I tried, but I didn't. Most of them ended in the substring "2nix" but the names kind of blur together so I can't definitively say I tried it. I have some free time on the 23rd and may see if pypi2nix works with the project or not, and file a bug if it doesn't.
Re:Building Go Programs with Nix Flakes by Filligree on Wednesday December 14, 2022 @12:04PM (#33986395)
In all fairness, this is impossible with or without nix.

I've had some success with Poetry. But then I ran into programs that invoke pip during startup...

Re:Building Go Programs with Nix Flakes by ewuhic on Thursday December 15, 2022 @02:22AM (#33996326)
Could you please elaborate more, for a person who has never used poetry?
Re:Building Go Programs with Nix Flakes by xena on Wednesday December 14, 2022 @12:21PM (#33986637)
Yeah the situation with Python is kind of crap to begin with. The main problem with requirements.txt is that it doesn't lock the SHAsums of the packages being depended on.

The Python ecosystem also doesn't seem to have a sensible solution for dependency declaration in general. It's kind of remarkable that anything works at all in Python land, it's a lot of "let's hope it works often enough". To be fair it does work out a lot of the time, but when that fails you end up coming to people like me.

I should do some research and see if I can figure out the best way to do this in Python, but I don't use Python at all personally or professionally.

Re:Building Go Programs with Nix Flakes by drpyser22 on Wednesday December 14, 2022 @02:02PM (#33988338)
What would you consider a sensible solution? What about * Pip-tools(requirements.in + requirements.txt) * Poetry (pyproject.toml+poetry.lock) * Pipenv(Pipfile+Pipfile.lock)

Those and others enable easy declaration of direct dependencies and compile (resolve) a lock file of the actual dependency graph with hashes. Those tools have their issues and idiosyncrasies, but the dependency declaration aspect seems sensible and functional.

Re:Building Go Programs with Nix Flakes by ac130kz on Wednesday December 14, 2022 @02:17PM (#33988602)
PEP 518 has been around for a long time. All of the projects must be running pyproject.toml + poetry.lock. Like really, it's the new modern standard, which solves a lot of headaches. The configs, the Python version, the dependencies, are all nicely crammed together. There's even a thing poetry2nix, which seems pretty well supported.