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 ''
42 Anonymous = ['"Host"' '"Authorization"'];
43 ReversePath = '"/example/" "http://www.example.com/"';
46 type = types.submodule ({name, ...}: {
47 freeformType = settingsFormat.type;
51 default = "127.0.0.1";
53 Specify which address to listen to.
60 Specify which port to listen to.
63 Anonymous = mkOption {
64 type = types.listOf types.str;
67 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.
71 type = types.nullOr types.path;
74 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.
82 config = mkIf cfg.enable {
83 systemd.services.tinyproxy = {
84 description = "TinyProxy daemon";
85 after = [ "network.target" ];
86 wantedBy = [ "multi-user.target" ];
91 ExecStart = "${getExe cfg.package} -d -c ${configFile}";
92 ExecReload = "${pkgs.coreutils}/bin/kill -SIGHUP $MAINPID";
93 KillSignal = "SIGINT";
94 TimeoutStopSec = "30s";
95 Restart = "on-failure";
99 users.users.tinyproxy = {
103 users.groups.tinyproxy = {};
105 meta.maintainers = with maintainers; [ tcheronneau ];