How does pkgsStatic not clobber overlays/crossOverlays?

If I import nixpkgs with some overlays or crossOverlays set, and then invoke pkgsStatic.something, that’s defined as

Which uses nixpkgsFun, which is defined as:

in top-level/default.nix. Notice that it’s importing itself with args // newArgs, so I would expect the overlays and crossOverlays from pkgsStatic (newArgs) to overwrite any that you passed in to top-level/default.nix through top-level/impure.nix through the default.nix at the base of the github directory (args).

And yet, I’m able to pass in overlays and crossOverlays just fine while using pkgsStatic. How is that happening?

1 Like

At least something happens to buildInputs in crossOverlays. They become propagatedBuildInputs when pkgsStatic in use. For example, here super.libwebsockets.overrideAttrs (def: ...) def.propagatedBuildInputs refers to original buildInputs and also you need to override propagatedBuildInputs instead.
This is annoying if you want to have the same overlay for both dynamic and static builds. I have to write:

    propagatedBuildInputs =
      if super.stdenv.hostPlatform.isStatic
      then with self; [ glib openssl ]
      else def.propagatedBuildInputs;
    buildInputs =
      if ! super.stdenv.hostPlatform.isStatic
      then with self; [ glib openssl ]
      else def.buildInputs;

@matthewbauer, maybe I miss something here, is it intended behavior?

Hosted by Flying Circus.