Skip to content

New virtual store method(s) to support builder stores #15533

@lisanna-dettwyler

Description

@lisanna-dettwyler

Is your feature request related to a problem?

To allow the build hook mechanism to be fully deprecated but still provide facilities for implementing custom builders, we want to support a concept of "builder stores" which are lightweight store implementations that just implement custom building logic and no-op/error for other unrelated store methods. Today, build hooks have the advantage of receiving the path to build alongside its inputs, whereas with stores this information is passed in separate calls (addMultipleToStore, buildPathsWithResults) with no relation to each other other than timing / sequencing. For a builder store that wants to multiplex builds across multiple machines, it may not know ahead of time what machine to query for queryValidPaths or copy the paths to from addMultipleToStore before it receives a build request and assigns (or is given) a machine for it.

Proposed solution

Virtual store method(s) that allow you to pass a build request along with its inputs, using a similar signature as the existing build hook mechanism. It could look something like this:

virtual BuildResult buildDerivation(
        const StorePath & drvPath,
        const BasicDerivation & drv,
        StorePathSet & inputs,
        BuildMode buildMode = bmNormal);

This would provide a direct method for the daemon to invoke remote building via the store implementation in place of calling out to the build hook or having to call multiple store methods sequentially. Thus, the store can deal with copying the inputs at the same time as it performing the build, so it is guaranteed to know what machine to copy the inputs to.

inputs should be a StorePathSet because the custom store can just open the local store itself to access the underlying paths, just like the build hook currently does.

A default implementation of the virtual method should be provided to cover built-in stores that just calls existing methods in sequence to copy the inputs and build the derivation(s).

A builder store could be used in the following ways:

  • A plugin, allowing usage of --store or specifying it in a machines file / --builder argument.
  • A custom nix-daemon which passes the builder store to processConnection,
    • ...to create build services like nixbuild.net.
    • ...to enable usage with ssh-ng://localhost?remoteProgram=/path/to/my-daemon.
    • ...that runs as a service exposing a socket to use with NIX_REMOTE.

This also provides usage options with more flexibility for smarter scheduling, allowing the store to receive the entire closure of a build request rather than piecemeal when used with --store or the daemon model.

This should not require any modifications to the daemon protocol.

Alternative solutions

  • Keeping the build hook mechanism (undesirable)

Additional context

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or proposal

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions