Fix race condition in partition script
This commit is contained in:
parent
6d6b93fb64
commit
70964072b6
1 changed files with 9 additions and 4 deletions
|
@ -91,9 +91,14 @@ let
|
||||||
type);
|
type);
|
||||||
|
|
||||||
fdiskCommand = arguments: "sudo sfdisk ${arguments}";
|
fdiskCommand = arguments: "sudo sfdisk ${arguments}";
|
||||||
fdiskScript = script: append: "echo ${script} | ${fdiskCommand "${if append then "--append" else ""} ${diskVar}"}";
|
fdiskScript = script: args: append:
|
||||||
wipeScript = script: fdiskScript script false;
|
"echo ${script} | ${
|
||||||
appendScript = script: fdiskScript script true;
|
fdiskCommand "${builtins.concatStringsSep " " args} ${
|
||||||
|
if append then "--append" else ""
|
||||||
|
} ${diskVar}"
|
||||||
|
}";
|
||||||
|
wipeScript = script: fdiskScript script [] false;
|
||||||
|
appendScript = index: script: fdiskScript script ["-N" (builtins.toString index)] true;
|
||||||
|
|
||||||
cleanup = lib.strings.concatLines (builtins.map
|
cleanup = lib.strings.concatLines (builtins.map
|
||||||
(partition: "${fdiskCommand "--delete ${diskVar} ${toString partition.index}"} || true")
|
(partition: "${fdiskCommand "--delete ${diskVar} ${toString partition.index}"} || true")
|
||||||
|
@ -130,7 +135,7 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
create = lib.strings.concatLines [
|
create = lib.strings.concatLines [
|
||||||
(appendScript ''${toString index}: "$(${sizeOption})" type=${mkType type}'')
|
(appendScript index ''${toString index}: "$(${sizeOption})" type=${mkType type}'')
|
||||||
probeScript
|
probeScript
|
||||||
"sudo ${formatScripts.${format}}"
|
"sudo ${formatScripts.${format}}"
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue