Skip to content

Add support for external builders #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 29 commits into
base: detsys-main
Choose a base branch
from

Conversation

edolstra
Copy link
Collaborator

@edolstra edolstra commented May 28, 2025

Motivation

External builders are helper programs that execute derivations for specified system types (e.g. using QEMU to emulate another system type).

To use, set external-builders:

external-builders = [{"systems": ["aarch64-linux"], "program": "/path/to/external-builder.py"}]

The external builder gets one command line argument, the path to a JSON file containing all necessary information about the derivation:

{
  "args": [...],
  "builder": "/nix/store/kwcyvgdg98n98hqapaz8sw92pc2s78x6-bash-5.2p37/bin/bash",
  "env": {
    "HOME": "/homeless-shelter",
    ...
  },
  "realStoreDir": "/tmp/nix/nix/store",
  "storeDir": "/nix/store",
  "tmpDir": "/tmp/nix-shell.dzQ2hE/nix-build-patchelf-0.14.3.drv-46/build",
  "tmpDirInSandbox": "/build"
}

This PR incorporates upstream NixOS#13276.

TODO: Don't run external builders as root.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

Copy link

github-actions bot commented May 28, 2025

@github-actions github-actions bot temporarily deployed to pull request May 28, 2025 17:21 Inactive
@edolstra edolstra force-pushed the refactor-derivation-builder branch 2 times, most recently from 5d095b4 to 79509d0 Compare May 30, 2025 17:00
@edolstra
Copy link
Collaborator Author

edolstra commented May 30, 2025

TODO: come up with a better name than "external builder" since "builder" is pretty overloaded (it's both the derivation build script and now the thing that executes the derivation).

Build wrappers?

@github-actions github-actions bot temporarily deployed to pull request May 30, 2025 17:12 Inactive
@edolstra edolstra force-pushed the refactor-derivation-builder branch 2 times, most recently from dc19372 to df90dea Compare May 30, 2025 18:23
@github-actions github-actions bot temporarily deployed to pull request May 30, 2025 18:35 Inactive
@github-actions github-actions bot temporarily deployed to pull request May 30, 2025 19:08 Inactive
edolstra added 17 commits June 17, 2025 08:22
The use of a `buildUser` is an implementation detail of some types of
sandboxes that shouldn't exposed.
Having the exact same doc comments isn't very useful/maintainable.
No point in computing this lazily, since it's pretty much the first
thing the DerivationBuilder does.
These are helper programs that execute derivations for specified
system types (e.g. using QEMU to emulate another system type).

To use, set `external-builders`:

  external-builders = [{"systems": ["aarch64-linux"], "program": "/path/to/external-builder.py"}]

The external builder gets one command line argument, the path to a JSON file containing all necessary information about the derivation:

  {
    "args": [...],
    "builder": "/nix/store/kwcyvgdg98n98hqapaz8sw92pc2s78x6-bash-5.2p37/bin/bash",
    "env": {
      "HOME": "/homeless-shelter",
      ...
    },
    "realStoreDir": "/tmp/nix/nix/store",
    "storeDir": "/nix/store",
    "tmpDir": "/tmp/nix-shell.dzQ2hE/nix-build-patchelf-0.14.3.drv-46/build",
    "tmpDirInSandbox": "/build"
  }
Co-authored-by: Cole Helbling <cole.e.helbling@outlook.com>
@cole-h cole-h force-pushed the refactor-derivation-builder branch from 740aecb to 5842d54 Compare June 17, 2025 18:01
@cole-h cole-h force-pushed the refactor-derivation-builder branch from d8bda44 to ef4e7df Compare June 30, 2025 18:31
Ericson2314 and others added 8 commits June 30, 2025 11:40
Clang doesn't like the double indent that is needed for the `if...else`
that is CPP'd away. Adding braces is fine in the `if...else...` case,
and fine as a naked block in the CPP'd away case, and properly-indented
both ways.
I don't want to figure out how to make nlohmann treat std::optional<>
the same way Rust's serde_json treats Option<> (i.e. skip it if it's
not there).
Add an `external-builders` experimental feature
@github-actions github-actions bot temporarily deployed to pull request July 14, 2025 20:46 Inactive
@github-actions github-actions bot temporarily deployed to pull request July 15, 2025 16:54 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants