diff options
author | Claudio Bley <claudio.bley@gmail.com> | 2019-01-19 21:44:05 +0100 |
---|---|---|
committer | Claudio Bley <claudio.bley@gmail.com> | 2019-01-19 22:02:49 +0100 |
commit | 352e06d3da68f0faf600e8f765328751dfe29266 (patch) | |
tree | 676e684ede6b42f1dc1beb9620b1bede7f5c3bbf | |
parent | 50555a6d35b5a8b0794bb1fb295f9c0af7e0956e (diff) | |
download | nixlib-352e06d3da68f0faf600e8f765328751dfe29266.tar nixlib-352e06d3da68f0faf600e8f765328751dfe29266.tar.gz nixlib-352e06d3da68f0faf600e8f765328751dfe29266.tar.bz2 nixlib-352e06d3da68f0faf600e8f765328751dfe29266.tar.lz nixlib-352e06d3da68f0faf600e8f765328751dfe29266.tar.xz nixlib-352e06d3da68f0faf600e8f765328751dfe29266.tar.zst nixlib-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`.
-rw-r--r-- | nixos/modules/installer/tools/nixos-generate-config.pl | 6 |
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 52a129b39bcd..bad9356ab5a6 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"; + } } } } |