News for hackers. Stuff that matters.
Re:What Is Nix? by tel on Wednesday May 20, 2020 @05:35PM (#23252080)
It's kind of a mess.

Nix is a collection of tools and systems that together form a highly reproducible build system.

Nix is also a declarative, largely pure and lazy programming language that you use to design and specify the different build outputs for the Nix build system.

Nixpkgs is, more or less, the only project written using Nix (and a lot of shell). It's a collection of many thousands of "derivations", many of the things you'd expect to be able to fetch from brew or apt. Each derivation encodes the steps to use Nix (the build system) to construct that output.

NixOS is a Linux distribution built atop Nix, Nix, and Nixpkgs. The basic claim to fame here is "totally declarative system setup" where you write all of the configuration for your system in Nix, using Nixpkgs and some other NixOS specific tooling and libraries, and then "build" the entire system with high repeatability.

Then there are a few other related projects such as Hydra (a CI server and binary cache builder—most of the time you don't build with Nix, just download the proper thing from the cache) and NixOps (an extension to NixOS which provisions whole fleets of servers declaratively).

Finally, you don't need to run NixOS in order to benefit from Nix. Nix and Nixpkgs are (largely) compatible with MacOS and Linux. That means you can install Nix onto your existing MacOS or Linux system and use it a lot like you'd use brew or apt. That said, the premiere Nix experience is always NixOS.

Re:What Is Nix? by illumin8 on Wednesday May 20, 2020 @07:00PM (#23253016)
I've had the (dis)pleasure of working with several projects that have been built by developers that have religion around Nix. These projects were contract work where the client paid a significant amount of money, and the final product was really poor quality. One of them is a financial application that has strict security requirements, so having a reproducible build system and some of the other qualities of Nix sounds great, however, the auditor, which is one of the top auditors in this industry had this to say in their report:

> Overall, we found the dashboard code to be difficult to review and build. In particular, the manner in which the frontend JavaScript is compiled made it difficult to comprehensively evaluate. Given that this includes the driver code for Ledger devices and handling of user input, we believe this to be an area of concern and poses a significant risk. Building the dashboard took hours on an AWS EC2 VM (with a four-core CPU and 32 GB RAM) and while much of that build time is attributable to Nix's way of building dependencies, the code complexity adds unnecessary risk. We encourage a rework of this area of the project to follow more idiomatic web development practices and patterns. This would make the code more comprehensible and conducive to security evaluations, therefore reducing the risk of vulnerabilities that go unnoticed.

Re:What Is Nix? by floriol on Friday May 22, 2020 @10:38AM (#23272565)
It sounds like "this is the first time I've seen this build system and don't really see how it works, would be better to change it to a more often used one".

Which is fair for a security auditor, but it stems from the newness of the project and nothing inherently bad with it - like I doubt they know what actually happens inside whatever other build system other's use, but since they empirically know it poses no threat they are okay with it. If you ask me, this is absolutely no reason to not use Nix - well maybe not for a bank (though on long term they would definitely win with it)

Re:What Is Nix? by woah on Wednesday May 20, 2020 @07:20PM (#23253171)
Ah yes.. cryptocurrency, where bizarre programming practices secure large sums of money
Re:What Is Nix? by CapriciousCptl on Wednesday May 20, 2020 @08:00PM (#23253451)
LOL. Reading that audit report made me immediately wonder who in the heck is blowing money on bringing new tech to their critical finance systems. And then I saw your post and, yes, that answers that.
Re:What Is Nix? by danharaj on Wednesday May 20, 2020 @09:55PM (#23254119)
I am aware of a few trading firms that are phasing in nix to handle their dependency clusterfucks.
Re:What Is Nix? by bulldoa on Wednesday May 20, 2020 @07:27PM (#23253237)
Woah, I didn't know there is an entire ecosystem of contract job and auditors for big projects. How do companies usually hire contract jobs (outsourced HR, upwork, Accenture)? And how do they hire auditors?
Re:What Is Nix? by kitplummer on Thursday May 21, 2020 @09:11AM (#23257895)
This used to be called "quality assurance". Web and .com blew that apart. We ain't got time for that.
Re:What Is Nix? by all_blue_chucks on Wednesday May 20, 2020 @08:46PM (#23253727)
This sounds like a security audit, and auditors found the build system difficult to work with when attempting to audit code.
Re:What Is Nix? by yawaramin on Wednesday May 20, 2020 @07:13PM (#23253109)
Sounds like their main concern wasn't Nix but the complexity of the code itself.
Re:What Is Nix? by addicted on Wednesday May 20, 2020 @08:33PM (#23253645)
The hours long build system appears to be attributed to Nix.

Is Nix really that slow?

Re:What Is Nix? by geofft on Wednesday May 20, 2020 @08:40PM (#23253688)
If you're applying idiomatic Nix to modern JS, I wouldn't be surprised - modern JS tends to involve installing thousands of packages by just combining them into a directory, but Nix doesn't want you to edit existing directories. So your dependency graph turns into a build-dependency graph, with each JS package requiring a full build of everything it depends on, and the Nix build system is presumably not optimized for fast turnaround times on five-line JS modules that don't even have a compilation step.

(Personally, I wouldn't try to apply idiomatic Nix to modern JS - I'd apply it to the major components like "my web server" and "my database library" and have "all the JS I depend on" as one big Nix package. That's not really a claim about Nix, I wouldn't try to apply idiomatic, say, Debian packaging to modern JS either. In both cases I'd still get about 90% of the benefit of using Nix/Debian as a delivery mechanism.)

The other thing that could be slow is if you start compiling all your dependencies, including gcc and node.js, from scratch. While there's some security benefit in doing so, the reality is that just about nobody actually does that. You'd want to set things up to use the precompiled packages, or at least set up your own cache server and have compiled binaries you trust but only do it once.

Re:What Is Nix? by joepie91_ on Wednesday May 20, 2020 @08:56PM (#23253783)
Hi, JS developer here who uses Nix and who liberally makes use of single-responsibility modules.

No, Nix does not need "hours" to build a modern JS project. Something else is going on here. Nix is slow, but not that slow.

(With the limited information provided here, my first guess would be "someone turned off the binary cache because they don't trust prebuilt binaries, and now it recompiles the world from scratch because there are no prebuilt binaries anymore".)

Re:What Is Nix? by yawaramin on Wednesday May 20, 2020 @09:17PM (#23253914)
I suspect that someone being the auditors who are suspicious of opaque binary caches and insist on building everything from scratch.
Re:What Is Nix? by joepie91_ on Wednesday May 20, 2020 @09:20PM (#23253940)
I don't know. If that were the case, I'd imagine they would know why their build was taking hours and that it wasn't a Nix problem.
Re:What Is Nix? by yawaramin on Wednesday May 20, 2020 @11:07PM (#23254454)
That was my reading, based on the fact that they glossed over Nix itself and attributed most of the issues to code complexity.
Re:What Is Nix? by joepie91_ on Thursday May 21, 2020 @07:52AM (#23257293)
It explicitly says this, though:

> while much of that build time is attributable to Nix's way of building dependencies

And that part just doesn't make sense to me. I can't see any way in which specifically Nix's way of building dependencies would contribute to this. The compiling of the universe, sure, but then why mention Nix?

Re:What Is Nix? by yawaramin on Thursday May 21, 2020 @09:07PM (#23267654)
It does say that, but it's off in its own clause, then shifts focus away from it towards what seems like the focus of the auditors.
[dead]
Re:What Is Nix? by yawaramin on Wednesday May 20, 2020 @09:18PM (#23253923)
Part of the removed code:

    test("guy", function() {
      assert.equal(typeof babel.guy, "string");
    });
Facepalming so hard right now
Re:What Is Nix? by joepie91_ on Thursday May 21, 2020 @08:02AM (#23257363)
In case you hadn't noticed, this was a joke commit. The code in question was never actually a real part of Babel.
Re:What Is Nix? by yawaramin on Thursday May 21, 2020 @09:09PM (#23267673)
I assure you, I understand what an easter egg is. I was facepalming at the test, which was doing the equivalent of:

    expect(true).toBe(true)
[dead]
Re:What Is Nix? by geofft on Thursday May 21, 2020 @02:27AM (#23255429)
Thank you for heavily derailing the productive, technically meaningful conversation I was having. Next time I won't say anything since apparently productive and technically meaningful conversations aren't what this site is for.
Re:What Is Nix? by joepie91_ on Wednesday May 20, 2020 @09:23PM (#23253954)
Please take your badly-informed language bashing elsewhere.

I actually audit dependencies for a living, and the dependency model that JS uses is far, far preferable for auditability over the "monolithic tightly-coupled framework and a mountain of custom badly-maintained copy-pasted business logic" approach that is widely used elsewhere.

[dead]
Re:What Is Nix? by joepie91_ on Thursday May 21, 2020 @07:54AM (#23257305)
Seriously, piss off. You clearly don't understand the tools you're loudly complaining about, and it's interfering with what was otherwise a productive discussion about Nix and build times.
Re:What Is Nix? by dang on Thursday May 21, 2020 @03:14PM (#23263527)
Please don't break the site guidelines yourself, regardless of how wrong or annoying other comments are or you feel they are. It only makes the thread even worse.

I've responded to the other user elsewhere, but actually your replies were worse than what you were replying to, even if you're right on the fundamentals. "Please take your badly-informed $thing elsewhere" and "Seriously, piss off" are well out of bounds here.

If you feel like another user is derailing the discussion, flag the comments (https://news.ycombinator.com/newsfaq.html). If you feel like more is needed, email [email protected] so we can take a look. We frequently moderate off-topic subthreads.

Re:What Is Nix? by somatic on Wednesday May 20, 2020 @09:02PM (#23253821)
The term “modern JS” should be used only as a pejorative.
Re:What Is Nix? by dang on Thursday May 21, 2020 @03:13PM (#23263500)
Would you please not post in the flamewar style to HN? It damages the container here (i.e. the capacity of this place to sustain curious conversation), and you unfortunately did it repeatedly in this thread.

https://news.ycombinator.com/newsguidelines.html

Re:What Is Nix? by tomberek on Wednesday May 20, 2020 @09:13PM (#23253893)
I've built a combined python2/3,c,c++,javascript (VueJS) deployment along with hardware-in-the-loop integration testing and compiling for ARM on an Raspberry Pi with Nix. Should not take hours.

Something else is wrong. Perhaps binary cache is not being used? Something is invalidating the builds like a "src = ./.;" which telling the build system to include every single file in the directory in the build rather than using a .gitignore or git-hash for reproducibility. Or someone was using npm2nix (deprecated)?

Re:What Is Nix? by floriol on Friday May 22, 2020 @10:42AM (#23272608)
No, nix can cache already built binaries with hydra, so on a normal system it simply downloads from there - same speed as apt or the like. During the audit they likely disabled it, so nix had to build everything from scratch (like even system libraries, the build tools, everything).
Re:What Is Nix? by mason55 on Wednesday May 20, 2020 @08:38PM (#23253680)
Dependencies can take awhile if you can’t used cached versions of the binaries. Building some Haskell tooling from scratch took ~3 hours on my MBP.
Re:What Is Nix? by gmfawcett on Thursday May 21, 2020 @08:33AM (#23257617)
There are few compilers that are slower than GHC. I suspect this issue has nothing to do with Nix, and the tools would have taken ages to build from scratch without Nix.
Re:What Is Nix? by Kinrany on Wednesday May 20, 2020 @07:20PM (#23253177)
So the auditors said that the system was hard to audit?
Re:What Is Nix? by karatestomp on Wednesday May 20, 2020 @08:41PM (#23253696)
Considering that “difficult to audit” overlaps with: difficult to understand, difficult to deploy, difficult to onboard, and a bunch of other things that are also very important to non-auditors, that seems like an entirely reasonable and informative complaint.

If you hire a financial auditor and their report was basically an nicer version of “‘books‘ were written in pencil on napkins, many food stained, some illegible. Attempting to make sense of them took forever. Fix this shit to meet minimum standards for business accounting, it’s entirely unsuitable for its purpose” that’s be great info, if you didn’t already know it.

Re:What Is Nix? by yakshaving_jgt on Thursday May 21, 2020 @04:43AM (#23256167)
"books written in pencil on napkins" is analogous to how most web application projects are organised today. Nix would be the formalisation of this.
Re:What Is Nix? by atoav on Thursday May 21, 2020 @10:58AM (#23259120)
Never used nix, but their stated goal is to make implicit dependecies explicit (and reproducible). Isn't it only natural for this to sometimes bring a dependency hell to light, that otherwise could have been swept under the rug?

Or phrased differently: maybe the problem here wasn't nix, but the way developers chose their dependecies

Re:What Is Nix? by mehrdadn on Wednesday May 20, 2020 @07:59PM (#23253445)
Putting it this way it misses the point of that statement, but yes, that does appear to be what they said.
Re:What Is Nix? by WatchDog on Wednesday May 20, 2020 @07:11PM (#23253094)
I haven't used Nix, but I would have thought that builds would be fast, due to how cache-able the dependencies should be.
Re:What Is Nix? by mzaccari on Wednesday May 20, 2020 @08:04PM (#23253483)
We've been using Nix for deploying a Rails app for an enterprise customer for quite a few years now. One area where it shines for us is the ability to build it on relatively recent version of Ubuntu and deploy to a (almost EOL) RHEL6 box. Bundling, assets and various other tasks take just a few minutes. We also have ~20 Go services that are also deployed via Nix, and building takes seconds.

However, it can be quite cumbersome to get a Nix expression to the point where it builds reliably for something that takes multiple steps like a Rails app, especially if you're building on macOS and deploying to Linux. It's come a _long_ way in recent years, but with Enterprise customers now embracing containerization we migrated everything to that and haven't looked back.

Re:What Is Nix? by smichel17 on Wednesday May 20, 2020 @08:13PM (#23253535)
I'm having a hard time parsing -- you migrated everything from nix to containers (containers removed the need for nix) or to nix+containers (containers solved the "having to build for multiple platforms" issue)?
Re:What Is Nix? by mzaccari on Wednesday May 20, 2020 @08:27PM (#23253614)
Ah my apologies - We use Bazel to build our services, and the output artifacts were then pulled into Nix and deployed as Nix packages. Bazel has _excellent_ support taking the same application code and creating Docker images from them (https://github.com/bazelbuild/rules_docker#language-rules), and the tools available for deploying containers is orders of magnitude more feature-full and higher quality than what you get with Nix today. So we no longer have Nix anywhere in our pipeline, and all of our artifacts are now deployed inside containers.
Re:What Is Nix? by takeda on Wednesday May 20, 2020 @08:21PM (#23253581)
It is, perhaps they didn't use cache to store previously built packages and build everything from scratch. With no cache Nix will start with building compilers and glibc until it has everything to build the actual application.
Re:What Is Nix? by illumin8 on Wednesday May 20, 2020 @08:22PM (#23253589)
While this is true if you are building new versions of dependencies on an existing system, in many cases in high security environments you want to start with a clean build environment every time. Cached dependencies might be considered to be a security risk. Bootstrapping an entire Nix environment can take a lot of time.
Re:What Is Nix? by ryukafalz on Thursday May 21, 2020 @12:50PM (#23260892)
Sure, but in most systems you wouldn’t have much of a choice; if you’re using Debian or Ubuntu, you’re probably using binary packages built by someone else. It takes a lot more work to build everything you want from source in a traditional distro.

It seems like a pretty straightforward tradeoff: do you want to rely on prebuilt packages for speed, or do you want to rebuild it all (and accept the extra time that takes)? Nix and Guix at least make the latter pretty straightforward to do.

Re:What Is Nix? by throwaway894345 on Wednesday May 20, 2020 @07:16PM (#23253140)
Sounds like they were building everything from scratch, for some reason.
Re:What Is Nix? by maytc on Wednesday May 20, 2020 @07:38PM (#23253311)
That’s how nix guarantees reproducibility. The compiled artifacts can be cached but that didnt quite work out of the box
Re:What Is Nix? by throwaway894345 on Wednesday May 20, 2020 @07:57PM (#23253435)
Nix guarantees reproducibility, which means anything can be rebuilt from scratch, but that's a very abnormal use case. If it didn't work out of the box, it's a problem with the package scripts (the "derivations"). That said, all of our software tends to bottom out in a bunch of shitty C libraries that are all delicately cobbled together with autotools and cmake, so anything that aspires to reproduce these things is going to have issues. This tends to make Nix difficult to use, because it doesn't have nearly the same investment/manpower (yet) as other package ecosystems that is necessary to wrangle these dependencies into a stable foundation that doesn't leak its underlying havoc to higher levels of the stack.
Re:What Is Nix? by microphone987 on Wednesday May 20, 2020 @08:17PM (#23253557)
This comment is really, really confusing. If it builds once Nix, it will build again with Nix... If you can find a derivation that builds on one machine and not on the other there's usually a fundamental difference - either in CPU arch, your nixpkgs config differs (overlays), etc. Or I guess you could write a build script that non-deterministic ally fails, but that has nothing to do with Nix's maturity.

Nix ensures the tooling is called the same. I can understand having a non-autotools project that is more difficult to write a derivation for, but "Nix can't wrangle messy libraries" makes absolutely no sense, either from a "make compiling reliable" or anything at use-time.

Do you have a specific example in mind that is less hand-wavy?

Re:What Is Nix? by throwaway894345 on Thursday May 21, 2020 @11:15AM (#23259384)
> If it builds once Nix, it will build again with Nix...

That's the aspiration, but it doesn't always pan out. The rate at which you run into problems depends a lot on the packages you use, how much attention is given to them, and how hard it is to reproducibly package them. I've noticed in particular that the Python ecosystem is really fragile.

> Do you have a specific example in mind that is less hand-wavy?

A specific example that comes to mind was the psycopg2 Python package, which would build on some developers' machines but not on others. This sort of thing happens all the time, usually on macOS, and usually with C packages (sadly, so much of the Python ecosystem is built on C and its shoddy build tooling). I've also found quite a few packages in nixpkgs that simply don't build on macOS, but which presumably build on Linux; however, I forget which ones specifically.

Re:What Is Nix? by sadfklsjlkjwt on Thursday May 21, 2020 @12:06AM (#23254688)
But the build time dependencies would still be there. Just implicit and undocumented.
Re:What Is Nix? by m_mueller on Wednesday May 20, 2020 @10:19PM (#23254238)
So I understand correctly from this that nix has no binary packages? If so, why not? To me, compiling from source is not strictly necessary to get reproduceability guarantees. It might actually be harmful if you're not carefully checksumming the build products (e.g. cosmic rays messing with complex builds).
Re:What Is Nix? by yakshaving_jgt on Wednesday May 20, 2020 @10:49PM (#23254373)
You do not understand correctly.

Nix users use binary caches[0] instead of building everything from source. You can use the binary cache provided by NixOS, or Cachix[1], or something you set up and host yourself, or all of the above.

[0]: https://nixos.wiki/wiki/Binary_Cache

[1]: https://cachix.org/

Re:What Is Nix? by m_mueller on Thursday May 21, 2020 @04:21AM (#23256022)
Then why would a build take so long as GP describes?
Re:What Is Nix? by yakshaving_jgt on Thursday May 21, 2020 @04:40AM (#23256144)
I can't imagine why some unknown people encountered difficulty building some unknown project.

We use Nix to build and deploy our big Haskell monolith along with the operating system itself, and all system dependencies, e.g., PostgreSQL, Redis, Grafana, collectd, influxdb, openssh, ejabberd, Elm applications, etc, and it works fabulously.

Re:What Is Nix? by illumin8 on Thursday May 21, 2020 @10:55AM (#23259086)
GP here. My guess is that they intentionally disabled binary caching because this is a financial application and they wanted to make sure no untrusted binaries got into the build pipeline.
Re:What Is Nix? by m_mueller on Friday May 22, 2020 @04:09AM (#23269724)
Thanks! That makes some sense. Though, I work for a financial service provider as well and have never found compile-from source to be solution to that problem. If you do have dependencies, whether you trust the sources or the binaries shouldn't really matter, as long as you trust the repositories where they come from. And if you don't trust it I wanna see the army of developers actually checking all the sources down to the system level.
Re:What Is Nix? by ryukafalz on Wednesday May 20, 2020 @10:53PM (#23254391)
I can't entirely speak for Nix, but I know they're fairly similar, so: Guix (and I'm pretty sure Nix) have optional binary packages. Realistically most users will use those, but the option to build from source is always there. So, while you say:

>To me, compiling from source is not strictly necessary to get reproduceability guarantees.

...I somewhat agree, but you do of course need to be able to build from source. And, in a system like Nix or Guix, you have an easy way to verify that a build and all its transitive dependencies are reproducible, if you have someone else's build to compare it against. See `guix challenge` for example: https://guix.gnu.org/manual/en/html_node/Invoking-guix-chall...

Re:What Is Nix? by ninetax on Wednesday May 20, 2020 @06:47PM (#23252894)
Unfortunately there's a pretty annoying bug with MacOS which resulted from Apple making /nix non-writable by default. And since /nix is hard coded in all the cached packages it's not easy to fix.

This is one big thing that's preventing us from adopting nix

https://github.com/NixOS/nix/issues/2925

Re:What Is Nix? by aeontech on Wednesday May 20, 2020 @07:52PM (#23253409)
It's not a bug in macOS, it's a security feature.

However, you can use synthetic firmlinks to define arbitrary root-level paths that _are_ writable.

See `man synthetic.conf` and check out https://derflounder.wordpress.com/2020/01/18/creating-root-l... for an example usage.

PS: It looks like nix has a PR open to test that solution here: https://github.com/NixOS/nix/pull/3212

Re:What Is Nix? by danieldk on Thursday May 21, 2020 @02:11AM (#23255350)
However, you can use synthetic firmlinks to define arbitrary root-level paths that _are_ writable.

See `man synthetic.conf`

No, synthetic.conf only creates directories or symlinks. If it actually created firmlinks, the problem would probably be much smaller.

The problem with symlinks is that some builds use realpath. If /nix was a symlink to e.g. /usr/local/nix, this would result in /usr/local/nix being used in this builds. This leads to various build problems [1] and can result in the wrong paths ending up in binaries. If this happens on a builder, the resulting binaries are not portable between macOS + Nix machines.

So, instead the only way to get it currently working is to use synthetic.conf to create a new top-level directory and mount a APFS volume with the Nix store there.

If Apple actually allowed creating firmlinks with synthetic.conf, the Nix installation would be drastically simplified. /nix could just be a firmlink to e.g. /usr/local/nix, since realpath does not report the actual path on firmlinks.

[1] https://github.com/NixOS/nix/issues/2926#issuecomment-559989...

Re:What Is Nix? by aeontech on Thursday May 21, 2020 @07:32PM (#23266898)
I stand corrected, I must have misunderstood the doc.
Re:What Is Nix? by geofft on Wednesday May 20, 2020 @06:56PM (#23252976)
I'm trying to understand why macOS can't use a different path (since it's a different OS anyway, and you can't run Linux Nix binaries on macOS). From the end of the thread, it sounds like

> The main consequence of using a separate prefix for macOS is that you can't have Hydra jobsets anymore containing jobs for macOS and Linux. It would also make it harder to deploy from macOS to Linux.

i.e., if the same package builds for both Linux and macOS, you can't write a single shell script that runs on both Linux Nix and macOS Nix and calls that package? Maybe I'm misunderstanding how people deploy things, but is that a huge problem in practice?

(I don't quite follow the thing about Hydra jobsets. Aren't you building once for Linux and once for macOS anyway? Figuring out how to make the build do that seems like it would subsume any complexity of using /nix vs. /opt/nix.)

Re:What Is Nix? by elbear on Thursday May 21, 2020 @05:06AM (#23256309)
You can use a different path, but then you don't have access to the binary cache, because of the mismatch between your path and the path found in the cached binaries. That's how I understand it.
Re:What Is Nix? by derefr on Wednesday May 20, 2020 @09:22PM (#23253951)
Perhaps they hardcode full paths into whatever Nix calls its formula files (which are then, if I understand correctly, referred to by their cryptographic hashes, meaning that a file with a different path would have a different hash, and so break the whole hierarchy of formula-to-formula dependency references above it.)
Re:What Is Nix? by takeda on Wednesday May 20, 2020 @08:27PM (#23253617)
From looking at PR seems that it will utilize some extra space (for derivations that aren't really OS specific) and there might be problems wih deploying from os x to linux, but feels like they are planning to go that route ultimately.
Re:What Is Nix? by endgame on Wednesday May 20, 2020 @09:20PM (#23253942)
Buried in that issue is a workaround, although GitHub's UI hides it from you: https://github.com/NixOS/nix/issues/2925#issuecomment-604501...
Re:What Is Nix? by MaxGabriel on Wednesday May 20, 2020 @10:05PM (#23254174)
Several people in my company use the separate volume workaround and it's been totally painless.

Nix has sharp edges but this one is less of a concern than you'd think ime

Re:What Is Nix? by tome on Thursday May 21, 2020 @05:37AM (#23256472)
Hardcoding /nix is a very big downside of Nix for me. I understand why this makes other things easier, but it's a huge compromise on flexibility.
Re:What Is Nix? by eloff on Wednesday May 20, 2020 @06:30PM (#23252759)
This comment was better than the article at explaining what is nix, thanks!
Re:What Is Nix? by mehrdadn on Wednesday May 20, 2020 @05:47PM (#23252274)
Thanks! So let's say I start installing Nix packages. What distro's packages would they end up most similar to? Say, maybe Arch (which mostly leaves things unmodified)? Does that mean you basically end up with Arch no matter which distro you're on?
Re:What Is Nix? by tel on Wednesday May 20, 2020 @06:48PM (#23252902)
In addition to other answers, I think it's important to note that Nix is comparatively very small (but growing!). To that end, the Nixpkgs policies are still in flux and defined somewhat culturally (at least compared to older, larger distros).

There's a release schedule for NixPkgs which is being continuously updated, you mostly subscribe to a fixed "channel" which gives you the default set of derivations. If you need something more fresh then you either modify a derivation yourself (hot-patching the distro) or pull something temporarily from master on NixPkgs.

This is hugely facilitated by the way Nix allows you to install multiple package versions in parallel without conflict.

Finally, Nix is still sometimes a bit of a research project. The "best" way to manage a distro that's being built using this technology is still being uncovered. For instance, there's an upcoming feature (flakes) which hopes to seriously change the way you talk about and consider versions of NixPkgs and NixOS.

Using Nix definitely requires some patience with living on the edge of tech. It can be frustrating and less reliable than other repos due both to the bigger challenge of building a repo using Nix's technology and the smaller contributor base.

That said, the returns on using this weird technology are really high. The short pitch is something like "zero runtime cost, highly repeatable Docker containers for everything". Of course, the technology works nothing like that, but it really hit some of the big position independence value props of Docker in a way that's lightweight enough to use it for everything.

Re:What Is Nix? by takeda on Wednesday May 20, 2020 @08:41PM (#23253697)
> That said, the returns on using this weird technology are really high. The short pitch is something like "zero runtime cost, highly repeatable Docker containers for everything". Of course, the technology works nothing like that, but it really hit some of the big position independence value props of Docker in a way that's lightweight enough to use it for everything.

It simply delivers what docker was promising to deliver.

Re:What Is Nix? by catern on Wednesday May 20, 2020 @05:53PM (#23252359)
Trying to put it politely, but your question seems a bit confused.

Arch is not the only distro that strives for minimal modifications on upstream packages. In fact, most distributions work that way - it's Debian and its derivatives that's the outlier, and these days, even Debian rarely patches upstream packages.

There is much more to distributions than what patches they apply to their packages. The package manger they use, their default configurations, their compiler toolchain, their C library, their init system, their stance on software freedom, etc etc - much more than just what patches they apply to their packages.

But, yes, Nix packages are mostly close to upstream, with occasional patches to improve determinism and reproducibility.

Re:What Is Nix? by dataflow on Wednesday May 20, 2020 @06:03PM (#23252483)
Thanks for explaining. I'm (obviously, I thought) not suggesting distros are only about the patches, but patches are a very significant aspect of their raisons d'être to me. I thought most distro maintainers do things like backporting changes though, for security/stability/etc.? Including RedHat, Canonical, the Debian maintainers, etc.? Arch (and I guess Gentoo, and maybe their derivatives like Manjaro) are the only ones I know that minimize upstream package changes. With other popular distros like Fedora, Ubuntu, SUSE, etc. I fully expect they've made custom modifications to some popular packages, but it's been years since I've touched other flavors. You're saying this is wrong and only Debian derivatives tend to do this?
Re:What Is Nix? by catern on Wednesday May 20, 2020 @06:15PM (#23252608)
Fedora stays close to upstream: https://fedoraproject.org/wiki/Staying_close_to_upstream_pro...

Ubuntu is a Debian derivative, they patch things heavily, just like Debian.

SUSE, I don't know about their policy. I assume they're like RHEL, which starts from Fedora, which is close to upstream, and then backports bugfixes from later versions on to stable branches.

Many distros maintain stable branches and just update the packages on that branch when they have security issues. Backporting security fixes has (somewhat) gone out of favor, because backports executed by package maintainers that weren't familiar with the code have caused serious security issues in the past. Of course, distros like RHEL and (I guess) SUSE still do backport security fixes to their stable branches. But they start from a base which is close to upstream - it just diverges more and more as their stable branch gets older and older.

Re:What Is Nix? by takeda on Wednesday May 20, 2020 @08:36PM (#23253672)
GuixSD? Only because Guix was build from Nix.

Frankly I don't think there's anything else like it. I don't know Arch enough to compare, but there's something also similar to Gentoo, except Nix knows that if source + dependencies + architecture + configuration is the same it will pull compiled version from cache, if something changes it will recompile it.

The killer NixOS feature is that it has a single configuration file that's declarative which you can use to describe your OS, so it has something like salt/ansible/chef/puppet built in, and unlike them it's also is truly declarative. For example if you have package installed, to remove it, you just remove it from the list, where in those tools you need to create a state that ensures the package must not be present.

Edit: from other comments I see that you meant that packages in arch are not modified, I guess Nix does follow that and only add patches if it absolutely needs them to make application work correctly, but unlike other distros nix also allows user trivially (ignoring the steep curve to learn nix :) to modify a derivation (for example applying patches, changing dependencies, changing ./configure flags) similarly how you would extend a class in OO language. In any other OS to do such customization, you would need to generate a new package, place it in package repo, and worry about your modified package breaking other parts of the system. NixOS will then recompile that package and use it (if you use caching it will pull from cache)

Re:What Is Nix? by chpatrick on Wednesday May 20, 2020 @08:21PM (#23253584)
In my experience, nixpkgs packages are modified with the bare minimum to get the upstream code to work.
Re:What Is Nix? by mikepurvis on Wednesday May 20, 2020 @08:20PM (#23253572)
Thank you for this thoughtful comment. I was involved in establishing a bunch of build and deployment infrastructure at my org that's currently based around large (300mb+) "bundle" Debian packages, but that bundle package is composed of hundreds of small sub-packages, most of which don't change day to day (it's extremely convenient to ship them all as one big unit for versioning sanity and ABI consistency reasons).

Nix seems like it would be a great fit for this use case, but there are a number of things about it which give me pause, particularly when it may be possible to get at least some of its advantages by applying the lessons learned to a system built out of boring, old-school packaging tools.

Re:What Is Nix? by jariel on Wednesday May 20, 2020 @09:48PM (#23254075)
"Nix is a collection of tools and systems that together form a highly reproducible build system."

Wouldn't it have been nice to have that statement at the start of the article?