at 24.11-pre 73 lines 2.4 kB view raw
1{ lib, coreutils, curl, fetchFromGitHub, unzip, p7zip, gnused, gnugrep, stdenv 2, blacklist ? [ "adwords.google.com" ] 3, whitelist ? [ 4 ".dropbox.com" 5 " www.malwaredomainlists.com" 6 " www.arcamax.com" 7 " www.instructables.com" 8 " goo.gl" 9 " www.reddit.com" 10 " t.co" 11 " bit.ly" 12 " www.viddler.com" 13 " viddler.com" 14 " tinyurl.com" 15 " ompldr.org" 16 " www.ompldr.org" 17 "login.yahoo.com" 18 " l.yimg.com" 19 ".bp.blogspot.com" 20] }: 21 22stdenv.mkDerivation { 23 pname = "hostsblock"; 24 version = "20161213"; 25 26 src = fetchFromGitHub { 27 owner = "gaenserich"; 28 repo = "hostsblock"; 29 rev = "91cacbdfbfb5e7ae9ba3babf8de41e135270c310"; 30 sha256 = "1w91fbgf8v2nn0a6m8l6kd455km2j1lvpvqil4yxhrg018aigax0"; 31 }; 32 33 installPhase = '' 34 mkdir -p $out/bin 35 install -Dm744 src/hostsblock.sh $out/bin/hostsblock 36 install -Dm744 src/hostsblock-urlcheck.sh $out/bin/hostsblock-urlcheck 37 38 mkdir -p $out/lib 39 install -Dm644 src/hostsblock-common.sh $out/lib/ 40 41 mkdir -p $out/etc 42 install -Dm644 conf/hostsblock.conf $out/etc/ 43 ${lib.concatMapStrings (d: "echo ${d} >> $out/etc/black.list\n") blacklist} 44 ${lib.concatMapStrings (d: "echo ${d} >> $out/etc/white.list\n") whitelist} 45 install -Dm644 conf/hosts.head $out/etc/ 46 47 for f in $out/bin/* $out/lib/* $out/etc/hostsblock.conf; do 48 substituteInPlace $f --replace "/dev/shm" "/tmp" 49 substituteInPlace $f --replace "/usr/lib/" "$out/lib/" 50 substituteInPlace $f --replace "/etc/hostsblock/" "$out/etc/" 51 sed --in-place --regexp-extended "s|([\` ])curl |\1${curl}/bin/curl |g" $f 52 substituteInPlace $f --replace grep ${gnugrep}/bin/grep 53 substituteInPlace $f --replace " sed " " ${gnused}/bin/sed " 54 sed --in-place --regexp-extended "s|([^_])unzip |\1${unzip}/bin/unzip |" $f 55 sed --in-place --regexp-extended "s|7za([^,])|${p7zip}/bin/7za\1|g" $f 56 done 57 58 echo "postprocess(){ ${coreutils}/bin/true; }" >> $out/etc/hostsblock.conf 59 60 mkdir -p $out/share/dbus-1/system-services 61 install -Dm644 systemd/hostsblock.service $out/share/dbus-1/system-services 62 install -Dm644 systemd/hostsblock.timer $out/share/dbus-1/system-services 63 ''; 64 65 meta = with lib; { 66 description = "An ad- and malware-blocking script for Linux"; 67 homepage = "http://gaenserich.github.io/hostsblock/"; 68 license = licenses.gpl3; 69 maintainers = [ maintainers.nicknovitski ]; 70 platforms = platforms.unix; 71 }; 72 73}