From a7baec7cb1539bd82bd458c64994bf476cdfe273 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 25 May 2016 15:34:37 +0200 Subject: [PATCH] nixos-generate-config: Emit LUKS configuration for boot device --- .../doc/manual/man-nixos-generate-config.xml | 4 ++-- .../installer/tools/nixos-generate-config.pl | 23 +++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/nixos/doc/manual/man-nixos-generate-config.xml b/nixos/doc/manual/man-nixos-generate-config.xml index 140642bc9c9c..993a932ddfbe 100644 --- a/nixos/doc/manual/man-nixos-generate-config.xml +++ b/nixos/doc/manual/man-nixos-generate-config.xml @@ -113,8 +113,8 @@ - Omit everything concerning file system information - (which includes swap devices) from the hardware configuration. + Omit everything concerning file systems and swap devices + from the hardware configuration. diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index ed6c1b2dcd31..ca7fb71ba9b8 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -410,7 +410,7 @@ EOF EOF if (scalar @extraOptions > 0) { - $fileSystems .= < 'quiet') =~ /^CRYPT-LUKS/) + { + my @slaves = glob("/sys/class/block/$deviceName/slaves/*"); + if (scalar @slaves == 1) { + my $slave = "/dev/" . basename($slaves[0]); + if (-e $slave) { + my $dmName = read_file("/sys/class/block/$deviceName/dm/name"); + chomp $dmName; + $fileSystems .= " boot.initrd.luks.devices.\"$dmName\".device = \"${\(findStableDevPath $slave)}\";\n\n"; + } + } + } + } } @@ -459,7 +478,7 @@ my $modulePackages = toNixList(uniq @modulePackages); my $fsAndSwap = ""; if (!$noFilesystems) { - $fsAndSwap = "\n${fileSystems} "; + $fsAndSwap = "\n$fileSystems "; $fsAndSwap .= "swapDevices =" . multiLineList(" ", @swapDevices) . ";\n"; }