Remove separate os disk declaration

This commit is contained in:
Manuel Thalmann 2024-12-07 16:11:19 +01:00
parent 03e42c5578
commit 127ac0688f
4 changed files with 25 additions and 38 deletions

View file

@ -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,19 +169,18 @@ 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
if fish ${./confirm.fish} "Do you want to choose a different \"${name}\" disk?"; then
${diskSelector}
else
exit 1
@ -194,8 +189,6 @@ let
fallback
fi
'' else
""}
'';
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

View file

@ -25,7 +25,7 @@
};
};
fileSystems.diskSetup.osDisk.partitions = {
fileSystems.diskSetup.disks.OS.partitions = {
# Keep Windows' boot partition
Boot.keepExisting = true;

View file

@ -5,8 +5,8 @@ in {
config = {
valhalla = {
fileSystems.diskSetup = {
osDisk = {
fileSystems.diskSetup.disks = {
OS = {
partitions = {
Boot = {
index = 1;

View file

@ -5,8 +5,8 @@ in {
config = {
valhalla = {
fileSystems.diskSetup = {
osDisk = {
fileSystems.diskSetup.disks = {
OS = {
partitions = {
Boot = {
index = 1;