From ce65df3a3643706f27ed21fecf973ce0600ed386 Mon Sep 17 00:00:00 2001 From: Patrick Hilhorst Date: Tue, 6 Nov 2018 17:32:54 +0100 Subject: nixos-generate-config: fix for swapless kernels Fixes #49826 --- nixos/modules/installer/tools/nixos-generate-config.pl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'nixos/modules/installer') diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index b70faa380e54..52a129b39bcd 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -314,14 +314,16 @@ push @attrs, "services.xserver.videoDrivers = [ \"$videoDriver\" ];" if $videoDr # Generate the swapDevices option from the currently activated swap # devices. -my @swaps = read_file("/proc/swaps"); -shift @swaps; +my @swaps = read_file("/proc/swaps", err_mode => 'carp'); my @swapDevices; -foreach my $swap (@swaps) { - $swap =~ /^(\S+)\s/; - next unless -e $1; - my $dev = findStableDevPath $1; - push @swapDevices, "{ device = \"$dev\"; }"; +if (@swaps) { + shift @swaps; + foreach my $swap (@swaps) { + $swap =~ /^(\S+)\s/; + next unless -e $1; + my $dev = findStableDevPath $1; + push @swapDevices, "{ device = \"$dev\"; }"; + } } -- cgit 1.4.1