disko/lib/types/lvm_pv.nix
2024-03-13 09:58:33 +01:00

59 lines
1.5 KiB
Nix

{ config, options, lib, diskoLib, parent, device, ... }:
{
options = {
type = lib.mkOption {
type = lib.types.enum [ "lvm_pv" ];
internal = true;
description = "Type";
};
device = lib.mkOption {
type = lib.types.str;
description = "Device";
default = device;
};
vg = lib.mkOption {
type = lib.types.str;
description = "Volume group";
};
_parent = lib.mkOption {
internal = true;
default = parent;
};
_meta = lib.mkOption {
internal = true;
readOnly = true;
type = lib.types.functionTo diskoLib.jsonType;
default = dev: {
deviceDependencies.lvm_vg.${config.vg} = [ dev ];
};
description = "Metadata";
};
_create = diskoLib.mkCreateOption {
inherit config options;
default = ''
if ! (blkid '${config.device}' | grep -q 'TYPE='); then
pvcreate ${config.device}
fi
echo "${config.device}" >>"$disko_devices_dir"/lvm_${config.vg}
'';
};
_mount = diskoLib.mkMountOption {
inherit config options;
default = { };
};
_config = lib.mkOption {
internal = true;
readOnly = true;
default = [ ];
description = "NixOS configuration";
};
_pkgs = lib.mkOption {
internal = true;
readOnly = true;
type = lib.types.functionTo (lib.types.listOf lib.types.package);
default = pkgs: [ pkgs.gnugrep pkgs.lvm2 ];
description = "Packages";
};
};
}