1 { config, lib, pkgs, ... }:
6 cfg = config.services.tinyproxy;
7 mkValueStringTinyproxy = with lib; v:
8 if true == v then "yes"
9 else if false == v then "no"
10 else if types.path.check v then ''"${v}"''
11 else generators.mkValueStringDefault {} v;
12 mkKeyValueTinyproxy = {
13 mkValueString ? mkValueStringDefault {}
16 else "${lib.strings.escape [sep] k}${sep}${mkValueString v}";
18 settingsFormat = (pkgs.formats.keyValue {
19 mkKeyValue = mkKeyValueTinyproxy {
20 mkValueString = mkValueStringTinyproxy;
22 listsAsDuplicateKeys= true;
24 configFile = settingsFormat.generate "tinyproxy.conf" cfg.settings;
30 services.tinyproxy = {
31 enable = mkEnableOption "Tinyproxy daemon";
32 package = mkPackageOption pkgs "tinyproxy" {};
34 description = "Configuration for [tinyproxy](https://tinyproxy.github.io/).";
36 example = literalExpression ''{
41 Anonymous = ['"Host"' '"Authorization"'];
42 ReversePath = '"/example/" "http://www.example.com/"';
44 type = types.submodule ({name, ...}: {
45 freeformType = settingsFormat.type;
49 default = "127.0.0.1";
51 Specify which address to listen to.
58 Specify which port to listen to.
61 Anonymous = mkOption {
62 type = types.listOf types.str;
65 If an `Anonymous` keyword is present, then anonymous proxying is enabled. The headers listed with `Anonymous` are allowed through, while all others are denied. If no Anonymous keyword is present, then all headers are allowed through. You must include quotes around the headers.
69 type = types.nullOr types.path;
72 Tinyproxy supports filtering of web sites based on URLs or domains. This option specifies the location of the file containing the filter rules, one rule per line.
80 config = mkIf cfg.enable {
81 systemd.services.tinyproxy = {
82 description = "TinyProxy daemon";
83 after = [ "network.target" ];
84 wantedBy = [ "multi-user.target" ];
89 ExecStart = "${getExe cfg.package} -d -c ${configFile}";
90 ExecReload = "${pkgs.coreutils}/bin/kill -SIGHUP $MAINPID";
91 KillSignal = "SIGINT";
92 TimeoutStopSec = "30s";
93 Restart = "on-failure";
97 users.users.tinyproxy = {
101 users.groups.tinyproxy = {};
103 meta.maintainers = with maintainers; [ tcheronneau ];