2015-02-10 01:27:04 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2015-02-10 10:52:46 +00:00
|
|
|
let cfg = config.programs.cdemu;
|
2015-02-10 01:27:04 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
options = {
|
2015-02-10 10:52:46 +00:00
|
|
|
programs.cdemu = {
|
2024-04-17 11:37:58 +00:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2015-02-10 01:27:04 +00:00
|
|
|
default = false;
|
2015-09-06 22:47:18 +00:00
|
|
|
description = ''
|
|
|
|
{command}`cdemu` for members of
|
|
|
|
{option}`programs.cdemu.group`.
|
|
|
|
'';
|
2015-02-10 01:27:04 +00:00
|
|
|
};
|
2024-04-17 11:37:58 +00:00
|
|
|
group = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2015-02-10 01:27:04 +00:00
|
|
|
default = "cdrom";
|
2015-09-06 22:47:18 +00:00
|
|
|
description = ''
|
|
|
|
Group that users must be in to use {command}`cdemu`.
|
|
|
|
'';
|
2015-02-10 01:27:04 +00:00
|
|
|
};
|
2024-04-17 11:37:58 +00:00
|
|
|
gui = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2015-02-10 01:27:04 +00:00
|
|
|
default = true;
|
2015-09-06 22:47:18 +00:00
|
|
|
description = ''
|
|
|
|
Whether to install the {command}`cdemu` GUI (gCDEmu).
|
|
|
|
'';
|
2015-02-10 01:27:04 +00:00
|
|
|
};
|
2024-04-17 11:37:58 +00:00
|
|
|
image-analyzer = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2015-02-10 01:27:04 +00:00
|
|
|
default = true;
|
2015-09-06 22:47:18 +00:00
|
|
|
description = ''
|
|
|
|
Whether to install the image analyzer.
|
|
|
|
'';
|
2015-02-10 01:27:04 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-17 11:37:58 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2015-02-10 10:49:32 +00:00
|
|
|
|
2015-02-10 01:27:04 +00:00
|
|
|
boot = {
|
2016-01-07 16:15:01 +00:00
|
|
|
extraModulePackages = [ config.boot.kernelPackages.vhba ];
|
2015-02-10 01:27:04 +00:00
|
|
|
kernelModules = [ "vhba" ];
|
|
|
|
};
|
2015-02-10 10:49:32 +00:00
|
|
|
|
2015-02-10 01:27:04 +00:00
|
|
|
services = {
|
|
|
|
udev.extraRules = ''
|
|
|
|
KERNEL=="vhba_ctl", MODE="0660", OWNER="root", GROUP="${cfg.group}"
|
|
|
|
'';
|
|
|
|
dbus.packages = [ pkgs.cdemu-daemon ];
|
|
|
|
};
|
2015-02-10 10:49:32 +00:00
|
|
|
|
2023-10-08 22:28:33 +00:00
|
|
|
users.groups.${config.programs.cdemu.group} = {};
|
|
|
|
|
|
|
|
# Systemd User service
|
|
|
|
# manually adapted from example in source package:
|
|
|
|
# https://sourceforge.net/p/cdemu/code/ci/master/tree/cdemu-daemon/service-example/cdemu-daemon.service
|
|
|
|
systemd.user.services.cdemu-daemon.description = "CDEmu daemon";
|
|
|
|
systemd.user.services.cdemu-daemon.serviceConfig = {
|
|
|
|
Type = "dbus";
|
|
|
|
BusName = "net.sf.cdemu.CDEmuDaemon";
|
2024-09-18 21:17:11 +00:00
|
|
|
ExecStart = "${lib.getExe pkgs.cdemu-daemon} --config-file \"%h/.config/cdemu-daemon\"";
|
2023-10-08 22:28:33 +00:00
|
|
|
Restart = "no";
|
|
|
|
};
|
|
|
|
|
2015-02-10 01:27:04 +00:00
|
|
|
environment.systemPackages =
|
|
|
|
[ pkgs.cdemu-daemon pkgs.cdemu-client ]
|
2024-04-17 11:37:58 +00:00
|
|
|
++ lib.optional cfg.gui pkgs.gcdemu
|
|
|
|
++ lib.optional cfg.image-analyzer pkgs.image-analyzer;
|
2015-02-10 01:27:04 +00:00
|
|
|
};
|
2015-02-10 10:49:32 +00:00
|
|
|
|
2015-02-10 01:27:04 +00:00
|
|
|
}
|