Skip to content
  • Duncan Coutts's avatar
    Solver feature: soft prefs for enabling testsuites/benchmarks · 114b3810
    Duncan Coutts authored
    The solver has the concept of hard constraints and soft preferences.
    For versions we have both constraints and preferences. We also have
    soft preferences available for whether we'd like installed instanes
    or not.
    
    We also have hard constraints for enabling "optional stanzas" (ie test
    suites or benchmarks). This patch adds soft preferences for the same.
    That is it lets us express the desire to please try enabling test suites
    and/or benchmarks, but allow them to be disabled if a solution cannot
    easily be found with them enabled.
    
    The implementation is very straightforward and not at all scary. :-)
    The original design was discussed with kosmikus and it has seen
    extensive testing in the nix-local-build branch.
    
    Optional stanzas in the solver are treated very much like flags, and so
    we can follow the pattern of a similar feature for flags for this
    feature for optional stanzas. For both flags and optional stanzas the
    solver has a node with up to two choices: True & False, corresponding to
    enable and disable. Various policies can be expressed by reordering
    these two choices or replacing one or other branch with failure. For
    example we can force enabling by replacing the False choice with
    failure. Flag default values are implemented by reordering the True and
    False branches (since the solver will try the first branch first).
    
    So this preference is implemented simply by reordering to put the True
    branch first (keeping both branches). That way the solver will try the
    enable branch first and backtrack to the False branch (which imposes no
    constraints). It integrates smoothly with stanza constraints, which
    adjusts the False branch to be a failure, thereby forcing the True
    branch (or further failure).
    
    The top down solver is simply adjusted for the types, the feature is not
    implemented there.
    
    The feature is not yet used. It's not intended to have any command line
    flag, but to express future policies.
    114b3810