diff options
| author | Carlos D <m@cdagostino.io> | 2018-08-02 10:09:22 +1000 |
|---|---|---|
| committer | Carlos D <m@cdagostino.io> | 2018-08-02 10:09:22 +1000 |
| commit | 41a6a40f5393c1652e65d1e557c755bcd2eccfb9 (patch) | |
| tree | 71bd8b22db7e455a78b1abc98d6b9efaeb662a49 /modules | |
| parent | fa3f67966bfb912eef0f76fc0566aef6d73ae330 (diff) | |
Add a privoxy service
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/services/privoxy/default.nix | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/modules/services/privoxy/default.nix b/modules/services/privoxy/default.nix new file mode 100644 index 0000000..5cb16c8 --- /dev/null +++ b/modules/services/privoxy/default.nix @@ -0,0 +1,66 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.privoxy; +in +{ + options = { + services.privoxy.enable = mkOption { + type = types.bool; + default = false; + description = "Whether to enable the privoxy proxy service."; + }; + + services.privoxy.listenAddress = mkOption { + type = types.str; + default = "127.0.0.1:8118"; + description = "The address and TCP port on which privoxy will listen."; + }; + + services.privoxy.package = mkOption { + type = types.package; + default = pkgs.privoxy; + example = literalExample "pkgs.privoxy"; + description = "This option specifies the privoxy package to use."; + }; + + services.privoxy.config = mkOption { + type = types.lines; + default = ""; + example = "forward / upstream.proxy:8080"; + description = "Config to use for privoxy"; + }; + + services.privoxy.templdir = mkOption { + type = types.path; + default = "${pkgs.privoxy}/etc/templates"; + defaultText = "\${pkgs.privoxy}/etc/templates"; + description = "Directory for privoxy template files."; + }; + + services.privoxy.confdir = mkOption { + type = types.nullOr types.path; + default = null; + description = "Directory for privoxy files such as .action and .filter."; + }; + }; + + config = mkIf cfg.enable { + environment.etc."privoxy-config".text = '' + ${optionalString (cfg.confdir != null) "confdir ${cfg.confdir}"} + templdir ${cfg.templdir} + listen-address ${cfg.listenAddress} + ${cfg.config} + ''; + + launchd.user.agents.privoxy = { + path = [ config.environment.systemPath ]; + command = '' + ${cfg.package}/bin/privoxy /etc/privoxy-config + ''; + serviceConfig.KeepAlive = true; + }; + }; +} |
