1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 20:16:03 +01:00

Merge pull request #13808 from obsidiansystems/derivation-builder-kvm

Create `StringSet DerivationBuilderParams::systemFeatures`
This commit is contained in:
John Ericson 2025-08-27 15:19:06 -04:00 committed by GitHub
commit 193ad73ce2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View file

@ -766,6 +766,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
.initialOutputs = initialOutputs, .initialOutputs = initialOutputs,
.buildMode = buildMode, .buildMode = buildMode,
.defaultPathsInChroot = std::move(defaultPathsInChroot), .defaultPathsInChroot = std::move(defaultPathsInChroot),
.systemFeatures = worker.store.config.systemFeatures.get(),
.finalEnv = std::move(finalEnv), .finalEnv = std::move(finalEnv),
.extraFiles = std::move(extraFiles), .extraFiles = std::move(extraFiles),
}); });

View file

@ -65,6 +65,14 @@ struct DerivationBuilderParams
*/ */
PathsInChroot defaultPathsInChroot; PathsInChroot defaultPathsInChroot;
/**
* May be used to control various platform-specific functionality.
*
* For example, on Linux, the `kvm` system feature controls whether
* `/dev/kvm` should be exposed to the builder within the sandbox.
*/
StringSet systemFeatures;
struct EnvEntry struct EnvEntry
{ {
/** /**

View file

@ -492,7 +492,7 @@ struct ChrootLinuxDerivationBuilder : ChrootDerivationBuilder, LinuxDerivationBu
createDirs(chrootRootDir + "/dev/shm"); createDirs(chrootRootDir + "/dev/shm");
createDirs(chrootRootDir + "/dev/pts"); createDirs(chrootRootDir + "/dev/pts");
ss.push_back("/dev/full"); ss.push_back("/dev/full");
if (store.Store::config.systemFeatures.get().count("kvm") && pathExists("/dev/kvm")) if (systemFeatures.count("kvm") && pathExists("/dev/kvm"))
ss.push_back("/dev/kvm"); ss.push_back("/dev/kvm");
ss.push_back("/dev/null"); ss.push_back("/dev/null");
ss.push_back("/dev/random"); ss.push_back("/dev/random");