No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-01 14:30:32 +01:00
nix feat: Implement services-flake caddy module 2026-11-01 14:30:32 +01:00
.envrc chore: Init repo with nix flake 2026-11-01 13:04:07 +01:00
.gitignore chore: Init repo with nix flake 2026-11-01 13:04:07 +01:00
flake.lock chore: Init repo with nix flake 2026-11-01 13:04:07 +01:00
flake.nix feat: Implement services-flake caddy module 2026-11-01 14:30:32 +01:00
README.md feat: Implement services-flake caddy module 2026-11-01 14:30:32 +01:00

services-flake-caddy

A services-flake add-on providing a Caddy service for local HTTPS reverse proxies.

Remote: https://forgejo.920301.xyz/dan/services-flake-caddy.git

Usage

Add the flake as an input and import its process-compose module alongside services-flake:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-parts.url = "github:hercules-ci/flake-parts";
    systems.url = "github:nix-systems/default";
    process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
    services-flake.url = "github:juspay/services-flake";
    services-flake-caddy.url = "git+https://forgejo.920301.xyz/dan/services-flake-caddy.git";
  };

  outputs = inputs:
    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      systems = import inputs.systems;
      imports = [ inputs.process-compose-flake.flakeModule ];
      perSystem = { pkgs, ... }: {
        process-compose.default = {
          imports = [
            inputs.services-flake.processComposeModules.default
            inputs.services-flake-caddy.processComposeModules.default
          ];

          services.caddy.caddy1 = {
            enable = true;
            projectName = "demo";
            routes = {
              authelia.upstream = "127.0.0.1:9091";
              api.upstream = "127.0.0.1:8080";
            };
          };

          services.authelia.authelia1.enable = true;
        };
      };
    };
}

Then run:

nix run .#default

authelia is available at https://authelia.demo.localhost and api at https://api.demo.localhost.

Options

  • services.caddy.<name>.enable — enable the service.
  • projectName — used for generated hostnames (default dev).
  • httpPort / httpsPort — default 80 / 443.
  • routes.<route>.host — hostname (default <route>.<projectName>.localhost).
  • routes.<route>.upstream — upstream host:port.
  • routes.<route>.extraConfig — extra Caddyfile directives for the host.
  • extraGlobalConfig / extraConfig — escape hatches for the Caddyfile.
  • trust.enable — install Caddy's local CA into trust stores (default true).
  • trust.useSudo — use sudo for caddy trust on Linux (default true on Linux).

Certificate trust

Caddy uses its internal CA. On first run it generates a root certificate under dataDir/caddy/pki/authorities/local/root.crt.

  • macOS: Caddy installs it into the system Keychain automatically.
  • Linux: the caddy-trust process runs sudo caddy trust ...; passwordless sudo may be required.
  • NixOS: add the generated root certificate to security.pki.certificateFiles (see the NixOS note below).
  • WSL: copy the root certificate to the Windows host and import it into the Windows certificate store (see the WSL note below).

NixOS

Because the NixOS trust store is built at evaluation time, reference the generated certificate path and rebuild after the first Caddy run:

security.pki.certificateFiles = [
  "/path/to/your/project/data/caddy1/caddy/pki/authorities/local/root.crt"
];

WSL

Copy root.crt to a Windows-accessible path and import it, for example with PowerShell run as administrator:

Import-Certificate -FilePath C:\path\to\root.crt -CertStoreLocation Cert:\LocalMachine\Root

Notes

  • Binding ports 80/443 may require elevated privileges on some systems.
  • Automatic service discovery from process-compose is not implemented yet; routes are declared manually. EOF echo written