1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.goxlr-utility;
9in
10{
11
12 options = {
13 services.goxlr-utility = {
14 enable = lib.mkOption {
15 default = false;
16 type = lib.types.bool;
17 description = ''
18 Whether to enable goxlr-utility for controlling your TC-Helicon GoXLR or GoXLR Mini
19 '';
20 };
21 package = lib.mkPackageOption pkgs "goxlr-utility" { };
22 autoStart.xdg = lib.mkOption {
23 default = true;
24 type = with lib.types; bool;
25 description = ''
26 Start the daemon automatically using XDG autostart.
27 Sets `xdg.autostart.enable = true` if not already enabled.
28 '';
29 };
30 };
31 };
32
33 config =
34 let
35 goxlr-autostart = pkgs.stdenv.mkDerivation {
36 name = "autostart-goxlr-daemon";
37 priority = 5;
38
39 buildCommand = ''
40 mkdir -p $out/etc/xdg/autostart
41 cp ${cfg.package}/share/applications/goxlr-utility.desktop $out/etc/xdg/autostart/goxlr-daemon.desktop
42 chmod +w $out/etc/xdg/autostart/goxlr-daemon.desktop
43 echo "X-KDE-autostart-phase=2" >> $out/etc/xdg/autostart/goxlr-daemon.desktop
44 substituteInPlace $out/etc/xdg/autostart/goxlr-daemon.desktop \
45 --replace-fail goxlr-launcher goxlr-daemon
46 '';
47 };
48 in
49 lib.mkIf config.services.goxlr-utility.enable {
50 services.udev.packages = [ cfg.package ];
51
52 xdg.autostart.enable = lib.mkIf cfg.autoStart.xdg true;
53 environment.systemPackages = lib.mkIf cfg.autoStart.xdg [
54 cfg.package
55 goxlr-autostart
56 ];
57 };
58
59 meta.maintainers = with lib.maintainers; [ errnoh ];
60}