diff options
Diffstat (limited to 'modules/device/default.nix')
| -rw-r--r-- | modules/device/default.nix | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/device/default.nix b/modules/device/default.nix new file mode 100644 index 0000000..22cf180 --- /dev/null +++ b/modules/device/default.nix @@ -0,0 +1,41 @@ +{ config, pkgs, lib, ... }: +with builtins // lib; +let + devices = import ../../data/devices.nix; + + hardware = mkOption { + type = types.strMatching ''^kobo\d+$''; + }; + deviceID = mkOption { + type = types.strMatching ''00000000-0000-0000-0000-000000000\d\d\d''; + }; + + deviceInfo = types.submodule { + options = { + inherit hardware deviceID; + }; + }; +in { + options = { + _allDevices = mkOption { + default = devices; + readOnly = true; + internal = true; + type = types.attrsOf deviceInfo; + }; + + device = { + name = mkOption { + type = types.enum (attrNames devices); + }; + + hardware = hardware // { + default = config._allDevices.${config.device.name}.hardware; + }; + + deviceID = deviceID // { + default = config._allDevices.${config.device.name}.deviceID; + }; + }; + }; +} |
