diff options
author | Benjamin Staffin <benley@gmail.com> | 2023-08-21 20:04:48 -0400 |
---|---|---|
committer | Jade Lovelace <software@lfcode.ca> | 2024-05-15 14:10:26 -0700 |
commit | b45bb628ea3eadb967da73cff18a705dd0dd6cd0 (patch) | |
tree | 3ae649e66b6b7b2cd2046692ae9255509d77c8ef /nixos | |
parent | 64c94bd40ad53df26d1c2b4b8e769262422e8e66 (diff) |
nixos/oauth2_proxy: Conditionally depend on keycloak.service
Co-Authored-By: Jade Lovelace <software@lfcode.ca>
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/security/oauth2-proxy.nix | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/nixos/modules/services/security/oauth2-proxy.nix b/nixos/modules/services/security/oauth2-proxy.nix index 78a772845a352..3079a1d030c52 100644 --- a/nixos/modules/services/security/oauth2-proxy.nix +++ b/nixos/modules/services/security/oauth2-proxy.nix @@ -577,20 +577,22 @@ in users.groups.oauth2-proxy = {}; - systemd.services.oauth2-proxy = { - description = "OAuth2 Proxy"; - path = [ cfg.package ]; - wantedBy = [ "multi-user.target" ]; - wants = [ "network-online.target" ]; - after = [ "network-online.target" ]; - - serviceConfig = { - User = "oauth2-proxy"; - Restart = "always"; - ExecStart = "${cfg.package}/bin/oauth2-proxy ${configString}"; - EnvironmentFile = lib.mkIf (cfg.keyFile != null) cfg.keyFile; + systemd.services.oauth2-proxy = + let needsKeycloak = lib.elem cfg.provider ["keycloak" "keycloak-oidc"] + && config.services.keycloak.enable; + in { + description = "OAuth2 Proxy"; + path = [ cfg.package ]; + wantedBy = [ "multi-user.target" ]; + wants = [ "network-online.target" ] ++ lib.optionals needsKeycloak [ "keycloak.service" ]; + after = [ "network-online.target" ] ++ lib.optionals needsKeycloak [ "keycloak.service" ]; + + serviceConfig = { + User = "oauth2-proxy"; + Restart = "always"; + ExecStart = "${cfg.package}/bin/oauth2-proxy ${configString}"; + EnvironmentFile = lib.mkIf (cfg.keyFile != null) cfg.keyFile; + }; }; - }; - }; } |