From 6fdc890e790cb6337c34bda5d4a2f4d857e52baa Mon Sep 17 00:00:00 2001 From: Alexander Sieg Date: Mon, 10 Mar 2025 10:00:58 +0100 Subject: [PATCH] nixos/alloy: automaticlly include all .alloy files in reload trigger --- nixos/modules/services/monitoring/alloy.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/monitoring/alloy.nix b/nixos/modules/services/monitoring/alloy.nix index 25ca8eb1a74b..73f967addc91 100644 --- a/nixos/modules/services/monitoring/alloy.nix +++ b/nixos/modules/services/monitoring/alloy.nix @@ -30,12 +30,10 @@ in configuration file via `environment.etc."alloy/config.alloy"`. This allows config reload, contrary to specifying a store path. - A `reloadTrigger` for `config.alloy` is configured. - Other `*.alloy` files in the same directory (ignoring subdirs) are also - honored, but it's necessary to manually extend - `systemd.services.alloy.reloadTriggers` to enable config reload - during nixos-rebuild switch. + All `.alloy` files in the same directory (ignoring subdirs) are also + honored and are added to `systemd.services.alloy.reloadTriggers` to + enable config reload during nixos-rebuild switch. This can also point to another directory containing `*.alloy` files, or a single Alloy file in the Nix store (at the cost of reload). @@ -68,7 +66,9 @@ in config = lib.mkIf cfg.enable { systemd.services.alloy = { wantedBy = [ "multi-user.target" ]; - reloadTriggers = [ config.environment.etc."alloy/config.alloy".source or null ]; + reloadTriggers = lib.mapAttrsToList (_: v: v.source or null) ( + lib.filterAttrs (n: _: lib.hasPrefix "alloy/" n && lib.hasSuffix ".alloy" n) config.environment.etc + ); serviceConfig = { Restart = "always"; DynamicUser = true;