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

This failure is intentional. As WiVRn has to be built with a pinned version of Monado, we have a check in the derivation to ensure that we use the exact same version.

You have to additionally override the monado attribute of the derivation. Example:

pkgs.wivrn.overrideAttrs (finalAttrs: prevAttrs: {
  version = "3cea1afee2c29d00056b3a10687431990ef860c8";
  src = pkgs.fetchFromGitHub {
    owner = "notpeelz";
    repo = "WiVRn";
    rev = finalAttrs.version;
    hash = "sha256-zaJoW5rnzcKn/vQrepJSFEJU1b3eyBwu1ukJLCjtJtE=";
  };
  monado = pkgs.applyPatches {
    src = fetchFromGitLab {
      domain = "gitlab.freedesktop.org";
      owner = "monado";
      repo = "monado";
      rev = "c80de9e7cacf2bf9579f8ae8c621d8bf16e85d6c";
      hash = "";
    };

    patches = [
      "${pkgs.path}/pkgs/by-name/wi/wivrn/force-enable-steamvr_lh.patch"
    ];

    postPatch = ''
      ${finalAttrs.src}/patches/apply.sh ${finalAttrs.src}/patches/monado/*
    '';
  };
  cmakeFlags =
    prevAttrs.cmakeFlags
    ++ [
      (lib.cmakeBool "WIVRN_FEATURE_SOLARXR" true)
    ];
  });

Perhaps in the future we could simplfy the monado override, but for now this is your best bet.

1 Like

I understand that now thank you, but cannot understand why the check passes when doing an inline override, there should be no difference right?

It only happens when the monado version defined in Nixpkgs differs from the monado version used in the actual src.

So it could be that one of your overrides uses a slightly different version of WiVRn or Nixpkgs

1 Like

AH! I believe it is because I am using the overlay from nix-community/nixpkgs-xr and it was overriding the monado source!