disko/lib/types/disk.nix

52 lines
1.6 KiB
Nix
Raw Normal View History

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-07-18 01:10:35 +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";
};
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 =
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;
default = config.content._create;
2023-01-28 18:19:13 +03:00
};
_mount = diskoLib.mkMountOption {
inherit config options;
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 =
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);
default = pkgs: [ pkgs.jq ] ++ lib.optionals (config.content != null) (config.content._pkgs pkgs);
2023-01-28 18:19:13 +03:00
description = "Packages";
};
};
}