forked from jan-leila/nix-config
		
	made boot disko partition configurable
This commit is contained in:
		
							parent
							
								
									a68f81cf3b
								
							
						
					
					
						commit
						99ea355472
					
				
					 2 changed files with 45 additions and 56 deletions
				
			
		|  | @ -40,6 +40,8 @@ | ||||||
|         tokenFile = config.sops.secrets."services/zfs_smtp_token".path; |         tokenFile = config.sops.secrets."services/zfs_smtp_token".path; | ||||||
|       }; |       }; | ||||||
|       pool = { |       pool = { | ||||||
|  |         # We are having to boot off of the nvm cache drive because I cant figure out how to boot via the HBA | ||||||
|  |         bootDrives = ["nvme-Samsung_SSD_990_PRO_4TB_S7KGNU0X907881F"]; | ||||||
|         vdevs = [ |         vdevs = [ | ||||||
|           [ |           [ | ||||||
|             "ata-ST18000NE000-3G6101_ZVTCXVEB" |             "ata-ST18000NE000-3G6101_ZVTCXVEB" | ||||||
|  |  | ||||||
|  | @ -50,16 +50,25 @@ in { | ||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
|     pool = { |     pool = { | ||||||
|       vdevs = lib.mkOption { |       # list of drives in pool that will have a boot partition put onto them | ||||||
|         type = lib.types.listOf (lib.types.listOf lib.types.str); |       bootDrives = lib.mkOption { | ||||||
|         description = "list of disks that are going to be in"; |         type = lib.types.listOf lib.types.str; | ||||||
|         default = [config.host.storage.pool.drives]; |         description = "list of disks that are going to have a boot partition installed on them"; | ||||||
|  |         default = lib.lists.flatten config.host.storage.pool.vdevs; | ||||||
|       }; |       }; | ||||||
|  |       # shorthand for vdevs if you only have 1 vdev | ||||||
|       drives = lib.mkOption { |       drives = lib.mkOption { | ||||||
|         type = lib.types.listOf lib.types.str; |         type = lib.types.listOf lib.types.str; | ||||||
|         description = "list of drives that are going to be in the vdev"; |         description = "list of drives that are going to be in the vdev"; | ||||||
|         default = []; |         default = []; | ||||||
|       }; |       }; | ||||||
|  |       # list of all drives in each vdev | ||||||
|  |       vdevs = lib.mkOption { | ||||||
|  |         type = lib.types.listOf (lib.types.listOf lib.types.str); | ||||||
|  |         description = "list of disks that are going to be in"; | ||||||
|  |         default = [config.host.storage.pool.drives]; | ||||||
|  |       }; | ||||||
|  |       # list of cache drives for pool | ||||||
|       cache = lib.mkOption { |       cache = lib.mkOption { | ||||||
|         type = lib.types.listOf lib.types.str; |         type = lib.types.listOf lib.types.str; | ||||||
|         description = "list of drives that are going to be used as cache"; |         description = "list of drives that are going to be used as cache"; | ||||||
|  | @ -156,59 +165,37 @@ in { | ||||||
|     disko.devices = { |     disko.devices = { | ||||||
|       disk = ( |       disk = ( | ||||||
|         builtins.listToAttrs ( |         builtins.listToAttrs ( | ||||||
|  |           builtins.map | ||||||
|  |           (drive: | ||||||
|  |             lib.attrsets.nameValuePair (drive.name) { | ||||||
|  |               type = "disk"; | ||||||
|  |               device = "/dev/disk/by-id/${drive.value}"; | ||||||
|  |               content = { | ||||||
|  |                 type = "gpt"; | ||||||
|  |                 partitions = { | ||||||
|  |                   ESP = lib.mkIf (builtins.elem drive.value config.host.storage.pool.bootDrives) { | ||||||
|  |                     # The 2GB here for the boot partition might be a bit overkill we probably only need like 1/4th of that but storage is cheap | ||||||
|  |                     size = "2G"; | ||||||
|  |                     type = "EF00"; | ||||||
|  |                     content = { | ||||||
|  |                       type = "filesystem"; | ||||||
|  |                       format = "vfat"; | ||||||
|  |                       mountpoint = "/boot"; | ||||||
|  |                       mountOptions = ["umask=0077"]; | ||||||
|  |                     }; | ||||||
|  |                   }; | ||||||
|  |                   zfs = { | ||||||
|  |                     size = "100%"; | ||||||
|  |                     content = { | ||||||
|  |                       type = "zfs"; | ||||||
|  |                       pool = "rpool"; | ||||||
|  |                     }; | ||||||
|  |                   }; | ||||||
|  |                 }; | ||||||
|  |               }; | ||||||
|  |             }) | ||||||
|           ( |           ( | ||||||
|             builtins.map |             (lib.lists.flatten vdevs) ++ cache | ||||||
|             (drive: |  | ||||||
|               lib.attrsets.nameValuePair (drive.name) { |  | ||||||
|                 type = "disk"; |  | ||||||
|                 device = "/dev/disk/by-id/${drive.value}"; |  | ||||||
|                 content = { |  | ||||||
|                   type = "gpt"; |  | ||||||
|                   partitions = { |  | ||||||
|                     zfs = { |  | ||||||
|                       size = "100%"; |  | ||||||
|                       content = { |  | ||||||
|                         type = "zfs"; |  | ||||||
|                         pool = "rpool"; |  | ||||||
|                       }; |  | ||||||
|                     }; |  | ||||||
|                   }; |  | ||||||
|                 }; |  | ||||||
|               }) |  | ||||||
|             (lib.lists.flatten vdevs) |  | ||||||
|           ) |  | ||||||
|           ++ ( |  | ||||||
|             builtins.map |  | ||||||
|             (drive: |  | ||||||
|               lib.attrsets.nameValuePair (drive.name) { |  | ||||||
|                 type = "disk"; |  | ||||||
|                 device = "/dev/disk/by-id/${drive.value}"; |  | ||||||
|                 content = { |  | ||||||
|                   type = "gpt"; |  | ||||||
|                   partitions = { |  | ||||||
|                     # We are having to boot off of the nvm cache drive because I cant figure out how to boot via the HBA |  | ||||||
|                     ESP = { |  | ||||||
|                       # 2G here because its not much relative to how much storage we have for caching |  | ||||||
|                       size = "2G"; |  | ||||||
|                       type = "EF00"; |  | ||||||
|                       content = { |  | ||||||
|                         type = "filesystem"; |  | ||||||
|                         format = "vfat"; |  | ||||||
|                         mountpoint = "/boot"; |  | ||||||
|                         mountOptions = ["umask=0077"]; |  | ||||||
|                       }; |  | ||||||
|                     }; |  | ||||||
|                     zfs = { |  | ||||||
|                       size = "100%"; |  | ||||||
|                       content = { |  | ||||||
|                         type = "zfs"; |  | ||||||
|                         pool = "rpool"; |  | ||||||
|                       }; |  | ||||||
|                     }; |  | ||||||
|                   }; |  | ||||||
|                 }; |  | ||||||
|               }) |  | ||||||
|             cache |  | ||||||
|           ) |           ) | ||||||
|         ) |         ) | ||||||
|       ); |       ); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue