Live data from Hacker News

What Is Nix?

engineering.shopify.com

301–310 of 344 posts

Re: What Is Nix?

#301
post #283
post #129

This article is a good explanation of how nix works at a high level, and I'm excited to see nix getting some really prominent support, but for some reason it never tells you what the point of all of this is, so I think many folks might feel turned off by it. In other words, I don't believe it ever compellingly answers the question that constitutes its title. The word "package" doesn't even appear until near the end o…

> for some reason it never tells you what the point of all of this is, so I think many folks might feel turned off by it I’m attempting to write some hands-on pragmatic no-bullshit articles tackling that. Why? I’ve been hearing a lot about Nix over the years, how it’s an experiment yet so good it’s actually usable. But every article I found obscure the good parts, either because of too much details and theory or beca…

That sounds great. I remeber when I started, it was very difficult, I don't think I would be able to start without nix-pills articles.

Nix needs more tutorials, especially in areas that could showcase it (which you planning to do).

Nix is often referred as a package manager, but I believe that characterization does a bit of disservice to it, because it can do much more than that. IMO the areas where it excels the most for me is the build system. Ability to have a language define the exact environment that developer has is IMO awesome.

Re: What Is Nix?

#302
post #258

Earlier quoted context omitted.

It'll only rebuild the packages that depended on that particular openssl. This is an area where Nix shines, because all packages are explicitly bound to their dependencies, it means it's no longer relevant what one file happens to be occupying `/usr/lib/libssl.so`, or even `/lib/x86_64-linux-gnu/libc.so.6`, so you can be running different apps that rely on totally different glibc versions alongside each other with no…

I mean if there's a bug, it's not enough to patch one particular OpenSSL. You have to audit manually, so Nix won't make much of a difference.

Well, by default it uses the same library everywhere, but it gives you an option that you can have two apps that rely on e.g. different version of openssl. If you do that it is on you to make sure both dependencies are updated. There is a bit of benefit as well. For example instead of creating a new derivation, you can override existing one (kind of like you extend a class in OO) if for example you make another version of openssl based off the existing one, but maybe changed compile flags, then nix will be smart enough to recompile both.

Re: What Is Nix?

#303
post #287

Earlier quoted context omitted.

nix is the solution. It's totally different from any random packager you've seen. It goes the reversed direction of abstracting dependencies away: it makes dependencies explicit (and reproducible!)

I get it, but my point is that unless it can cope with packages that aren't in the ecosystem, it will just add another variant rather than solving the problem, as per https://xkcd.com/927/ It reminds me a lot of http://www.vestasys.org/

Nix at this point is almost 20 years old, and we have 10,000s of packages.

If that meme wants you to blame something, it should be Docker.

(First of all, it's younger. There's big tons of effort with Docker and yet nothing is reproducible, and DPKG, APT and all their ilk can't even be deprecated but instead are used awkwardly within the Docker ecosystem.)

Re: What Is Nix?

#304
post #257

Earlier quoted context omitted.

I'm sure there are reasons for it, but it still sucks. It ought to be possible to use binary caches and still swap out the path. (Modifying a string in an ELF executable isn't that hard.)

Modifying a string in ELF is hard. As long as the string has the same length as the original one, it has a good chance to work (but still fails for compressed data). But if you want an arbitrary directory, you need to replace it with a different length path, and that will probably break a lot of things.

The nix author created utility called patchelf which is used by nix all the time during the build (to rewrite library paths).

