2

I asked this question in the IRC channel, but thought I'd document it here for my own as well as other's reference.


I have a shell.nix file that is taking a long time to build, in particular it seems to be building a HUnit package.

My shell.nix file looks like:

{
 sources ? import ./nix/sources.nix
, compiler ? "ghc865" } :
let
  niv = import sources.nixpkgs {
    overlays = [
      (_ : _ : { niv = import sources.niv {}; })
    ] ;
    config = {};
  };
  pkgs = niv.pkgs;
  myHaskellPackages = pkgs.haskell.packages.${compiler}.override {
  };
in
myHaskellPackages.callCabal2nix "moscoviumorange" (./.) {}

And the source's is pinned to (with niv):

{
    "niv": {
        "branch": "master",
        "description": "Easy dependency management for Nix projects",
        "homepage": "https://github.com/nmattia/niv",
        "owner": "nmattia",
        "repo": "niv",
        "rev": "88d6f20882b0422470acbcbf2d1b5f07e1d436f0",
        "sha256": "0wkvz4drnglmmdrz8q1i1yr2fqizpf96k1wq2rlhd8l8x1522izq",
        "type": "tarball",
        "url": "https://github.com/nmattia/niv/archive/88d6f20882b0422470acbcbf2d1b5f07e1d436f0.tar.gz",
        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    },
    "nixpkgs": {
        "branch": "nixos-19.03",
        "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
        "homepage": "https://github.com/NixOS/nixpkgs",
        "owner": "NixOS",
        "repo": "nixpkgs-channels",
        "rev": "775fb69ed73e7cf6b7d3dd9853a60f40e8efc340",
        "sha256": "1w068b0ydw4c26mcjiwlzdfqcdk3rrwmfx4hxzgfhfwcz2nmh3if",
        "type": "tarball",
        "url": "https://github.com/NixOS/nixpkgs-channels/archive/775fb69ed73e7cf6b7d3dd9853a60f40e8efc340.tar.gz",
        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    }
}

Why is nix building a bunch of packages, when I assume they should be in the nixpkg's binary cache?

For example the output of nix-shell includes:

building '/nix/store/7011izw8f2xyvhqadrhnmapddyz61f29-HUnit-1.6.0.0.drv'...
1

We can search for the HUnit package in Hydra (for 19.03):

https://hydra.nixos.org/eval/1552169?filter=HUnit&compare=1551557&full=#tabs-still-fail

According to the above HUnit is built and would be in the binary cache.


We determine the store path with:

nix-store --query --binding out /nix/store/7011izw8f2xyvhqadrhnmapddyz61f29-HUnit-1.6.0.0.drv
/nix/store/ryr2qdms3n0qbj8d3l9pvs7ajz4dzav4-HUnit-1.6.0.0

We can compare the below with hydra: https://hydra.nixos.org/build/103222205#tabs-details

curl https://cache.nixos.org/ryr2qdms3n0qbj8d3l9pvs7ajz4dzav4.narinfo
404

404 means that path is NOT in the binary cache.


The answer turned out to be that I was referencing ghc to be ghc865 while hydra is probably building with ghc864 by default (for 19.03).

The above answers were originally from clever in the #nixos IRC channel, thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.