From d1236d548d52b2681c2eb1ef5cd7bba9a313bb4d Mon Sep 17 00:00:00 2001 From: Florian Agbuya Date: Fri, 22 Nov 2024 15:34:23 +0800 Subject: [PATCH] afws: enable file logging with afws group permissions --- nixbld-etc-nixos/afws-module.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/nixbld-etc-nixos/afws-module.nix b/nixbld-etc-nixos/afws-module.nix index 1410b5a..353a664 100644 --- a/nixbld-etc-nixos/afws-module.nix +++ b/nixbld-etc-nixos/afws-module.nix @@ -10,16 +10,34 @@ in default = false; description = "Enable AFWS server"; }; + logFile = mkOption { + type = types.str; + default = "/var/lib/afws/logs/afws.log"; + description = "Path to the log file"; + }; + logBackupCount = mkOption { + type = types.int; + default = 30; + description = "Number of daily log files to keep"; + }; }; config = mkIf config.services.afws.enable { systemd.services.afws = { description = "AFWS server"; wantedBy = [ "multi-user.target" ]; + preStart = '' + mkdir -p "$(dirname ${config.services.afws.logFile})" + chown afws:afws "$(dirname ${config.services.afws.logFile})" + ''; serviceConfig = { User = "afws"; Group = "afws"; - ExecStart = "${afws}/bin/afws_server"; + ExecStart = '' + ${afws}/bin/afws_server \ + --log-file ${config.services.afws.logFile} \ + --log-backup-count ${toString config.services.afws.logBackupCount} + ''; ExecReload = "${pkgs.coreutils}/bin/kill -USR1 $MAINPID"; }; path = [ pkgs.nix pkgs.git ];