[Nix-dev] Bug(?) in derivation/hashing

Sergey Mironov grrwlf at gmail.com
Fri Aug 26 12:50:48 CEST 2016


Hi. I recently faced a strange behavior of nix, wiich resulted in
installation of package with incorrect name. Here I'd like to describe
the steps I performed.

There is an compilers/urweb/default.nix expression containing the
expression for building Ur/Web compiler. Originally, it contained the
following header

```
stdenv.mkDerivation rec {
  name = "urweb-${version}";
  version = "20151220";

  src = fetchurl {
    url = "http://www.impredicative.com/ur/${name}.tgz";
    sha256 = "155maalm4l1ni7az3yqs0lrgl5f2xr3pz4118ag1hnk82qldd4s5";
  };

....
```

As you can see, name depends on version, and src depends on name. I
decided to bump a version. Since there is 20160805 version available,
I wanted to 1) replace "20151220" with "20160805", 2) run `nix-env -i
urweb` to see a 'Hash mismatch' error, and finaly 3) copy correct hash
to she sha256 field.

Surprisingly, `nix-env -i urweb` finished without errors. It reported
that installation of urweb-20160805 was successful, but in fact it was
old urweb-20151220 with new name. (urweb --version showed it clearly).

In order to install _real_ 20160805, I had to replace sha256 with all
zeroes, to force `nix-env -i urweb` to download correct source.

Now what do you think about it? (Besides the fact that copying hashes
from error messages is bad practice) Does nix-build really count URLs
when check fixed-hash derivations? If no (AFAIK), why is it correct?

Regards,
Sergey


More information about the nix-dev mailing list