nix-config/pkgs/unbound-zones-adblock/default.nix
Bruno BELANYI cd02cbff45
All checks were successful
continuous-integration/drone/push Build is passing
pkgs: use 'lib' as first input
This is the idiomatic style in nixpkgs.
2021-06-16 20:13:25 +02:00

39 lines
1.1 KiB
Nix

{ lib, fetchFromGitHub, gawk, stdenvNoCC, unified-hosts-lists }:
stdenvNoCC.mkDerivation rec {
name = "unbound-zones-adblock";
version = unified-hosts-lists.version;
src = unified-hosts-lists;
phases = [ "installPhase" ];
installPhase =
let
gawkCmd = lib.concatStringsSep " " [
''${gawk}/bin/awk''
'''{sub(/\r$/,"")}''
''{sub(/^127\.0\.0\.1/,"0.0.0.0")}''
''BEGIN { OFS = "" }''
''NF == 2 && $1 == "0.0.0.0" { print "local-zone: \"", $2, "\" static"}' ''
];
in
''
mkdir -p $out
for file in $src/*; do
${gawkCmd} $file | tr '[:upper:]' '[:lower:]' | sort -u > $out/$(basename $file)
done
'';
meta = with lib; {
description = "Unified host lists, ready to be used by unbound";
longDescription = ''
This is a simple derivation based on StevenBlack's unified hosts list.
The files have been modified for easy use wih unbound.
'';
homepage = "https://github.com/StevenBlack/hosts";
license = licenses.mit;
platforms = platforms.all;
maintainers = with maintainers; [ ambroisie ];
};
}