-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
lib, | ||
pkgs, | ||
config, | ||
... | ||
}: | ||
|
||
let | ||
inherit (lib) | ||
maintainers | ||
mkIf | ||
mkEnableOption | ||
mkPackageOption | ||
mkOption | ||
; | ||
inherit (lib.types) | ||
nullOr | ||
path | ||
attrs | ||
; | ||
|
||
cfg = config.services.rauthy; | ||
format = pkgs.formats.ini { }; | ||
configFile = format.generate "rauthy.cfg" cfg.settings; | ||
in | ||
{ | ||
meta.maintainers = with maintainers; [ | ||
gepbird | ||
]; | ||
|
||
options.services.rauthy = { | ||
enable = mkEnableOption "Rauthy"; | ||
|
||
package = mkPackageOption pkgs "rauthy" { }; | ||
|
||
environmentFile = mkOption { | ||
type = nullOr path; | ||
default = null; | ||
example = "/run/secrets/rauthy.cfg"; | ||
description = '' | ||
Environment file to inject e.g. secrets into the configuration. | ||
''; | ||
}; | ||
|
||
settings = mkOption { | ||
type = attrs; | ||
default = { }; | ||
example = { | ||
PROXY_MODE = true; | ||
}; | ||
description = '' | ||
Additional key-value pair configuration options. | ||
See https://sebadob.github.io/rauthy/config/production_config.html. | ||
''; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
systemd.services.rauthy = { | ||
description = "rauthy"; | ||
after = [ | ||
"postgresql.service" | ||
]; | ||
wantedBy = [ "multi-user.target" ]; | ||
|
||
serviceConfig = { | ||
Type = "simple"; | ||
WorkingDirecotry = "/var/lib/rauthy"; | ||
# rauthy must find rauthy.cfg in the cwd | ||
ExecStartPre = pkgs.writeShellScript "rauthy-pre" '' | ||
ln -sf ${configFile} /var/lib/rauthy/rauthy.cfg | ||
''; | ||
ExecStart = pkgs.writeShellScript "rauthy-start" '' | ||
cd /var/lib/rauthy | ||
${cfg.package}/bin/rauthy | ||
''; | ||
StateDirectory = "rauthy"; | ||
EnvironmentFile = [ | ||
configFile | ||
] ++ lib.optional (cfg.environmentFile != null) cfg.environmentFile; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import ./make-test-python.nix ( | ||
{ | ||
lib, | ||
... | ||
}: | ||
{ | ||
name = "rauthy"; | ||
meta.maintainers = with lib.maintainers; [ | ||
gepbird | ||
]; | ||
|
||
nodes.machine = | ||
{ | ||
... | ||
}: | ||
{ | ||
services.rauthy = { | ||
enable = true; | ||
}; | ||
|
||
services.postgresql = { | ||
enable = true; | ||
ensureDatabases = [ "rauthy" ]; | ||
ensureUsers = [ | ||
{ | ||
name = "rauthy"; | ||
ensureDBOwnership = true; | ||
} | ||
]; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
machine.wait_for_unit("rauthy.service") | ||
machine.succeed("sleep 5") | ||
''; | ||
} | ||
) |