2022-11-27 09:42:12 +00:00
|
|
|
{ lib
|
|
|
|
, pkgs
|
|
|
|
, config
|
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.evcc;
|
|
|
|
|
|
|
|
format = pkgs.formats.yaml {};
|
|
|
|
configFile = format.generate "evcc.yml" cfg.settings;
|
|
|
|
|
|
|
|
package = pkgs.evcc;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
meta.maintainers = with lib.maintainers; [ hexa ];
|
|
|
|
|
|
|
|
options.services.evcc = with types; {
|
|
|
|
enable = mkEnableOption (lib.mdDoc "EVCC, the extensible EV Charge Controller with PV integration");
|
|
|
|
|
|
|
|
extraArgs = mkOption {
|
|
|
|
type = listOf str;
|
|
|
|
default = [];
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Extra arguments to pass to the evcc executable.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = format.type;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
evcc configuration as a Nix attribute set.
|
|
|
|
|
|
|
|
Check for possible options in the sample [evcc.dist.yaml](https://github.com/andig/evcc/blob/${package.version}/evcc.dist.yaml].
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.evcc = {
|
2024-01-25 14:12:00 +00:00
|
|
|
wants = [ "network-online.target" ];
|
2022-11-27 09:42:12 +00:00
|
|
|
after = [
|
|
|
|
"network-online.target"
|
|
|
|
"mosquitto.target"
|
|
|
|
];
|
|
|
|
wantedBy = [
|
|
|
|
"multi-user.target"
|
|
|
|
];
|
2022-12-17 10:02:37 +00:00
|
|
|
environment.HOME = "/var/lib/evcc";
|
|
|
|
path = with pkgs; [
|
2023-07-15 17:15:38 +00:00
|
|
|
getent
|
2022-12-17 10:02:37 +00:00
|
|
|
];
|
2022-11-27 09:42:12 +00:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${package}/bin/evcc --config ${configFile} ${escapeShellArgs cfg.extraArgs}";
|
|
|
|
CapabilityBoundingSet = [ "" ];
|
|
|
|
DeviceAllow = [
|
|
|
|
"char-ttyUSB"
|
|
|
|
];
|
|
|
|
DevicePolicy = "closed";
|
|
|
|
DynamicUser = true;
|
|
|
|
LockPersonality = true;
|
|
|
|
MemoryDenyWriteExecute = true;
|
|
|
|
RestrictAddressFamilies = [
|
|
|
|
"AF_INET"
|
|
|
|
"AF_INET6"
|
|
|
|
"AF_UNIX"
|
|
|
|
];
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
PrivateUsers = true;
|
|
|
|
ProcSubset = "pid";
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectControlGroups= true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectProc = "invisible";
|
2022-12-17 10:02:37 +00:00
|
|
|
StateDirectory = "evcc";
|
2022-11-27 09:42:12 +00:00
|
|
|
SystemCallArchitectures = "native";
|
|
|
|
SystemCallFilter = [
|
|
|
|
"@system-service"
|
|
|
|
"~@privileged"
|
|
|
|
];
|
|
|
|
UMask = "0077";
|
|
|
|
User = "evcc";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.buildDocsInSandbox = false;
|
|
|
|
}
|