15 ms·
Nixos-unstable’s ISO_minimal.x86_64-Linux is 100% reproducible
- avalys 5y agoCan anyone comment on the significance of this accomplishment, and why it was hard to achieve before? I (naively, apparently) assumed this had been possible with open-source toolchains for a long time.
- xyzzy_plugh 5y agoThere's a lot of problems with reproducible builds. Filesystem paths, timestamps, deterministic build order to say the least. This is a pretty great achievement and I'm looking forward to a non-minimal stable ISO.
- bombcar 5y agoYeah even the “gcc compiled Jan 23, 2021 at 11:23AM” messages you often see breaks deterministic builds.
- twisrkrr 5y agoThe code has to be changed so that things like system specific paths, time of compilation, hardware, etc. Don’t cause the compiled program to be unique to that computer (meaning compiling the same code on a different computer will give you a file that still works but has a different md5 hash) By being able to reproduce the file completely, down to identical md5 hashes, you know you have the same file the creator has, and know with certainty that the file has not been tampered with
- secondcoming 5y agoDoes this mean that the code cannot be built with CPU specific optimisations (march option with gcc)
- Avamander 5y agoPretty much. But hopefully x86_64 feature levels will provide the benefits of native builds to a reasonable extent.
- Denvercoder9 5y agoThe software doesn't suddenly become incompatible with CPU-specific optimisations (or many other compiler flags that change its output), but if you do so, you won't be able to reproduce the distribution binaries. Distributions don't enable CPU-specific optimisations anyway, since they want to be usable on more than one CPU model.
- pas 5y agoLikely it means that with the same input arguments the end result is bit-by-bit identical. (As I understand the problems were hard to control output elements. So it was not enough to se the same args, set the same time, and use the same path and filesystem, because there were things that happened at different speeds, so they ended up happening at relative different elapsed times, so the outputs contained different timestamps, etc.)
- clhodapp 5y agoNo, just that you need to avoid naively conflating the machine that is doing the compilation with the one that optimization is being performed for. Concretely, you would need to keep track of and reproduce e.g. the march flag value as a part of your build input. If you wanted to optimize for multiple architectures, that would mean separate builds or a larger binary with function multi-versioning.
- maartenh 5y agoNixpkgs contains the build / patch instructions for any packages in NixOS. If you want to compile any piece of software available in Nixpkgs, you can override it's attributes (inputs used to build it). One can trivially have an almost identical operation system to your colleagues install, but override just one package to enable optimisations for a certain cpu. This would however imply that you'd lose the transparent binary cache that you could otherwise use. Exactly this method is used to configure the entire operating install! Your OS install is just another package that has some custom inputs set.
- danbst 5y agoJust recently, there were large non-reproducible projects: python, gcc. Not sure where is the history of non-r13y. --- There is Debian initiative to create bit-to-bit reproducible builds for all their software (well, all critical). https://reproducible-builds.org/ https://reproducible-builds.org/ R13y is akin to "computer proofs" in math -- if you don't have it, that's fine, but if you have it, that's awesome. There are practical reasons to favor reproducibility too, but those are more for distro maintainers. The fact that NixOS (not Debian) got this 100% is mostly because - minimal image has a small subset of packages (https://hydra.nixos.org/build/146009592#tabs-build-deps https://hydra.nixos.org/build/146009592#tabs-build-deps) - Nix tooling was created 15 years ago *exactly* for this, Nix is mad to make packages bit-to-bit rebuildable from scratch. - Nix/Nixpkgs is growing in number of maintainers and got more funds - Nix has fewer Docker/Snap pragmatics
- infogulch 5y agoBeing bit-for-bit reproduceable means you could do fun things like distribute packages as just sources and a big blob of signatures, and you can still run only signed binaries.
- Foxboron 5y ago>- Nix tooling was created 15 years ago exactly for this, Nix is mad to make packages bit-to-bit rebuildable from scratch. I don't think this is accurate? Nix is about reproducing system behaviour, largely by capturing the dependency graph and replaying the build. But this doesn't entail bit-for-bit identical binaries. It's very much sits in the same group such as Docker and similar technologies. This is also how I read the original thesis from Eelco[0]. And well, claims like this always rubs me the wrong way since nixos only really started using the word "reproducible builds" after Debian started their efforts in 2015-2016[1], and started their reproducible builds effort later. It also muddies the language since people are now talking about "reproducible builds" in terms of system behavior as well as bit-for-bit identical builds. The result has been that people talk about "verifiable builds" instead. [0]: https://edolstra.github.io/pubs/phd-thesis.pdf https://edolstra.github.io/pubs/phd-thesis.pdf [1]: https://github.com/NixOS/nixpkgs/issues/9731 https://github.com/NixOS/nixpkgs/issues/9731
- 5y ago
- mananaysiempre 5y agoThe GCC developers in particular were hostile to such efforts for a long time, IIRC. (This is a non-trivial issue because randomized data structures exist and can be a good idea to use: treaps, universal hashes, etc. I’d guess it also pays for compiler heuristics to be randomized sometimes. Incremental compilation is much harder to achieve when you require bit-for-bit identical output. Even just stripping your compile paths from debug info is not entirely straightforward.)
- pas 5y agoHow/why was the randomness part not "solveable" via using fixed seeds?
- bruce343434 5y agothe security benefit of things like stack canaries rest on them being random and not known beforehand, I guess. Otherwise stack smashing malware could know to avoid them.
- mananaysiempre 5y agoWait, how is that relevant? Nothing says stack canaries have to use the same RNG as the main program, let alone the same seed, and there are cases such as this one where they probably shouldn’t, so it makes sense to separate them.
- moonchild 5y ago> Incremental compilation is much harder to achieve when you require bit-for-bit identical output Presumably, incremental compilation is only for development. For release, you would do a clean build, which would be reproducible. > Even just stripping your compile paths from debug info is not entirely straightforward Just use the same paths.
- mananaysiempre 5y ago> Presumably, incremental compilation is only for development. For release, you would do a clean build, which would be reproducible. I’d say that’s exactly the wrong approach: given how hard incremental anything is, it would make sense to insist on bit-exact output and then fuzz the everliving crap out of it until bit-exactness was reached. (The GCC maintainers do not agree.) But yes, you could do that. It’s not impossible to do reproducible builds with GCC 4.7 or whatever, it’s just intensely unpleasant, especially as a distro maintainer faced with yet another bespoke build system. (Saying that with all the self-awareness of a person making their own build system.) > Just use the same paths. I mean, sure, but then you have to build and debug in a chroot and waste half a day of your life figuring out how to do that and just generally feel stupid. And your debug info is still useless to anybody not using the exact same setup. Can’t we just embed relative paths instead, or even arbitrary prefixes it the code is coming from more than one place? In recent GCC versions we can, just chuck the right incantation into CPPFLAGS and you’re golden. All of this is not really difficult except insofar as getting a large and complicated program to do anything is difficult. (Stares in the direction of the 17-year-old Firefox bug for XDG basedir support.) That’s why I said it wasn’t a GCC problem so much as a maintainer attitude problem.
- deleted 5y ago[deleted]
- peterkelly 5y agoFor some reason, many compilers and build scripts have traditionally been written in a way that's not referentially transparent (a pure function from input to output). Unnecessary information like the time of the build, absolute path names of sources and intermediate files, usernames and hostnames often would find their way into build outputs. Compiling the same source on different machines or at different times would yield different results. Reproducible builds avoid all this and always produce the same outputs given the same inputs. There's no good reason (that I can think of) why this shouldn't have been the case all along, but for a long time I guess it just wasn't seen as a priority. The benefit of reproducible builds is that it's possible to verify that a distributed binary was definitely compiled from known source files and hasn't been tampered with, because you can recompile the program yourself and check that the result matches the binary distribution.
- dane-pgp 5y ago> There's no good reason (that I can think of) why this shouldn't have been the case all along Well, it's not like developers consciously thought "How can I make my build process as non-deterministic as possible?", it's just that by the time people started to become aware of the benefits of reproducibility, various forms of non-determinism had already crept in. For example, someone writing an archiving tool would be completely right to think it is a useful feature to store the creation date of the archive in the archive's metadata. The idea that a user might want to force this value to instead be some fixed constant would only occur to someone later when they noticed that their packages were non-reproducible because of this. But you're right; if the goal had been thought of from the start, there's no reason why every build tool wouldn't have supported this.
- russfink 5y agoThank you both. I was wondering the same thing.
- otabdeveloper4 5y ago> The benefit of reproducible builds is that it's possible to verify that a distributed binary was definitely compiled from known source files and hasn't been tampered with, because you can recompile the program yourself and check that the result matches the binary distribution. It's not just security. If a hash of the input sources maps directly to a hash of the output binaries, then you can automatically cache build artefacts by hash tag and get huge speedups when compiling stuff from scratch. This was the primary motivation for Nix, since Nix does a whole lot of building from scratch and caching.
- Arnavion 5y agoIs there a list of the 1486 packages in the minimal ISO?
- danbst 5y agohttps://hydra.nixos.org/build/146009592#tabs-build-deps https://hydra.nixos.org/build/146009592#tabs-build-deps
- fouronnes3 5y agoAre there synergies with the Debian reproducible build project that this can benefit from?
- Denvercoder9 5y agoIn general, Debian aims to upstream the changes they make to software. That allows all other distributions, including Nix, to profit from their work making software reproducible.
- aseipp 5y agoDebian has been a major driver in making many pieces of software reproducible across every distribution; that Debian maintainers so often submit patches upstream and work directly to solve these issues is a big reason for this. In other words: the work Debian has done absolutely set the stage for this to happen, and it would have taken much longer without them.
- dcposch 5y agoThis really deserves more love. Who remembers Ken Thompson's "Reflections on Trusting Trust"? The norm today is auto-updating, pre-built software. This places a ton of trust in the publisher. Even for open-source, well-vetted software, we all collectively cross our fingers and hope that whoever is building these binaries and running the servers that disseminate them, is honest and good at security. So far this has mostly worked out due to altruism (for open source maintainers) and self interest (companies do not want to attack their own users). But the failure modes are very serious. I predict that everyone's imagination on this topic will expand once there's a big enough incident in the news. Say some package manager gets compromised, nobody finds out, and 6mo later every computer on earth running `postgres:latest` from docker hub gets ransomwared. There are only two ways around this: - Build from source. This will always be a deeply niche thing to do. It's slow, inconvenient, and inaccessible except to nerds. - Reproducible builds. Reproducible builds are way more important than is currently widely appreciated. I'm grateful to the nixos team for being beating a trail thru the jungle here. Retrofitting reproducibility onto a big software project that grew without it, is hard work.
- zamadatix 5y agoUnless you are going to be the equivalent of a full time maintainer doing code review for every piece of software you use you need to trust other software maintainers reproducible builds or not. Considering this is Linux and not even Linus can deeply review every change in just the kernel anymore that philosophy can't apply to meaningfully large software like Nixos.
- jnxx 5y agoThat's too black-and-white. Being able to reproduce stuff makes some kind of attacks entirely uninteresting because malicious changes can be traced back. Which is what many types of attackers do not want. Debian, or the Linux kernel, for example, are not fool-proof, but both are in practice quite safe to work with.
- zamadatix 5y ago
- georgyo 5y agoMandatory link to the Debian single purpose site: https://isdebianreproducibleyet.com/ https://isdebianreproducibleyet.com/ However that is for everything in Debian, not just the iso. It is truly remarkable to see all the Linux distributions move the needle forward.
- Foxboron 5y agoAnd Arch Linux :) https://reproducible.archlinux.org/ https://reproducible.archlinux.org/
- deleted 5y ago[deleted]
- jnxx 5y agoA good sign that the friendly competition by Guix has a positive influence :) https://guix.gnu.org/manual/en/html_node/Bootstrapping.html https://guix.gnu.org/manual/en/html_node/Bootstrapping.html https://guix.gnu.org/en/blog/2020/guix-further-reduces-bootstrap-seed-to-25/ https://guix.gnu.org/en/blog/2020/guix-further-reduces-boots...
- delroth 5y agoThis smaller bootstrap seed thing is a different problem from reproducible builds. nixpkgs does still have a pretty big initial TCB (aka. stage0) compared to Guix. But as far as I can tell NixOS has the upper hand in terms of how much can be built reproducibly (aka. the output hash matches across separate builds).
- jnxx 5y agoBootstrapping from a very small binary core (I think 512 bytes) with an initial C compiler written in Scheme also has the advantage that the system can easily be ported to different hardware. Which is one major strength of the GNU projects and tools.
- delroth 5y agoNot necessarily. Usually these very small cores end up being more architecture specific binaries than a stage0 consisting of gcc + some other core packages. A good illustration of this is that Guix's work on bootstrap seed reduction has been so far mostly applied to i686/amd64 and not even other architectures they support (at least, not fully).
- pxc 5y agoDoes this still matter if you can work your way up to a cross compiler, though? Do you actually need to go all the way down to ‘native’ hex monitors for a bunch of architectures or whatever?
- siraben 5y ago
- rejectedandsad 5y agoI really want to adopt Nix and NixOS for my systems but the cost of wrapping packages is just a little too high for me right now (or perhaps I'm out of date and a new cool tool that does it automatically is out). IMHO, a dependency graph-based build system that builds a hermetically sealed transitive closure of an app's dependencies that can be plopped into a rootfs via Nix [0] is far superior security wise to the traditional practice of writing docker files. [0] https://yann.hodique.info/blog/using-nix-to-build-docker-images/ https://yann.hodique.info/blog/using-nix-to-build-docker-ima...
- SuperSandro2000 5y agoDid you try https://github.com/Mic92/nix-ld https://github.com/Mic92/nix-ld or https://nixos.org/manual/nixpkgs/unstable/#setup-hook-autopatchelfhook https://nixos.org/manual/nixpkgs/unstable/#setup-hook-autopa... ?
- rejectedandsad 5y agoHm, this seems like a lower level set of tools that can be composed into something a bit more user-friendly (one of my personal complaints with Nix as well, despite being a big fan of the concept and overall execution. Nothing too steep that can't be learned eventually, but the curve exists). I'm wondering if there would be an audience for a higher level abstraction on top of Nix, or if one already exists.
- Atemu12 5y agohttps://discourse.nixos.org/t/announcing-nomia-a-general-resource-manager-inspired-by-nix/12591 https://discourse.nixos.org/t/announcing-nomia-a-general-res...
- amelius 5y agoHopefully this will one day also work with NVidia's software packages.
- jeroenhd 5y agoThe trick with nvidia on Linux is to not expect that they will ever work on anything. If you want to be sure that stuff works, either don't buy Nvidia or use Windows.
- amelius 5y agoWhat would you recommend instead of NVidia's Jetson embedded platform?
- jeroenhd 5y agoI'm not familiar with the market the Jetson is in and what purposes it serves. From a quick Google, it seems to build boards for machine learning? If that's true, I'm pretty sure Google and Intel have products in that space, and I'm sure there's other brands I don't know of. If Nvidia has its own distribution, it might well work for as long as it's willing to maintain the software because then they can tune their open source stuff to make it work with their proprietary drivers, the same way Apple is hiding their tensorflow code. I still would be hesitant to rely on Nvidia in that case given their history.
- aseipp 5y agoGoogle and Intel's solutions are just as proprietary, with the downside almost nobody uses them so bugs, performance, supported tooling, community, and support windows are often much worse. It's not even clear their solutions actually offer better performance in general, given this. (And if you think proprietary Nvidia software packages are infuriating messes, wait until you try Intel proprietary software.) How you feel about their history of Linux support all that said is basically irrelevant, and they'll continue to dominate because of it.
- solarkraft 5y agoThat is a pretty big deal. This means everyone building NixOS will get the exact same binary, meaning you can now trust any source for it because you can verify the hash. It’s a huge win compared to the current default distribution model of “just trust these 30 american entities that the software does what they say it does”. Big congratulations to the team.
- koolba 5y agoThere’s something very poetic about “unstable” being “reproducible”. It’s like controlled chaos.
- dane-pgp 5y agoI believe that's known as the Chaotic Good alignment.
- groodt 5y agoThis is a big deal. Congratulations to all involved. In Software, complexity naturally increases over time and dependencies and interactions between components become impossible to reason about. Eventually this complexity causes the Software to collapse under its own weight. Truly reproducible builds (such as NixOS and Nixpkgs) provides us with islands of "determinism" which can be taken as true invariants. This enables us to build more Systems and Software on top of deterministic foundations that can be reproduced by others. This reproducibility also enables powerful things like decentralized / distributed trust. Different third-parties can build the same software and compare the results. If they differ, it could indicate one of the sources has been compromised. See Trustix https://github.com/tweag/trustix https://github.com/tweag/trustix
- goodpoint 5y agoReminder: https://reproducible-builds.org/ https://reproducible-builds.org/ was born in Debian and pioneered reproducible building. It took very significant efforts and largely benefit build tools (compilers, linkers, libraries) that are not Debian-specific.
- aseipp 5y agoI think r13y has said the minimal ISO was less than 10 packages away from 100% over 2 years now. The long tail has finally been overcome! Huge news.
- jonringer117 5y agoSome of the issues were really difficult to tackle, like the linux kernel generating random hashes. The last mile was done by removing the use of ruby (which uses some random tmp directories) from the final image. Asciidoctor (ruby) was replaced with asciidoc (python).
- taviso 5y agoI don't see a single comment doubting the value of reproducibility, so I'll be the resident skeptic :) I think build reproducibility is a cargo cult. The website says reproducibility can reduce the risk of developers being threatened or bribed to backdoor their software, but that is just ridiculous. Developers have a perfect method for making their own software malicious: bugdoors. A bugdoor (bug + backdoor) is a deliberately introduced "vulnerability" that the vendor can "exploit" when they want backdoor access. If the bug is ever discovered you simply issue a patch and say it was a mistake, it's perfectly deniable. It's not unusual for major vendors to patch critical vulnerabilities every month, there is zero penalty for doing this. The existence of bugdoors means you have to trust the vendor who provided the source code, there is no way around this. You have to trust the developer, but in theory, reproducible builds could be used to convince yourself their build server hasn't been hacked. This isn't really necessary or useful, you can already produce a trustworthy binary by just building the source code yourself. You still have to trust the vendor to keep hackers off everything else though! Okay, but building software is tedious, and for some reason you are particularly concerned about build servers being hacked. Perhaps you will nominate a dozen different organization that will all build the code, and make this a consensus system. If they all agree, then you can be sure enough the binaries were built with a trustworthy toolchain. A modest improvement in theory, but that introduces a whole bunch of new crazy problems. You can't just pick one or two consensus servers, because then an attacker can stop you getting updates by compromising any one of them. You will have to do something like choose a lot of servers, and only require 51% to agree. Now, imagine a contentious update like a adopting a cryptocurrency fork, or switching to systemd (haha). If the server operators rebel, they can effectively veto a change the vendor wants to make. Perhaps vendors will implement a killswitch that allows them to have the final say, or perhaps they operate all the consensus build servers themselves. The problem is now you've either just replaced build servers with killswitches, or just replicated the same potentially-compromised buildserver. I wrote a blog post about this a while ago, although I should update it at some point. https://blog.cmpxchg8b.com/2020/07/you-dont-need-reproducible-builds.html https://blog.cmpxchg8b.com/2020/07/you-dont-need-reproducibl...
- dane-pgp 5y ago> If the server operators rebel, they can effectively veto a change the vendor wants to make. How often do you think there will be a change so controversial that teams who have volunteered to secure the update system will start effectively carrying out a Denial of Service attack against all the users of that distro? We also have to imagine that these malicious attestation nodes can easily be ignored by users just updating a config file, so the only thing the node operators could achieve by boycotting the attestation process is temporarily inconveniencing people who used to rely on them (which is not a great return on investment for the reputation they burn in doing this).
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- brianzelip 5y agoHere’s an informative podcast episode on Nix with one of its maintainers, https://changelog.com/podcast/437 https://changelog.com/podcast/437.
- pabs3 5y agoI wonder when PyPI and similar ecosystems will get deterministic reproducible builds.
- mraza007 5y agoThis might be a dumb question but what’s a reproducible build
- egberts1 5y agoThe ability to recreate a binary image from the same set of source files and getting that binary to be identical to the package-provided binary. This is useful form of ensuring that nothing is amiss during compile/link time. Today’s GNU toolchain clutters the interior of binary files with random hash values, full file path (that you couldn’t recreate … easily), and random tmpfile directories. The idea is to make it easier to verify a binary, compare it with earlier-built-but-same-source binary, or to be able to reverse engineering it (and catch unexpected changes in code).
- mraza007 5y agoOh okay thank you for explanation. You explained it really well
- pabs3 5y agoI wonder what else other than disorderfs they could throw in to flush out additional currently hidden non-determinism.
- rswail 5y agoRecently, President Biden put out an executive order that mandates that NIST et al work out, over the next year, an SBOM/supply chain mandate for software used by Federal departments. That's going to require the equivalent of "chain of custody" attestations along the entire build chain. Along with SOC and PCI/DSS and other standards, this is going to require companies and developers to adopt NixOS type immutable environments.
- ffk 5y agoUnfortunately, I don't think this is going to be the outcome. We're more likely to end up with "Here is the list of filenames, subcomponents, and associated hashes" as opposed to requiring NixOS style environments. Vendors to the subcontractors will likely be required to provide the same list of filename/subcomponent/hashes, a far cry from repeatable builds.
- 1MachineElf 5y agoI doubt it will happen until NixOS or similar tool has a corresponding DISA STIG.
- toastal 5y agoI really liked how easy it was to create a custom ISO when I installed Nix. For once I had Dvorak as the default keyboard from the outset, neovim for editing, and the proprietary WiFi drivers I needed all from a minimal config file and `nix build`.
- FRidh 5y agoIt should be noted this was achieved by removing Python bytecode from the builds. This has a performance hit and should probably be reverted.