Package definition fails to build, inline override succeeds

I’m trying to define my package override as it’s own package, instead of doing it inline or using an overlay, but I am running into problems

This is how I have defined the package:

{
  pkgs,
  packageSources,
  lib,
  ...
}: (pkgs.wivrn.overrideAttrs (old: rec {
  version = "3cea1afee2c29d00056b3a10687431990ef860c8";
  src = pkgs.fetchFromGitHub {
    owner = "notpeelz";
    repo = "WiVRn";
    rev = version;
    hash = "sha256-zaJoW5rnzcKn/vQrepJSFEJU1b3eyBwu1ukJLCjtJtE=";
  };
  cmakeFlags =
    old.cmakeFlags
    ++ [
      (lib.cmakeBool "WIVRN_FEATURE_SOLARXR" true)
    ];
}))

And I import it like so:

{
  perSystem = {pkgs, ...}: {
    packages = {
      wivrn-solarxr = pkgs.callPackage ./wivrn-solarxr.nix {};
    };
  };
}

And then in my config set the package for the wivrn module like so:

services.wivrn = {
  enable = true;
  package = self.packages.${pkgs.system}.wivrn-solarxr;
}

However this results in the following build error:

wivrn> Our Monado source revision doesn't match CMakeLists.txt.
wivrn>   theirs: c80de9e7cacf2bf9579f8ae8c621d8bf16e85d6c
wivrn>     ours: 848a24aa106758fd6c7afcab6d95880c57dbe450

Which is due to the check performed in postUnpack of the wivrn nixpkg

However, if I overwrite the package inline like so:

services.wivrn = {
  enable = true;
  package = pkgs.wivrn.overrideAttrs (old: rec {
    version = "3cea1afee2c29d00056b3a10687431990ef860c8";
    src = pkgs.fetchFromGitHub {
      owner = "notpeelz";
      repo = "WiVRn";
      rev = version;
      hash = "sha256-zaJoW5rnzcKn/vQrepJSFEJU1b3eyBwu1ukJLCjtJtE=";
    };
    cmakeFlags =
      old.cmakeFlags
      ++ [
        (lib.cmakeBool "WIVRN_FEATURE_SOLARXR" true)
      ];
  });

Then I have no issues and it builds perfectly

I’m not sure why there is a difference between these two, or how to fix the package definition

See this commit for everything that changed between working and broken state