nix: format with alejandra

This commit is contained in:
Primrose 2025-02-08 12:05:12 +01:00
parent d5cad148da
commit 95eb4b71e0
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
118 changed files with 1291 additions and 1703 deletions

View file

@ -3,14 +3,9 @@
lib,
config,
...
}:
let
}: let
cfg = config.services."battery-notify";
in
{
in {
options = {
services."battery-notify" = {
enable = lib.mkEnableOption "battery-notify";
@ -22,7 +17,7 @@ in
checkAt = lib.mkOption {
type = with lib.types; listOf str;
description = "At which frequency should the service check for the battery status";
default = [ "*:0/5" ]; # every five minutes
default = ["*:0/5"]; # every five minutes
};
device_full = lib.mkOption {
type = with lib.types; str;
@ -39,29 +34,27 @@ in
systemd.user.services."battery-notify" = {
Unit.Description = "Notify when battery is low";
Install = {
WantedBy = [ "multi-user.target" ];
WantedBy = ["multi-user.target"];
};
Service = {
ExecStart =
let
script = pkgs.writeShellApplication {
name = "battery-notify";
runtimeInputs = [
pkgs.libnotify
pkgs.bc
pkgs.uutils-coreutils-noprefix
];
text = ''
now="$(cat ${cfg.device_now})"
full="$(cat ${cfg.device_full})"
ExecStart = let
script = pkgs.writeShellApplication {
name = "battery-notify";
runtimeInputs = [
pkgs.libnotify
pkgs.bc
pkgs.uutils-coreutils-noprefix
];
text = ''
now="$(cat ${cfg.device_now})"
full="$(cat ${cfg.device_full})"
if (( $(bc -l <<< "($now / $full) * 100 < ${builtins.toString cfg.triggerLevel}") )); then
notify-send -u critical "Battery Low" "Please charge your battery"
fi
'';
};
in
"${lib.getExe script}";
if (( $(bc -l <<< "($now / $full) * 100 < ${builtins.toString cfg.triggerLevel}") )); then
notify-send -u critical "Battery Low" "Please charge your battery"
fi
'';
};
in "${lib.getExe script}";
};
};
@ -71,8 +64,7 @@ in
OnCalendar = cfg.checkAt;
Persistent = true;
};
Install.WantedBy = [ "timers.target" ];
Install.WantedBy = ["timers.target"];
};
};
}