mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
privoxy: upstart to systemd conversion, actions file editing
fix missing actions and filters
This commit is contained in:
parent
47f84c63bb
commit
e7597b12b8
1 changed files with 44 additions and 32 deletions
|
@ -6,19 +6,18 @@ let
|
||||||
|
|
||||||
inherit (pkgs) privoxy;
|
inherit (pkgs) privoxy;
|
||||||
|
|
||||||
stateDir = "/var/spool/privoxy";
|
|
||||||
|
|
||||||
privoxyUser = "privoxy";
|
privoxyUser = "privoxy";
|
||||||
|
|
||||||
privoxyFlags = "--no-daemon --user ${privoxyUser} ${privoxyCfg}";
|
cfg = config.services.privoxy;
|
||||||
|
|
||||||
privoxyCfg = pkgs.writeText "privoxy.conf" ''
|
confFile = pkgs.writeText "privoxy.conf" ''
|
||||||
listen-address ${config.services.privoxy.listenAddress}
|
user-manual ${privoxy}/share/doc/privoxy/user-manual
|
||||||
logdir ${config.services.privoxy.logDir}
|
confdir ${privoxy}/etc/
|
||||||
confdir ${privoxy}/etc
|
listen-address ${cfg.listenAddress}
|
||||||
filterfile default.filter
|
enable-edit-actions ${if (cfg.enableEditActions == true) then "1" else "0"}
|
||||||
|
${concatMapStrings (f: "actionsfile ${f}\n") cfg.actionsFiles}
|
||||||
${config.services.privoxy.extraConfig}
|
${concatMapStrings (f: "filterfile ${f}\n") cfg.filterFiles}
|
||||||
|
${cfg.extraConfig}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
|
@ -32,27 +31,51 @@ in
|
||||||
services.privoxy = {
|
services.privoxy = {
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Whether to run the machine as a HTTP proxy server.
|
Whether to enable the Privoxy non-caching filtering proxy.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
listenAddress = mkOption {
|
listenAddress = mkOption {
|
||||||
|
type = types.str;
|
||||||
default = "127.0.0.1:8118";
|
default = "127.0.0.1:8118";
|
||||||
description = ''
|
description = ''
|
||||||
Address the proxy server is listening to.
|
Address the proxy server is listening to.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
logDir = mkOption {
|
actionsFiles = mkOption {
|
||||||
default = "/var/log/privoxy" ;
|
type = types.listOf types.str;
|
||||||
|
example = [ "match-all.action" "default.action" "/etc/privoxy/user.action" ];
|
||||||
|
default = [ "match-all.action" "default.action" ];
|
||||||
description = ''
|
description = ''
|
||||||
Location for privoxy log files.
|
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;
|
||||||
|
description = ''
|
||||||
|
Whether or not the web-based actions file editor may be used.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
extraConfig = mkOption {
|
||||||
|
type = types.lines;
|
||||||
default = "" ;
|
default = "" ;
|
||||||
description = ''
|
description = ''
|
||||||
Extra configuration. Contents will be added verbatim to the configuration file.
|
Extra configuration. Contents will be added verbatim to the configuration file.
|
||||||
|
@ -62,33 +85,22 @@ in
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf config.services.privoxy.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
environment.systemPackages = [ privoxy ];
|
|
||||||
|
|
||||||
users.extraUsers = singleton
|
users.extraUsers = singleton
|
||||||
{ name = privoxyUser;
|
{ name = privoxyUser;
|
||||||
uid = config.ids.uids.privoxy;
|
uid = config.ids.uids.privoxy;
|
||||||
description = "Privoxy daemon user";
|
description = "Privoxy daemon user";
|
||||||
home = stateDir;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
jobs.privoxy =
|
systemd.services.privoxy = {
|
||||||
{ name = "privoxy";
|
description = "Filtering web proxy";
|
||||||
|
after = [ "network.target" "nss-lookup.target" ];
|
||||||
startOn = "startup";
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
serviceConfig.ExecStart = "${privoxy}/sbin/privoxy --no-daemon --user ${privoxyUser} ${confFile}";
|
||||||
preStart =
|
};
|
||||||
''
|
|
||||||
mkdir -m 0755 -p ${stateDir}
|
|
||||||
chown ${privoxyUser} ${stateDir}
|
|
||||||
'';
|
|
||||||
|
|
||||||
exec = "${privoxy}/sbin/privoxy ${privoxyFlags}";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue