2009-10-12 19:27:57 +02:00
|
|
|
{ config, pkgs, ... }:
|
2009-10-05 17:11:32 +02:00
|
|
|
|
2009-10-12 19:27:57 +02:00
|
|
|
with pkgs.lib;
|
2009-10-05 17:11:32 +02:00
|
|
|
|
2009-10-12 19:27:57 +02:00
|
|
|
let
|
2009-10-05 17:11:32 +02:00
|
|
|
|
|
|
|
inherit (pkgs) privoxy;
|
|
|
|
|
|
|
|
stateDir = "/var/spool/privoxy";
|
|
|
|
|
|
|
|
privoxyUser = "privoxy";
|
|
|
|
|
2010-05-02 06:38:45 +02:00
|
|
|
privoxyFlags = "--no-daemon --user ${privoxyUser} ${privoxyCfg}";
|
2009-10-05 17:11:32 +02:00
|
|
|
|
|
|
|
privoxyCfg = pkgs.writeText "privoxy.conf" ''
|
|
|
|
listen-address ${config.services.privoxy.listenAddress}
|
|
|
|
logdir ${config.services.privoxy.logDir}
|
|
|
|
confdir ${privoxy}/etc
|
|
|
|
filterfile default.filter
|
|
|
|
|
|
|
|
${config.services.privoxy.extraConfig}
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-05 17:11:32 +02:00
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-05 17:11:32 +02:00
|
|
|
services.privoxy = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to run the machine as a HTTP proxy server.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
listenAddress = mkOption {
|
|
|
|
default = "127.0.0.1:8118";
|
|
|
|
description = ''
|
|
|
|
Address the proxy server is listening to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
logDir = mkOption {
|
|
|
|
default = "/var/log/privoxy" ;
|
|
|
|
description = ''
|
|
|
|
Location for privoxy log files.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
default = "" ;
|
|
|
|
description = ''
|
|
|
|
Extra configuration. Contents will be added verbatim to the configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.privoxy.enable {
|
2012-03-17 18:26:17 +01:00
|
|
|
|
2009-10-05 17:11:32 +02:00
|
|
|
environment.systemPackages = [ privoxy ];
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-05 17:11:32 +02:00
|
|
|
users.extraUsers = singleton
|
|
|
|
{ name = privoxyUser;
|
|
|
|
uid = config.ids.uids.privoxy;
|
2012-03-17 18:26:17 +01:00
|
|
|
description = "Privoxy daemon user";
|
2009-10-05 17:11:32 +02:00
|
|
|
home = stateDir;
|
|
|
|
};
|
|
|
|
|
2009-10-12 20:09:34 +02:00
|
|
|
jobs.privoxy =
|
2009-10-12 19:27:57 +02:00
|
|
|
{ name = "privoxy";
|
2009-10-05 17:11:32 +02:00
|
|
|
|
2009-10-12 19:27:57 +02:00
|
|
|
startOn = "startup";
|
2009-10-05 17:11:32 +02:00
|
|
|
|
2009-10-12 19:27:57 +02:00
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
mkdir -m 0755 -p ${stateDir}
|
|
|
|
chown ${privoxyUser} ${stateDir}
|
|
|
|
'';
|
2009-10-05 17:11:32 +02:00
|
|
|
|
2009-10-12 19:27:57 +02:00
|
|
|
exec = "${privoxy}/sbin/privoxy ${privoxyFlags}";
|
|
|
|
};
|
2009-10-05 17:11:32 +02:00
|
|
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-05 17:11:32 +02:00
|
|
|
}
|