1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let cfg = config.programs.cdemu;
6in {
7
8 options = {
9 programs.cdemu = {
10 enable = mkOption {
11 default = false;
12 description = ''
13 <command>cdemu</command> for members of
14 <option>programs.cdemu.group</option>.
15 '';
16 };
17 group = mkOption {
18 default = "cdrom";
19 description = ''
20 Group that users must be in to use <command>cdemu</command>.
21 '';
22 };
23 gui = mkOption {
24 default = true;
25 description = ''
26 Whether to install the <command>cdemu</command> GUI (gCDEmu).
27 '';
28 };
29 image-analyzer = mkOption {
30 default = true;
31 description = ''
32 Whether to install the image analyzer.
33 '';
34 };
35 };
36 };
37
38 config = mkIf cfg.enable {
39
40 boot = {
41 extraModulePackages = [ config.boot.kernelPackages.vhba ];
42 kernelModules = [ "vhba" ];
43 };
44
45 services = {
46 udev.extraRules = ''
47 KERNEL=="vhba_ctl", MODE="0660", OWNER="root", GROUP="${cfg.group}"
48 '';
49 dbus.packages = [ pkgs.cdemu-daemon ];
50 };
51
52 environment.systemPackages =
53 [ pkgs.cdemu-daemon pkgs.cdemu-client ]
54 ++ optional cfg.gui pkgs.gcdemu
55 ++ optional cfg.image-analyzer pkgs.image-analyzer;
56 };
57
58}