1 { lib, pkgs, config, ... }:
4 cfg = config.services.go-camo;
5 inherit (lib) mkOption mkEnableOption mkIf mkMerge types optionalString;
8 options.services.go-camo = {
9 enable = mkEnableOption "go-camo service";
11 type = types.nullOr types.str;
13 description = "Address:Port to bind to for HTTP (default: 0.0.0.0:8080).";
14 apply = v: optionalString (v != null) "--listen=${v}";
16 sslListen = mkOption {
17 type = types.nullOr types.str;
19 description = "Address:Port to bind to for HTTPS.";
20 apply = v: optionalString (v != null) "--ssl-listen=${v}";
23 type = types.nullOr types.path;
25 description = "Path to TLS private key.";
26 apply = v: optionalString (v != null) "--ssl-key=${v}";
29 type = types.nullOr types.path;
31 description = "Path to TLS certificate.";
32 apply = v: optionalString (v != null) "--ssl-cert=${v}";
38 A file containing the HMAC key to use for signing URLs.
39 The file can contain any string. Can be generated using "openssl rand -base64 18 > the_file".
42 extraOptions = mkOption {
43 type = with types; listOf str;
45 description = "Extra options passed to the go-camo command.";
49 config = mkIf cfg.enable {
50 systemd.services.go-camo = {
51 description = "go-camo service";
52 wantedBy = [ "multi-user.target" ];
53 after = [ "network.target" ];
55 GOCAMO_HMAC_FILE = "%d/hmac";
58 export GOCAMO_HMAC=$(cat "$GOCAMO_HMAC_FILE")
59 exec ${lib.escapeShellArgs(lib.lists.remove "" ([ "${pkgs.go-camo}/bin/go-camo" cfg.listen cfg.sslListen cfg.sslKey cfg.sslCert ] ++ cfg.extraOptions))}
62 NoNewPrivileges = true;
63 ProtectSystem = "strict";