nh2 / static-haskell-nix

easily build most Haskell programs into fully static Linux executables
388 stars 36 forks source link

Can't use the repo to get e.g pandoc from binary caches #40

Closed doronbehar closed 5 years ago

doronbehar commented 5 years ago

Continuing from our discussion at https://github.com/NixOS/nixpkgs/issues/43795 and after @Profpatsch's request for moving this into an new issue (damn right he is I was so ignorant!), I'll be very thankful if you'll help me debug this here.

Many thanks.

nh2 commented 5 years ago

Quoting https://github.com/NixOS/nixpkgs/issues/43795#issuecomment-518322315

/nix/store/sn6aarcyap8kn5wbrh4ffdqrvr1p7q46-pandoc-2.7.2.drv

And on your machine, this command will print somehow /nix/store/ivl4560iqpcz7xk0ih6f33shs8ygdmwq-pandoc-2.7.2

First some explanation: The derivation (.drv) file and the build output (path without .drv) are different.

The .drv is the "build description" that says what to build. The build output is the directory that is supposed to be built by it (can also be multiple output dirs). Both are in /nix/store, have hashes in the file path, and those are supposed to be different.

What matters is that we arrive at the same .drv files and output paths (if nix is working correctly, same .drv implies same output paths).

So, let's have only a look at the .drvs generated.

We can use nix-instantiate to output just the .drvs.

$ NIX_PATH=nixpkgs=nixpkgs nix-instantiate survey/default.nix -A haskellPackages.pandoc
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/sn6aarcyap8kn5wbrh4ffdqrvr1p7q46-pandoc-2.7.2.drv

Do you get this output?

If yes, then everything is fine, if it's still not fetching from the binary cache, then the binary cache is somehow setup incorrectly in your nix.conf.

Perhaps would it be worth it to share my $NIX_PATH?

It should not matter, because in the command we explicitly override NIX_PATH.

doronbehar commented 5 years ago

Thanks for the thorough explanation..

Do you get this output?

Yes.

You were right, the nix binary caches were not setup correctly - I guess the problem was that my substituters didn't include what I added to trusted-substituters.

Now that I've finally got my hands on pandoc which is not a dynamic executable :smile: , I was wondering: How come there are so many dependencies downloaded just for this package? I get the exact same output as you had here. It seems these are mostly nativeBuildInputs and not buildInputs. Is it a general Nix issue - the fact that nativeBuildInputs are downloaded as well? I guess it's not that simple so feel free to explain as much as you want.

Thanks again.

nh2 commented 5 years ago

I think this is specific to pandoc and other packages that reference strings, from other packages, see also https://github.com/nh2/static-haskell-nix/issues/2#issuecomment-519768417.

I'm quite sure it can be fixed by looking specifically into what pandoc does, but it's probably not a general static-haskell-nix issue.

The Pandoc project itself also distributes some static binaries (see e.g. pandoc-2.7.3-linux.tar.gz on the release page); comparing how they build them might give hints on what the nix build does that isn't necessary.

(Closing this one, if you're interested in working on the pandoc issue, let's make a new one specific to that topic.)