-
-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from carlosdagos/privoxy-service
Add a privoxy service
- Loading branch information
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
privoxy = pkgs.runCommand "privoxy-0.0.0" {} "mkdir $out"; | ||
in | ||
|
||
{ | ||
services.privoxy.enable = true; | ||
services.privoxy.package = privoxy; | ||
services.privoxy.config = "forward / ."; | ||
|
||
test = '' | ||
echo >&2 "checking privoxy service in ~/Library/LaunchAgents" | ||
grep "org.nixos.privoxy" ${config.out}/user/Library/LaunchAgents/org.nixos.privoxy.plist | ||
echo grep "${privoxy}/bin/privoxy" ${config.out}/user/Library/LaunchAgents/org.nixos.privoxy.plist | ||
grep "${privoxy}/bin/privoxy" ${config.out}/user/Library/LaunchAgents/org.nixos.privoxy.plist | ||
echo >&2 "checking config in /etc/privoxy-config" | ||
grep "forward / ." ${config.out}/etc/privoxy-config | ||
''; | ||
} |