disko.nix 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. { inputs, lib, ... }:
  2. let
  3. storageDisks = [
  4. "ata-ST8000VN002-2ZM188_WPV023WG"
  5. "ata-ST8000VN002-2ZM188_WPV07RMA"
  6. "ata-ST8000VN002-2ZM188_WPV020CG"
  7. ];
  8. in
  9. {
  10. imports = [
  11. inputs.disko.nixosModules.disko
  12. ];
  13. disko.devices = {
  14. disk = {
  15. # Root system drive (1TB NVMe)
  16. main = {
  17. type = "disk";
  18. device = "/dev/disk/by-id/nvme-KINGSTON_SNV3S1000G_50026B7383CC0908";
  19. content = {
  20. type = "gpt";
  21. partitions = {
  22. # EFI boot partition
  23. efi = {
  24. size = "1G";
  25. type = "EF00";
  26. content = {
  27. type = "filesystem";
  28. format = "vfat";
  29. mountpoint = "/boot";
  30. };
  31. };
  32. # Main Btrfs partition
  33. root = {
  34. end = "-0";
  35. content = {
  36. type = "btrfs";
  37. extraArgs = [ "-f" ];
  38. subvolumes = {
  39. "@root" = {
  40. mountpoint = "/";
  41. mountOptions = [ "compress=zstd1" "noatime" ];
  42. };
  43. "@nix" = {
  44. mountpoint = "/nix";
  45. mountOptions = [ "compress=zstd1" "noatime" ];
  46. };
  47. "@persist" = {
  48. mountpoint = "/persist";
  49. mountOptions = [ "compress=zstd1" "noatime" ];
  50. };
  51. "@services" = {
  52. mountpoint = "/var/lib";
  53. mountOptions = [ "compress=zstd1" "noatime" "space_cache=v2" ];
  54. };
  55. "@logs" = {
  56. mountpoint = "/var/log";
  57. mountOptions = [ "compress=zstd1" "noatime" ];
  58. };
  59. };
  60. };
  61. };
  62. };
  63. };
  64. };
  65. } // lib.listToAttrs (lib.imap1
  66. (i: diskId: {
  67. name = "storage${toString i}";
  68. value = {
  69. type = "disk";
  70. device = "/dev/disk/by-id/${diskId}";
  71. content = {
  72. type = "gpt";
  73. partitions = {
  74. primary = {
  75. size = "100%";
  76. content = {
  77. type = "filesystem";
  78. format = "xfs";
  79. mountpoint = "/mnt/disk${toString i}";
  80. mountOptions = [ "defaults" "noatime" ];
  81. };
  82. };
  83. };
  84. };
  85. };
  86. })
  87. storageDisks);
  88. };
  89. }