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