Live data from Hacker News

How Nix and NixOS get so close to perfect

christine.website

91–100 of 183 posts

Re: How Nix and NixOS get so close to perfect

#91

I’ve been trying out GUIX, but I wasn’t able to figure out a good way to do rust development on it. Tools like Cargo and Rust analyzer are extremely useful but introduce a lot of complexity which doesn’t seem to mix well with functional package managers like guix and nix.

Here are my two favorite (bookmarked) links for packaging and developing for rust. The trick is keep packaging and rust development separate and use specific dev environment flakes. So for dev work just bring cargo and rust as the nativeBuildInputs in mkShell (and any non rust dependencies) and then use standard cargo for development. But for packaging use one of the fancy tools. 1. https://srid.ca/rust-nix

2. https://discourse.nixos.org/t/cargo2nix-dramatically-simpler...

Re: How Nix and NixOS get so close to perfect

#92

Earlier quoted context omitted.

> Using Haskell as a base for the syntax I don’t really think this is a problem at all? I mean, at the particular design point the language occupies there are basically three possibilities: - Kind of like Lisp (parens everywhere, painful with pervasive currying); - Kind of like ML (var and fun everywhere); - Kind of like Haskell. Nix is chooses the last of those, and it does not have most of Haskell’s funkiness: no “…

> I don’t really think this is a problem at all? I mean, at the particular design point the language occupies there are basically three possibilities: How so? Where's the Java/Python-like languages in this consideration, why wouldn't those work? Or something more like Ansible? I'm pretty sure that you can express the same concepts for the most part in something imperative as well.

You could make a package manager or distribution along the principles of Nix with any reasonable language, of course. Insisting on first-order data (i.e. not functions) exclusively would probably have the standard problems of trying to cram into a declarative configuration something that really wants to be a program (“YAML ops”, programs-as-SQL-tables disasters like Windows Installer, XML hells like Ant and XSLT, etc.); but once you go all the way to a general programming language, sure.

I would probably prefer Lua to Python because while Python can sort of do declarative EDSLs they invariably suck, and the expressive power and general style of the two is largely similar; Java has all those problems times a hundred so I expect you would end up staging the whole thing into a config processor in Java and a config in something else; but while the ergonomics may vary it’s certainly not impossible. Guix, Pacman with Aconfmgr, or the venerable GNU Stow are all this to some degree.

That is not what I was saying, though. The semantics of the Nix language (JSON-like data model, lazy, higher-order, dynamic types) are a vital part of the implementation approach taken by the Nix package manager, and once those semantics are fixed the syntax (so I argued) has to be broadly similar to what it is now. (You could force a Java- or Python-like syntax upon an ML- or Scheme-like language if you really wanted, but the result would just be miserable to program in; the F# people tried but mostly gave up.)

Is that approach the right one? I suspect so, but it is still to early in the life of the whole idea to be really sure. The idea that a dynamically-typed lazy (thus pure) higher-order language is a good middle ground between a completely declarative configuration and a completely imperative setup script (neither of which can usually stand alone) is a fresh and interesting one, and I’d very much like to see it explored. I’ll be the first to admit that the documentation on Nix internals is lacking, but once the requisite source spelunking is done it’s delightful how the whole thing comes together and how much flexibility being written in itself affords it. (Did you know that NixOS was originally a fun experimental addon to the whole thing? The packaging language accidentally ended up being powerful enough to make a usable and novel system configuration language.)

But the complaint seemed to be that the syntax (which is relatively superficial and does not require particularly deep argumentation) is Haskell-like, not that the implementation approach (which is crucial to the whole design and requires arguments on the scale of a research paper) is wrong. My point was that the latter pretty much implies the former.

Re: How Nix and NixOS get so close to perfect

#93
post #88
post #83

Earlier quoted context omitted.

We use naersk[0] for Rust projects in our Nix monorepo (for example [1]). It's pretty hands-off in terms of the Nix code needed (you don't need to pin hashes inside of the Nix code as long as you have a Cargo lockfile) and all the existing tooling keeps working fine. The main drawback of it is that it currently builds all of your dependencies in one big derivation, so any dependency changes cause a full rebuild. Ther…

It's crate2nix: https://github.com/kolloch/crate2nix

No, unless something significantly changed there. There's another project like naersk which doesn't need to generate a "Cargo.nix" file.

Re: How Nix and NixOS get so close to perfect

#94

Earlier quoted context omitted.

> Using Haskell as a base for the syntax I don’t really think this is a problem at all? I mean, at the particular design point the language occupies there are basically three possibilities: - Kind of like Lisp (parens everywhere, painful with pervasive currying); - Kind of like ML (var and fun everywhere); - Kind of like Haskell. Nix is chooses the last of those, and it does not have most of Haskell’s funkiness: no “…

>> Using Haskell as a base for the syntax > I don’t really think this is a problem at all? Of course it's a problem. You shouldn't use a syntax that has been soundly rejected by the industry.

Because industry makes good decisions? Decisions like adopting python, dooming a large part of the world software to be bug ridden slow messes. Or to elevate CUDA to the facto machine learning backend? Besides it's not clear that Haskell isn't adopted by industry due to the syntax.

Re: How Nix and NixOS get so close to perfect

#95

