lib/disko: add more filesystem functions
This commit is contained in:
parent
85cc227f47
commit
1fa24aefcd
1 changed files with 46 additions and 7 deletions
|
@ -1,4 +1,8 @@
|
||||||
{ lib }:
|
{ lib }:
|
||||||
|
let
|
||||||
|
inherit (builtins) mapAttrs removeAttrs;
|
||||||
|
inherit (lib) optionals;
|
||||||
|
in
|
||||||
rec {
|
rec {
|
||||||
# Constants
|
# Constants
|
||||||
|
|
||||||
|
@ -17,17 +21,52 @@ rec {
|
||||||
} // content;
|
} // content;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mkESP' = mountOptions: size: mountpoint: {
|
||||||
|
inherit size;
|
||||||
|
type = "EF00";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
inherit mountpoint mountOptions;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
mkESP = mkESP' defaultMountOptions;
|
||||||
|
|
||||||
|
mkTmpfs' = mountOptions: size: mode: {
|
||||||
|
fsType = "tmpfs";
|
||||||
|
mountOptions = mountOptions ++ [ "size=${size}" "mode=${mode}" ];
|
||||||
|
};
|
||||||
|
mkTmpfs = size: mkTmpfs' defaultMountOptions size "755";
|
||||||
|
|
||||||
|
# btrfs
|
||||||
|
|
||||||
|
mkBtrfsPart = size: mountpoint: content: {
|
||||||
|
inherit size;
|
||||||
|
content = {
|
||||||
|
inherit mountpoint;
|
||||||
|
type = "btrfs";
|
||||||
|
} // content;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkBtrfsSubvols' = mountOptions: mapAttrs (n: v: {
|
||||||
|
mountpoint = n;
|
||||||
|
mountOptions = mountOptions ++ (optionals (v ? mountOptions) v.mountOptions);
|
||||||
|
} // (removeAttrs v ["mountOptions"]));
|
||||||
|
mkBtrfsSubvols = mkBtrfsSubvols' defaultMountOptions;
|
||||||
|
|
||||||
# ZFS
|
# ZFS
|
||||||
|
|
||||||
mkZDisk = id: pool: mkDisk id {
|
mkZPart = size: pool: {
|
||||||
partitions = {
|
inherit size;
|
||||||
zfs = {
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
content = {
|
||||||
type = "zfs";
|
type = "zfs";
|
||||||
inherit pool;
|
inherit pool;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mkZDisk = id: pool: mkDisk id {
|
||||||
|
partitions = {
|
||||||
|
zfs = mkZPart "100%" pool;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue