From fda65523fbb8dd7ef4a2eba4d39f88ce19245713 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 11 Dec 2022 01:23:22 +0100 Subject: [PATCH 1/2] nixos/evcc: Fix unit environment In some recent version evcc started requiring `getent` in the PATH, or else it would fail to start. It also now requires an sqlite database, which it tries to create a directory for at `$HOME/.evcc`, so we now need to provide a StateDirectory. --- nixos/modules/services/home-automation/evcc.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/home-automation/evcc.nix b/nixos/modules/services/home-automation/evcc.nix index c12ba9d0c1e2..efa2cf244313 100644 --- a/nixos/modules/services/home-automation/evcc.nix +++ b/nixos/modules/services/home-automation/evcc.nix @@ -48,7 +48,10 @@ in wantedBy = [ "multi-user.target" ]; - + environment.HOME = "/var/lib/evcc"; + path = with pkgs; [ + glibc # requires getent + ]; serviceConfig = { ExecStart = "${package}/bin/evcc --config ${configFile} ${escapeShellArgs cfg.extraArgs}"; CapabilityBoundingSet = [ "" ]; @@ -77,6 +80,7 @@ in ProtectKernelModules = true; ProtectKernelTunables = true; ProtectProc = "invisible"; + StateDirectory = "evcc"; SystemCallArchitectures = "native"; SystemCallFilter = [ "@system-service" From 76e962151ae9dc0660f343afae782a8b6df3b102 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 11 Dec 2022 01:23:48 +0100 Subject: [PATCH 2/2] nixos/tests/evcc: Fail when the unit produces fatal log messages --- nixos/tests/evcc.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/tests/evcc.nix b/nixos/tests/evcc.nix index 0fc261142f78..c223977a9d82 100644 --- a/nixos/tests/evcc.nix +++ b/nixos/tests/evcc.nix @@ -87,6 +87,7 @@ import ./make-test-python.nix ({ pkgs, lib, ...} : with subtest("Check journal for errors"): _, output = machine.execute("journalctl -o cat -u evcc.service") + assert "FATAL" not in output assert "ERROR" not in output with subtest("Check systemd hardening"):