From 080b11b4d4011a8c54f6279ddbecf577c76172d8 Mon Sep 17 00:00:00 2001 From: Varun Narravula Date: Sat, 16 Nov 2024 13:20:52 -0800 Subject: [PATCH] atuin: make daemon log level configurable --- modules/programs/atuin.nix | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/modules/programs/atuin.nix b/modules/programs/atuin.nix index fe15cd252..94d67745d 100644 --- a/modules/programs/atuin.nix +++ b/modules/programs/atuin.nix @@ -1,10 +1,8 @@ { config, pkgs, lib, ... }: - with lib; - let - cfg = config.programs.atuin; + daemonCfg = cfg.daemon; tomlFormat = pkgs.formats.toml { }; @@ -96,7 +94,18 @@ in { ''; }; - daemon.enable = mkEnableOption "atuin daemon"; + daemon = { + enable = mkEnableOption "Atuin daemon"; + + logLevel = mkOption { + default = null; + type = + types.nullOr (types.enum [ "trace" "debug" "info" "warn" "error" ]); + description = '' + Verbosity of Atuin daemon logging. + ''; + }; + }; }; config = let flagsStr = escapeShellArgs cfg.flags; @@ -143,7 +152,7 @@ in { }; } - (mkIf cfg.daemon.enable (mkMerge [ + (mkIf daemonCfg.enable (mkMerge [ { assertions = [ { @@ -175,7 +184,8 @@ in { }; Service = { ExecStart = "${lib.getExe cfg.package} daemon"; - Environment = [ "ATUIN_LOG=info" ]; + Environment = lib.optionals (daemonCfg.logLevel != null) + [ "ATUIN_LOG=${daemonCfg.logLevel}" ]; Restart = "on-failure"; RestartSteps = 3; RestartMaxDelaySec = 6; @@ -197,7 +207,10 @@ in { enable = true; config = { ProgramArguments = [ "${lib.getExe cfg.package}" "daemon" ]; - EnvironmentVariables = { ATUIN_LOG = "info"; }; + EnvironmentVariables = + lib.optionalAttrs (daemonCfg.logLevel != null) { + ATUIN_LOG = daemonCfg.logLevel; + }; KeepAlive = { Crashed = true; SuccessfulExit = false;