The Nixpkgs-documentation says, that Each phase can be overridden ... to a string containing some shell commands. (NixOS - Nixpkgs 21.05 manual)
But:
Which shell language? sh, bash, …?
How can I set variables?
E.g. read -a array <<< $srcs or ${var% *} results in an error.
Which commands can I use? E.g. echo, mkdir, cd, mv, chmod all do not work; but that may be caused by the next:
How can I overwrite a phase?
When I e.g. use unpackPhase = ''mkdir test'', then run nix-shell test.nix, and then enter unpackPhase, the original unpackPhase-function is called, and my definition is completely ignored…
Regarding the overriding: You’re doing it right. If you want to execute the overridden phase manually, you have to eval $unpackPhase. See this wiki page and rfc 32 (which proposes to change this behavior).
Since you seem new I will suggest looking into trivial builders, writeScriptBin where you write text into a script and then your install phase would be, say, ${pkgs.python3}/bin/python3 ${script_you_just_wrote}