patate: update to nixos-23.11
[julm/julm-nix.git] / nixos / profiles / zfs.nix
index 195f6f1de863c613d530752410076c7de65e2982..87e7abfc06cfe839bbeac4356ab63736e259344f 100644 (file)
 
   boot.supportedFilesystems = [ "zfs" ];
   boot.initrd.supportedFilesystems = [ "zfs" ];
-  boot.zfs.requestEncryptionCredentials = lib.mkDefault [ hostName ];
 
   # Using ZFS together with hibernation (suspend to disk)
   # may cause filesystem corruption.
   # See https://github.com/openzfs/zfs/issues/260
   boot.kernelParams = [ "nohibernate" ];
 
-  # Ensure extra safeguards are active that zfs uses to protect zfs pools.
+  # Stable enough, clearer, and faster than the default /dev/disk/by-id
+  boot.zfs.devNodes = "/dev/disk/by-partlabel";
+  # Not useful so far.
+  # See also https://github.com/NixOS/nixpkgs/issues/62644#issuecomment-1479523469
   boot.zfs.forceImportAll = false;
-  boot.zfs.forceImportRoot = false;
+  # More resilient for remote hosts,
+  # though it may call zpool clear.
+  boot.zfs.forceImportRoot = true;
+  boot.zfs.requestEncryptionCredentials = lib.mkDefault [ "${hostName}/root" ];
 
   boot.zfs.enableUnstable = false;
 
   services.zfs.trim.enable = true;
   services.zfs.trim.interval = "Sun *-*-01..07 00:15:00";
 
+  # Hide ZFS mountpoints from gio, hence nautilus or caja
+  systemd.services.zfs-mount.postStart = ''
+    /run/wrappers/bin/mount -t zfs | cut -f 1 -d ' ' |
+    xargs -n 1 -r -t /run/wrappers/bin/mount -o remount,x-gvfs-hide
+  '';
+
   environment.systemPackages = [
     pkgs.lzop # For remote syncoid
     pkgs.mbuffer # For remote syncoid