2023-05-16 14:40:03 +03:00
|
|
|
{ config, options, lib, diskoLib, ... }:
|
2023-01-28 18:19:13 +03:00
|
|
|
{
|
|
|
|
options = {
|
|
|
|
name = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2023-08-11 09:11:01 +03:00
|
|
|
default = lib.replaceStrings [ "/" ] [ "_" ] config._module.args.name;
|
2023-01-28 18:19:13 +03:00
|
|
|
description = "Device name";
|
|
|
|
};
|
|
|
|
type = lib.mkOption {
|
|
|
|
type = lib.types.enum [ "disk" ];
|
|
|
|
default = "disk";
|
|
|
|
internal = true;
|
|
|
|
description = "Type";
|
|
|
|
};
|
|
|
|
device = lib.mkOption {
|
2023-05-16 14:40:03 +03:00
|
|
|
type = diskoLib.optionTypes.absolute-pathname; # TODO check if subpath of /dev ? - No! eg: /.swapfile
|
2023-01-28 18:19:13 +03:00
|
|
|
description = "Device path";
|
|
|
|
};
|
2023-07-28 14:23:07 +03:00
|
|
|
imageSize = lib.mkOption {
|
|
|
|
type = lib.types.strMatching "[0-9]+[KMGTP]?";
|
|
|
|
description = ''
|
2023-09-14 18:06:31 +03:00
|
|
|
size of the image if the makeDiskImages function from diksoLib is used.
|
2023-07-28 14:23:07 +03:00
|
|
|
is used as an argument to truncate -s
|
|
|
|
'';
|
2023-07-28 15:02:16 +03:00
|
|
|
default = "2G";
|
2023-07-28 14:23:07 +03:00
|
|
|
};
|
2023-07-01 20:02:01 +03:00
|
|
|
content = diskoLib.deviceType { parent = config; device = config.device; };
|
2023-01-28 18:19:13 +03:00
|
|
|
_meta = lib.mkOption {
|
|
|
|
internal = true;
|
|
|
|
readOnly = true;
|
|
|
|
type = diskoLib.jsonType;
|
|
|
|
default =
|
2023-02-06 17:24:34 +03:00
|
|
|
lib.optionalAttrs (config.content != null) (config.content._meta [ "disk" config.device ]);
|
2023-01-28 18:19:13 +03:00
|
|
|
description = "Metadata";
|
|
|
|
};
|
|
|
|
_create = diskoLib.mkCreateOption {
|
|
|
|
inherit config options;
|
2023-07-01 20:02:01 +03:00
|
|
|
default = config.content._create;
|
2023-01-28 18:19:13 +03:00
|
|
|
};
|
|
|
|
_mount = diskoLib.mkMountOption {
|
|
|
|
inherit config options;
|
2023-08-11 09:11:01 +03:00
|
|
|
default = lib.optionalAttrs (config.content != null) config.content._mount;
|
2023-01-28 18:19:13 +03:00
|
|
|
};
|
|
|
|
_config = lib.mkOption {
|
|
|
|
internal = true;
|
|
|
|
readOnly = true;
|
|
|
|
default =
|
2023-08-11 09:11:01 +03:00
|
|
|
lib.optional (config.content != null) config.content._config;
|
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);
|
2023-02-06 17:24:34 +03:00
|
|
|
default = pkgs: [ pkgs.jq ] ++ lib.optionals (config.content != null) (config.content._pkgs pkgs);
|
2023-01-28 18:19:13 +03:00
|
|
|
description = "Packages";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|