lib/disko: init

This commit is contained in:
Infinidoge 2024-05-05 04:29:10 -04:00
parent da6002b618
commit 826e5e8ef5
Signed by: Infinidoge
SSH key fingerprint: SHA256:oAMyvotlNFraMmZmr+p6AxnNfW/GioTs1pOn3V4tQ7A
2 changed files with 59 additions and 1 deletions

View file

@ -65,4 +65,6 @@ rec {
import ./hosts.nix { inherit lib; } import ./hosts.nix { inherit lib; }
) // ( ) // (
import ./options.nix { inherit lib; } import ./options.nix { inherit lib; }
)) )) // {
disko = import ./disko.nix { inherit lib; };
}

56
lib/disko.nix Normal file
View file

@ -0,0 +1,56 @@
{ lib }:
rec {
# Constants
defaultMountOptions = [
"defaults"
"noatime"
];
# Common
mkDisk = id: content: {
type = "disk";
device = "/dev/disk/by-id/${id}";
content = {
type = "gpt";
} // content;
};
# ZFS
mkZDisk = id: pool: mkDisk id {
partitions = {
zfs = {
size = "100%";
content = {
type = "zfs";
inherit pool;
};
};
};
};
mkZPool' = mountOptions: name: options: {
type = "zpool";
mode = "raidz";
mountpoint = "/media/${name}";
rootFsOptions = {
compression = "zstd";
atime = "off";
};
inherit mountOptions;
} // options;
mkZPool = mkZPool' defaultMountOptions;
mkZfs' = mountOptions: mountpoint: options: {
type = "zfs_fs";
inherit mountpoint mountOptions options;
};
mkZfs = mkZfs' defaultMountOptions;
mkZvol = size: content: {
type = "zfs_volume";
inherit size content;
};
}