Remove separate os disk declaration
This commit is contained in:
parent
ce13e03ef1
commit
7b3b7fcdbc
4 changed files with 25 additions and 38 deletions
|
@ -12,7 +12,7 @@ let
|
|||
"udevadm trigger"
|
||||
];
|
||||
|
||||
mkDiskType = osDisk: types.submodule (
|
||||
mkDiskType = types.submodule (
|
||||
{ config, name, ... }: {
|
||||
options = {
|
||||
id = mkOption {
|
||||
|
@ -30,18 +30,14 @@ let
|
|||
deviceName = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The name of the device.";
|
||||
default = if osDisk then null else name;
|
||||
default = name;
|
||||
};
|
||||
|
||||
devicePath = mkOption {
|
||||
type =
|
||||
if osDisk then
|
||||
types.nullOr types.str
|
||||
else
|
||||
types.str;
|
||||
type = types.nullOr types.str;
|
||||
description = "The path to the device.";
|
||||
default =
|
||||
if osDisk && config.deviceName == null then
|
||||
if config.deviceName == null then
|
||||
null
|
||||
else
|
||||
"/dev/${config.deviceName}";
|
||||
|
@ -78,7 +74,7 @@ let
|
|||
|
||||
diskSelector = ''
|
||||
result="$(mktemp)"
|
||||
fish ${./choose-disk.fish} "$result" "Which disk do you wish to install the OS on?" ${./select.fish}
|
||||
fish ${./choose-disk.fish} "$result" "Please specify the \"${name}\" disk:" ${./select.fish}
|
||||
${diskVarName}="$(cat "$result")"
|
||||
'';
|
||||
|
||||
|
@ -173,29 +169,26 @@ let
|
|||
partitions);
|
||||
in
|
||||
{
|
||||
id = if osDisk then "os" else "disk-${name}";
|
||||
id = "disk-${name}";
|
||||
deviceVariable = diskVar;
|
||||
|
||||
deviceScript =
|
||||
if osDisk && config.devicePath == null then ''
|
||||
if config.devicePath == null then ''
|
||||
${diskSelector}
|
||||
'' else ''
|
||||
${diskVarName}=${config.devicePath}
|
||||
${if osDisk then ''
|
||||
if [ ! -b ${diskVar} ]; then
|
||||
function fallback() {
|
||||
echo "Couldn't find the specified disk \"${diskVar}\"."
|
||||
if fish ${./confirm.fish} "Do you want to install the OS on another disk?"; then
|
||||
${diskSelector}
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
if [ ! -b ${diskVar} ]; then
|
||||
function fallback() {
|
||||
echo "Couldn't find the specified disk \"${diskVar}\"."
|
||||
if fish ${./confirm.fish} "Do you want to choose a different \"${name}\" disk?"; then
|
||||
${diskSelector}
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
fallback
|
||||
fi
|
||||
'' else
|
||||
""}
|
||||
fallback
|
||||
fi
|
||||
'';
|
||||
|
||||
script = lib.mkDefault ''
|
||||
|
@ -299,13 +292,8 @@ in
|
|||
};
|
||||
|
||||
diskSetup = {
|
||||
osDisk = mkOption {
|
||||
type = mkDiskType true;
|
||||
description = "The partition layout of the OS disk.";
|
||||
};
|
||||
|
||||
disks = mkOption {
|
||||
type = types.attrsOf (mkDiskType false);
|
||||
type = types.attrsOf (mkDiskType);
|
||||
description = "The additional disks to format.";
|
||||
default = { };
|
||||
};
|
||||
|
@ -326,10 +314,9 @@ in
|
|||
let
|
||||
cfg = config.valhalla.fileSystems;
|
||||
inherit (cfg) rootDir;
|
||||
inherit (cfg.diskSetup) osDisk;
|
||||
inherit (lib.strings) normalizePath;
|
||||
partPath = part: "/dev/disk/by-label/${part.label}";
|
||||
disks = ([ osDisk ] ++ (builtins.attrValues cfg.diskSetup.disks));
|
||||
disks = ((builtins.attrValues cfg.diskSetup.disks));
|
||||
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
|
||||
|
||||
mountScript = lib.strings.concatLines (builtins.concatMap
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
fileSystems.diskSetup.osDisk.partitions = {
|
||||
fileSystems.diskSetup.disks.OS.partitions = {
|
||||
# Keep Windows' boot partition
|
||||
Boot.keepExisting = true;
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ in {
|
|||
|
||||
config = {
|
||||
valhalla = {
|
||||
fileSystems.diskSetup = {
|
||||
osDisk = {
|
||||
fileSystems.diskSetup.disks = {
|
||||
OS = {
|
||||
partitions = {
|
||||
Boot = {
|
||||
index = 1;
|
||||
|
|
|
@ -5,8 +5,8 @@ in {
|
|||
|
||||
config = {
|
||||
valhalla = {
|
||||
fileSystems.diskSetup = {
|
||||
osDisk = {
|
||||
fileSystems.diskSetup.disks = {
|
||||
OS = {
|
||||
partitions = {
|
||||
Boot = {
|
||||
index = 1;
|
||||
|
|
Loading…
Reference in a new issue