Mkdir: cannot create directory '/homeless-shelter': Permission denied

Trying to package praxisLIVE, but i’m running into said error

{
  stdenv,
  fetchzip,
  jdk,
  maven,
}:

stdenv.mkDerivation rec {
  pname = "praxis-live";
  version = "6.7.0";

  src = fetchzip {
    url = "https://github.com/praxis-live/praxis-live/archive/refs/tags/v${version}.tar.gz";
    sha256 = "sha256-ujdHtr7b5pFeykS2fEPTzQXM6pUbh1jtKf2LG17c3EE=";
  };

  nativeBuildInputs = [
    maven
  ];
  buildInputs = [ jdk ];

  buildPhase = ''
    runHook preBuild 
    ./mvnw clean package
    runHook postBuild
  '';
}

I also tried adding mkdir $out before running ./mvnw clean package but it still tries to create /homeless-shelter, the only solution i found was running export HOME=$TMPDIR but that doesn’t seem very clean to me

We have writableTmpDirAsHomeHook for this purpose! Add it to nativeBuildInputs

There is also a dedicated maven builder that you may want to check out. See the docs at Nixpkgs Manual