modules: add disko partition module for common partition patterns

This commit is contained in:
xinyangli 2024-11-27 17:43:47 +08:00
parent 0f4a315658
commit 3dc3775a6c
Signed by: xin
SSH key fingerprint: SHA256:UU5pRTl7NiLFJbWJZa+snLylZSXIz5rgHmwjzv8v4oE
5 changed files with 92 additions and 0 deletions

View file

@ -0,0 +1,46 @@
{
size = "100%";
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # Override existing partition
# Subvolumes must set a mountpoint in order to be mounted,
# unless their parent is mounted
subvolumes = {
# Subvolume name is different from mountpoint
"/rootfs" = {
mountpoint = "/";
};
# Subvolume name is the same as the mountpoint
"/home" = {
mountOptions = [ "compress=zstd" ];
mountpoint = "/home";
};
# Parent is not mounted so the mountpoint must be set
"/nix" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/nix";
};
"/persistent" = {
mountOptions = [
"compress=zstd"
"noatime"
# Lots of dbs in /var/lib, let's disable cow
"nodatacow"
];
mountpoint = "/var/lib";
};
# Subvolume for the swapfile
"/swap" = {
mountpoint = "/.swapvol";
swap = {
swapfile.size = "2G";
};
};
};
mountpoint = "/partition-root";
};
}

View file

@ -0,0 +1,15 @@
{ lib, ... }:
{
options = {
diskPartitions = lib.mkOption {
type = lib.types.attrs;
default = { };
};
};
config = {
diskPartitions = {
btrfs = import ./btrfs.nix;
grubMbr = import ./grub-mbr.nix;
};
};
}

View file

@ -0,0 +1,4 @@
{
size = "1M";
type = "EF02"; # for grub MBR
}