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