Hacker News new | past | comments | ask | show | jobs | submit login

That is not the case.

Consider the following flake:

    # flake.nix
    {
      outputs = { self, nixpkgs }: {
        packages.x86_64-linux.default = with nixpkgs.legacyPackages.x86_64-linux; dockerTools.buildImage {
          name = "nonreproducible-image";
          copyToRoot = (runCommand "not-reproducible" {} ''
            mkdir -p $out
            head -c 100 /dev/urandom > $out/random
          '');
        };
      };
    }
That is "pure" in the sense that "nix build" will let you build that in pure mode (i.e. in a flake).

It will produce a store path with the same hash on any machine you 'nix build' it on, but the contents of 'random' will be different each time.

Flakes do not make nix reproducible since flakes do not prevent derivations from running arbitrary commands and producing their own impurities.




Reproducibility and build determinism are slightly different. Nix is not really about bit-for-bit reproducibility, that is a side-goal, and one that is being worked towards. It is far more pragmatic than that. If you use `--rebuild` like `nix build nixpkgs#hello --rebuild` it *will* warn you if the output is not deterministic FWIW.

Instead, Nix ensures the inputs are fetched deterministically via Fixed Output Derivations (FODs) that guarantee the output of building/compiling against that input can only vary so much, and in ways often insignificant to code flow in the output program, (timestamps/byte layout, etc). In the Nix thesis this is referred to as "the extensional model" in Section 5 (Page 87), otherwise known as input-addressing rather than the intensional model which is in reference to content-addressing.

Of course we'd all like build outputs to be deterministic, but that's not very pragmatic, or achievable. Many compilers and toolchains don't produce the same results twice, but this often does not effect the behavior of the program. There's some tracking of that goal on r13y.com, and it's probably a goal that will always be limited to a small subset of deterministic outputs, as it's unlikely that all toolchains used in the dependency graph will exhibit deterministic behavior.

Sometimes things that do effect code flow leak in, but are squashed by the Nix stdenv where possible, and also by the culture of fixing/patching those problems in Nixpkgs. The result is a pragmatic set of 100,000+ packages that work properly and can be reproduced anywhere.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: