From 4f2ae6218408d5b86a595260b4acbe7a003256dc Mon Sep 17 00:00:00 2001 From: Samuel Rounce Date: Sun, 22 Sep 2024 15:49:38 +0100 Subject: [PATCH] nixos/dex: Restart on referenced file changes Dex now restarts when EnvironmentFile or client secretFile paths change. --- nixos/doc/manual/release-notes/rl-2505.section.md | 2 ++ nixos/modules/services/web-apps/dex.nix | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index 0f24a0cd49600d..2e7635ef2dc3b5 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -22,6 +22,8 @@ - The default Elixir version has been updated to 1.18. +- `services.dex` now restarts upon changes to the `.environmentFile` or entries in `.settings.staticClients[].secretFile` when the entry is a `path` type. + - `nixos-rebuild-ng`, a full rewrite of `nixos-rebuild` in Python, is available for testing. You can enable it by setting [system.rebuild.enableNg](options.html#opt-system.rebuild.enableNg) in your configuration (this will replace the old `nixos-rebuild`), or by adding `nixos-rebuild-ng` to your `environment.systemPackages` (in this case, it will live side-by-side with `nixos-rebuild` as `nixos-rebuild-ng`). It is expected that the next major version of NixOS (25.11) will enable `system.rebuild.enableNg` by default. - A `nixos-rebuild build-image` sub-command has been added. diff --git a/nixos/modules/services/web-apps/dex.nix b/nixos/modules/services/web-apps/dex.nix index ca87ba273a9d18..5788f6b880fb15 100644 --- a/nixos/modules/services/web-apps/dex.nix +++ b/nixos/modules/services/web-apps/dex.nix @@ -32,6 +32,10 @@ let '') secretFiles ) ); + + restartTriggers = [] + ++ (optionals (cfg.environmentFile != null) [ cfg.environmentFile ]) + ++ (filter (file: builtins.typeOf file == "path") secretFiles); in { options.services.dex = { @@ -90,6 +94,7 @@ in "networking.target" ] ++ (optional (cfg.settings.storage.type == "postgres") "postgresql.service"); path = with pkgs; [ replace-secret ]; + restartTriggers = restartTriggers; serviceConfig = { ExecStart = "${pkgs.dex-oidc}/bin/dex serve /run/dex/config.yaml";