1# Getdns and Stubby are released together, see https://getdnsapi.net/releases/
2
3{ lib, stdenv, fetchurl, cmake, darwin, doxygen, libidn2, libyaml, openssl
4, systemd, unbound, yq }:
5let
6 metaCommon = with lib; {
7 maintainers = with maintainers; [ leenaars ehmry ];
8 license = licenses.bsd3;
9 platforms = platforms.all;
10 };
11in rec {
12
13 getdns = stdenv.mkDerivation rec {
14 pname = "getdns";
15 version = "1.7.2";
16 outputs = [ "out" "dev" "lib" "man" ];
17
18 src = fetchurl {
19 url = "https://getdnsapi.net/releases/${pname}-${
20 with builtins;
21 concatStringsSep "-" (splitVersion version)
22 }/${pname}-${version}.tar.gz";
23 sha256 =
24 # upstream publishes hashes in hex format
25 "db89fd2a940000e03ecf48d0232b4532e5f0602e80b592be406fd57ad76fdd17";
26 };
27
28 nativeBuildInputs = [ cmake doxygen ];
29
30 buildInputs = [ libidn2 openssl unbound ];
31
32 # https://github.com/getdnsapi/getdns/issues/517
33 postPatch = ''
34 substituteInPlace getdns.pc.in \
35 --replace '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ \
36 --replace '$'{prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@
37 '';
38
39 postInstall = "rm -r $out/share/doc";
40
41 meta = with lib;
42 metaCommon // {
43 description = "A modern asynchronous DNS API";
44 longDescription = ''
45 getdns is an implementation of a modern asynchronous DNS API; the
46 specification was originally edited by Paul Hoffman. It is intended to make all
47 types of DNS information easily available to application developers and non-DNS
48 experts. DNSSEC offers a unique global infrastructure for establishing and
49 enhancing cryptographic trust relations. With the development of this API the
50 developers intend to offer application developers a modern and flexible
51 interface that enables end-to-end trust in the DNS architecture, and which will
52 inspire application developers to implement innovative security solutions in
53 their applications.
54 '';
55 homepage = "https://getdnsapi.net";
56 };
57 };
58
59 stubby = stdenv.mkDerivation rec {
60 pname = "stubby";
61 version = "0.4.2";
62 outputs = [ "out" "man" "stubbyExampleJson" ];
63
64 inherit (getdns) src;
65 sourceRoot = "${getdns.name}/stubby";
66
67 nativeBuildInputs = [ cmake doxygen yq ];
68
69 buildInputs = [ getdns libyaml openssl systemd ]
70 ++ lib.optionals stdenv.isDarwin [ darwin.Security ];
71
72 postInstall = ''
73 rm -r $out/share/doc
74 yq \
75 < $NIX_BUILD_TOP/$sourceRoot/stubby.yml.example \
76 > $stubbyExampleJson
77 '';
78
79 passthru.settingsExample = with builtins;
80 fromJSON (readFile stubby.stubbyExampleJson);
81
82 meta = with lib;
83 metaCommon // {
84 description = "A local DNS Privacy stub resolver (using DNS-over-TLS)";
85 longDescription = ''
86 Stubby is an application that acts as a local DNS Privacy stub
87 resolver (using RFC 7858, aka DNS-over-TLS). Stubby encrypts DNS
88 queries sent from a client machine (desktop or laptop) to a DNS
89 Privacy resolver increasing end user privacy. Stubby is developed by
90 the getdns team.
91 '';
92 homepage = "https://dnsprivacy.org/wiki/x/JYAT";
93 };
94 };
95
96}