mirror of
https://github.com/NotAShelf/batmon.git
synced 2025-01-19 08:22:29 +00:00
nix: enable power-profiles-daemon while batmon is enabled; assert
This commit is contained in:
parent
cdf8a82c27
commit
9e387aa673
1 changed files with 21 additions and 5 deletions
|
@ -4,7 +4,7 @@ self: {
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkForce;
|
inherit (lib.modules) mkIf mkForce mkDefault;
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib) types;
|
inherit (lib) types;
|
||||||
|
|
||||||
|
@ -37,16 +37,25 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
# Create the batmon configuration file in /etc/batmon.json
|
environment = {
|
||||||
environment.etc."batmon.json".source = format.generate "batmon.json" cfg.settings;
|
systemPackages = [cfg.package];
|
||||||
|
|
||||||
environment.systemPackages = [cfg.package];
|
# Create the batmon configuration file in /etc/batmon.json
|
||||||
|
etc."batmon.json".source = format.generate "batmon.json" cfg.settings;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Batmon depends on power-profiles daemon
|
||||||
|
services.power-profiles-daemon.enable = mkDefault true;
|
||||||
|
|
||||||
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"];
|
||||||
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 [
|
||||||
|
# Batmon expects powerprofilesctl in PATH
|
||||||
|
config.services.power-profiles-daemon.package
|
||||||
|
]}";
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
${lib.getExe cfg.package} --config /etc/batmon.json
|
${lib.getExe cfg.package} --config /etc/batmon.json
|
||||||
'';
|
'';
|
||||||
|
@ -56,5 +65,12 @@ in {
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = config.services.power-profiles-daemon.enable;
|
||||||
|
message = "Batmon requies 'services.power-profiles-daemon.enable' to be true!";
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue