How to create an overlay to modify failed sources with working ones

Do you need help to define an overlay, or to use the said overlay system-wide ?

As an example, here is an overlay that I use for factorio, to get the exact version needed (it also changes the version and the name).

self: super:
{
  factorio = super.factorio.overrideAttrs (oldAttrs: rec {
    version = "0.17.4";
    name = "factorio-${version}";
    src = super.fetchurl {
      url = null;
      name = "factorio_alpha_x64_0.17.4.tar.xz";
      sha256 = "408a8fff6a87bfb48da4a4054cba10a868ee3339938c4a6ac3aca13a1545d93f";
    };
  });

}

Now, to make nixos-rebuild use your overlay, the simplest way is to put it in the nixpkgs.overlays config option. There is a literal example in the linked option documentation, but you can also import it from a standalone file like this

nixpkgs.overlays = [ (import /path/to/your/overlay.nix) ];

Hope this helps,

– Layus

4 Likes