summary refs log tree commit diff
path: root/nixos/modules/installer/tools/nixos-generate-config.pl
diff options
context:
space:
mode:
authorPatrick Hilhorst <git@hilhorst.be>2018-11-06 17:32:54 +0100
committerPatrick Hilhorst <git@hilhorst.be>2018-11-06 17:32:54 +0100
commitce65df3a3643706f27ed21fecf973ce0600ed386 (patch)
tree10376d6cefe7782aced1f18d6835817c2f2d5ac7 /nixos/modules/installer/tools/nixos-generate-config.pl
parentfccfc775d11053db6b1197bc2909ca98387e4543 (diff)
downloadnixpkgs-ce65df3a3643706f27ed21fecf973ce0600ed386.tar
nixpkgs-ce65df3a3643706f27ed21fecf973ce0600ed386.tar.gz
nixpkgs-ce65df3a3643706f27ed21fecf973ce0600ed386.tar.bz2
nixpkgs-ce65df3a3643706f27ed21fecf973ce0600ed386.tar.lz
nixpkgs-ce65df3a3643706f27ed21fecf973ce0600ed386.tar.xz
nixpkgs-ce65df3a3643706f27ed21fecf973ce0600ed386.tar.zst
nixpkgs-ce65df3a3643706f27ed21fecf973ce0600ed386.zip
nixos-generate-config: fix for swapless kernels
Fixes #49826
Diffstat (limited to 'nixos/modules/installer/tools/nixos-generate-config.pl')
-rw-r--r--nixos/modules/installer/tools/nixos-generate-config.pl16
1 files changed, 9 insertions, 7 deletions
diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl
index b70faa380e5..52a129b39bc 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\"; }";
+    }
 }