1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.oidc-playground;
pkg = pkgs.callPackage ./pkg.nix { inherit pkgs; };
in
{
options.services.oidc-playground = {
enable = lib.mkEnableOption "OIDC Playground";
package = lib.mkOption {
type = lib.types.package;
default = pkg;
description = "OIDC Playground package";
};
user = lib.mkOption {
type = lib.types.str;
default = "oidc-playground";
description = "User to run as";
};
group = lib.mkOption {
type = lib.types.str;
default = "oidc-playground";
description = "Group to run as";
};
port = lib.mkOption {
type = lib.types.port;
default = 6432;
description = "Port to serve on";
};
origin = lib.mkOption {
type = lib.types.str;
default = "http://localhost:6432";
description = "Web origin";
};
issuer = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "https://auth.example.com";
description = "Default issuer URL";
};
scopes = lib.mkOption {
type = lib.types.str;
default = "profile email";
description = "Default OIDC scopes";
};
};
config = lib.mkIf cfg.enable {
systemd.services.oidc-playground = {
description = "OIDC Playground Service";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart =
let
args =
[
"--port=${builtins.toString cfg.port}"
"--origin=${cfg.origin}"
"--scopes=${lib.escapeShellArg cfg.scopes}"
]
++ lib.optionals (cfg.issuer != null) [
"--client-provider=${cfg.issuer}"
];
in
"${lib.getExe cfg.package} ${lib.concatStringsSep " " args}";
Restart = "always";
User = cfg.user;
Group = cfg.group;
};
};
users = {
users.${cfg.user} = {
isSystemUser = true;
group = cfg.group;
};
groups.${cfg.group} = { };
};
};
}
|