about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMatthias Berndt <matthias_berndt@gmx.de>2023-05-15 20:41:10 -0400
committerMatthias Berndt <matthias_berndt@gmx.de>2023-05-15 20:48:10 -0400
commit3aa262b644feff5153888ed85661450cb151088b (patch)
treeaa61e423a0ac4a7819f9218b80d79d08c0c5f73b /nixos
parent8aa320b4c2d0d7699170f6da154ebb7598e4d154 (diff)
downloadnixlib-3aa262b644feff5153888ed85661450cb151088b.tar
nixlib-3aa262b644feff5153888ed85661450cb151088b.tar.gz
nixlib-3aa262b644feff5153888ed85661450cb151088b.tar.bz2
nixlib-3aa262b644feff5153888ed85661450cb151088b.tar.lz
nixlib-3aa262b644feff5153888ed85661450cb151088b.tar.xz
nixlib-3aa262b644feff5153888ed85661450cb151088b.tar.zst
nixlib-3aa262b644feff5153888ed85661450cb151088b.zip
make nixos-generate-config generate stratis pool UUIDs
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/installer/tools/nixos-generate-config.pl21
1 files changed, 19 insertions, 2 deletions
diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl
index c65898b261cb..c822ea61200d 100644
--- a/nixos/modules/installer/tools/nixos-generate-config.pl
+++ b/nixos/modules/installer/tools/nixos-generate-config.pl
@@ -335,7 +335,7 @@ sub findStableDevPath {
 
     my $st = stat($dev) or return $dev;
 
-    foreach my $dev2 (glob("/dev/disk/by-uuid/*"), glob("/dev/mapper/*"), glob("/dev/disk/by-label/*")) {
+    foreach my $dev2 (glob("/dev/stratis/*/*"), glob("/dev/disk/by-uuid/*"), glob("/dev/mapper/*"), glob("/dev/disk/by-label/*")) {
         my $st2 = stat($dev2) or next;
         return $dev2 if $st->rdev == $st2->rdev;
     }
@@ -467,6 +467,17 @@ EOF
         }
     }
 
+    # is this a stratis fs?
+    my $stableDevPath = findStableDevPath $device;
+    my $stratisPool;
+    if ($stableDevPath =~ qr#/dev/stratis/(.*)/.*#) {
+        my $poolName = $1;
+        my ($header, @lines) = split "\n", qx/stratis pool list/;
+        my $uuidIndex = index $header, 'UUID';
+        my ($line) = grep /^$poolName /, @lines;
+        $stratisPool = substr $line, $uuidIndex - 32, 36;
+    }
+
     # Don't emit tmpfs entry for /tmp, because it most likely comes from the
     # boot.tmp.useTmpfs option in configuration.nix (managed declaratively).
     next if ($mountPoint eq "/tmp" && $fsType eq "tmpfs");
@@ -474,7 +485,7 @@ EOF
     # Emit the filesystem.
     $fileSystems .= <<EOF;
   fileSystems.\"$mountPoint\" =
-    { device = \"${\(findStableDevPath $device)}\";
+    { device = \"$stableDevPath\";
       fsType = \"$fsType\";
 EOF
 
@@ -484,6 +495,12 @@ EOF
 EOF
     }
 
+    if ($stratisPool) {
+        $fileSystems .= <<EOF;
+      stratis.poolUuid = "$stratisPool";
+EOF
+    }
+
     $fileSystems .= <<EOF;
     };