3 ms·
> It does have a really harsh learning curve though. Would it be possible to automatically translate all Nix build scripts into a language that is more ergonom
by amelius 1y ago
> It does have a really harsh learning curve though.
Would it be possible to automatically translate all Nix build scripts into a language that is more ergonomic and fun to work with?
- huimang 1y agoThe learning curve isn't due to the language, and personally I find writing nix files to be much more pleasant than any other build system I've worked with, and most languages that I've worked with.
- mikepurvis 1y agoAbsolutely this. Everyone fixates on the language but the hard part is really the packaging ecosystem and how-do-I-X type questions where Nix has ten answers that are all better than what Debian or Arch can do, but it's not obvious which is the best between them or how they compare. See things like Python packaging, how to make ISOs/installers/containers, how to override a scope, how to maintain a dev environment, how to do package testing, how to set up your own CI with caching and binary delivery, etc.
- zxexz 1y agoYea, IME the best manual for nixos/nixpkgs is the repo and the manual for git, grep etc. I clone or save every public repo or article or whatnot i find that helps me or seems interesting. These two examples come to mind: the page that made what the config/options system really is [0], and the post that really drive home to me it’s all just configs! A config language all the way down! [1] [0] https://nlewo.github.io/nixos-manual-sphinx/development/replace-modules.xml.html https://nlewo.github.io/nixos-manual-sphinx/development/repl... [1] https://astrid.tech/2022/11/03/0/overlay-nixpkgs-pr/ https://astrid.tech/2022/11/03/0/overlay-nixpkgs-pr/
- mikepurvis 1y agoYeah, and that's obviously pretty hostile when the best guide is reading the source. I think the deeper problem that maybe isn't always considered in the "Nix needs better docs" discourse is that there are many tasks that simply don't have an optimal workflow in Nix (yet). It can be weird documenting how do some particular thing, but having to frontload that doc with a bunch of caveats about which particular set of tradeoffs the suggested approach is embracing. For example with Python, a huge one is around how much you want to leverage the Python packages already in nixpkgs. If you want to use them, which makes sense if you don't really care about versions or you've got a lot of things with tie-ins to non-Python such as bindings packages, then you probably want the conventional buildPythonPackage workflow, where you manually package any missing deps, perhaps assisted by pip2nix: https://wiki.nixos.org/wiki/Python https://wiki.nixos.org/wiki/Python But if you have a self-contained app that already has everything locked and you just want minimum friction, then you almost certainly want uv2nix: https://github.com/pyproject-nix https://github.com/pyproject-nix A lot of things in Nix are like this. Same story with containers where you've got dockerTools.buildImage but depending on your workflow nix2container is almost certainly the better choice. Nix's limitations around IFD are finally being addressed by https://tvix.dev/ https://tvix.dev/ but that's a rewrite and brings yet another potential split. Nix is the epitome of being perpetually stuck in the 1000 flowers blooming [1] state of things, and in some ways that's beautiful, but it needs people to build a cathedral or two within the bazaar. Determinate [2] is trying, but they've also taken some heat from the community for concerns around OSS and governance. [1]: https://news.ycombinator.com/item?id=10294833 https://news.ycombinator.com/item?id=10294833 / https://gigamonkeys.com/flowers/ https://gigamonkeys.com/flowers/ [2]: https://determinate.systems/ https://determinate.systems/
- zxexz 1y agoThat's an excellent way to put it! Also, never read the 'Let 1000 Flowers Bloom' article, thanks. What I find extremely interesting, is I would give (and have given) exactly same advice to someone asking me about python or docker packaging. Which means that we both ended up with the same long struggles and rabbit holes independently. It would certainly be excellent if those cathedrals in the bazaar were more centrally known and documented, to concentrate efforts, and to help others avoid having to spend so much time doing the same.
- microtonal 1y agoNix guarantees that a given derivation will always evaluate to the same store .drv (the 'recipe' that is actually built) if the derivation itself (or anything it depends on, passed as arguments) does not change. This property requires a pure language with no side-effects. Nix was not completely pure (e.g. `currentSystem` and `getEnv` were impure), but Flakes close this gap. You could of course generate Nix from another language (or .drvs), but you probably want to keep the same guarantees. Besides that, Nix itself is actually a pretty simple functional programming language. The difficulty is probably for most people knowing/understanding everything that is built on top of it: fixed points, overlays, nixpkgs.lib, stdenv, overriding, hooks, all the programming-language specific builders, etc. It is a pretty big ecosystem and a lot of it is not very well documented. That said, when I started using nixpkgs/NixOS in 2018, it was the easiest package ecosystem to start contributing too. RPM .spec and Debian rules files are quite archaic, nixpkgs was really a breath of fresh air. It's just that because NixOS is very principled and does not follow HFS, you have to become a packager yourself much sooner than most other distributions to get stuff working. (Though this changed a bit with nix-ld.)
- lillecarl 1y agoHonestly just start "vibe coding". After some discussion and iteration with Copilot I had a derivation that pulls the CSI protobuf spec and dumps python code and types into something LARPing as a real python library. A few hours later I implemented my own CSI driver using these things. Github crawls nixpkgs and everyone and their aunt have public nixos configs, the LLM is good at Nix. That all nix build instructions are bash isn't the worst, and I hate bash. You can always create a python script to call in a derivation if you need.
- bjackman 1y agoYeah I have had some luck with vibe coding Nix but also I've found you have to be extremely cautious. It bullshits a LOT more than with other coding things I use LLMs for. This has led me on a couple of wild goose chases. I think it helps to have comments like # AN AI WROTE THIS BIT, REUSE WITH CAUTION
- lillecarl 1y agoIt guided me to write the Nix expression to package the grpc libs, then it implemented a complete CSI interface with hostPath mounts that I could tweak afterwards. Also very good at making Kubernetes manifests, and CRD manifests and other config-like things.
- bjackman 1y agoAs others have said, this would be a solution to the wrong problem. The language itself is fine. I just read through the language intro on https://nix.dev https://nix.dev and immediately just "got it" - if you've done any functional programming at all and/or used stuff like JSonnet/Cue there's not much to learn. But also the fundamental model of Nix is incompatible with anything that can be translated to a simple Bash script. If you could translate it to Bash I wouldn't wanna use it But yeah the difficulty is the ecosystem. "Nix" is a lot of things and all of those things are individually extremely flexible. This adds up to a system that can do almost anything and that inevitably makes it kinda hard to break into. The docs are honestly better than I could do but documenting this system just seems unbelievably hard to do well.
- otabdeveloper4 1y agoNo, because the Nix language is already ergonomic and fun. Any other language will make it worse. It's a difficult problem domain that isn't solved with syntax sugar.
- zxexz 1y agoAgreed. Except for “with”. The with statement is definitely fun. And ergonomic. Until it bites you.