nixos-generate-config: Make robust against missing newline

The substr solution assumed a newline to be present.
The new solution will not remove the newline if it goes missing in the future.

Apparently this is idiomatic perl.

Thanks pennae for the suggestion!
This commit is contained in:
Robert Hensing 2022-06-21 14:37:16 +02:00
parent 1b4f4ddb5b
commit 82da0794c2

View File

@ -89,7 +89,7 @@ my ($status, @systemLines) = runCommand("nix-instantiate --impure --eval --expr
if ($status != 0 || join("", @systemLines) =~ /error/) {
die "Failed to retrieve current system type from nix.\n";
}
my $system = substr(@systemLines[0], 0, -1);
chomp(my $system = @systemLines[0]);
push @attrs, "nixpkgs.hostPlatform = lib.mkDefault $system;";