Skip to content

Commit

Permalink
nix: configuration and systemd service fixes (#2)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
fxzzi authored Jan 8, 2025
1 parent 51831ae commit cdf8a82
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
};
Expand Down

0 comments on commit cdf8a82

Please sign in to comment.