Create a script for prompting the device path
This commit is contained in:
parent
2d72556079
commit
42e9cd15d3
|
@ -44,6 +44,12 @@
|
||||||
else "/dev/${config.deviceName}";
|
else "/dev/${config.deviceName}";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
deviceScript = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "A command for loading the device path into the device variable";
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
|
|
||||||
partitions = mkOption {
|
partitions = mkOption {
|
||||||
type = types.attrsOf (types.nullOr partitionType);
|
type = types.attrsOf (types.nullOr partitionType);
|
||||||
description = "The partitions of the disk.";
|
description = "The partitions of the disk.";
|
||||||
|
@ -155,31 +161,32 @@
|
||||||
''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 {
|
||||||
|
deviceScript = if osDisk && config.devicePath == null then ''
|
||||||
|
${diskSelector}
|
||||||
|
''
|
||||||
|
else ''
|
||||||
|
local ${diskVarName}=${config.devicePath}
|
||||||
|
${if osDisk then ''
|
||||||
|
. ${./../../scripts/Common/Scripts/is-truthy.sh}
|
||||||
|
if [ ! -b ${diskVar} ]; then
|
||||||
|
function fallback() {
|
||||||
|
echo "Couldn't find the specified disk \"${diskVar}\"."
|
||||||
|
local answer
|
||||||
|
read -p "Do you want to install the OS on another disk? [y/n] " answer
|
||||||
|
if isTruthy "$answer"; then
|
||||||
|
${diskSelector}
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
fallback;
|
||||||
|
fi
|
||||||
|
'' else ""}
|
||||||
|
'';
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
function partition() {
|
function partition() {
|
||||||
${
|
${config.deviceScript}
|
||||||
if osDisk && config.devicePath == null then ''
|
|
||||||
${diskSelector}
|
|
||||||
''
|
|
||||||
else ''
|
|
||||||
local ${diskVarName}=${config.devicePath}
|
|
||||||
${if osDisk then ''
|
|
||||||
. ${./../../scripts/Common/Scripts/is-truthy.sh}
|
|
||||||
if [ ! -b ${diskVar} ]; then
|
|
||||||
function fallback() {
|
|
||||||
echo "Couldn't find the specified disk \"${diskVar}\"."
|
|
||||||
local answer
|
|
||||||
read -p "Do you want to install the OS on another disk? [y/n] " answer
|
|
||||||
if isTruthy "$answer"; then
|
|
||||||
${diskSelector}
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
fallback;
|
|
||||||
fi
|
|
||||||
'' else ""}
|
|
||||||
''}
|
|
||||||
|
|
||||||
${if (!config.wipe) then cleanup else ""}
|
${if (!config.wipe) then cleanup else ""}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue