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

Implement resource-management experimental feature

Adds basic resource tracking to system features used by distributed
builds, similar to resource management in job schedulers like Slurm.

Includes a positive and negative functional test and a documentation
update to the distributed builds section.

Resolves #2307

Signed-off-by: Lisanna Dettwyler <lisanna.dettwyler@gmail.com>
This commit is contained in:
Lisanna 2025-11-03 15:41:52 -05:00
parent 5390bba920
commit 1b69645641
12 changed files with 261 additions and 15 deletions

View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
source common.sh
enableFeatures "resource-management"
requireSandboxSupport
[[ $busybox =~ busybox ]] || skipTest "no busybox"
here=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
export NIX_USER_CONF_FILES=$here/config/nix-with-resource-management.conf
expectStderr 1 nix build -Lvf resource-management.nix \
--arg busybox "$busybox" \
--out-link "$TEST_ROOT/result-from-remote" \
--store "$TEST_ROOT/local" \
--builders "ssh-ng://localhost?system-features=testf - - 4 1 testf:1" \
| grepQuiet "Failed to find a machine for remote build!"

View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
source common.sh
enableFeatures "resource-management"
requireSandboxSupport
[[ $busybox =~ busybox ]] || skipTest "no busybox"
here=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
export NIX_USER_CONF_FILES=$here/config/nix-with-resource-management.conf
nix build -Lvf resource-management.nix \
--arg busybox "$busybox" \
--out-link "$TEST_ROOT/result-from-remote" \
--store "$TEST_ROOT/local" \
--builders "ssh-ng://localhost?system-features=test - - 4 1 test:4"
grepQuiet 'Hello World!' < "$TEST_ROOT/result-from-remote/hello"

View file

@ -0,0 +1,2 @@
experimental-features = resource-management nix-command
system-features = test

View file

@ -109,6 +109,8 @@ suites = [
'build-remote-trustless-should-pass-3.sh',
'build-remote-trustless-should-fail-0.sh',
'build-remote-with-mounted-ssh-ng.sh',
'build-remote-resource-management-should-fail.sh',
'build-remote-resource-management.sh',
'nar-access.sh',
'impure-eval.sh',
'pure-eval.sh',

View file

@ -0,0 +1,50 @@
{ busybox }:
with import ./config.nix;
let
drv1 = mkDerivation {
name = "resource-management-1";
shell = busybox;
builder = ./simple.builder.sh;
PATH = "";
goodPath = path;
requiredSystemFeatures = ["test:2"];
meta.position = "${__curPos.file}:${toString __curPos.line}";
};
drv2 = mkDerivation {
name = "resource-management-2";
shell = busybox;
builder = ./simple.builder.sh;
PATH = "";
goodPath = path;
requiredSystemFeatures = ["test:2"];
meta.position = "${__curPos.file}:${toString __curPos.line}";
};
drv3 = mkDerivation {
name = "resource-management-3";
shell = busybox;
builder = ./simple.builder.sh;
PATH = "";
goodPath = path;
requiredSystemFeatures = ["test:2"];
meta.position = "${__curPos.file}:${toString __curPos.line}";
};
drv4 = mkDerivation {
name = "resource-management-4";
shell = busybox;
builder = ./simple.builder.sh;
PATH = "";
goodPath = path;
requiredSystemFeatures = ["test:2"];
meta.position = "${__curPos.file}:${toString __curPos.line}";
};
in mkDerivation {
name = "resource-management";
shell = busybox;
builder = ./simple.builder.sh;
PATH = "";
goodPath = path;
DRVS = "${drv1}${drv2}${drv3}${drv4}";
meta.position = "${__curPos.file}:${toString __curPos.line}";
}