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;
|
|
|
|
|
|
|
|
privoxyUser = "privoxy";
|
|
|
|
|
2014-07-22 23:30:04 +01:00
|
|
|
cfg = config.services.privoxy;
|
2009-10-05 16:11:32 +01:00
|
|
|
|
2014-07-22 23:30:04 +01:00
|
|
|
confFile = pkgs.writeText "privoxy.conf" ''
|
|
|
|
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}
|
|
|
|
${cfg.extraConfig}
|
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
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
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 {
|
2012-03-17 17:26:17 +00:00
|
|
|
|
2009-10-05 16:11:32 +01:00
|
|
|
users.extraUsers = singleton
|
|
|
|
{ name = privoxyUser;
|
|
|
|
uid = config.ids.uids.privoxy;
|
2012-03-17 17:26:17 +00:00
|
|
|
description = "Privoxy daemon user";
|
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" ];
|
|
|
|
serviceConfig.ExecStart = "${privoxy}/sbin/privoxy --no-daemon --user ${privoxyUser} ${confFile}";
|
|
|
|
};
|
2009-10-05 16:11:32 +01:00
|
|
|
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-10-05 16:11:32 +01:00
|
|
|
}
|