From 100d1e49f6578d4c30a7f6b5baf3704a7c9b9510 Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Wed, 28 May 2025 12:58:35 -0500 Subject: Updated flake inputs + added option to auto-restart service on changes --- modules/nixos/cooklang-chef.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'modules/nixos') diff --git a/modules/nixos/cooklang-chef.nix b/modules/nixos/cooklang-chef.nix index 65af966..823227c 100644 --- a/modules/nixos/cooklang-chef.nix +++ b/modules/nixos/cooklang-chef.nix @@ -59,6 +59,8 @@ in { default = "/"; }; }; + + restartOnChanges = mkEnableOption "Restart cooklang-chef service on changes to ${cfg.recipeRoot}"; }; config = mkIf cfg.enable { @@ -118,6 +120,25 @@ in { }; }; + systemd.services.cooklang-chef-watcher = mkIf cfg.restartOnChanges { + description = "Restart cooklang-chef on file change"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = "/run/current-system/sw/bin/systemctl restart cooklang-chef.service"; + Type = "oneshot"; + }; + }; + + systemd.paths.cooklang-chef-watcher = mkIf cfg.restartOnChanges { + description = "Restart cooklang-chef on file change"; + wantedBy = [ "multi-user.target" ]; + pathConfig = { + Unit = "cooklang-chef-watcher.service"; + PathChanged = cfg.recipeRoot; + }; + }; + services.nginx = mkIf cfg.nginx.enable { enable = mkDefault true; virtualHosts.${cfg.nginx.virtualHost} = { -- cgit v1.2.3