disko test

This commit is contained in:
DashieTM 2025-02-28 18:30:31 +01:00
parent 547ea3e7bb
commit 62e462a0df
4 changed files with 92 additions and 80 deletions

View file

@ -3,35 +3,7 @@
config,
options,
...
}: let
driveModule = lib.types.submodule {
options = {
name = lib.mkOption {
type = lib.types.str;
description = ''
The path of the drive.
Note that a / is already added at the beginning.
'';
default = "";
example = "drive2";
};
drive = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
description = "The attrs of the drive";
default = {};
example = {
device = "/dev/disk/by-label/DRIVE2";
fsType = "ext4";
options = [
"noatime"
"nodiratime"
"discard"
];
};
};
};
};
in {
}: {
options.mods = {
drives = {
useSwap = {
@ -83,55 +55,84 @@ in {
config = (
lib.optionalAttrs (options ? fileSystems) {
fileSystems =
builtins.listToAttrs (
map (
{
name,
drive,
}: {
name = "/" + name;
value = drive;
}
)
config.mods.drives.extraDrives
)
// (lib.optionalAttrs config.mods.drives.defaultDrives.enable) {
"/" = {
device = "/dev/disk/by-label/ROOT";
fsType = "btrfs";
options = [
"noatime"
"nodiratime"
"discard"
];
};
"/boot" = {
device = "/dev/disk/by-label/BOOT";
fsType = "vfat";
options = [
"rw"
"fmask=0022"
"dmask=0022"
"noatime"
];
};
"/home" = {
device = "/dev/disk/by-label/HOME";
fsType = "btrfs";
options = [
"noatime"
"nodiratime"
"discard"
];
};
};
# TODO make this convert to choice of drives -> thanks to funny types this doesn't work...
swapDevices = lib.mkIf config.mods.drives.useSwap.enable [
{device = "/dev/disk/by-label/SWAP";}
];
disko.devices = {
disk =
{
main = (lib.optionalAttrs config.mods.drives.defaultDrives.enable) {
device = "${config.conf.defaultDiskId}";
type = "disk";
content = {
type = "gpt";
partitions = {
root = {
start = "33G";
end = "30%";
content = {
type = "filesystem";
format = "btrfs";
mountpoint = "/";
mountOptions = [
"noatime"
"nodiratime"
"discard"
];
};
};
plainSwap = {
start = "1G";
end = "33G";
content = {
type = "swap";
discardPolicy = "both";
resumeDevice = true;
};
};
boot = {
start = "0G";
end = "1G";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"rw"
"fmask=0022"
"dmask=0022"
"noatime"
];
};
};
home = {
start = "30%";
end = "100%";
content = {
type = "filesystem";
format = "btrfs";
mountpoint = "/home";
mountOptions = [
"noatime"
"nodiratime"
"discard"
];
};
};
};
};
};
}
// builtins.listToAttrs (
map (
{
name,
drive,
}: {
name = "/" + name;
value = drive;
}
)
config.mods.drives.extraDrives
);
};
}
);
}