Add support for MBR partition IDs
This commit is contained in:
parent
46820f376f
commit
1f24914de4
1 changed files with 9 additions and 3 deletions
|
@ -68,6 +68,12 @@
|
|||
(_: if ((!isSwap _) && (_.size == null)) then 1 else 0)
|
||||
];
|
||||
|
||||
mkType = type:
|
||||
lib.strings.escapeShellArg (
|
||||
if builtins.isInt type
|
||||
then "${lib.trivial.toHexString type}"
|
||||
else type);
|
||||
|
||||
fdiskCommand = arguments: "sudo sfdisk ${arguments}";
|
||||
fdiskScript = script: append: "echo ${script} | ${fdiskCommand "${if append then "--append" else ""} ${diskVar}"}";
|
||||
wipeScript = script: fdiskScript script false;
|
||||
|
@ -116,7 +122,7 @@
|
|||
};
|
||||
|
||||
create = lib.strings.concatLines [
|
||||
(appendScript "${toString index}: \"$(${sizeOption})\" type=${lib.strings.escapeShellArg type}")
|
||||
(appendScript "${toString index}: \"$(${sizeOption})\" type=${mkType type}")
|
||||
];
|
||||
|
||||
fallback = ''
|
||||
|
@ -145,8 +151,8 @@
|
|||
fixType = lib.strings.concatLines (
|
||||
builtins.concatMap
|
||||
(partition: lib.optional
|
||||
partition.keepExisting
|
||||
''sudo sfdisk --part-type ${diskVar} ${toString partition.index} ${lib.strings.escapeShellArg partition.type}'')
|
||||
(partition.keepExisting && !(builtins.isNull partition.type))
|
||||
''sudo sfdisk --part-type ${diskVar} ${toString partition.index} ${mkType partition.type}'')
|
||||
partitions);
|
||||
in {
|
||||
script = ''
|
||||
|
|
Loading…
Reference in a new issue