mirror of
https://github.com/NixOS/nix.git
synced 2024-11-25 08:12:29 +00:00
Prefer 'remote builder' over 'slave'
This commit is contained in:
parent
5b2fdfdca2
commit
0aca1ffb6e
@ -275,7 +275,7 @@ as a means of providing Nix store access to a restricted ssh user.
|
||||
|
||||
<listitem><para>Allow the connected client to request the realization
|
||||
of derivations. In effect, this can be used to make the host act
|
||||
as a build slave.</para></listitem>
|
||||
as a remote builder.</para></listitem>
|
||||
|
||||
</varlistentry>
|
||||
|
||||
|
@ -8,8 +8,8 @@ makeTest (
|
||||
|
||||
let
|
||||
|
||||
# The configuration of the build slaves.
|
||||
slave =
|
||||
# The configuration of the remote builders.
|
||||
builder =
|
||||
{ config, pkgs, ... }:
|
||||
{ services.openssh.enable = true;
|
||||
virtualisation.writableStore = true;
|
||||
@ -36,21 +36,21 @@ in
|
||||
{
|
||||
|
||||
nodes =
|
||||
{ slave1 = slave;
|
||||
slave2 = slave;
|
||||
{ builder1 = builder;
|
||||
builder2 = builder;
|
||||
|
||||
client =
|
||||
{ config, pkgs, ... }:
|
||||
{ nix.maxJobs = 0; # force remote building
|
||||
nix.distributedBuilds = true;
|
||||
nix.buildMachines =
|
||||
[ { hostName = "slave1";
|
||||
[ { hostName = "builder1";
|
||||
sshUser = "root";
|
||||
sshKey = "/root/.ssh/id_ed25519";
|
||||
system = "i686-linux";
|
||||
maxJobs = 1;
|
||||
}
|
||||
{ hostName = "slave2";
|
||||
{ hostName = "builder2";
|
||||
sshUser = "root";
|
||||
sshKey = "/root/.ssh/id_ed25519";
|
||||
system = "i686-linux";
|
||||
@ -75,33 +75,33 @@ in
|
||||
$client->copyFileFromHost("key", "/root/.ssh/id_ed25519");
|
||||
$client->succeed("chmod 600 /root/.ssh/id_ed25519");
|
||||
|
||||
# Install the SSH key on the slaves.
|
||||
# Install the SSH key on the builders.
|
||||
$client->waitForUnit("network.target");
|
||||
foreach my $slave ($slave1, $slave2) {
|
||||
$slave->succeed("mkdir -p -m 700 /root/.ssh");
|
||||
$slave->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
|
||||
$slave->waitForUnit("sshd");
|
||||
$client->succeed("ssh -o StrictHostKeyChecking=no " . $slave->name() . " 'echo hello world'");
|
||||
foreach my $builder ($builder1, $builder2) {
|
||||
$builder->succeed("mkdir -p -m 700 /root/.ssh");
|
||||
$builder->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
|
||||
$builder->waitForUnit("sshd");
|
||||
$client->succeed("ssh -o StrictHostKeyChecking=no " . $builder->name() . " 'echo hello world'");
|
||||
}
|
||||
|
||||
# Perform a build and check that it was performed on the slave.
|
||||
# Perform a build and check that it was performed on the builder.
|
||||
my $out = $client->succeed(
|
||||
"nix-build ${expr nodes.client.config 1} 2> build-output",
|
||||
"grep -q Hello build-output"
|
||||
);
|
||||
$slave1->succeed("test -e $out");
|
||||
$builder1->succeed("test -e $out");
|
||||
|
||||
# And a parallel build.
|
||||
my ($out1, $out2) = split /\s/,
|
||||
$client->succeed('nix-store -r $(nix-instantiate ${expr nodes.client.config 2})\!out $(nix-instantiate ${expr nodes.client.config 3})\!out');
|
||||
$slave1->succeed("test -e $out1 -o -e $out2");
|
||||
$slave2->succeed("test -e $out1 -o -e $out2");
|
||||
$builder1->succeed("test -e $out1 -o -e $out2");
|
||||
$builder2->succeed("test -e $out1 -o -e $out2");
|
||||
|
||||
# And a failing build.
|
||||
$client->fail("nix-build ${expr nodes.client.config 5}");
|
||||
|
||||
# Test whether the build hook automatically skips unavailable slaves.
|
||||
$slave1->block;
|
||||
# Test whether the build hook automatically skips unavailable builders.
|
||||
$builder1->block;
|
||||
$client->succeed("nix-build ${expr nodes.client.config 4}");
|
||||
'';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user