diff --git a/lib/modules/partition.nix b/lib/modules/partition.nix index 6ca586ac..3ddc33f4 100644 --- a/lib/modules/partition.nix +++ b/lib/modules/partition.nix @@ -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} ''