As far as I know it creates a new elf each time it is called (it doesn't modify a file on place) so the length of library name is not an issue.

Re: What Is Nix?

#305
post #37

Earlier quoted context omitted.

So it processes the config file (and thus all needed packages) one time or does it process it every time you boot?

You type nixos-rebuild switch and it builds you an entire OS and drops you into it. It also makes the new OS the default on startup. Because it's all purely declarative, your old OS is still there. If things go wrong then you can just pop back to it, either in the command line with: nixos-rebuild switch --rollback Or when you reboot, the previous 'generations' of your operating system show up in GRUB, so just choose…

Thanksfor your comment.This is very interesting for my Raspberry Pi. The ability kit it out according to function is great.

Re: What Is Nix?

#306
post #111

Earlier quoted context omitted.

You can use Nix on MacOS X and with nix you don't need brew. I used it for few years that way. If you use nix-darwin + home-manager you can also configure your mac the way you would NixOS. Amazing tools that discovered not long ago (they aren't specific to os x) is: niv - makes pinning to specific repos/versions in repos much easier which helps with reproducibility, especially pinning of nixpkgs version which is now…

I've had luck with using the approach in here https://nixos.wiki/wiki/Python#Emulating_virtualenv_with_nix... because it allows the escape hatch of using pip if something isn't packaged and I want to quickly try something out. I have also been meaning to try mach-nix which may obviate the need for pip at all. Having a good standard skeleton for a python/nix project would be super helpful to add to the wiki, etc.

I tried multiple solutions myself, this one is the closest to what I want, because:

- overlays the packages on top of nixpkgs - understands setup.cfg and can get dependencies from it

It is still not perfect, but when I find some time I think to submit a PR to nixpkgs to improve setupcfg2nix. Particularly it doesn't understand tests_require which you can list dependencies to run unit tests. Nix has equivalent checkDepends.

Re: What Is Nix?

#307
post #195

A lot of misunderstanding and overexplaining in these comments. The reality is that Nix is a complex system of many parts, under active development, and yet is perhaps the best infrastructure we have for creating deterministic, hermetic, reproducible builds. I've worked on one of the largest Nix systems and it saves our entire dev team hours. Everything is only built once, on a large set of specialized remote builder…

This is what I'm personally looking for, are there some kind of tutorials how to configure nix in an organization to do CI/CD best practices etc.

Re: What Is Nix?

#308
post #236

Earlier quoted context omitted.

Nix comes with its own glibc, so that's 3, although I guess while it is not the default you could compile statically.

I use C but I never use the C standard library. It blows.

Maybe I'm missing the joke, but even if you use printf() in C you are using C standard library.

Re: What Is Nix?

#309
post #248
post #236

Earlier quoted context omitted.

Nix comes with its own glibc, so that's 3, although I guess while it is not the default you could compile statically.

If you compile statically, you've got musl, which is still a (build-time) dependency.

There's a confusion between build and runtime dependencies. From Nix point of view. Even if you compile statically your code still depends on libc, it's just that you include the libc in the resulting binary. With Nix all dependencies are listed for your application. Because if no compiled version is available in binary cache, Nix will get a compiler and build one. This is actually awesome, imagine there's a program in nixpkgs that you want to use, but you want to have it linked with different libraries.

For example pgbouncer[1] can be linked with different DNS resolvers, which have their strengths and weaknesses (currently it is linked with c-ares which probably is what most people want, but until version 1.10 that wasn't true) you can override the derivation and use different dependency. Nix will build on the fly the new version that does do what you want, and this is awesome.

[1] https://www.pgbouncer.org/install.html

Re: What Is Nix?

#310
post #111

Earlier quoted context omitted.

You can use Nix on MacOS X and with nix you don't need brew. I used it for few years that way. If you use nix-darwin + home-manager you can also configure your mac the way you would NixOS. Amazing tools that discovered not long ago (they aren't specific to os x) is: niv - makes pinning to specific repos/versions in repos much easier which helps with reproducibility, especially pinning of nixpkgs version which is now…

This is only sort of true: I’ve found that Nix on a Mac is great except that about 10% of the derivations just don’t work: some are excluded explicitly as broken and some just fail in strange ways and need lots of debugging.

For me, most of packages worked, the ones that didn't were actually justified to not work, definitively far more than 10% (it was more like 90% for me). The stuff that didn't work was justifiably linux specific, except one thing, that now memory escapes me what it was.
Post reply on HN