mirror of
https://github.com/TECHNOFAB11/disko.git
synced 2025-12-12 08:00:05 +01:00
split disko type into multiple files
This commit is contained in:
parent
aa26c0ce0d
commit
48e4c06004
21 changed files with 1595 additions and 3 deletions
76
types/lvm_lv.nix
Normal file
76
types/lvm_lv.nix
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
{ config, options, lib, diskoLib, ... }:
|
||||
{
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = config._module.args.name;
|
||||
description = "Name of the logical volume";
|
||||
};
|
||||
type = lib.mkOption {
|
||||
type = lib.types.enum [ "lvm_lv" ];
|
||||
default = "lvm_lv";
|
||||
internal = true;
|
||||
description = "Type";
|
||||
};
|
||||
size = lib.mkOption {
|
||||
type = lib.types.str; # TODO lvm size type
|
||||
description = "Size of the logical volume";
|
||||
};
|
||||
lvm_type = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.enum [ "mirror" "raid0" "raid1" ]); # TODO add all lib.types
|
||||
default = null; # maybe there is always a default type?
|
||||
description = "LVM type";
|
||||
};
|
||||
extraArgs = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
description = "Extra arguments";
|
||||
};
|
||||
content = diskoLib.partitionType;
|
||||
_meta = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
type = lib.types.functionTo diskoLib.jsonType;
|
||||
default = dev:
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._meta dev);
|
||||
description = "Metadata";
|
||||
};
|
||||
_create = diskoLib.mkCreateOption {
|
||||
inherit config options;
|
||||
default = { vg }: ''
|
||||
lvcreate \
|
||||
--yes \
|
||||
${if lib.hasInfix "%" config.size then "-l" else "-L"} ${config.size} \
|
||||
-n ${config.name} \
|
||||
${lib.optionalString (!isNull config.lvm_type) "--type=${config.lvm_type}"} \
|
||||
${config.extraArgs} \
|
||||
${vg}
|
||||
${lib.optionalString (!isNull config.content) (config.content._create {dev = "/dev/${vg}/${config.name}";})}
|
||||
'';
|
||||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
inherit config options;
|
||||
default = { vg }:
|
||||
lib.optionalAttrs (!isNull config.content) (config.content._mount { dev = "/dev/${vg}/${config.name}"; });
|
||||
};
|
||||
_config = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
default = vg:
|
||||
[
|
||||
(lib.optional (!isNull config.content) (config.content._config "/dev/${vg}/${config.name}"))
|
||||
(lib.optional (!isNull config.lvm_type) {
|
||||
boot.initrd.kernelModules = [ "dm-${config.lvm_type}" ];
|
||||
})
|
||||
];
|
||||
description = "NixOS configuration";
|
||||
};
|
||||
_pkgs = lib.mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
||||
default = pkgs: lib.optionals (!isNull config.content) (config.content._pkgs pkgs);
|
||||
description = "Packages";
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue