Support multiple machines files

This is primarily useful for the Hydra provisioner, which can write
its machines to another file than /etc/nix/machines.
This commit is contained in:
Eelco Dolstra
2015-08-25 14:11:50 +02:00
parent 442bed3b59
commit 7aa52517e9
3 changed files with 63 additions and 34 deletions

View File

@ -286,12 +286,13 @@ sub getEvals {
sub getMachines {
my $machinesConf = $ENV{"NIX_REMOTE_SYSTEMS"} || "/etc/nix/machines";
# Read the list of machines.
my %machines = ();
if (-e $machinesConf) {
open CONF, "<$machinesConf" or die;
my @machinesFiles = split /:/, ($ENV{"NIX_REMOTE_SYSTEMS"} || "/etc/nix/machines");
for my $machinesFile (@machinesFiles) {
next unless -e $machinesFile;
open CONF, "<$machinesFile" or die;
while (<CONF>) {
chomp;
s/\#.*$//g;
@ -310,6 +311,7 @@ sub getMachines {
}
close CONF;
}
return \%machines;
}