Restructure partition config

This commit is contained in:
Manuel Thalmann 2024-12-07 12:24:10 +01:00
parent 7cf715f4d8
commit 03e42c5578
6 changed files with 53 additions and 22 deletions

View file

@ -0,0 +1,27 @@
{ lib, config, ... }:
let
inherit (lib) types mkOption;
in {
imports = [
./partition/disks.nix
];
options = {
valhalla = {
fileSystems = {
script = mkOption {
type = types.str;
description = "The script for preparing the system's mounts.";
};
};
};
};
config = {
valhalla = {
fileSystems = {
script = config.valhalla.fileSystems.diskSetup.script;
};
};
};
}

View file

@ -291,14 +291,15 @@ in
{
options = {
valhalla = {
partition = {
fileSystems = {
rootDir = mkOption {
type = types.str;
description = "The root of the installation directory to mount disks into.";
default = "/mnt";
};
os = mkOption {
diskSetup = {
osDisk = mkOption {
type = mkDiskType true;
description = "The partition layout of the OS disk.";
};
@ -316,17 +317,19 @@ in
};
};
};
};
config = {
valhalla = {
partition = {
fileSystems.diskSetup = {
script = lib.mkDefault (
let
cfg = config.valhalla.partition;
inherit (cfg) os rootDir;
cfg = config.valhalla.fileSystems;
inherit (cfg) rootDir;
inherit (cfg.diskSetup) osDisk;
inherit (lib.strings) normalizePath;
partPath = part: "/dev/disk/by-label/${part.label}";
disks = ([ os ] ++ (builtins.attrValues cfg.disks));
disks = ([ osDisk ] ++ (builtins.attrValues cfg.diskSetup.disks));
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
mountScript = lib.strings.concatLines (builtins.concatMap

View file

@ -2,6 +2,7 @@
let inherit (lib) mkOption types;
in {
imports = [
./fileSystems.nix
./hardware.nix
./i18n.nix
./os.nix

View file

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

View file

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

View file

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