Discussion:
[Nix-dev] unequal build hash
Harmen via nix-dev
2017-07-06 16:35:15 UTC
Permalink
Hello all,
another day, another problem :/

I'm trying to figure out why a build generates different build IDs in different
contexts.
I have a nix expression and some code. If I copy that from machine A
to machine B they both give the same build hash. All's fine there.
If on machine B I run nix-build in a docker container it won't give the same
build hash.
`nix-hash .` gives the same hash for B and B-docker. Same nix version, same
nixpkgs version.

Any hints what to look for?
Thanks!
Harmen via nix-dev
2017-07-06 17:35:10 UTC
Permalink
Post by Harmen via nix-dev
Hello all,
another day, another problem :/
I'm trying to figure out why a build generates different build IDs in different
contexts.
I have a nix expression and some code. If I copy that from machine A
to machine B they both give the same build hash. All's fine there.
If on machine B I run nix-build in a docker container it won't give the same
build hash.
`nix-hash .` gives the same hash for B and B-docker. Same nix version, same
nixpkgs version.
I'm getting a bit further, and it worked on different machines because I
happened to name the directory the same on both machines. Seems like the name
of the directory is used in the build process. As long as I checkout the repo
in a subdir with the same name everything is fine. If I rename the checkout dir
nix will rebuild. This my current default.nix:

<some nixpkgs stuff>
with pkgs; buildGoPackage rec {
name = "mypackage";
src = builtins.filterSource
(name: type:
(lib.hasPrefix (toString ./vendor) name) ||
(lib.hasPrefix (toString ./rzutil) name) ||
(lib.hasPrefix (toString ./util) name) ||
(lib.hasPrefix (toString ./datatype) name) ||
(lib.hasPrefix (toString ./one) name)
) ./.;

goPackagePath = "example.com/mypackage";

meta = with stdenv.lib; {
description = "My First Package";
homepage = https://github.com/example-com/mypackage;
platforms = platforms.unix;
};
}

If I do the checkout in /tmp/fooo part of the .drv gives:

...
["/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh","/nix/store/zw7ax2gxc8qr5cx5a7byjpxdshx73297-fooo"]
...

Does that makes sense? Did I forget a 'name' somewhere?

Thanks!
Post by Harmen via nix-dev
Any hints what to look for?
Thanks!
_______________________________________________
nix-dev mailing list
https://mailman.science.uu.nl/mailman/listinfo/nix-dev
Vladimír Čunát via nix-dev
2017-07-07 05:59:46 UTC
Permalink
Post by Harmen via nix-dev
Does that makes sense? Did I forget a 'name' somewhere?
When you use things like
src = ./.;
the directory gets copied into nix store and the resulting path's name
is based on the name of the directory.

--Vladimir
Harmen via nix-dev
2017-07-07 08:28:13 UTC
Permalink
Post by Vladimír Čunát via nix-dev
Post by Harmen via nix-dev
Does that makes sense? Did I forget a 'name' somewhere?
When you use things like
src = ./.;
the directory gets copied into nix store and the resulting path's name
is based on the name of the directory.
I see. That was rather unobvious and unexpected to me.

Anyone knows a (creative) way around that? I would like to have it build code
from ./., but where the name of the directory you happened to have checked the
project out in doesn't matter (because then the binary cache works).

Thanks,
Harmen
Post by Vladimír Čunát via nix-dev
--Vladimir
Guillaume Maudoux (Layus) via nix-dev
2017-07-07 09:56:33 UTC
Permalink
Post by Harmen via nix-dev
Post by Vladimír Čunát via nix-dev
Post by Harmen via nix-dev
Does that makes sense? Did I forget a 'name' somewhere?
When you use things like
src = ./.;
the directory gets copied into nix store and the resulting path's name
is based on the name of the directory.
I see. That was rather unobvious and unexpected to me.
Anyone knows a (creative) way around that? I would like to have it build code
from ./., but where the name of the directory you happened to have checked the
project out in doesn't matter (because then the binary cache works).
Well, you could try to play with symlinks. A self-symlinks seems to be
enough.

git checkout ... somewhere
cd somewhere
ln -s . knownName

then

src = builtins.filterSource (path: type: path != "./knownName") ./knownName; # syntax my not be correct here, check by yourself :-).


-- Layus.

Loading...