From 0d781369c03a81df74af5160066670da84bb5736 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 15 Jul 2014 10:07:25 -0400 Subject: [PATCH 1/2] polipo: update to 1.1.1 --- pkgs/servers/polipo/default.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/servers/polipo/default.nix b/pkgs/servers/polipo/default.nix index 3e49715b94d1..08ccbbd06c6b 100644 --- a/pkgs/servers/polipo/default.nix +++ b/pkgs/servers/polipo/default.nix @@ -1,12 +1,12 @@ { stdenv, fetchurl, texinfo }: -stdenv.mkDerivation rec { +stdenv.mkDerivation rec { name = "polipo-${version}"; - version = "1.0.4.1"; + version = "1.1.1"; src = fetchurl { - url = "http://freehaven.net/~chrisd/polipo/${name}.tar.gz"; - sha256 = "1ykwkyvmdw6fsaj2hc40971pkwf60hvi9c43whijim00qvgbyvwd"; + url = "http://www.pps.univ-paris-diderot.fr/~jch/software/files/polipo/${name}.tar.gz"; + sha256 = "05g09sg9qkkhnc2mxldm1w1xkxzs2ylybkjzs28w8ydbjc3pand2"; }; buildInputs = [ texinfo ]; @@ -16,7 +16,7 @@ stdenv.mkDerivation rec { homepage = http://www.pps.jussieu.fr/~jch/software/polipo/; description = "A small and fast caching web proxy"; license = licenses.mit; - maintainers = [ maintainers.phreedom ]; + maintainers = with maintainers; [ phreedom emery ]; platforms = platforms.all; }; } \ No newline at end of file From e5988bf4dd274a359271385030ab1a9fadb5c649 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 15 Jul 2014 10:16:58 -0400 Subject: [PATCH 2/2] polipo: new service expression --- nixos/modules/misc/ids.nix | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/networking/polipo.nix | 118 +++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 nixos/modules/services/networking/polipo.nix diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 31de680514e6..a71f5152bd15 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -136,6 +136,7 @@ nsd = 126; gitolite = 127; znc = 128; + polipo = 129; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! @@ -246,6 +247,7 @@ nsd = 126; firebird = 127; znc = 128; + polipo = 129; # When adding a gid, make sure it doesn't match an existing uid. And don't use gids above 399! diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index a9039eea71d4..a5a2d691d7a8 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -215,6 +215,7 @@ ./services/networking/openfire.nix ./services/networking/openvpn.nix ./services/networking/prayer.nix + ./services/networking/polipo.nix ./services/networking/privoxy.nix ./services/networking/quassel.nix ./services/networking/radicale.nix diff --git a/nixos/modules/services/networking/polipo.nix b/nixos/modules/services/networking/polipo.nix new file mode 100644 index 000000000000..05ded84625d0 --- /dev/null +++ b/nixos/modules/services/networking/polipo.nix @@ -0,0 +1,118 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.polipo; + + polipoConfig = pkgs.writeText "polipo.conf" '' + proxyAddress = ${cfg.proxyAddress} + proxyPort = ${toString cfg.proxyPort} + allowedClients = ${concatStringsSep ", " cfg.allowedClients} + ${optionalString (cfg.parentProxy != "") "parentProxy = ${cfg.parentProxy}" } + ${optionalString (cfg.socksParentProxy != "") "socksParentProxy = ${cfg.socksParentProxy}" } + ${config.services.polipo.extraConfig} + ''; + +in + +{ + + options = { + + services.polipo = { + + enable = mkOption { + type = types.bool; + default = false; + description = "Whether to run the polipo caching web proxy."; + }; + + proxyAddress = mkOption { + type = types.string; + default = "127.0.0.1"; + description = "IP address on which Polipo will listen."; + }; + + proxyPort = mkOption { + type = types.int; + default = 8123; + description = "TCP port on which Polipo will listen."; + }; + + allowedClients = mkOption { + type = types.listOf types.string; + default = [ "127.0.0.1" "::1" ]; + example = [ "127.0.0.1" "::1" "134.157.168.0/24" "2001:660:116::/48" ]; + description = '' + List of IP addresses or network addresses that may connect to Polipo. + ''; + }; + + parentProxy = mkOption { + type = types.string; + default = ""; + example = "localhost:8124"; + description = '' + Hostname and port number of an HTTP parent proxy; + it should have the form ‘host:port’. + ''; + }; + + socksParentProxy = mkOption { + type = types.string; + default = ""; + example = "localhost:9050"; + description = '' + Hostname and port number of an SOCKS parent proxy; + it should have the form ‘host:port’. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = '' + Polio configuration. Contents will be added + verbatim to the configuration file. + ''; + }; + + }; + + }; + + config = mkIf cfg.enable { + + users.extraUsers = singleton + { name = "polipo"; + uid = config.ids.uids.polipo; + description = "Polipo caching proxy user"; + home = "/var/cache/polipo"; + createHome = true; + }; + + users.extraGroups = singleton + { name = "polipo"; + gid = config.ids.gids.polipo; + members = [ "polipo" ]; + }; + + systemd.services.polipo = { + description = "caching web proxy"; + after = [ "network.target" "nss-lookup.target" ]; + wantedBy = [ "multi-user.target"]; + preStart = '' + ${pkgs.coreutils}/bin/chown polipo:polipo /var/cache/polipo -R + ''; + serviceConfig = { + ExecStart = "${pkgs.polipo}/bin/polipo -c ${polipoConfig}"; + ExecReload = "${pkgs.coreutils}/bin/kill -USR1 $MAINPID"; + User = "polipo"; + }; + }; + + }; + +} \ No newline at end of file