Package building in flake despite provided substitutes


I have a flake setup like the one below:

    nixConfig = {
        extra-substituters = "";
        extra-trusted-public-keys = "";
        extra-experimental-features = "nix-command flakes";

    inputs = rec {
        nixos-unstable.url = "";
        nixos-21-11.url = "";
        j.url = github:shadowrylander/nixpkgs/j;
        nixpkgs.follows = "j";

    outputs = inputs@{ ... };

And an overlay list like the one below:

    channel = "master";
    pkgsets = {
        nixos-unstable = [ "bash" ];
        nixos-21-11 = [ "gcc" ];
in mapAttrsToList (
    pkgchannel: pkglist: map (
        pkg: (final: prev: {
            "${pkg}" = if (pkgchannel == channel) then prev.${pkg} else allpkgs.${pkgchannel}.${pkg};
    ) pkglist
) pkgsets)

I updated the flake lockfile, accepted the nixConfig options, and then tried to install a new system using configuration.nix and flake-compat (so no need for nixUnstable), but while bash is being taken from the binary cache, gcc is still being built locally, regardless of whether I take it from nixos-unstable or nixos-21-11, and the nix-build process is ultimately killed with no error code.

How do I make sure everything in the overlay is taken from the cache, while building everything else?

Thank you kindly for the help!

I don’t know why gcc always builds from source, but by default packages are built in /tmp so you are probably running out of memory. As a work around, nix-daemon can be told to use a different directory by setting the TMPDIR environment variable in nix-daemon’s systemd service file.

1 Like

Got it; I’ve taken to mounting a larger drive as /tmp instead, which seems to be working for the moment!