![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include <unix-derivation-builder-impl.hh>
Classes | |
| struct | DaemonWorkerState |
| struct | RunChildArgs |
Public Member Functions | |
| void | cleanupOnDestruction () noexcept |
| std::optional< Descriptor > | startBuild () override |
| BuilderExit | unprepareBuild () override |
| void | cleanupBuild (bool force) override |
| bool | killChild () override |
| DerivationBuilderImpl (std::shared_ptr< BuildingStore > store, std::shared_ptr< DerivationBuilderCallbacks > miscMethods, DerivationBuilderParams params) | |
| Public Member Functions inherited from nix::DerivationBuilderImpl | |
| DerivationBuilderImpl (std::shared_ptr< BuildingStore > store, std::shared_ptr< DerivationBuilderCallbacks > miscMethods, DerivationBuilderParams params) | |
| SingleDrvOutputs | registerOutputs (LocalStore &localStore) override |
| SingleDrvOutputs | checkSubmittedOutputs (LocalStore &localStore) override |
| Public Member Functions inherited from nix::DerivationBuilder | |
| MuxablePipePollState::CommChannel | logChannel () |
| Descriptor | logDescriptor () |
| Public Member Functions inherited from nix::RestrictionContext | |
| bool | isAllowed (const DerivedPath &id) |
| void | addDependency (const StorePath &path) |
Protected Types | |
| typedef StringMap | Environment |
| Protected Types inherited from nix::DerivationBuilderImpl | |
| typedef std::map< StorePath, StorePath > | RedirectedOutputs |
Protected Member Functions | |
| const StorePathSet & | originalPaths () override |
| bool | isAllowed (const StorePath &path) override |
| bool | isAllowed (const DrvOutput &id) override |
| bool | isAllowed (const DerivedPath &req) |
| bool | shouldModifySandbox () override |
| void | submitOutput (const SingleDerivedPath &path, const OutputName &output) override |
| virtual bool | needsHashRewrite () |
| virtual std::unique_ptr< UserLock > | getBuildUser () |
| PathsInChroot | getPathsInSandbox () |
| virtual void | setBuildTmpDir () |
| virtual std::filesystem::path | tmpDirInSandbox () |
| virtual void | prepareUser () |
| virtual void | prepareSandbox () |
| virtual Strings | getPreBuildHookArgs () |
| void | openSlave () |
| virtual void | startChild () |
| void | processSandboxSetupMessages () |
| void | addDependencyImpl (const StorePath &path) override |
| void | chownToBuilder (const std::filesystem::path &path) |
| void | chownToBuilder (int fd, const std::filesystem::path &path) |
| void | writeBuilderFile (const OsFilename &name, std::string_view contents) |
| void | runChild (RunChildArgs args) |
| virtual void | enterChroot () |
| virtual void | setUser () |
| virtual void | execBuilder (const Strings &args, const Strings &envStrs) |
| virtual void | killSandbox (bool getStats) |
| Protected Member Functions inherited from nix::DerivationBuilderImpl | |
| virtual std::filesystem::path | realPathInHost (const StorePath &p) |
Protected Attributes | |
| std::filesystem::path | topTmpDir |
| AutoCloseFD | tmpDirFd |
| Environment | env |
| bool | usingSubmitted |
| AutoCloseFD | daemonSocket |
| std::thread | daemonThread |
| std::list< DaemonWorkerState > | daemonWorkerThreads |
| Protected Attributes inherited from nix::DerivationBuilderImpl | |
| Pid | pid |
| std::shared_ptr< BuildingStore > | store |
| std::shared_ptr< DerivationBuilderCallbacks > | miscMethods |
| std::filesystem::path | tmpDir |
| const derivation::Type | derivationType |
| const LocalSettings & | localSettings = store->getLocalSettings() |
| std::unique_ptr< UserLock > | buildUser |
| StringMap | inputRewrites |
| StringMap | outputRewrites |
| RedirectedOutputs | redirectedOutputs |
| OutputPathMap | scratchOutputs |
Static Protected Attributes | |
| static const std::filesystem::path | homeDir = "/homeless-shelter" |
Friends | |
| struct | RestrictedStore |
Additional Inherited Members | |
| Public Attributes inherited from nix::DerivationBuilderImpl | |
| Sync< OutputPathMap > | submittedOutputs |
| Public Attributes inherited from nix::DerivationBuilder | |
| AutoCloseFD | builderOut |
| Public Attributes inherited from nix::RestrictionContext | |
| Sync< State > | state_ |
| Public Attributes inherited from nix::DerivationBuilderParams | |
| const StorePath & | drvPath |
| BuildResult & | buildResult |
| const BasicDerivation & | drv |
| const DerivationOptions< StorePath > & | drvOptions |
| const StorePathSet & | inputPaths |
| const std::map< std::string, InitialOutput > | initialOutputs |
| const BuildMode & | buildMode |
| PathsInChroot | defaultPathsInChroot |
| StringSet | systemFeatures |
| DesugaredEnv | desugaredEnv |
This class represents the state for building locally on Unix.
|
overrideprotectedvirtual |
This is the underlying implementation to be defined. The caller will ensure that this is only called on newly added dependencies, and that idempotent calls are a no-op.
Implements nix::RestrictionContext.
|
protected |
Make a file owned by the builder.
SAFETY: this function is prone to TOCTOU as it receives a path and not a descriptor. It's only safe to call in a child of a directory only visible to the owner.
|
protected |
Make a file owned by the builder addressed by its file descriptor.
| path | Only used for error messages. |
|
overridevirtual |
Delete the temporary directory, if we have one.
| force | We know the build succeeded, so don't attempt to preserve anything for debugging. |
Implements nix::DerivationBuilder.
|
inlinenoexcept |
Cleanup code to run when destroying any UnixDerivationBuilderImpl implementation.
|
inlineprotectedvirtual |
Move the current process into the chroot, if any. Called early by runChild().
Reimplemented in nix::ChrootFreeBSDDerivationBuilder, nix::ChrootLinuxDerivationBuilder, and nix::LinuxDerivationBuilder.
|
protectedvirtual |
Execute the derivation builder process. Called by runChild() as its final step. Should not return unless there is an error.
Reimplemented in nix::DarwinDerivationBuilder.
|
inlineprotectedvirtual |
Acquire a build user lock. Return nullptr if no lock is available.
Reimplemented in nix::ChrootLinuxDerivationBuilder.
|
protected |
Return the paths that should be made available in the sandbox. This includes:
|
inlineoverrideprotectedvirtual |
Implements nix::RestrictionContext.
|
inlineoverrideprotectedvirtual |
Recursive Nix calls are only allowed to build or realize paths in the original input closure or added via a recursive Nix call (so e.g. you can't do nix-store -r /nix/store/<bla> where /nix/store/<bla> is some arbitrary path in a binary cache).
Implements nix::RestrictionContext.
|
overridevirtual |
Forcibly kill the child process, if any.
Implements nix::DerivationBuilder.
|
protectedvirtual |
Kill any processes running under the build user UID or in the cgroup of the build.
Reimplemented in nix::ChrootLinuxDerivationBuilder, and nix::DarwinDerivationBuilder.
|
inlineprotectedvirtual |
Whether we need to perform hash rewriting if there are valid output paths.
Reimplemented in nix::ChrootDerivationBuilder.
|
protected |
Open the slave side of the pseudoterminal and use it as stderr.
|
inlineoverrideprotectedvirtual |
Paths that are already allowed to begin with
Implements nix::RestrictionContext.
|
protectedvirtual |
Called by prepareBuild() to do any setup in the parent to prepare for a sandboxed build.
Reimplemented in nix::ChrootDerivationBuilder, nix::ChrootFreeBSDDerivationBuilder, nix::ChrootLinuxDerivationBuilder, and nix::DarwinDerivationBuilder.
|
inlineprotectedvirtual |
Ensure that there are no processes running that conflict with buildUser.
Reimplemented in nix::ChrootLinuxDerivationBuilder.
|
protected |
Process messages send by the sandbox initialization.
|
protected |
Run the builder's process.
|
protectedvirtual |
Change the current process's uid/gid to the build user, if any. Called by runChild().
Reimplemented in nix::ChrootLinuxDerivationBuilder, and nix::DarwinDerivationBuilder.
|
inlineoverrideprotectedvirtual |
Whether mounting dependencies inside the sandbox should happen, or if it should be entirely skipped.
Implements nix::RestrictionContext.
|
overridevirtual |
Set up build environment / sandbox, acquiring resources (e.g. locks as needed). After this is run, the builder should be started.
Implements nix::DerivationBuilder.
|
protectedvirtual |
Called by prepareBuild() to start the child process for the build. Must set pid. The child must call runChild().
Reimplemented in nix::ChrootFreeBSDDerivationBuilder, and nix::ChrootLinuxDerivationBuilder.
|
overrideprotectedvirtual |
Register a store path to an output name For builder-rpc-v0
Implements nix::RestrictionContext.
|
inlineprotectedvirtual |
Return the path of the temporary directory in the sandbox.
Reimplemented in nix::ChrootDerivationBuilder.
|
overridevirtual |
Tear down build environment after the builder exits (either on its own or if it is killed).
Implements nix::DerivationBuilder.
|
protected |
|
protected |
The recursive Nix daemon socket.
|
protected |
The daemon main thread.
|
protected |
The daemon worker threads.
|
protected |
The file descriptor of the temporary directory.
|
protected |
The top-level temporary directory. tmpDir is either equal to or a child of this directory.
|
protected |
Whether or not derivation is using outputs submitted via recursive-nix