Cache miss when using in a flake
I have made the simplest possible Haskell project using LTS-17.8 (GHC 8.10.4), which is supposed to be in your cache as it is tested by your CI. My flake.nix is written according to the “Getting started with Flakes” section of your tutorial and I have your Hydra configured as a binary cache.
Nevertheless, I seem to get a really huge cache miss, as Nix is starting to download GHC 8.8.4:
$ nix build
trace: To make project.stack-nix a fixed-output derivation but not materialized, set `stack-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.stack-nix entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: WARNING: `cleanSourceWith` called on /nix/store/3sdrhc48q3khnvcbhdrwx7fb196ldzrf-source without a `name`. Consider adding `name = "3sdrhc48q3khnvcbhdrwx7fb196ldzrf-source";`
[0/466 built, 1/0/[0/466 built, 1/0/15 copied (473.2/1996.1 MiB), 31.5/172.7 MiB DL] fetching ghc-8.8.4 from https://hydra.iohk.io
Here is my entire repository: https://gist.github.com/kirelagin/0e966f1fcd4caa81a0953cab6c41d0f1.
I tried with (what is supposed to be) an equivalent flake-less default.nix and I don’t get this cache miss with it.
Hmmm, ok, so my guess is that your CI is not building the eval-on-build version of the overlay :(.
bump
Also hit this =/
Same here. Do you know why Nix is building the wrong GHC version? In your case it's building 8.8.4 instead of 8.10.4 (from your Stackage LTS version).
We don't currently have aarch64-darwin in the cache. So it could be that. What OS are you building on? Have you configured any additional builders? Did you modify the flake.nix file at all? What is the contents of the flake.lock file?
I use NixOS and tried the flake.nix file from https://github.com/jonascarpay/template-haskell quite similar to the default example in https://input-output-hk.github.io/haskell.nix/tutorials/getting-started-flakes.html#setting-up-the-binary-cache:
{
description = "PKGNAME";
inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils, haskellNix }:
flake-utils.lib.eachDefaultSystem (system:
let
overlay = self: _: {
hsPkgs =
self.haskell-nix.project' rec {
src = ./.;
compiler-nix-name = "ghc8107";
shell = {
tools = {
cabal = "latest";
ghcid = "latest";
haskell-language-server = "latest";
hlint = "latest";
# See https://github.com/input-output-hk/haskell.nix/issues/1337
ormolu = {
version = "latest";
modules = [ ({ lib, ... }: { options.nonReinstallablePkgs = lib.mkOption { apply = lib.remove "Cabal"; }; }) ];
};
};
};
};
};
pkgs = import nixpkgs {
inherit system;
overlays = [
haskellNix.overlay
overlay
];
};
flake = pkgs.hsPkgs.flake { };
in
flake // { defaultPackage = flake.packages."PKGNAME:exe:PKGNAME-exe"; }
);
I have copied the binary cache settings from https://input-output-hk.github.io/haskell.nix/tutorials/getting-started-flakes.html#setting-up-the-binary-cache into my configuration.nix
# Binary Cache for Haskell.nix
nix.settings.trusted-public-keys =
[ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
nix.settings.substituters = [ "https://cache.iog.io" ];
which i load into a flake from which i build my system. Could NixOS config as a flake be a problem? Do you know or know a guide on how to debug cache misses?
Debugging cache misses is a nightmare, sorry (https://github.com/NixOS/nix/issues/4146). Are you sure you've got the settings applied properly? You may need to restart the nix daemon.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.