forked from lix-project/lix
Add a setting for enabling cgroups
This commit is contained in:
parent
ff12d1c1a1
commit
67bcb99700
|
@ -43,10 +43,11 @@
|
||||||
|
|
||||||
```
|
```
|
||||||
extra-experimental-features = cgroups
|
extra-experimental-features = cgroups
|
||||||
|
use-cgroups = true
|
||||||
```
|
```
|
||||||
|
|
||||||
to `nix.conf`. It is also automatically enabled for builds that
|
to `nix.conf`. Cgroups are required for derivations that require the
|
||||||
require the `uid-range` system feature.
|
`uid-range` system feature.
|
||||||
|
|
||||||
* `nix build --json` now prints some statistics about top-level
|
* `nix build --json` now prints some statistics about top-level
|
||||||
derivations, such as CPU statistics when cgroups are enabled.
|
derivations, such as CPU statistics when cgroups are enabled.
|
||||||
|
|
|
@ -401,9 +401,14 @@ static void linkOrCopy(const Path & from, const Path & to)
|
||||||
void LocalDerivationGoal::startBuilder()
|
void LocalDerivationGoal::startBuilder()
|
||||||
{
|
{
|
||||||
if ((buildUser && buildUser->getUIDCount() != 1)
|
if ((buildUser && buildUser->getUIDCount() != 1)
|
||||||
|| settings.isExperimentalFeatureEnabled(Xp::Cgroups))
|
#if __linux__
|
||||||
|
|| settings.useCgroups
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
#if __linux__
|
#if __linux__
|
||||||
|
settings.requireExperimentalFeature(Xp::Cgroups);
|
||||||
|
|
||||||
auto ourCgroups = getCgroups("/proc/self/cgroup");
|
auto ourCgroups = getCgroups("/proc/self/cgroup");
|
||||||
auto ourCgroup = ourCgroups[""];
|
auto ourCgroup = ourCgroups[""];
|
||||||
if (ourCgroup == "")
|
if (ourCgroup == "")
|
||||||
|
|
|
@ -304,6 +304,17 @@ public:
|
||||||
"id-count",
|
"id-count",
|
||||||
"The number of UIDs/GIDs to use for dynamic ID allocation."};
|
"The number of UIDs/GIDs to use for dynamic ID allocation."};
|
||||||
|
|
||||||
|
#if __linux__
|
||||||
|
Setting<bool> useCgroups{
|
||||||
|
this, false, "use-cgroups",
|
||||||
|
R"(
|
||||||
|
Whether to execute builds inside cgroups. Cgroups are
|
||||||
|
enabled automatically for derivations that require the
|
||||||
|
`uid-range` system feature.
|
||||||
|
)"
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
Setting<bool> impersonateLinux26{this, false, "impersonate-linux-26",
|
Setting<bool> impersonateLinux26{this, false, "impersonate-linux-26",
|
||||||
"Whether to impersonate a Linux 2.6 machine on newer kernels.",
|
"Whether to impersonate a Linux 2.6 machine on newer kernels.",
|
||||||
{"build-impersonate-linux-26"}};
|
{"build-impersonate-linux-26"}};
|
||||||
|
|
|
@ -23,7 +23,7 @@ makeTest ({
|
||||||
nix.binaryCaches = lib.mkForce [ ];
|
nix.binaryCaches = lib.mkForce [ ];
|
||||||
nix.extraOptions =
|
nix.extraOptions =
|
||||||
''
|
''
|
||||||
extra-experimental-features = nix-command auto-allocate-uids
|
extra-experimental-features = nix-command auto-allocate-uids cgroups
|
||||||
extra-system-features = uid-range
|
extra-system-features = uid-range
|
||||||
'';
|
'';
|
||||||
nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
|
nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
|
||||||
|
|
Loading…
Reference in a new issue