Skip to content
  • Duncan Coutts's avatar
    Add new style project planning · 352f5795
    Duncan Coutts authored and Mikhail Glushenkov's avatar Mikhail Glushenkov committed
    This implements the planning phase of the new nix-style package build and
    install system. In particular it includes the calculation of the
    nix-style package ids by hashing all the package configuration.
    
    Project planning is separated from project building.
    
    The planning phase starts with finding the packages in the project and
    then solving. We solve without looking at the installed packages in the
    store. This makes everything more deterministic. The only installed
    packages the solver looks at are the globally installed ones. This
    approach also means we don't have any need of solver options like
    --reinstall or --avoid-reinstalls etc.
    
    The bulk of the planning phase is elaboration. We take the project
    configuration and the solver's InstallPlan and elaborate the latter into
    an ElaboratedInstallPlan. This is intended to contain all the details
    needed for the build phase. For example all the "setup" command flags
    are calculated directly from the elaborated plan.
    
    The building phase is then intended to be much simpler and free of much
    logic or policy. All of the complicated logic and policy is supposed to
    be in the planning phase. This should also make things a lot easier to
    debug, we can look at the plan we calculate and see if we're producing
    the right build instructions, rather than debugging based on the actions
    we end up executing.
    
    Doing all the planning up front is also crucial to calculating nix-style
    package hashes. This means we have the package ids up front. This then
    allows us to have another up-front phase where we improve the plan by
    replacing source packages with installed packages from the store.
    
    All of this stuff is done in the Rebuild monad, with a few levels of
    caches, so most of the time we can avoid recomputing the plan. In
    particular we want to avoid re-running the solver unless we have to.
    
    There are still quite a number of TODOs, which are categorised.
    
    (cherry picked from commit 2d065c8c)
    352f5795