Skip to content

Can't update with applyPatches src #472

@diogotcorreia

Description

@diogotcorreia

Relates to #375

I'm having the same issue while trying to package dawarich (NixOS/nixpkgs#423867):

  src = applyPatches {
    src = fetchFromGitHub {
      owner = "Freika";
      repo = "dawarich";
      tag = finalAttrs.version;
      hash = "sha256-2WXu7Y2lujRvi0fFaUEIp5qTEV4AC5zsGV5vtQ/oiNo=";

    };
    postPatch = ''
      substituteInPlace ./Gemfile \
        --replace-fail "ruby File.read('.ruby-version').strip" "ruby '>= 3.4.0'"
    '';
  };

I'm getting the following error:

$ nix-build --expr 'let src = (import "/home/dtc/documents/vcs/nixpkgs/.worktree/dawarich" (if (builtins.hasAttr "config" (builtins.functionArgs (import "/home/dtc/documents/vcs/nixpkgs/.worktree/dawarich"))) then { config.checkMeta = false; overlays = []; } else { }))."dawarich".src; in (src.overrideAttrs or (f: src // f src)) (_: { outputHash = ""; outputHashAlgo = "sha256"; })' --extra-experimental-features 'flakes nix-command'
warning: found empty hash, assuming 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
this derivation will be built:
  /nix/store/3x3481iwxnavsq95070vny7hlkhg62wv-source-patched.drv
building '/nix/store/3x3481iwxnavsq95070vny7hlkhg62wv-source-patched.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/d5y9hg26gc54pkjxjbkw175q1g5aj1jp-source
source root is source
Running phase: patchPhase
Running phase: installPhase
error: output path '/nix/store/3x3481iwxnavsq95070vny7hlkhg62wv-source-patched.drv.chroot/root/nix/store/n901vq79p9xivdg8w8zv31rhzgnbzpkg-source-patched' should be a non-executable regular file since recursive hashing is not enabled (one of outputHashMode={flat,text} is true)
Traceback (most recent call last):
  File "/nix/store/yqlvbxrp9may78fcbk0frlb471ad71xl-nix-update-1.13.0/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
             ~~~~^^
  File "/nix/store/yqlvbxrp9may78fcbk0frlb471ad71xl-nix-update-1.13.0/lib/python3.13/site-packages/nix_update/__init__.py", line 469, in main
    package = update(options)
  File "/nix/store/yqlvbxrp9may78fcbk0frlb471ad71xl-nix-update-1.13.0/lib/python3.13/site-packages/nix_update/update.py", line 218, in update
    update_src_hash(opts, package.filename, package.hash)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/yqlvbxrp9may78fcbk0frlb471ad71xl-nix-update-1.13.0/lib/python3.13/site-packages/nix_update/dependency_hashes.py", line 81, in update_hash_with_prefetch
    target_hash = nix_prefetch(opts, attr_name)
  File "/nix/store/yqlvbxrp9may78fcbk0frlb471ad71xl-nix-update-1.13.0/lib/python3.13/site-packages/nix_update/dependency_hashes.py", line 70, in nix_prefetch
    raise UpdateError(msg)
nix_update.errors.UpdateError: failed to retrieve hash when trying to update dawarich.src

Adding outputHashMode = "recursive"; to applyPatches fixes the issue.
Perhaps it needs to be added here? https://github.com/NixOS/nixpkgs/blob/fd6bb99e4b1705b8865d1294919712a4c9931165/pkgs/build-support/trivial-builders/default.nix#L1037-L1043

I'm using CppNix 2.28.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions