Undmg Trouble updating custom overlay app — IntelliJ IDEA 2020.1.4 to 2020.2

I’ve been happily updating IntelliJ a number of times using the below overlay 30-macos-apps.nix (snippet further below).

I’d recently happily updated from 2020.1.3 to 2020.1.4 using nix-env -u IntelliJIDEA.

Jetbrains have just released another update which I’d like to update to: 2020.2. But when updating my overlay with the new version and sha256 (using nix-prefetch-url) I’m getting the following error.

How do I debug this to see what’s going wrong? Why would it fail for this version?

I’m using the following version of nixpkgs (single user install on macOS Catalina):

nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'                            
"20.09pre226586.571212eb839"

logs

% nix-env -u IntelliJIDEA
upgrading 'IntelliJIDEA-2020.1.4' to 'IntelliJIDEA-2020.2'
these derivations will be built:
  /nix/store/pybflwfmqzf3pknb3pfc50pl0010sc7x-IntelliJIDEA-2020.2.drv
building '/nix/store/pybflwfmqzf3pknb3pfc50pl0010sc7x-IntelliJIDEA-2020.2.drv'...
unpacking sources
unpacking source archive /nix/store/xm545xvkbl41ng2bcgd5kg5rb0lsk1s0-ideaIU-2020.2.dmg
/nix/store/ndf7qlylf9cgairldjhjny13wcb1q154-undmg-1.0.3/nix-support/setup-hook: line 2: 20993 Segmentation fault: 11  undmg < "$curSrc"
do not know how to unpack source archive /nix/store/xm545xvkbl41ng2bcgd5kg5rb0lsk1s0-ideaIU-2020.2.dmg
builder for '/nix/store/pybflwfmqzf3pknb3pfc50pl0010sc7x-IntelliJIDEA-2020.2.drv' failed with exit code 1
error: build of '/nix/store/pybflwfmqzf3pknb3pfc50pl0010sc7x-IntelliJIDEA-2020.2.drv' failed

30-macos-apps.nix

self: super: {

installApplication =
  { name, appname ? name, version, src, description, homepage,
    postInstall ? "", sourceRoot ? ".", ... }:
  with super; stdenv.mkDerivation {
    name = "${name}-${version}";
    version = "${version}";
    src = src;
    buildInputs = [ undmg unzip ];
    sourceRoot = sourceRoot;
    phases = [ "unpackPhase" "installPhase" ];
    installPhase = ''
      mkdir -p "$out/Applications/${appname}.app"
      cp -pR * "$out/Applications/${appname}.app"
    '' + postInstall;
    meta = with stdenv.lib; {
      description = description;
      homepage = homepage;
      maintainers = with maintainers; [ jwiegley ];
      platforms = platforms.darwin;
    };
  };

IntelliJIDEA = self.installApplication rec {
  name = "IntelliJIDEA";
  appname = "IntelliJ IDEA";
  version = "2020.2";
  sourceRoot = "IntelliJ IDEA.app";
  src = super.fetchurl {
    url = "https://download.jetbrains.com/idea/ideaIU-${version}.dmg";
    sha256 = "1di3x8dp9vx7gpmq30z7kj1rx70psf17b6bapqdnwx1mnfz4bcrz";
  };
  description = "The most intelligent JVM IDE";
  homepage = https://www.jetbrains.com/idea/;
  appcast = https://www.jetbrains.com/idea/download/other.html;
};

}

previous derivation for IntelliJIDEA:

IntelliJIDEA = self.installApplication rec {
  name = "IntelliJIDEA";
  appname = "IntelliJ IDEA";
  version = "2020.1.4";
  sourceRoot = "IntelliJ IDEA.app";
  src = super.fetchurl {
    url = "https://download.jetbrains.com/idea/ideaIU-${version}.dmg";
    sha256 = "1csaflazc7412nycziji9zszj6nx7myy69vw389rmwc7kpsp9aci";
  };
  description = "The most intelligent JVM IDE";
  homepage = https://www.jetbrains.com/idea/;
  appcast = https://www.jetbrains.com/idea/download/other.html;
};

Is it possible there’s something about that dmg that’s problematic? I can open it happily, though, in the Finder via open /nix/store/xm545xvkbl41ng2bcgd5kg5rb0lsk1s0-ideaIU-2020.2.dmg.

I’ve just successfully updated my Firefox derivation (which is in the same overlay) from 78.0.2 to 79.0.

So running undmg manually as @jwiegley suggested, revealed undmg segmentation faults for this new dmg because it’s encoded / compressed with lzfse/lzvn which it seemingly doesn’t currently support.

I’ve raised an issue for this on undmg.
https://github.com/matthewbauer/undmg/issues/6