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!
main
Robert Hensing 2 years ago
parent 1b4f4ddb5b
commit 82da0794c2
  1. 2
      nixos/modules/installer/tools/nixos-generate-config.pl

@ -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;";

Loading…
Cancel
Save