lib/disko: add cleaner functions and handle inner partitions
This commit is contained in:
parent
c64238a3da
commit
870894841f
1 changed files with 14 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
{ lib }:
|
{ lib }:
|
||||||
let
|
let
|
||||||
inherit (builtins) mapAttrs removeAttrs;
|
inherit (builtins) mapAttrs removeAttrs;
|
||||||
inherit (lib) optionals;
|
inherit (lib) optionals flip genAttrs;
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
# Constants
|
# Constants
|
||||||
|
@ -40,13 +40,14 @@ rec {
|
||||||
|
|
||||||
# btrfs
|
# btrfs
|
||||||
|
|
||||||
mkBtrfsPart = size: mountpoint: content: {
|
mkBtrfsPart' = base: mountpoint: content': {
|
||||||
inherit size;
|
|
||||||
content = {
|
content = {
|
||||||
inherit mountpoint;
|
inherit mountpoint;
|
||||||
type = "btrfs";
|
type = "btrfs";
|
||||||
} // content;
|
} // content';
|
||||||
};
|
} // base;
|
||||||
|
mkBtrfsPart = size: mkBtrfsPart' { inherit size; };
|
||||||
|
mkBtrfsPartEndAt = end: mkBtrfsPart' { inherit end; };
|
||||||
|
|
||||||
mkBtrfsSubvols' = mountOptions: mapAttrs (n: v: {
|
mkBtrfsSubvols' = mountOptions: mapAttrs (n: v: {
|
||||||
mountpoint = n;
|
mountpoint = n;
|
||||||
|
@ -56,13 +57,14 @@ rec {
|
||||||
|
|
||||||
# ZFS
|
# ZFS
|
||||||
|
|
||||||
mkZPart = size: pool: {
|
mkZPart' = base: content: pool: {
|
||||||
inherit size;
|
|
||||||
content = {
|
content = {
|
||||||
type = "zfs";
|
type = "zfs";
|
||||||
inherit pool;
|
inherit pool;
|
||||||
};
|
} // content;
|
||||||
};
|
} // base;
|
||||||
|
mkZPart = size: mkZPart' { inherit size; } { };
|
||||||
|
mkZPartEndAt = end: mkZPart' { inherit end; } { };
|
||||||
|
|
||||||
mkZDisk = id: pool: mkDisk id {
|
mkZDisk = id: pool: mkDisk id {
|
||||||
partitions = {
|
partitions = {
|
||||||
|
@ -82,6 +84,7 @@ rec {
|
||||||
inherit mountOptions;
|
inherit mountOptions;
|
||||||
} // options;
|
} // options;
|
||||||
mkZPool = mkZPool' defaultMountOptions;
|
mkZPool = mkZPool' defaultMountOptions;
|
||||||
|
mkZPools = mapAttrs mkZPool;
|
||||||
|
|
||||||
mkZfs' = mountOptions: mountpoint: options: {
|
mkZfs' = mountOptions: mountpoint: options: {
|
||||||
type = "zfs_fs";
|
type = "zfs_fs";
|
||||||
|
@ -94,4 +97,6 @@ rec {
|
||||||
type = "zfs_volume";
|
type = "zfs_volume";
|
||||||
inherit size content;
|
inherit size content;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
markNeededForBoot = flip genAttrs (_: { neededForBoot = true; });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue