# Install (NixOS) You can configure applications declaratively or imperatively. To register applications by commandline: ```sh sudo ratlogin ratlogin add-client \ --id example_app \ --name "Example Application" \ --redirect-uri https://app.example.com/oauth/callback ``` Use the printed client id and secret to configure your application. The example below demonstrates the NixOS module and includes headscale and grafana pre-configured, as well as the required SSL provided by Caddy. ```nix { inputs.ratlogin.url = "git+https://tangled.org/quilling.dev/ratlogin"; outputs = { nixpkgs, ratlogin, ... }: { nixosConfigurations.example = nixpkgs.lib.nixosSystem { modules = [ ratlogin.nixosModules.default { services.ratlogin = { enable = true; # replace every `example.com` with your domain: issuer = "https://ratlogin.example.com"; # pre-register applications here: clients = [ { id = "headscale"; redirectUris = [ "https://headscale.example.com/oidc/callback" ]; # optional allowlist for DIDs and handles: allow = [ "did:plc:yourdid" "*.example.com" ]; # optional denylist for DIDs and handles: deny = [ "did:plc:deny" "deny.example.com" ]; } { id = "grafana"; name = "Grafana"; redirectUris = [ "https://grafana.example.com/login/generic_oauth" ]; email = "optional"; } ]; }; # example caddy config: services.caddy = { enable = true; virtualHosts."ratlogin.example.com".extraConfig = '' reverse_proxy 127.0.0.1:9411 ''; }; # example headscale config: services.headscale.settings.oidc = { issuer = "https://ratlogin.example.com"; client_id = "headscale"; client_secret_path = "/etc/ratlogin/clients/headscale"; scope = [ "openid" "profile" "groups" ]; pkce.enabled = true; }; # example grafana config: services.grafana.settings."auth.generic_oauth" = { enabled = true; name = "ratlogin"; client_id = "grafana"; client_secret = "$__file{/etc/ratlogin/clients/grafana}"; auth_url = "https://ratlogin.example.com/authorize"; token_url = "https://ratlogin.example.com/token"; api_url = "https://ratlogin.example.com/userinfo"; scopes = "openid profile email groups"; login_attribute_path = "preferred_username"; name_attribute_path = "name"; email_attribute_path = "email"; # configure your admin DIDs here: role_attribute_path = "contains(groups[*], 'did:plc:yourdid') && 'Admin' || 'Viewer'"; use_pkce = true; allow_sign_up = true; }; } ]; }; }; } ```