Move platform-specific code out of DerivationBuilder#13276
Merged
Ericson2314 merged 11 commits intomasterfrom May 27, 2025
Merged
Move platform-specific code out of DerivationBuilder#13276Ericson2314 merged 11 commits intomasterfrom
DerivationBuilder#13276Ericson2314 merged 11 commits intomasterfrom
Conversation
Ericson2314
approved these changes
May 27, 2025
Member
Ericson2314
left a comment
There was a problem hiding this comment.
Fantastic! Thanks for much for doing this @edolstra!
Comment on lines
+2102
to
+2104
| // FIXME: do this properly | ||
| #include "linux-derivation-builder.cc" | ||
| #include "darwin-derivation-builder.cc" |
Member
There was a problem hiding this comment.
I'll let this slide for now :)
Member
There was a problem hiding this comment.
Out of curiosity, what would "do this properly" look like? A separate file that has these includes and the function definition, or...?
Member
Author
There was a problem hiding this comment.
Yeah, we'd have to move DerivationBuilderImpl into a header. But putting an impl class in a header kind of defeats the purpose. And there are probably some more refactorings that we want to do (like splitting DerivationBuilder and UnixDerivationBuilder) but we can do that in a future PR.
This was referenced May 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This PR moves almost all of the Linux/Darwin-specific code out of
DerivationBuilderImpland into separate files/subclasses. I.e. we have the following class hierarchy:DerivationBuilderImplitself implements generic unsandboxed Unix building, but has virtual methods that allow the subclasses to provide sandboxing.LinuxDerivationBuilderperforms namespaced/chroot builds on Linux. It is not used on Linux if you have sandboxing disabled. (Currently the seccomp/personality code is part of this class, so we may want to split the class hierarchy a bit further.)makeDerivationBuilder()instantiates the right class based on the OS type and whether sandboxing is enabled.In the future, we should split the generic Unix code (e.g. user allocation,
runChild(), pseudo-terminal allocation) from the platform-independent code (e.g.registerOutputs()), so we could have something like this:Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.