mirror of
https://github.com/nix-community/disko.git
synced 2024-11-10 04:05:07 +03:00
53 lines
1.6 KiB
Nix
53 lines
1.6 KiB
Nix
|
{ config, options, lib, diskoLib, optionTypes, ... }:
|
||
|
{
|
||
|
options = {
|
||
|
name = lib.mkOption {
|
||
|
type = lib.types.str;
|
||
|
default = config._module.args.name;
|
||
|
description = "Device name";
|
||
|
};
|
||
|
type = lib.mkOption {
|
||
|
type = lib.types.enum [ "disk" ];
|
||
|
default = "disk";
|
||
|
internal = true;
|
||
|
description = "Type";
|
||
|
};
|
||
|
device = lib.mkOption {
|
||
|
type = optionTypes.absolute-pathname; # TODO check if subpath of /dev ? - No! eg: /.swapfile
|
||
|
description = "Device path";
|
||
|
};
|
||
|
content = diskoLib.deviceType;
|
||
|
_meta = lib.mkOption {
|
||
|
internal = true;
|
||
|
readOnly = true;
|
||
|
type = diskoLib.jsonType;
|
||
|
default =
|
||
|
lib.optionalAttrs (!isNull config.content) (config.content._meta [ "disk" config.device ]);
|
||
|
description = "Metadata";
|
||
|
};
|
||
|
_create = diskoLib.mkCreateOption {
|
||
|
inherit config options;
|
||
|
default = {}: config.content._create { dev = config.device; };
|
||
|
};
|
||
|
_mount = diskoLib.mkMountOption {
|
||
|
inherit config options;
|
||
|
default = {}:
|
||
|
lib.optionalAttrs (!isNull config.content) (config.content._mount { dev = config.device; });
|
||
|
};
|
||
|
_config = lib.mkOption {
|
||
|
internal = true;
|
||
|
readOnly = true;
|
||
|
default =
|
||
|
lib.optional (!isNull config.content) (config.content._config config.device);
|
||
|
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 (!isNull config.content) (config.content._pkgs pkgs);
|
||
|
description = "Packages";
|
||
|
};
|
||
|
};
|
||
|
}
|