| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- { lib, ... }:
- let
- mainDiskId = "nvme-KINGSTON_SNV3S1000G_50026B7383CC0908";
- storageDisks = [
- "ata-ST8000VN002-2ZM188_WPV023WG"
- "ata-ST8000VN002-2ZM188_WPV07RMA"
- "ata-ST8000VN002-2ZM188_WPV020CG"
- ];
- # Subvolumes with regular CoW behavior
- regular = [ "root" "home" "nix" "persist" "logs" "services" ];
- # Subvolumes that need noDataCow for performance
- noDataCow = [ "databases" "cache" "containers" ];
- # Function to create subvolume configuration
- mkSubvolume = name: {
- name = "@${name}";
- value = {
- mountpoint = if name == "root" then "/" else "/${name}";
- mountOptions = [
- "compress=zstd:1"
- "noatime"
- ] ++ lib.optional (lib.elem name noDataCow) "nodatacow";
- };
- };
- in
- {
- disko.devices = {
- disk = {
- # Root system drive (1TB NVMe)
- main = {
- type = "disk";
- device = "/dev/disk/by-id/${mainDiskId}";
- content = {
- type = "gpt";
- partitions = {
- # EFI boot partition
- efi = {
- size = "1G";
- type = "EF00";
- content = {
- type = "filesystem";
- format = "vfat";
- mountpoint = "/boot";
- };
- };
- # Main Btrfs partition
- root = {
- end = "-0";
- content = {
- type = "btrfs";
- extraArgs = [ "-f" ];
- subvolumes = {
- # Blank root template for ephemeral setup
- "@root-blank" = { };
- } // lib.listToAttrs (map mkSubvolume (regular ++ noDataCow));
- };
- };
- };
- };
- };
- } // lib.listToAttrs (lib.imap1
- (i: diskId: {
- name = "storage${toString i}";
- value = {
- type = "disk";
- device = "/dev/disk/by-id/${diskId}";
- content = {
- type = "gpt";
- partitions = {
- primary = {
- size = "100%";
- content = {
- type = "filesystem";
- format = "xfs";
- mountpoint = "/mnt/disk${toString i}";
- mountOptions = [ "defaults" "noatime" ];
- };
- };
- };
- };
- };
- })
- storageDisks);
- };
- }
|