diff options
author | Rob Vermaas <rob.vermaas@gmail.com> | 2009-10-05 15:11:32 +0000 |
---|---|---|
committer | Rob Vermaas <rob.vermaas@gmail.com> | 2009-10-05 15:11:32 +0000 |
commit | 0e2c160e2e7decf36f6a428bd1b802e7d1d5c2b1 (patch) | |
tree | cc15ea0e9e4cee19b64b570171cd56965c8b6d73 /modules/services/networking/privoxy.nix | |
parent | 8ab6828f31688151367c85756241111f6c48d964 (diff) | |
download | nixlib-0e2c160e2e7decf36f6a428bd1b802e7d1d5c2b1.tar nixlib-0e2c160e2e7decf36f6a428bd1b802e7d1d5c2b1.tar.gz nixlib-0e2c160e2e7decf36f6a428bd1b802e7d1d5c2b1.tar.bz2 nixlib-0e2c160e2e7decf36f6a428bd1b802e7d1d5c2b1.tar.lz nixlib-0e2c160e2e7decf36f6a428bd1b802e7d1d5c2b1.tar.xz nixlib-0e2c160e2e7decf36f6a428bd1b802e7d1d5c2b1.tar.zst nixlib-0e2c160e2e7decf36f6a428bd1b802e7d1d5c2b1.zip |
added privoxy nixos module
svn path=/nixos/trunk/; revision=17646
Diffstat (limited to 'modules/services/networking/privoxy.nix')
-rw-r--r-- | modules/services/networking/privoxy.nix | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/modules/services/networking/privoxy.nix b/modules/services/networking/privoxy.nix new file mode 100644 index 000000000000..4e2585aba81a --- /dev/null +++ b/modules/services/networking/privoxy.nix @@ -0,0 +1,103 @@ +{pkgs, config, ...}: + +let + + inherit (pkgs.lib) mkOption mkIf singleton; + + inherit (pkgs) privoxy; + + stateDir = "/var/spool/privoxy"; + + privoxyUser = "privoxy"; + + modprobe = config.system.sbin.modprobe; + + privoxyFlags = "--no-daemon ${privoxyCfg}"; + + 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 + + options = { + + 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 { + environment.systemPackages = [ privoxy ]; + + users.extraUsers = singleton + { name = privoxyUser; + uid = config.ids.uids.privoxy; + description = "privoxy daemon user"; + home = stateDir; + }; + + jobs = singleton { + + name = "privoxy"; + + startOn = "startup"; + stopOn = "shutdown"; + + preStart = '' + mkdir -m 0755 -p ${stateDir} + chown ${privoxyUser} ${stateDir} + + # Needed to run privoxy as an unprivileged user. + ${modprobe}/sbin/modprobe capability || true + ''; + + script = '' + ${privoxy}/sbin/privoxy ${privoxyFlags} + ''; + + }; + + }; + +} |