-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
External derivation builders #14145
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
External derivation builders #14145
Conversation
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 <[email protected]>
95246b0 to
73e4c40
Compare
Mic92
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a useful feature to have.
| Setting<ExternalBuilders> externalBuilders{ | ||
| this, | ||
| {}, | ||
| "external-builders", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a privileged nix option, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, every setting is privileged unless it's specifically exempted in daemon.cc.
| std::unique_ptr<DerivationBuilder> makeDerivationBuilder( | ||
| LocalStore & store, std::unique_ptr<DerivationBuilderCallbacks> miscMethods, DerivationBuilderParams params) | ||
| { | ||
| if (auto builder = ExternalDerivationBuilder::newIfSupported(store, miscMethods, params)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this filter out builtin derivations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently it doesn't. But that's the same for the build hook IIRC.
| "/nix/store/vj1c3wf9…-source-stdenv.sh", | ||
| "/nix/store/shkw4qm9…-default-builder.sh" | ||
| ], | ||
| "builder": "/nix/store/s1qkj0ph…-bash-5.2p37/bin/bash", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following are not needed?
"inputDrvs": {
"ag533xlxphzj8nh4y9wsksf057fgsls0-hello-2.12.2.tar.gz.drv": {
"dynamicOutputs": {},
"outputs": [
"out"
]
},
"j3aid0i43g57xkf4z9fbiqcbb4ljb06r-stdenv-darwin.drv": {
"dynamicOutputs": {},
"outputs": [
"out"
]
},
"pmlwjrsjfdk5r9j1mw97hm3pj0mc8lqk-version-check-hook.drv": {
"dynamicOutputs": {},
"outputs": [
"out"
]
},
"sbx1ghn3g6vaad1i8m730zbdsa3m9lyv-bash-5.3p3.drv": {
"dynamicOutputs": {},
"outputs": [
"out"
]
}
},
"inputSrcs": [
"l622p70vy8k5sh7y5wizi5f2mic6ynpg-source-stdenv.sh",
"shkw4qm9qcw5sc5n1k5jznc83ny02r39-default-builder.sh"
],
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't need those, but I did add the input closure and the (scratch) output paths so the external builder knows exactly what paths it may need to copy/mount into/out of its build environment.
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Motivation
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: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" }Context
Upstreamed from Determinate Nix (DeterminateSystems#78). This is the mechanism that allows doing Linux builds on macOS.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.