Allow partitions without format

This commit is contained in:
Manuel Thalmann 2024-12-07 18:45:44 +01:00
parent f6fbf7df3d
commit 10aa988418

View file

@ -145,11 +145,12 @@ let
${fs.fat32} = label: "fatlabel ${partVar} ${label}"; ${fs.fat32} = label: "fatlabel ${partVar} ${label}";
}; };
create = lib.strings.concatLines [ create = lib.strings.concatLines ([
(appendScript index ''${toString index}: "$(${sizeOption})" type=${mkType type}'') (appendScript index ''${toString index}: "$(${sizeOption})" type=${mkType type}'')
probeScript probeScript
] ++ (lib.optionals (format != null) [
"sudo ${formatScripts.${format}}" "sudo ${formatScripts.${format}}"
]; ]));
fallback = '' fallback = ''
if ! { ls "${partVar}" 2>&1; } > /dev/null if ! { ls "${partVar}" 2>&1; } > /dev/null
@ -162,8 +163,9 @@ let
''local diskPath="$(find -L /dev/disk/by-diskseq -samefile ${deviceVar})"'' ''local diskPath="$(find -L /dev/disk/by-diskseq -samefile ${deviceVar})"''
''local ${partVarName}="$diskPath-part${toString index}"'' ''local ${partVarName}="$diskPath-part${toString index}"''
(if keepExisting then fallback else create) (if keepExisting then fallback else create)
] ++ (lib.optionals (format != null) [
"sudo ${labelScripts.${format} label}" "sudo ${labelScripts.${format} label}"
] ])
) )
partitions)); partitions));
@ -242,13 +244,13 @@ let
}; };
format = mkOption { format = mkOption {
type = types.enum (builtins.attrValues fs); type = types.nullOr (types.enum (builtins.attrValues fs));
description = "The file system format of the partition."; description = "The file system format of the partition.";
default = default =
if (isSwap config) then if (isSwap config) then
fs.swap fs.swap
else else
throw ("Partition format not specified."); null;
}; };
size = mkOption { size = mkOption {