2023-07-01 20:02:01 +03:00
|
|
|
{ config, options, lib, diskoLib, parent, device, ... }:
|
2023-01-28 18:19:13 +03:00
|
|
|
{
|
|
|
|
options = {
|
|
|
|
type = lib.mkOption {
|
|
|
|
type = lib.types.enum [ "lvm_pv" ];
|
|
|
|
internal = true;
|
|
|
|
description = "Type";
|
|
|
|
};
|
2023-07-01 20:02:01 +03:00
|
|
|
device = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Device";
|
|
|
|
default = device;
|
|
|
|
};
|
2023-01-28 18:19:13 +03:00
|
|
|
vg = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Volume group";
|
|
|
|
};
|
2023-06-07 14:42:39 +03:00
|
|
|
_parent = lib.mkOption {
|
|
|
|
internal = true;
|
|
|
|
default = parent;
|
|
|
|
};
|
2023-01-28 18:19:13 +03:00
|
|
|
_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;
|
2023-07-01 20:02:01 +03:00
|
|
|
default = ''
|
2024-03-12 06:22:46 +03:00
|
|
|
if ! (blkid '${config.device}' | grep -q 'TYPE='); then
|
|
|
|
pvcreate ${config.device}
|
|
|
|
fi
|
2023-07-02 01:17:48 +03:00
|
|
|
echo "${config.device}" >>"$disko_devices_dir"/lvm_${config.vg}
|
2023-01-28 18:19:13 +03:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
_mount = diskoLib.mkMountOption {
|
|
|
|
inherit config options;
|
2023-07-01 20:02:01 +03:00
|
|
|
default = { };
|
2023-01-28 18:19:13 +03:00
|
|
|
};
|
|
|
|
_config = lib.mkOption {
|
|
|
|
internal = true;
|
|
|
|
readOnly = true;
|
2023-07-01 20:02:01 +03:00
|
|
|
default = [ ];
|
2023-01-28 18:19:13 +03:00
|
|
|
description = "NixOS configuration";
|
|
|
|
};
|
|
|
|
_pkgs = lib.mkOption {
|
|
|
|
internal = true;
|
|
|
|
readOnly = true;
|
|
|
|
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
2024-03-12 06:22:46 +03:00
|
|
|
default = pkgs: [ pkgs.gnugrep pkgs.lvm2 ];
|
2023-01-28 18:19:13 +03:00
|
|
|
description = "Packages";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|