Mix workflows by extracting build commands from each stages

Current build helpers and setup hooks tend to override phases from the base workflow, making it difficult to coexist with the build process from different toolchains.

Alternative models of pkgs and build helpers, such as module-configured pkgs and package-level overlays, may solve this problem, but they still have a long way to go.

For the current model of stdenv/generic/setup.sh, setup hooks, and build helper, we could significantly increase the interoperability from different workflows by extracting the build commands from each stage into a Bash function, such as cmakeConfigure from cmakeConfigurePhase or makeConfigure from the stdenv-configurePhase. A developer could then invoke the specific Bash function to insert part of the build process from another workflow and enjoy the associated attributes.

For example, Apptainer is a Go application configured through a configuration script but still needs the Go modules fetched by buldGoModule during its configure phase. Instead of invoking the configuration file manually inside postConfigure, we could call scriptConfigure inside the postConfigure phase and specify the name of the configuration file and the configuration flags through the configureScript and configureFlags attributes.

buildGoModule {
  configureScript = "mconfig";
  configureFlags = [
    "--localstatedir=${plaleholder "out"}/var/lib"
  postConfigure = ''
  # ...

I created a PR that implements this idea into stdenv/generic/setup.sh.