Skip to content

Support relative paths in hydra-build-products to enable relocatable derivations #1544

@roberth

Description

@roberth

Support relative paths in hydra-build-products to enable relocatable derivations

Is your feature request related to a problem? Please describe.

Currently, hydra-build-products requires absolute store paths in the path field. This prevents derivation outputs that are perfectly relocatable from verifying this fact, as specifying build products forces them to contain self-references.

For example, a derivation output at /nix/store/abc-foo must write:

doc none /nix/store/abc-foo/manual.pdf

This absolute path creates a self-reference in the output, making it non-relocatable even if the output would otherwise be position-independent.

The validation in src/hydra-queue-runner/build-result.cc:88 explicitly rejects non-absolute paths:

if (product.path == "" || product.path[0] != '/') continue;

Describe the solution you'd like

Support relative paths in hydra-build-products that are resolved relative to the output path. For example:

doc none manual.pdf

This would be resolved to $out/manual.pdf internally by Hydra, allowing the derivation to remain relocatable while still declaring its build products.

Alternatively, support an explicit output-relative syntax like:

doc none $out/manual.pdf

Describe alternatives you've considered

  1. Status quo: Continue requiring absolute paths, accepting that all derivations with build products will have self-references
  2. Store-path-relative paths: Allow paths like abc-foo/manual.pdf that are relative to the store directory, though this still encodes the hash
  3. Special sentinel paths: Use a placeholder like @OUTPUT@/manual.pdf that Hydra replaces, though this is more complex

Additional context

This issue affects reproducibility and content-addressability efforts, where minimizing self-references is important for enabling features like:

  • Content-addressed derivations that can be deduplicated across different store paths
  • Binary cache sharing where outputs might be relocated
  • Verification that outputs are truly position-independent

Related code: src/hydra-queue-runner/build-result.cc:84-90

cc @Ericson2314

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions