fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
2.0 KiB69 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.services.easyeffects;
8
9  presetOpts = optionalString (cfg.preset != "") "--load-preset ${cfg.preset}";
10
11in {
12  meta.maintainers = [ maintainers.fufexan ];
13
14  options.services.easyeffects = {
15    enable = mkEnableOption ''
16      Easyeffects daemon.
17      Note, it is necessary to add
18      ```nix
19      programs.dconf.enable = true;
20      ```
21      to your system configuration for the daemon to work correctly'';
22
23    package = mkOption {
24      type = types.package;
25      default = pkgs.easyeffects;
26      defaultText = literalExpression "pkgs.easyeffects";
27      description = "The `easyeffects` package to use.";
28    };
29
30    preset = mkOption {
31      type = types.str;
32      default = "";
33      description = ''
34        Which preset to use when starting easyeffects.
35        Will likely need to launch easyeffects to initially create preset.
36      '';
37    };
38  };
39
40  config = mkIf cfg.enable {
41    assertions = [
42      (hm.assertions.assertPlatform "services.easyeffects" pkgs platforms.linux)
43    ];
44
45    # running easyeffects will just attach itself to gapplication service
46    # at-spi2-core is to minimize journalctl noise of:
47    # "AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files"
48    home.packages = with pkgs; [ cfg.package at-spi2-core ];
49
50    systemd.user.services.easyeffects = {
51      Unit = {
52        Description = "Easyeffects daemon";
53        Requires = [ "dbus.service" ];
54        After = [ "graphical-session-pre.target" ];
55        PartOf = [ "graphical-session.target" "pipewire.service" ];
56      };
57
58      Install.WantedBy = [ "graphical-session.target" ];
59
60      Service = {
61        ExecStart =
62          "${cfg.package}/bin/easyeffects --gapplication-service ${presetOpts}";
63        ExecStop = "${cfg.package}/bin/easyeffects --quit";
64        Restart = "on-failure";
65        RestartSec = 5;
66      };
67    };
68  };
69}