How to get list of phases used to build package

I ran nix develop nixpkgs/nixos-22.11#freerdp to get build environment for freerdp package.
I can run build phases manually, for example unpackPhase or cmakeConfigurePhase.

What I want to do, is to run manually all phases which are used to build the original package it the right order. I was expecting to find something like $phases variable listing all phases, but I can’t see anything like that. How can I do it ?

Thank you for help.

1 Like

It looks that the only way to get list of phases is to do the same as genericBuild function does.

Actually,

running

nix develop nixpkgs/nixos-22.11#freerdp

if [ -z "${phases[*]:-}" ]; then
        phases="${prePhases[*]:-} unpackPhase patchPhase ${preConfigurePhases[*]:-} \
            configurePhase ${preBuildPhases[*]:-} buildPhase checkPhase \
            ${preInstallPhases[*]:-} installPhase ${preFixupPhases[*]:-} fixupPhase installCheckPhase \
            ${preDistPhases[*]:-} distPhase ${postPhases[*]:-}";
fi

gives me

echo $phases

unpackPhase patchPhase configurePhase buildPhase checkPhase glibPreInstallPhase installPhase glibPreFixupPhase fixupPhase installCheckPhase distPhase

which doesn’t look correct. For example freerdp is using cmakeConfigurePhase, not configurePhase.

I can get list of defined phases functions for my shell by running following command:

declare -F | grep -E ".*Phase"

declare -f buildPhase
declare -f checkPhase
declare -f cmakeConfigurePhase
declare -f cmakePcfileCheckPhase
declare -f configurePhase
declare -f distPhase
declare -f fixupPhase
declare -f glibPreFixupPhase
declare -f glibPreInstallPhase
declare -f installCheckPhase
declare -f installPhase
declare -f patchPhase
declare -f showPhaseFooter
declare -f showPhaseHeader
declare -f unpackPhase

this looks OK, but how do I know when cmakePcfileCheckPhase is executed ?

Use ‘grep’ on nixpkgs with ‘genericBuild’ and from builder.sh or setup.sh you see this call lots. In your nix-shell environment type ‘declare | less’ and look at the code.

This is some code from the nix-shell for nix itself:

genericBuild ()
{
    export GZIP_NO_TIMESTAMPS=1;
    if [ -f "${buildCommandPath:-}" ]; then
        source "$buildCommandPath";
        return;
    fi;
    if [ -n "${buildCommand:-}" ]; then
        eval "$buildCommand";
        return;
    fi;
    if [ -z "${phases[*]:-}" ]; then
        phases="${prePhases[*]:-} unpackPhase patchPhase ${preConfigurePhases[*]:-}             configurePhase ${preBuildPhases[*]:-} buildPhase checkPhase             ${preInstallPhases[*]:-} installPhase ${preFixupPhases[*]:-} fixupPhase installCheckPhase             ${preDistPhases[*]:-} distPhase ${postPhases[*]:-}";
    fi;
    for curPhase in ${phases[*]};
    do
        runPhase "$curPhase";
    done
}

Also have a look at https://nixos.wiki/wiki/Nixpkgs/Create_and_debug_packages

Check out nix-utils/nix-develop-interactive.bash at a2d8cf9b8b375d8364033cdee19d65e9e821ab6b · imincik/nix-utils · GitHub