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
This commit is contained in:
Fazzi 2025-01-08 10:10:23 +00:00 committed by GitHub
parent 51831ae23a
commit cdf8a82c27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,22 +37,23 @@ in {
}; };
config = mkIf cfg.enable { 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]; environment.systemPackages = [cfg.package];
systemd.user.services.batmon = { systemd.user.services.batmon = {
description = "Simple, reactive power management service"; description = "Simple, reactive power management service";
documentation = ["https://github.com/NotAShelf/batmon"]; documentation = ["https://github.com/NotAShelf/batmon"];
wants = ["power-profiles-daemon.service"];
requires = ["power-profiles-daemon.service"];
wantedBy = ["multi-user.target"]; wantedBy = ["multi-user.target"];
environment.PATH = mkForce "/run/wrappers/bin:${lib.makeBinPath [cfg.package]}"; environment.PATH = mkForce "/run/wrappers/bin:${lib.makeBinPath [cfg.package]}";
script = '' script = ''
${lib.getExe cfg.package} --config ${builtins.toJSON cfg.settings} ${lib.getExe cfg.package} --config /etc/batmon.json
''; '';
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
Restart = "on-failure"; Restart = "on-failure";
DynamicUser = true;
}; };
}; };
}; };