From cdf8a82c276fcb0bce4036ae046b1c4109e18cf9 Mon Sep 17 00:00:00 2001 From: Fazzi <18248986+Fxzzi@users.noreply.github.com> Date: Wed, 8 Jan 2025 10:10:23 +0000 Subject: [PATCH] nix: configuration and systemd service fixes (#2) * remove the DynamicUser systemd serviceConfig option, it isn't used on user services * remove references to power-profiles-daemon.service in the user service, you can't reference sysemd services in a systemd user service * make --config reference path to config, not the config itself --- nix/module.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nix/module.nix b/nix/module.nix index 2ca6002..7e94df7 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -37,22 +37,23 @@ in { }; config = mkIf cfg.enable { + # Create the batmon configuration file in /etc/batmon.json + environment.etc."batmon.json".source = format.generate "batmon.json" cfg.settings; + environment.systemPackages = [cfg.package]; + systemd.user.services.batmon = { description = "Simple, reactive power management service"; documentation = ["https://github.com/NotAShelf/batmon"]; - wants = ["power-profiles-daemon.service"]; - requires = ["power-profiles-daemon.service"]; wantedBy = ["multi-user.target"]; environment.PATH = mkForce "/run/wrappers/bin:${lib.makeBinPath [cfg.package]}"; script = '' - ${lib.getExe cfg.package} --config ${builtins.toJSON cfg.settings} + ${lib.getExe cfg.package} --config /etc/batmon.json ''; serviceConfig = { Type = "simple"; Restart = "on-failure"; - DynamicUser = true; }; }; };