From 82da0794c28cf7eff6f0a3755fe8ec9d1cb8ed7f Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 21 Jun 2022 14:37:16 +0200 Subject: 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! --- nixos/modules/installer/tools/nixos-generate-config.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos/modules') diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index 65b5c0331f42d..1935d8252607c 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/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;"; -- cgit 1.4.1