nixos-{rebuild,container}: Use flakeref#attrpath syntax

This makes them consistent with the 'nix' command line.
This commit is contained in:
Eelco Dolstra
2019-09-20 18:37:17 +02:00
parent 20087bd553
commit fb051f0dec
3 changed files with 27 additions and 38 deletions

View File

@@ -64,6 +64,7 @@ my $configFile;
my $hostAddress;
my $localAddress;
my $flake;
my $flakeAttr = "container";
GetOptions(
"help" => sub { showHelp() },
@@ -92,6 +93,11 @@ if (defined $configFile and defined $extraConfig) {
"Please define on or the other, but not both";
}
if (defined $flake && $flake =~ /^(.*)#([^#"]+)$/) {
$flake = $1;
$flakeAttr = $2;
}
# Execute the selected action.
mkpath("/etc/containers", 0, 0755);
@@ -137,7 +143,7 @@ EOF
sub buildFlake {
system("nix", "build", "-o", "$systemPath.tmp", "--",
"$flake:nixosConfigurations.container.config.system.build.toplevel") == 0
"$flake#nixosConfigurations.\"$flakeAttr\".config.system.build.toplevel") == 0
or die "$0: failed to build container from flake '$flake'\n";
$systemPath = readlink("$systemPath.tmp") or die;
unlink("$systemPath.tmp");