nixpkgs.hostPlatform.gcc.arch and tune overrides more than you'd expect

I’m sure I’m just misunderstanding something.

I am trying to build my whole system for my CPU architecture as per Build flags - NixOS Wiki. In my configuration this looks like:

  nix.settings.system-features = lib.mkForce [
    "gccarch-icelake-client"
    "benchmark"
    "big-parallel"
    "kvm"
    "nixos-test"
  ];
  nixpkgs.hostPlatform = {
    gcc.arch = "icelake-client";
    gcc.tune = "icelake-client";
    system = "x86_64-linux";
  };

Certain packages break, but what surprises me is that the fix is often going to the Source for the package and creating an overlay to just pull through what is already there. For example, the package libopus has this in its source:

  patches = [
    # Some tests time out easily on slower machines
    ./test-timeout.patch
  ];

This is the exact issue I’m having, and adding this to my configuration seemed to fix the issue:

  nixpkgs.overlays = [
    (self: super: {
      libopus = super.libopus.overrideDerivation (oldAttrs: {
        patches = oldAttrs.patches;
      });
    })
  ];

Is this intended behaviour to override attributes like patches or preConfigure with the nixpkgs.hostPlatform options?

I tried the single-file option that the wiki mentions:

let
  pkgs = import <nixpkgs> {
    localSystem = {
      gcc.arch = "icelake-client";
      gcc.tune = "icelake-client";
      system = "x86_64-linux";
    };
  };
in
  pkgs.libopus

nix show-derivation -f foo.nix says patches": "/nix/store/3ca5s98ga2f6n91yc6rww29bl1sjbp70-test-timeout.patch", so the patches are really there. What about your derivation?

nix show-derivation doesn’t seem to work for me. But the derivation fails to build if I don’t add the overlay, so I’m not sure there would be a derivation for it to check.

But am I at least correct that my overlay should do nothing if everything is working as expected? It should not allow these packages to build (or they should have built correctly in the first place), but I watch the builder complete them and move onto the next thing.

nix show-derivation doesn’t seem to work for me. But the derivation fails to build if I don’t add the overlay, so I’m not sure there would be a derivation for it to check.

when the build fails, it should display a message like:

error: builder for '/nix/store/1ji2immm5l9mfn19fr4y04qfq01yds6c-libopus.drv' failed with exit code 1;

then you can run

nix show-derivation /nix/store/1ji2immm5l9mfn19fr4y04qfq01yds6c-libopus.drv

(with the hash you obtained above of course) to obtain json details about the derivation. Notably you should find patches in the output.

In any case maybe you can post failed build logs as well.

1 Like

Oh I see, thank you.

The patches to avoid timeouts are working, and are in the derivation output, but it turns out my computer is still too slow at the lengthened timeout periods. It must have coincidentally completed the tests in time when I applied the overlay.

I checked the other packages that fail to build and they seem to be failing for unrelated reasons – the overlay I added does nothing, as expected, and nothing is accidentally overridden by the hostPlatform.gcc settings as I feared.