Overriding a version fails due to new dependencies

I am following the overlay docs on how to override a pkg version, but ti fails due to new dependencies added. The docs expect that to happen, but does not give any light on what to do from there!

For reference, this is how surrealist was updated the last time: surrealist: 1.11.7 -> 2.0.6 · NixOS/nixpkgs@dcd747d · GitHub

My research so far has indicated that I need to update the hash of the dependencies, both npm and cargo. How can I find the right dependencies hashes that need to be overridden?

Config

{ inputs, ... }:

{
  nixpkgs.overlays = [
    # The unstable nixpkgs set (declared in the flake inputs) will
    # be accessible through 'pkgs.unstable'
    (final: _prev: {
      unstable = import inputs.nixpkgs-unstable {
        system = final.system;
        config.allowUnfree = true;
      };
    })

    # https://nixos.wiki/wiki/Overlays#Overriding_a_package_inside_an_extensible_attribute_set
    # https://nixos.wiki/wiki/Overlays#Overriding_a_version
    (final: prev: {
      unstable = prev.unstable.extend
        (__final: __prev: {
          surrealist = __prev.surrealist.overrideAttrs (oldAttrs: {
            version = "2.1.6";
            src = prev.fetchFromGitHub {
              owner = "surrealdb";
              repo = "surrealist";
              rev = "surrealist-v2.1.6";
              hash = "sha256-jOjOdrVOcGPenFW5mkkXKA64C6c+/f9KzlvtUmw6vXc=";
            };
          });
        });
    })
  ];
}

Error

[0.0 MiB DL] downloading 'https://github.com/nix-community/home-manager/archive/e1391fb22e18a36f57e6999c7a9f966dc
building the system configuration...
error: builder for '/nix/store/ycj0qq23p2lc81533jp0df3xqqi3sik1-surrealist-ui-2.1.6.drv' failed with exit code 1;
       last 10 log lines:
       > Scope: all 3 workspace projects
       > Lockfile is up to date, resolution step is skipped
       > Progress: resolved 1, reused 0, downloaded 0, added 0
       > Packages: +809
       >
       > Progress: resolved 1, reused 0, downloaded 0, added 0
       > Progress: resolved 809, reused 0, downloaded 0, added 0
       > Progress: resolved 809, reused 14, downloaded 0, added 0
       >  ERR_PNPM_NO_OFFLINE_TARBALL  A package is missing from the store but cannot download it in offline mode. The missing package may be downloaded from https://registry.npmjs.org/@codemirror/language/-/language-6.10.2.tgz.
       > Progress: resolved 809, reused 14, downloaded 0, added 0
       For full logs, run 'nix log /nix/store/ycj0qq23p2lc81533jp0df3xqqi3sik1-surrealist-ui-2.1.6.drv'.
error: 1 dependencies of derivation '/nix/store/8s3ib15ghqw2aarvn8dq0cvrpc4x4wf9-surrealist-2.1.6.drv' failed to build

Couple notes:

  • The wiki isn’t documentation
  • What you were looking for was Nixpkgs Reference Manual, which mentions previousAttrs and how to use them
  • Depending on the builder, the further you stray from stdenv.mkDerivation, the harder it is to override
  • If this is a leaf package, don’t use overlays, just override if possible

I believe you forgot to override the hash of the cargo deps FOD, which meant that nix still wanted to use the old version’s dependency list.

You might be able to do something like this

surrealist.overrideAttrs (oldAttrs: {
  version = "2.1.6";
  src = fetchFromGitHub {
    owner = "surrealdb";
    repo = "surrealist";
    rev = "surrealist-v2.1.6";
    hash = "sha256-jOjOdrVOcGPenFW5mkkXKA64C6c+/f9KzlvtUmw6vXc=";
  };
  cargoDeps = oldAttrs.cargoDeps.overrideAttrs { outputHash = lib.fakeHash; };
})

once you run this, you’ll get a hash mismatch error, which will give you the right has. You’ll have to replace lib.fakeHash with the hash it shows you.

This override is a bit implementation specific, but I think it will work

Edit: I think you’ll also need to override some other hashes, I’ll update my post once I get that working

Thank you! I’ve tried

...
              ui = attrs.ui.overrideAttrs
                (__attrs: {
                  pnpmDeps = __attrs.pnpmDeps.overrideAttrs (____attrs: { hash = lib.fakeHash; });
                });

              cargoDeps = attrs.cargoDeps.overrideAttrs (__attrs: {
                outputHash = lib.fakeHash;
              });

but the error message remains the same.
We propably need to make a new call to pnpm.fetchDeps, no?

These are the values we want to update:

Yeah, something like that would work, however…
I did some searching and it looks like the project updated to tauri v2 a few months ago:
See Update to Tauri 2 (#291) · surrealdb/surrealist@d3faf28 · GitHub

However, the cargo-tauri cli app inside nixpkgs is not yet updated to tauri v2. This means that it’s going to take updating multiple packages to build this app’s current version.

Also, if we disregard the fact that cargo-tauri is outdated, there’s a point where overriding a package becomes too difficult, and it is easier to copy a package’s expression from nixpkgs.
Let’s say you copy it into ./surrealist.nix in your config, then you replace pkgs.surrealist in your config with (pkgs.callPackage ./surrealist.nix {}).

Then, you could edit ./surrealist.nix freely without having to use the override APIs.

Thank you so much for looking into this!

I might use the suggested approach of copying the pkg definition on the next time.
For the time being, as I am a newcomer, I don’t fell ready to deal with “updating multiple packages to build this app” yet. Thus, I will seat and wait for a while :sweat_smile: