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