Store disk paths in an associative array
This commit is contained in:
parent
42e9cd15d3
commit
d56088ebea
|
@ -2,7 +2,6 @@
|
|||
let
|
||||
inherit (lib) types mkOption;
|
||||
diskVarName = "myDisk";
|
||||
diskVar = ''''${${diskVarName}}'';
|
||||
isSwap = partition: builtins.elem partition.type ["swap" 19];
|
||||
|
||||
fs = {
|
||||
|
@ -20,6 +19,12 @@
|
|||
mkDiskType = osDisk: types.submodule (
|
||||
{ config, name, ... }: {
|
||||
options = {
|
||||
id = mkOption {
|
||||
type = types.str;
|
||||
description = "The internal identifier of the disk.";
|
||||
internal = true;
|
||||
};
|
||||
|
||||
wipe = mkOption {
|
||||
type = types.bool;
|
||||
description = "A value indicating whether the disk should be wiped.";
|
||||
|
@ -65,6 +70,8 @@
|
|||
|
||||
config =
|
||||
let
|
||||
diskVar = ''''${${diskVarName}[${config.id}]}'';
|
||||
|
||||
partitions = builtins.foldl'
|
||||
(list: predicate: lib.lists.sortOn predicate list)
|
||||
(builtins.filter (_: _ != null) (builtins.attrValues config.partitions))
|
||||
|
@ -161,6 +168,8 @@
|
|||
''sudo sfdisk --part-type ${diskVar} ${toString partition.index} ${mkType partition.type}'')
|
||||
partitions);
|
||||
in {
|
||||
id = if osDisk then "os" else "disk-${name}";
|
||||
|
||||
deviceScript = if osDisk && config.devicePath == null then ''
|
||||
${diskSelector}
|
||||
''
|
||||
|
|
Loading…
Reference in a new issue