News for hackers. Stuff that matters.
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...