{ lib, stdenv, }: { src, script, ... } @ args: lib.hiPrio (stdenv.mkDerivation ( { src = src; name = "${src.name}-script-override"; phases = [ "installPhase" "scriptOverridePhase" ]; installPhase = '' runHook preInstall cp -r $src $out chmod u+w -R $out runHook postInstall ''; scriptOverridePhase = script; } // lib.removeAttrs args [ "pkg" "commands" ] ))