News for hackers. Stuff that matters.
Re:We want to make Nix better by Jeaye on Friday September 02, 2022 @02:05PM (#32693894)
Writing the packaging expressions should not be harder than writing the program, for the average developer. The average developer doesn't know FP, at this point. Nix needs:

1. Approachability for those not indoctrinated in lazy, declarative, functional programming (i.e. Haskell); nope, Nix Pills are not sufficient for the average dev

2. Editor tooling to help guide the writing of expressions (just as anyone learning C# or Rust can use LSP); a better type system for Nix would help here

3. Better documentation for practical things like "Using Nix to manage the dependencies and package a C++ program using Meson", rather than having people piece this together from a bunch of disparate docs

4. A much better CLI UX than `nix-env -qa` and the like (this is ongoing and experimental, but even that broke recently, causing lots of confusion; now it requires `nix --extra-experimental-features nix-command --extra-experimental-features flakes search nixpkgs`)

5. To seriously answer the question: is the Nix language required for the Nix packaging system to exist? Laziness is required, to some degree, but can the next iteration provide an on-ramp which doesn't involve learning a new lang and paradigm? Guix folks sure think so.

I feel like Nix folks have been focused so long on solving the tough problems of declarative, deterministic packaging that they haven't been able to focus on the UX. I also feel like folks for whom Haskell is comfortable may not realize just how absurd it feels to everyone else. Perhaps like the early days of Git.

I do really hope Nix succeeds in this, though; I've been using it, or it's been using me, for several years. [1] and [2] for more info.

[1]: https://blog.jeaye.com/2015/11/24/nixos/

[2]: https://blog.jeaye.com/2017/07/30/nixos-revisited/

Re:We want to make Nix better by tikhonj on Friday September 02, 2022 @03:45PM (#32695004)
Having used Nix a bunch, the system has been hard to use and learn in exactly the same ways that messy legacy codebases I've worked with have been hard—which makes sense since Nixpkgs is an absolutely massive codebase that's evolved over the years with very distributed development. People latch onto the Nix language and the paradigm because that's the most tangible difference but, everything else held equal, Nix + Nixpkgs would be no easier to work with if everything were in Python. (And, if my limited experience is any guide, would be worse with an ad-hoc DSL pretending to be Python à la Starlark!)

This is a pattern I've seen over and over: if a project tries to do something different, the novel aspect gets blamed for issues that would not be surprising in any other context. When faced with a massive awful codebase in Java, well, sometimes legacy code can be a pain, right? It is what it is. People rarely jump to "OOP is a mistake" or "Java is completely unusable". But that's exactly what happens all the time with, say, functional programming.

Pointing to an uncommon choice as the underlying cause of a problem makes for a nice, pat story; the pervasive, diffuse problems inherent to messy legacy code do not. After all, here's a single thing that, presumably we can actually change! Nix being functional is an objective fact while people can—reasonably or not—disagree on how well-designed and well-written Nixpkgs-the-codebase is. Besides, even if we could agree, what could we do about it? We all know how much momentum legacy code has and how hard it is to make anything beyond local improvements. Being a socially convenient story doesn't mean it's a particularly strong explanation, but it does mean that people will believe it even if it isn't.

Re:We want to make Nix better by qbasic_forever on Friday September 02, 2022 @04:19PM (#32695303)
Yeah IMHO nix just needs someone like Brian Kernighan to sit down and write the definitive book about it and its internals. Something that clearly explains the practical and theoretical uses of nix and nixpkgs.

Nix pills, the official manual, etc. aren't really there yet--they talk about all kinds of paradigms that might (?) be going away like nix-env and its ilk. It's just extremely painful to track down the current best practice and way to do things in nix--you're bouncing off all kinds of docs and finding multiple conflicting or out of date ways to do things. Someone needs to give folks a slim book about nix flakes and the flakes way of doing things, the nix language, and a tour of nixpkgs, and IMHO there will be a lot more people using it.

Re:We want to make Nix better by barkingcat on Friday September 02, 2022 @04:30PM (#32695402)
I dislike that the way nix is onboarded for new folks is nix-env, and then for the next documentation to say: nix-env is bad don't use it.

If it was bad why show it to me at all?

Re:We want to make Nix better by Mic92 on Saturday September 03, 2022 @04:02AM (#32699772)
Eelco likes `nix-env` and its new equivalent, but not many other people in the community share this opinion... That's why its in the nix documentation but everyone else uses something else.
Re:We want to make Nix better by kaba0 on Saturday September 03, 2022 @04:04AM (#32699779)
I think the “famous” ‘Simple Made Easy’ talk makes this difference you mean quite palpable: simple is an objective term meaning something is not “interconnected” (not complected) with other parts of the code, while easy is a relative term originating from something being close to us, it being familiar.

So to most programmers, imperative code is easy and FP is hard, but on an objective basis both can be simple. In a way FP may be simpler (according to the talk), as e.g. mutable variables complect/mix together values and time.

Re:We want to make Nix better by dvdkon on Saturday September 03, 2022 @11:03AM (#32702513)
I agree, even with FP and (some) Haskell experience, customising Nix and debugging what's going on is made hard by Nixpkgs being a complex codebase more than anything. However, it is different than the usual large web app. The problem of packaging software is fundamentally easy to break down into tiny pieces, the package definitions themselves. Arch's PKGBUILDs were very easy to understand for me as a novice, much better than RPM SPECs or whatever Debian has, so I think it's not impossible for Nix-equivalent packages to be similarly simple.

The biggest barrier, as I see it, is not actually Nix or Nixpkgs code, but the way NixOS differs from every other Linux distro. Most of my delving into Nixpkgs has been motivated by getting something working that would be trivial in a traditional distro. I agree the Nix language is a red herring, what's really needed is to make work other than "adding a package to Nixpkgs" easier. Actually usable introspection tools that the GP mentioned would be great.

Re:We want to make Nix better by joshka on Friday September 02, 2022 @08:07PM (#32697161)
> Besides, even if we could agree, what could we do about it?

The same thing we do for other paradigms (system architecture, programming concepts, etc.) - find and document common patterns, then find ways to transition to the patterns away from things out of pattern, and lastly introduce automatic refactorings that do fix these things in bulk.

I definitely agree with you on the evolution thing. Homebrew is a similar DSL for installing packages on macOS. It has the problem where things get deprecated from the DSLs (Casks and Formulae) which leads to not being able to run various commands until previously installed software is fixed.

Re:We want to make Nix better by catern on Friday September 02, 2022 @05:21PM (#32695847)
Fascinating take! I've never heard this view before, thank you for sharing it!
Re:We want to make Nix better by a1369209993 on Friday September 02, 2022 @11:33PM (#32698398)
> People rarely jump

I'd just like to take a moment to reiterate that object-oriented programming is a mistake produced by cargo-culting half a dozen different styles used by competent programmers (including the devolpers of smalltalk and its relatives, from which OOP appropiated its name), and that Java is completely unusable by anyone with a sense of self-respect and a awareness that programming languages can be better than least-common-denominator noe-COBOLs. I'm not familiar with the specific codebase you're refering, but it would probably be at least less massive and less awful if it had been written in a more decent language, like Haskell or C.

Re:We want to make Nix better by kaba0 on Saturday September 03, 2022 @04:10AM (#32699810)
That’s like, your opinion, and we all know the common analogy to that :D

Java is a tiny language with not too many concepts going around sitting on top one of the best runtimes with one of the biggest ecosystems. It is a very sane and good choice for almost every program out there, especially that empirically we have absolutely zero evidence for any significant difference between language productivities, other than managed languages being a boost (so your mention of C, which is arguably a language with so many faults one could fill a whole book about, is frankly, quite laughable).

Re:We want to make Nix better by mongol on Saturday September 03, 2022 @06:40AM (#32700521)
If it would be unusuable it would not have been used to do so many useful things. By all means, there may be better options out there but it is far from as bad as you describe it.
Re:We want to make Nix better by rssoconnor on Friday September 02, 2022 @02:43PM (#32694377)
> To seriously answer the question: is the Nix language required for the Nix packaging system to exist? Laziness is required, to some degree, but can the next iteration provide an on-ramp which doesn't involve learning a new lang and paradigm? Guix folks sure think so.

I'd love to hear from someone deeply familiar with Nix and Guix about laziness.

I'm deeply familiar with Nix and I've concluded that lazy semantics is absolutely critical for a configuration language. It lets me refer to other attributes of my configuration from anywhere. For example, I can refer to port number from my whatever service in my firewall. Nix's system of overlays depends on laziness too to provide efficient late-binding familiar from OOP.

I don't need to topologically sort the evaluation of the various inter-dependencies of my configuration. So long as there exists an evaluation order, laziness finds it.

Laziness is compelling enough that I managed to convince the author of Jsonnet <https://jsonnet.org/> of it when he was designing it, and in turn he helped me design what is now known as overlays in Nix.

I don't even understand how Guix manages to work without laziness, though clearly it does somehow. I'm curious as to how that is possible, though I fear I will only ever truly understand by diving into Guix.

Re:We want to make Nix better by mikepurvis on Friday September 02, 2022 @03:53PM (#32695069)
As an 18 month Nix packager/user, I continue to be blown away by how powerful laziness is and how expressive the interactions between multiple overlays can be.
Re:We want to make Nix better by infogulch on Friday September 02, 2022 @02:57PM (#32694529)
I'm not convinced that any of the things you mentioned as benefits of lazy evaluation are a necessary condition to getting those benefits.
Re:We want to make Nix better by WastingMyTime89 on Saturday September 03, 2022 @04:01AM (#32699760)
It’s not. Guix has exactly the same properties while using an eager language.
Re:We want to make Nix better by joshka on Friday September 02, 2022 @08:12PM (#32697215)
> Nix's system of overlays depends on laziness too to provide efficient late-binding familiar from OOP.

As an OOPer, inheritance is one of the things that is generally trotted out as the worst aspect of OO languages. This leads to the mantra "favor composition over inheritance". Much has been written about why and how. But it seems to cause the same pain points that people talk about with respect to laziness in Nix. "Spooky action at a distance" is one of my favorite ways of describing some of these problems.

(I'm not super familiar with Nix, so I could be misreading the points about laziness. Please forgive me if so.)

Re:We want to make Nix better by rssoconnor on Friday September 02, 2022 @09:53PM (#32697803)
I actually agree with you about inheritance and OOP. It's funny because when I finally understood how to override packages with this late-binding technique, I said to myself "Finally I've found a use for inheritance!".

I certainly think people should exercise caution as this could probably be abused quite badly. Maybe people will come up with better designs in the future. However I will say, that the method it has replaced was much worse. The old way was adhoc and almost always failed to achieve ones desires in all but the simplest cases.

Don't just take my word for it. Peter Simons also agrees: <https://github.com/NixOS/nixpkgs/commit/3c8b33eee442fd573d47...>

Re:We want to make Nix better by WastingMyTime89 on Saturday September 03, 2022 @03:59AM (#32699742)
> I don't need to topologically sort the evaluation of the various inter-dependencies of my configuration. So long as there exists an evaluation order, laziness finds it.

That’s not a property of laziness but of how Nix evaluates configurations. I think people overvalue what laziness brings them because they attribute to it things which could be done equally well with an eager language.

Re:We want to make Nix better by rssoconnor on Saturday September 03, 2022 @05:39AM (#32700239)
There is nothing special about how Nix evaluate system configurations that is any different from how Nix evaluates any other expression.

Being able to write

     let usercfg = { username = "nix-user";
                     homedir = "/home/" + usercfg.username;
                   };
     in usercfg
is nearly a hallmark of non-strict semantics, which is achieved by lazy evaluation.

Strict languages can simulate these non-strict semantics by using functions of no parameters to delay evaluation, but you lose the efficiency that comes from the memoization of record fields that you get with lazy evaluation.

P.S. The above would perhaps be more likely be written as

    rec { username = "nix-user"; homedir = "/home/" + username; }
but when specifying larger configurations composed of multiple nested records with wide cross-cutting inter-dependencies, "rec" doesn't really cut it as "rec" works best with extremely local inter-dependencies.
Re:We want to make Nix better by jackac on Friday September 02, 2022 @06:07PM (#32696262)
Recursion and merging semantics are also necessary. I use Nix and Jsonnet a lot, but Nix is much more expressive for complex structures, but the tooling being tightly coupled with the package manage make it impossible to adopt for common use cases.
Re:We want to make Nix better by soraminazuki on Friday September 02, 2022 @08:23PM (#32697284)
There's lots of criticism about the Nix expression language, but it's way overblown IMO. The core language is small. It's essentially just JSON with functions, very similar to Jsonnet. But with Nix, people make too big of a deal out of implementation details like it being lazy, functional, etc. I personally like Nix as a configuration language because it's suitable for complex configurations despite it being small and simple.

There's a case to be made about improving the state of the Nixpkgs APIs though. Stabilizing the APIs and documenting it more thoroughly would dramatically change how people perceive the complexity of Nix. Experienced Nix users grep the Nixpkgs repo to learn about its APIs, but that's far from ideal for newcomers who won't even know where they should look for information.

Still, despite its reputation, Nix lowers the bar for software packaging. Package definitions tend to be more concise, customizable, and reusable than the competition. Nixpkgs contains many useful utilities for packaging and there's an abundance of real world examples contained in a single repo. I also frequently work with RPM, but Nix is much easier in comparison.

Re:We want to make Nix better by techdragon on Friday September 02, 2022 @02:21PM (#32694111)
Point 4 is what lost me when I tried using NixOS for a machine I explicitly wanted as reproducible as possible. I needed to get a bunch of stuff working, then freeze/bundle/lock the useland as a documented working state I could rebuild later if anything went wrong.

When documented examples began steering me towards the still experimental nix flakes and using the sorts of with ever more flags required commands, I bailed and built it using salt. I want to like nix but the current state of things was a massive put off.

Re:We want to make Nix better by ParetoOptimal on Friday September 02, 2022 @02:52PM (#32694470)
> When documented examples began steering me towards the still experimental nix flakes

There's a push to make them not be experimental anymore since so much of the community including myself is using them.

Re:We want to make Nix better by dial9-1 on Friday September 02, 2022 @04:29PM (#32695389)
flakes are anything but experimental at this point, they've been out for many years and I pretty much use them for everything. you don't have to type those flags if you add them to the configuration file
Re:We want to make Nix better by mook on Friday September 02, 2022 @05:33PM (#32695967)
A newcomer is going to treat anything documented as experimental as that, regardless of what the community thinks; if it's no longer experimental, it needs to be presented as such at all the normal entry points. (None of this is unique to Nix; imagine you needed to start packaging for Windows for some reason.)
Re:We want to make Nix better by techdragon on Friday September 02, 2022 @11:04PM (#32698244)
This is exactly what I mean. It’s a big put off to see several year old experimental features and other signs that no one is making the decision to move things forward.

If I’m learning something as big as nix with all the facets it has, I don’t also have time to learn it’s entire community history. It’s not a good thing that I need to do that in order to make a decision about how much to trust experimental features of a tool when I’ve not even been using it more than a few hours from the moment of downloading the iso and installing it. It’s a put off to someone new coming to use nix for the first time.

Re:We want to make Nix better by seqizz on Friday September 02, 2022 @03:56PM (#32695091)
> I also feel like folks for whom Haskell is comfortable may not realize just how absurd it feels to everyone else.

Yup. I can't even imagine what could I accomplish if I'd have something like a "python library" for nixpkgs. I still use nixos but gave up fiddling with nix for a while, after trying to wrap some stuff I am using/developing.*

* (Yes, I know it's easy. I just need flakes or correct amount of "lib: prev: { self"s. Sadly not for me.)

Re:We want to make Nix better by rgoulter on Friday September 02, 2022 @02:11PM (#32693991)
> they haven't been able to focus on the UX. I also feel like folks for whom Haskell is comfortable may not realize just how absurd it feels to everyone else.

The majority of communication I've seen from Nix maintainers over the last few months has been about exactly this.

The submitted post is about exactly that while Nix powerful, they want more people to be able to use it without having to pay a steep penalty to learn it.

Re:We want to make Nix better by tinco on Friday September 02, 2022 @04:09PM (#32695204)
It also doesn't have anything to do with Haskell or it looking somewhat like Haskell. I'm very comfortable in Haskell, and Nix looks awful to me. It's not that it's functional or it's declarative, it's that it's badly designed and not intuitive, making it hard to remember and therefore awkward to code in.
Re:We want to make Nix better by kaba0 on Saturday September 03, 2022 @04:35AM (#32699932)
I think the only hard part is not Nix, but Nixpkgs’s not well-documented/not-stable APIs. It would be a problem in any language.
Re:We want to make Nix better by avgcorrection on Friday September 02, 2022 @06:49PM (#32696593)
> Writing the packaging expressions should not be harder than writing the program, for the average developer.

Nah. The logical conclusion of this is that Nix should be some Java-like, Python-like, or whatever else qualifies as something that the average developer knows.

Nix needs to be declarative which rules out the average PL paradigm.

> […] , but can the next iteration provide an on-ramp which doesn't involve learning a new lang and paradigm? Guix folks sure think so.

Does the average developer know Scheme? I think you just played yourself.

Re:We want to make Nix better by theptip on Friday September 02, 2022 @04:26PM (#32695371)
Having just done some prototyping with Nix, this list is spot on in enumerating the pain points I hit.

I think most of the docs problems could be solved with the meta-strategy of “deeply understand all the things the Rust ecosystem got right with docs, discovery, and general pedagogical structure, and replicate that”. Actually have a canonical set of docs. Link liberally between packafes and stdlib. Figure out typing so you can get those hints and links in your IDE. Fix the package docs so they actually tell you what functions the packages export, instead of relying on the wiki for instructions. Etc.

Basically, pay a couple excellent docs people for a few years.

I found the language a bit weird but not terrible to learn. But if it’s possible to build some porcelain for common usecases that skips there need to grok the language, that could be quite transformative. I do wonder if the “dev env/packaging” use-case might be simpler than the “run and configure a whole OS” usecase.

Re:We want to make Nix better by WastingMyTime89 on Saturday September 03, 2022 @04:27AM (#32699901)
> I think most of the docs problems could be solved with the meta-strategy of “deeply understand all the things the Rust ecosystem got right with docs, discovery, and general pedagogical structure, and replicate that”.

I think every project would love having the money to hire someone full time to work on the documentation and evangelism.

Re:We want to make Nix better by theptip on Sunday September 04, 2022 @08:36AM (#32712379)
True, but the Nix project is actually investing in this area and did just hire a docs team.
Re:We want to make Nix better by WastingMyTime89 on Saturday September 03, 2022 @03:52AM (#32699710)
I think you are missing the heart of the issue.

Learning to use a lazy functional programming language remains relatively easy - we use to teach the basis in Ocaml in three hours when I was a student - and Git shows people can tolerate awful CLI tool UX.

I think your point 3 is where most of people issues with Nix lie except I wouldn’t limit myself at a lack of practical enough documentation. Nix documentation pretty much just doesn’t exist period.

If you want to use Nix, you will have to go through the packages or the implementation to understand what’s happening. That’s not very welcoming especially when you consider that’s the other Linux distributions which tried to do things differently in the past and could be a source of users for Nix OS, first of them Gentoo, have absolutely stellar documentation.

Re:We want to make Nix better by otabdeveloper4 on Saturday September 03, 2022 @05:10AM (#32700097)
Nix (the language) is just JSON with variables and arrow functions.

It's the easiest programming language in the world.

(Which is a problem when people start building huge projects like nixpkgs with it. It's not a language fit for programming-in-the-large, just like Javascript isn't.)

Re:We want to make Nix better by Bolkan on Friday September 02, 2022 @09:40PM (#32697728)
What nix needs more than anything is a centralized repository containing recipes for running all the different kinds of programs, as nic files. ie a dockerhub alternative.
Re:We want to make Nix better by xyzzy_plugh on Saturday September 03, 2022 @12:10AM (#32698628)
nixpkgs?
Re:We want to make Nix better by grumbel on Saturday September 03, 2022 @05:49AM (#32700287)
Something a little more compact would be welcome. There is:

    nix flake show templates
But the examples in there are a bit out of date and don't necessarily reflect real world usage and are lacking in comments (e.g. still using defaultPackage, not using flake-utils, etc.).
Re:We want to make Nix better by Bolkan on Friday September 02, 2022 @09:38PM (#32697716)
> Everything should be made as simple as possible, but not simpler
Re:We want to make Nix better by amelius on Friday September 02, 2022 @04:56PM (#32695624)
Also: it should be able to deal with NVidia cards.
Re:We want to make Nix better by ParetoOptimal on Friday September 02, 2022 @05:33PM (#32695964)
NixOS handles nvidia cards better than any linux distro i've ever uses including Debian, Ubuntu, and Archlinux.

I've only had to add a few lines to my configuration over 10 PCs and laptops.

Re:We want to make Nix better by amelius on Friday September 02, 2022 @05:37PM (#32695999)
Ok, that is good to know. But how well does it run on NVidia's Jetson line of systems?

https://developer.nvidia.com/embedded-computing

Re:We want to make Nix better by WastingMyTime89 on Saturday September 03, 2022 @04:30AM (#32699916)
The Jetson environment provided by Nvidia runs Ubuntu and are setup for you to use docker.

I have trouble understanding your question. Why do you want to use Nix if you use a system which comes pre-configured to do something else?

Re:We want to make Nix better by amelius on Saturday September 03, 2022 @08:13AM (#32701066)
Same reason why I removed Windows from my desktop computer and installed Linux :)