summary refs log tree commit diff
diff options
context:
space:
mode:
authorWill Fancher <elvishjerricco@gmail.com>2023-08-02 14:56:25 -0400
committerWill Fancher <elvishjerricco@gmail.com>2023-10-06 04:25:25 -0400
commit524714f7eaa37f599c978bc7cb6085934ca2c6b5 (patch)
treeb492202214329c2ac30e044c800521506a8f01dd
parentfdd898f8f79e8d2f99ed2ab6b3751811ef683242 (diff)
downloadnixpkgs-524714f7eaa37f599c978bc7cb6085934ca2c6b5.tar
nixpkgs-524714f7eaa37f599c978bc7cb6085934ca2c6b5.tar.gz
nixpkgs-524714f7eaa37f599c978bc7cb6085934ca2c6b5.tar.bz2
nixpkgs-524714f7eaa37f599c978bc7cb6085934ca2c6b5.tar.lz
nixpkgs-524714f7eaa37f599c978bc7cb6085934ca2c6b5.tar.xz
nixpkgs-524714f7eaa37f599c978bc7cb6085934ca2c6b5.tar.zst
nixpkgs-524714f7eaa37f599c978bc7cb6085934ca2c6b5.zip
systemd 254: ZFS /usr fix with systemd-stage-1
-rw-r--r--nixos/modules/tasks/filesystems/zfs.nix7
-rw-r--r--nixos/tests/installer.nix3
2 files changed, 9 insertions, 1 deletions
diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix
index 5cf863c87f2..9126d59f9f0 100644
--- a/nixos/modules/tasks/filesystems/zfs.nix
+++ b/nixos/modules/tasks/filesystems/zfs.nix
@@ -90,12 +90,17 @@ let
 
   getPoolMounts = prefix: pool:
     let
+      poolFSes = getPoolFilesystems pool;
+
       # Remove the "/" suffix because even though most mountpoints
       # won't have it, the "/" mountpoint will, and we can't have the
       # trailing slash in "/sysroot/" in stage 1.
       mountPoint = fs: escapeSystemdPath (prefix + (lib.removeSuffix "/" fs.mountPoint));
+
+      hasUsr = lib.any (fs: fs.mountPoint == "/usr") poolFSes;
     in
-      map (x: "${mountPoint x}.mount") (getPoolFilesystems pool);
+      map (x: "${mountPoint x}.mount") poolFSes
+      ++ lib.optional hasUsr "sysusr-usr.mount";
 
   getKeyLocations = pool: if isBool cfgZfs.requestEncryptionCredentials then {
     hasKeys = cfgZfs.requestEncryptionCredentials;
diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix
index 56ba85b76e6..963e670ee2d 100644
--- a/nixos/tests/installer.nix
+++ b/nixos/tests/installer.nix
@@ -690,6 +690,9 @@ in {
           "zpool create rpool /dev/vda2",
           "zfs create -o mountpoint=legacy rpool/root",
           "mount -t zfs rpool/root /mnt",
+          "zfs create -o mountpoint=legacy rpool/root/usr",
+          "mkdir /mnt/usr",
+          "mount -t zfs rpool/root/usr /mnt/usr",
           "udevadm settle",
       )
     '';