lib/disko: init
This commit is contained in:
parent
da6002b618
commit
826e5e8ef5
2 changed files with 59 additions and 1 deletions
|
@ -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
56
lib/disko.nix
Normal 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;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue