at 25.11-pre 2.0 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.programs.cdemu; 10in 11{ 12 13 options = { 14 programs.cdemu = { 15 enable = lib.mkOption { 16 type = lib.types.bool; 17 default = false; 18 description = '' 19 {command}`cdemu` for members of 20 {option}`programs.cdemu.group`. 21 ''; 22 }; 23 group = lib.mkOption { 24 type = lib.types.str; 25 default = "cdrom"; 26 description = '' 27 Group that users must be in to use {command}`cdemu`. 28 ''; 29 }; 30 gui = lib.mkOption { 31 type = lib.types.bool; 32 default = true; 33 description = '' 34 Whether to install the {command}`cdemu` GUI (gCDEmu). 35 ''; 36 }; 37 image-analyzer = lib.mkOption { 38 type = lib.types.bool; 39 default = true; 40 description = '' 41 Whether to install the image analyzer. 42 ''; 43 }; 44 }; 45 }; 46 47 config = lib.mkIf cfg.enable { 48 49 boot = { 50 extraModulePackages = [ config.boot.kernelPackages.vhba ]; 51 kernelModules = [ "vhba" ]; 52 }; 53 54 services = { 55 udev.extraRules = '' 56 KERNEL=="vhba_ctl", MODE="0660", OWNER="root", GROUP="${cfg.group}" 57 ''; 58 dbus.packages = [ pkgs.cdemu-daemon ]; 59 }; 60 61 users.groups.${config.programs.cdemu.group} = { }; 62 63 # Systemd User service 64 # manually adapted from example in source package: 65 # https://sourceforge.net/p/cdemu/code/ci/master/tree/cdemu-daemon/service-example/cdemu-daemon.service 66 systemd.user.services.cdemu-daemon.description = "CDEmu daemon"; 67 systemd.user.services.cdemu-daemon.serviceConfig = { 68 Type = "dbus"; 69 BusName = "net.sf.cdemu.CDEmuDaemon"; 70 ExecStart = "${lib.getExe pkgs.cdemu-daemon} --config-file \"%h/.config/cdemu-daemon\""; 71 Restart = "no"; 72 }; 73 74 environment.systemPackages = 75 [ 76 pkgs.cdemu-daemon 77 pkgs.cdemu-client 78 ] 79 ++ lib.optional cfg.gui pkgs.gcdemu 80 ++ lib.optional cfg.image-analyzer pkgs.image-analyzer; 81 }; 82 83}