1 { config, lib, pkgs, ...}:
3 cfg = config.services.hitch;
4 ocspDir = lib.optionalString cfg.ocsp-stapling.enabled "/var/cache/hitch/ocsp";
5 hitchConfig = with lib; pkgs.writeText "hitch.conf" (concatStringsSep "\n" [
6 ("backend = \"${cfg.backend}\"")
7 (concatMapStrings (s: "frontend = \"${s}\"\n") cfg.frontend)
8 (concatMapStrings (s: "pem-file = \"${s}\"\n") cfg.pem-files)
9 ("ciphers = \"${cfg.ciphers}\"")
10 ("ocsp-dir = \"${ocspDir}\"")
11 "user = \"${cfg.user}\""
12 "group = \"${cfg.group}\""
20 enable = mkEnableOption (lib.mdDoc "Hitch Server");
24 description = lib.mdDoc ''
25 The host and port Hitch connects to when receiving
26 a connection in the form [HOST]:PORT
32 default = "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
33 description = lib.mdDoc "The list of ciphers to use";
37 type = types.either types.str (types.listOf types.str);
38 default = "[127.0.0.1]:443";
39 description = lib.mdDoc ''
40 The port and interface of the listen endpoint in the
41 form [HOST]:PORT[+CERT].
46 pem-files = mkOption {
47 type = types.listOf types.path;
49 description = lib.mdDoc "PEM files to use";
56 description = lib.mdDoc "Whether to enable OCSP Stapling";
63 description = lib.mdDoc "The user to run as";
69 description = lib.mdDoc "The group to run as";
72 extraConfig = mkOption {
75 description = lib.mdDoc "Additional configuration lines";
81 config = mkIf cfg.enable {
83 systemd.services.hitch = {
84 description = "Hitch";
85 wantedBy = [ "multi-user.target" ];
86 after = [ "network.target" ];
88 ${pkgs.hitch}/sbin/hitch -t --config ${hitchConfig}
89 '' + (optionalString cfg.ocsp-stapling.enabled ''
91 chown -R hitch:hitch ${ocspDir}
95 ExecStart = "${pkgs.hitch}/sbin/hitch --daemon --config ${hitchConfig}";
96 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
103 environment.systemPackages = [ pkgs.hitch ];
105 users.users.hitch = {
109 users.groups.hitch = {};