2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-10-05 16:11:32 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2009-10-05 16:11:32 +01:00
|
|
|
|
2009-10-12 18:27:57 +01:00
|
|
|
let
|
2009-10-05 16:11:32 +01:00
|
|
|
|
|
|
|
inherit (pkgs) privoxy;
|
|
|
|
|
2014-07-22 23:30:04 +01:00
|
|
|
cfg = config.services.privoxy;
|
2009-10-05 16:11:32 +01:00
|
|
|
|
2020-12-15 21:30:24 +00:00
|
|
|
confFile = pkgs.writeText "privoxy.conf" (''
|
2014-07-22 23:30:04 +01:00
|
|
|
user-manual ${privoxy}/share/doc/privoxy/user-manual
|
|
|
|
confdir ${privoxy}/etc/
|
|
|
|
listen-address ${cfg.listenAddress}
|
|
|
|
enable-edit-actions ${if (cfg.enableEditActions == true) then "1" else "0"}
|
|
|
|
${concatMapStrings (f: "actionsfile ${f}\n") cfg.actionsFiles}
|
|
|
|
${concatMapStrings (f: "filterfile ${f}\n") cfg.filterFiles}
|
2020-12-15 21:30:24 +00:00
|
|
|
'' + optionalString cfg.enableTor ''
|
2020-09-11 06:46:59 +01:00
|
|
|
forward-socks5t / 127.0.0.1:9063 .
|
2020-12-15 21:30:24 +00:00
|
|
|
toggle 1
|
|
|
|
enable-remote-toggle 0
|
|
|
|
enable-edit-actions 0
|
|
|
|
enable-remote-http-toggle 0
|
|
|
|
'' + ''
|
2014-07-22 23:30:04 +01:00
|
|
|
${cfg.extraConfig}
|
2020-12-15 21:30:24 +00:00
|
|
|
'');
|
2009-10-05 16:11:32 +01:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-10-05 16:11:32 +01:00
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-10-05 16:11:32 +01:00
|
|
|
services.privoxy = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2014-07-22 23:30:04 +01:00
|
|
|
type = types.bool;
|
2009-10-05 16:11:32 +01:00
|
|
|
default = false;
|
|
|
|
description = ''
|
2014-07-22 23:30:04 +01:00
|
|
|
Whether to enable the Privoxy non-caching filtering proxy.
|
2009-10-05 16:11:32 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
listenAddress = mkOption {
|
2014-07-22 23:30:04 +01:00
|
|
|
type = types.str;
|
2009-10-05 16:11:32 +01:00
|
|
|
default = "127.0.0.1:8118";
|
|
|
|
description = ''
|
|
|
|
Address the proxy server is listening to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-07-22 23:30:04 +01:00
|
|
|
actionsFiles = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
example = [ "match-all.action" "default.action" "/etc/privoxy/user.action" ];
|
|
|
|
default = [ "match-all.action" "default.action" ];
|
|
|
|
description = ''
|
|
|
|
List of paths to Privoxy action files.
|
|
|
|
These paths may either be absolute or relative to the privoxy configuration directory.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
filterFiles = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
example = [ "default.filter" "/etc/privoxy/user.filter" ];
|
|
|
|
default = [ "default.filter" ];
|
|
|
|
description = ''
|
|
|
|
List of paths to Privoxy filter files.
|
|
|
|
These paths may either be absolute or relative to the privoxy configuration directory.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableEditActions = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2009-10-05 16:11:32 +01:00
|
|
|
description = ''
|
2014-07-22 23:30:04 +01:00
|
|
|
Whether or not the web-based actions file editor may be used.
|
2009-10-05 16:11:32 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-12-15 21:30:24 +00:00
|
|
|
enableTor = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to configure Privoxy to use Tor's faster SOCKS port,
|
|
|
|
suitable for HTTP.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-10-05 16:11:32 +01:00
|
|
|
extraConfig = mkOption {
|
2014-07-22 23:30:04 +01:00
|
|
|
type = types.lines;
|
2009-10-05 16:11:32 +01:00
|
|
|
default = "" ;
|
|
|
|
description = ''
|
|
|
|
Extra configuration. Contents will be added verbatim to the configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2014-07-22 23:30:04 +01:00
|
|
|
config = mkIf cfg.enable {
|
2016-12-05 11:27:51 +00:00
|
|
|
|
|
|
|
users.users.privoxy = {
|
|
|
|
isSystemUser = true;
|
|
|
|
home = "/var/empty";
|
|
|
|
group = "privoxy";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.privoxy = {};
|
2009-10-05 16:11:32 +01:00
|
|
|
|
2014-07-22 23:30:04 +01:00
|
|
|
systemd.services.privoxy = {
|
|
|
|
description = "Filtering web proxy";
|
|
|
|
after = [ "network.target" "nss-lookup.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2016-12-05 11:27:51 +00:00
|
|
|
serviceConfig.ExecStart = "${privoxy}/bin/privoxy --no-daemon --user privoxy ${confFile}";
|
2016-12-05 11:25:31 +00:00
|
|
|
|
|
|
|
serviceConfig.PrivateDevices = true;
|
|
|
|
serviceConfig.PrivateTmp = true;
|
|
|
|
serviceConfig.ProtectHome = true;
|
|
|
|
serviceConfig.ProtectSystem = "full";
|
2014-07-22 23:30:04 +01:00
|
|
|
};
|
2009-10-05 16:11:32 +01:00
|
|
|
|
2020-09-11 06:46:59 +01:00
|
|
|
services.tor.settings.SOCKSPort = mkIf cfg.enableTor [
|
|
|
|
# Route HTTP traffic over a faster port (without IsolateDestAddr).
|
|
|
|
{ addr = "127.0.0.1"; port = 9063; IsolateDestAddr = false; }
|
|
|
|
];
|
|
|
|
|
2009-10-05 16:11:32 +01:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2019-12-04 16:07:45 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ rnhmjoj ];
|
|
|
|
|
2009-10-05 16:11:32 +01:00
|
|
|
}
|