1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-03 07:31:03 +01:00
home-manager/modules/services/easyeffects.nix
hausken 125e40fa68
easyeffects: Make service compatible with v8.0.x (#8192)
Fixes #8185

The upstream easyeffects project has migrated from GTK to Qt, deprecating --gapplication-service and removing DBus integration. See #8185 for more details.
Tested with version 8.0.3 and 7.2.5 , uses lib.versionOlder cfg.package.version "8.0.0" to be backwards compatible.

    Removed DBus service configuration (Type=dbus, BusName)
    Move presets and config dir from $XDG_CONFIG_HOME to $XDG_DATA_HOME (new upstream location)

Other notes
Since they have moved config directory, it will warn show warnings because of empty dirs. These warnings will also show in the service until you remove them. I dont think this is a problem and new users will not experience this.

easyeffects --version
easyeffects: presets_directory_manager.cpp:140  Old /home/hausken/.config/easyeffects/output directory detected. Migrating its files to /home/hausken/.local/share/easyeffects/output
easyeffects: presets_directory_manager.cpp:149  Could not copy any file. Aborting migration of /home/hausken/.config/easyeffects/output
easyeffects: presets_directory_manager.cpp:140  Old /home/hausken/.config/easyeffects/irs directory detected. Migrating its files to /home/hausken/.local/share/easyeffects/irs
easyeffects: presets_directory_manager.cpp:149  Could not copy any file. Aborting migration of /home/hausken/.config/easyeffects/irs
easyeffects: presets_directory_manager.cpp:140  Old /home/hausken/.config/easyeffects/rnnoise directory detected. Migrating its files to /home/hausken/.local/share/easyeffects/rnnoise
easyeffects: presets_directory_manager.cpp:149  Could not copy any file. Aborting migration of /home/hausken/.config/easyeffects/rnnoise
easyeffects: presets_directory_manager.cpp:140  Old /home/hausken/.config/easyeffects/autoload/output directory detected. Migrating its files to /home/hausken/.local/share/easyeffects/autoload/output
easyeffects: presets_directory_manager.cpp:149  Could not copy any file. Aborting migration of /home/hausken/.config/easyeffects/autoload/output
2025-11-24 18:56:44 +01:00

147 lines
3.8 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib) literalExpression mkOption types;
cfg = config.services.easyeffects;
presetOpts = lib.optionalString (cfg.preset != "") "--load-preset ${cfg.preset}";
olderThan8 = lib.versionOlder cfg.package.version "8.0.0"; # This version introduces breaking changes and this check is used to stay backwards compatible
jsonFormat = pkgs.formats.json { };
presetType =
let
baseType = types.attrsOf jsonFormat.type;
in
types.addCheck baseType (
v:
baseType.check v
&& lib.elem (lib.head (lib.attrNames v)) [
"input"
"output"
]
);
presetOptionType = mkOption {
type = types.nullOr (types.attrsOf presetType);
default = { };
description = ''
List of presets to import to easyeffects.
Presets are written to input and output folder in `$XDG_DATA_HOME/easyeffects`.
Top level block (input/output) determines the folder the file is written to.
See community presets at:
https://github.com/wwmm/easyeffects/wiki/Community-Presets
'';
example = literalExpression ''
{
my-preset = {
input = {
blocklist = [
];
"plugins_order" = [
"rnnoise#0"
];
"rnnoise#0" = {
bypass = false;
"enable-vad" = false;
"input-gain" = 0.0;
"model-path" = "";
"output-gain" = 0.0;
release = 20.0;
"vad-thres" = 50.0;
wet = 0.0;
};
};
};
};
'';
};
in
{
meta.maintainers = with lib.maintainers; [
fufexan
hausken
];
options.services.easyeffects = {
enable = lib.mkEnableOption ''
Easyeffects daemon.
Note, it is necessary to add
```nix
programs.dconf.enable = true;
```
to your system configuration for the daemon to work correctly'';
package = lib.mkPackageOption pkgs "easyeffects" { };
preset = mkOption {
type = types.str;
default = "";
description = ''
Which preset to use when starting easyeffects.
Will likely need to launch easyeffects to initially create preset.
'';
};
extraPresets = presetOptionType;
};
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.easyeffects" pkgs lib.platforms.linux)
];
home.packages = with pkgs; lib.optional olderThan8 at-spi2-core ++ [ cfg.package ]; # Only include if easyeffects version is below 8.0.0
xdg.dataFile = lib.mkIf (cfg.extraPresets != { }) (
lib.mapAttrs' (
k: v:
# Assuming only one of either input or output block is defined, having both in same file not seem to be supported by the application since it separates it by folder
let
folder = builtins.head (builtins.attrNames v);
in
lib.nameValuePair "easyeffects/${folder}/${k}.json" {
source = jsonFormat.generate "${folder}-${k}.json" v;
}
) cfg.extraPresets
);
systemd.user.services.easyeffects = {
Unit = {
Description = "Easyeffects daemon";
};
Install.WantedBy = [ "graphical-session.target" ];
Service = {
ExecStart =
if olderThan8 then
"${cfg.package}/bin/easyeffects --gapplication-service ${presetOpts}"
else
"${cfg.package}/bin/easyeffects --hide-window --service-mode ${presetOpts}";
ExecStop = "${cfg.package}/bin/easyeffects --quit";
KillMode = "mixed";
Restart = "on-failure";
RestartSec = 5;
TimeoutStopSec = 10;
}
// (
if olderThan8 then
{
Type = "dbus";
BusName = "com.github.wwmm.easyeffects";
}
else
{ }
);
};
};
}