I'm starting to see more of a cult attitude with Nix. It is like the Arch Linux crowd (I use Arch) but much worse. I think is is great that Nix has provided something valuable to a lot of people, but so does a lot of software and tools. Nix fills a void in package management. It is like Ansible or Terraform for a semi-idempotent distro. It is probably quicker in most ways than building something similar with other co…

What’s powerful about nix is the language IMO. I was able to build an automatic WireGuard setup[1] with tagging that automatically works on each new machine thanks to the ability to do config as code. Just provide some basic config for each machine and the code turns it into an interface with peers. The issue to me isn’t the language persay (it’s really a tiny surface area language, see the built in/lib functions [2]) but the tooling built around packaging is a hodgepodge mess of semi-documented workarounds (with Nixpkgs blessed ways vs user libraries) and is extremely difficult to approach and understand.

[1]: https://github.com/jordanisaacs/dotfiles

[2]: https://teu5us.github.io/nix-lib.html

Re: How Nix and NixOS get so close to perfect

#96

Earlier quoted context omitted.

> Using Haskell as a base for the syntax I don’t really think this is a problem at all? I mean, at the particular design point the language occupies there are basically three possibilities: - Kind of like Lisp (parens everywhere, painful with pervasive currying); - Kind of like ML (var and fun everywhere); - Kind of like Haskell. Nix is chooses the last of those, and it does not have most of Haskell’s funkiness: no “…

>> Using Haskell as a base for the syntax > I don’t really think this is a problem at all? Of course it's a problem. You shouldn't use a syntax that has been soundly rejected by the industry.

OK, fair enough, not an—independent? terminal?—problem: the syntax is largely forced upon us by the semantics, it’s not a Common Lisp vs Dylan or a Python vs Lua vs Ruby thing; and the semantics is the crux of the implementation approach (though not of the packaging organization being implemented).

If you want to argue against the semantics, by all means, but “industry doesn’t think it looks pretty” does not cut it, even “I don’t think it looks pretty” would afford more respect on my part (not least because the speaker is then able to explain what specifically they find off-putting or annoying, while “the industry” isn’t).

More details on syntax vs semantics in sibling comment[1].

[1] https://news.ycombinator.com/item?id=31143616

Re: How Nix and NixOS get so close to perfect

#97
post #63

Earlier quoted context omitted.

> Using Haskell as a base for the syntax I don’t really think this is a problem at all? I mean, at the particular design point the language occupies there are basically three possibilities: - Kind of like Lisp (parens everywhere, painful with pervasive currying); - Kind of like ML (var and fun everywhere); - Kind of like Haskell. Nix is chooses the last of those, and it does not have most of Haskell’s funkiness: no “…

How about HCL? (Hashicorp Configuration Language, as used in Terraform for example.) It's not really 'kind of like' any of Lisp/ML/Haskell IMO, and a good fit I think. Maybe it wouldn't allow everything or easily, but then if we're already only talking about being 'kind of like' (not actually using) an existing language that's not a problem. (It's more like Prolog I suppose, not syntactically but in declarativeness,…

No particular problem with parens, hell if you want to do postfix I’m cool with that too, it’s just that the leading parens really discourage you from currying by default while ML-style juxtaposition-is-application does not (normally ML and F# curry a bit less, Haskell and Scala a bit more, but both curry much more than is usual in Common Lisp or Scheme). And currying is really useful when some of the curried functions are values of config settings.

I didn’t think HCL had laziness (which is vital to how NixOS module or Nixpkgs overlay A can set or use things in B which in turn set or use things in A), I’ll have to look at the theory more closely, thanks. (Its documentation tries pretty hard to make HCL look boring and weak, I guess it’s my fault for believing it.) Doing logic-programming-like things would probably also work as an approach to achieving these goals, yes, just a different one from that implied by my constraints above. I’d count CUE as being interesting in that direction as well even if it’s not technically logic programming (is it?.. the bibliography is not great). I’ll guess we’ll see.

Re: How Nix and NixOS get so close to perfect

#98

Earlier quoted context omitted.

Quoted post unavailable.

Survivor of a cult does not necessarily mean that someone joined a cult themselves. Kids escaping environment they were born in may be survivors of a cult. People with spouses who joined a cult may be survivors. Environments may change, leaving a mainstream church in a specific area may mean leaving a cult. Etc. Don't look down on them unless you know all the details.

In fairness, I think it's hard to environmentally fall into "several" cults. If there are several, chances are high that perhaps even a majority were entered into voluntarily. I don't mean this as a dig on the OP.

Re: How Nix and NixOS get so close to perfect

#99

Earlier quoted context omitted.

>> Using Haskell as a base for the syntax > I don’t really think this is a problem at all? Of course it's a problem. You shouldn't use a syntax that has been soundly rejected by the industry.

Because industry makes good decisions? Decisions like adopting python, dooming a large part of the world software to be bug ridden slow messes. Or to elevate CUDA to the facto machine learning backend? Besides it's not clear that Haskell isn't adopted by industry due to the syntax.

> Because industry makes good decisions?

That's irrelevant - if you want uptake, you need to support what user's want. It's been clear for at least a decade now that programmers don't want Haskell syntax.

Whether it's a good syntax or not is irrelevant.

Post reply on HN