summary refs log tree commit diff
path: root/nixos/modules/installer/tools/nixos-generate-config.pl
diff options
context:
space:
mode:
authorClaudio Bley <claudio.bley@gmail.com>2019-01-19 21:44:05 +0100
committerClaudio Bley <claudio.bley@gmail.com>2019-01-19 22:02:49 +0100
commit352e06d3da68f0faf600e8f765328751dfe29266 (patch)
tree676e684ede6b42f1dc1beb9620b1bede7f5c3bbf /nixos/modules/installer/tools/nixos-generate-config.pl
parent50555a6d35b5a8b0794bb1fb295f9c0af7e0956e (diff)
downloadnixpkgs-352e06d3da68f0faf600e8f765328751dfe29266.tar
nixpkgs-352e06d3da68f0faf600e8f765328751dfe29266.tar.gz
nixpkgs-352e06d3da68f0faf600e8f765328751dfe29266.tar.bz2
nixpkgs-352e06d3da68f0faf600e8f765328751dfe29266.tar.lz
nixpkgs-352e06d3da68f0faf600e8f765328751dfe29266.tar.xz
nixpkgs-352e06d3da68f0faf600e8f765328751dfe29266.tar.zst
nixpkgs-352e06d3da68f0faf600e8f765328751dfe29266.zip
installer/tools: Avoid duplicate LUKS device entries in hw config
There are situations where several filesystems reside on a single encrypted LUKS
device (e.g. when using BTRFS subvolumes).

Simply generating a `boot.init.luks.devices.NAME.device` entry for each mounted
filesystem will result in an error later when evaluating the nix expression in
`hardware-configuration.nix`.
Diffstat (limited to 'nixos/modules/installer/tools/nixos-generate-config.pl')
-rw-r--r--nixos/modules/installer/tools/nixos-generate-config.pl6
1 files changed, 5 insertions, 1 deletions
diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl
index 52a129b39bc..bad9356ab5a 100644
--- a/nixos/modules/installer/tools/nixos-generate-config.pl
+++ b/nixos/modules/installer/tools/nixos-generate-config.pl
@@ -449,7 +449,11 @@ EOF
                 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";
+                    # Ensure to add an entry only once
+                    my $luksDevice = "  boot.initrd.luks.devices.\"$dmName\".device";
+                    if ($fileSystems !~ /^\Q$luksDevice\E/m) {
+                        $fileSystems .= "$luksDevice = \"${\(findStableDevPath $slave)}\";\n\n";
+                    }
                 }
             }
         }