nixos-config/modules/nixos/oidc-agent.nix

61 lines
1.5 KiB
Nix
Raw Normal View History

2024-08-25 09:45:58 +00:00
{
config,
lib,
pkgs,
...
}:
2024-07-09 13:17:10 +00:00
let
2024-08-25 09:45:58 +00:00
inherit (lib)
mkIf
mkEnableOption
mkOption
types
;
2024-07-09 13:17:10 +00:00
cfg = config.programs.oidc-agent;
2024-08-25 09:45:58 +00:00
providerFormat = pkgs.formats.json { };
2024-07-09 13:17:10 +00:00
in
{
options.programs.oidc-agent = {
enable = mkEnableOption "OpenID Connect Agent";
package = mkOption {
type = types.package;
default = pkgs.oidc-agent;
description = ''
Which oidc-agent package to use
'';
};
providers = mkOption {
type = providerFormat.type;
2024-08-25 09:45:58 +00:00
default = { };
2024-07-09 13:17:10 +00:00
description = ''
Configuration of providers which contains a json array of json objects
each describing an issuer, see https://indigo-dc.gitbook.io/oidc-agent/configuration/issuers
'';
};
};
config = mkIf cfg.enable {
systemd.user.services.oidc-agent = {
unitConfig = {
Description = "OpenID Connect Agent";
Documentation = "man:oidc-agent(1)";
};
serviceConfig = {
ExecStart = "${cfg.package}/bin/oidc-agent -d --log-stderr -a %t/oidc-agent";
};
};
# environment.etc."oidc-agent/config".source = "${pkgs.oidc-agent}/etc/oidc-agent/config";
# environment.etc."oidc-agent/issuer.config.d".source =
# "${pkgs.oidc-agent}/etc/oidc-agent/issuer.config.d";
# environment.etc."oidc-agent/issuer.config".source =
# providerFormat.generate "oidc-agent-issuer.config" cfg.providers;
environment.extraInit = ''export OIDC_SOCK="$XDG_RUNTIME_DIR/oidc-agent"'';
};
}