nixos-generate-config: fix for swapless kernels

Fixes #49826
This commit is contained in:
Patrick Hilhorst 2018-11-06 17:32:54 +01:00
parent fccfc775d1
commit ce65df3a36
No known key found for this signature in database
GPG Key ID: 589BB0A8DAFEF2B2

View File

@ -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) {
if (@swaps) {
shift @swaps;
foreach my $swap (@swaps) {
$swap =~ /^(\S+)\s/;
next unless -e $1;
my $dev = findStableDevPath $1;
push @swapDevices, "{ device = \"$dev\"; }";
}
}