From 25300d75be2336ad9e938bd5102ad8ba11149eb7 Mon Sep 17 00:00:00 2001
From: Harry Ying <lexugeyky@outlook.com>
Date: Fri, 13 Mar 2020 00:13:12 +0800
Subject: [PATCH] smartdns: init at 30

---
 pkgs/tools/networking/smartdns/default.nix | 38 ++++++++++++++++++++++
 pkgs/top-level/all-packages.nix            |  2 ++
 2 files changed, 40 insertions(+)
 create mode 100644 pkgs/tools/networking/smartdns/default.nix

diff --git a/pkgs/tools/networking/smartdns/default.nix b/pkgs/tools/networking/smartdns/default.nix
new file mode 100644
index 000000000000..62a9aaf216cc
--- /dev/null
+++ b/pkgs/tools/networking/smartdns/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchFromGitHub, openssl }:
+
+stdenv.mkDerivation rec {
+  pname = "smartdns";
+  version =
+    "30"; # This would be used later in the next release as the FHS commit integrated into realse 31.
+
+  src = fetchFromGitHub {
+    owner = "pymumu";
+    repo = pname;
+    rev = "3ad7cd7f454eec2fbdf338c0eb0541da301f1e73";
+    sha256 = "1y9p8gxpj2k4a10maggkxg8l55jvr7x1wyxi69waxf56ggh2dvv0";
+  };
+
+  buildInputs = [ openssl ];
+
+  makeFlags = [
+    "PREFIX=${placeholder "out"}"
+    "SYSTEMDSYSTEMUNITDIR=${placeholder "out"}/lib/systemd/system"
+    "RUNSTATEDIR=/run"
+  ];
+
+  installFlags = [ "SYSCONFDIR=${placeholder "out"}/etc" ];
+
+  meta = with stdenv.lib; {
+    description =
+      "A local DNS server to obtain the fastest website IP for the best Internet experience";
+    longDescription = ''
+      SmartDNS is a local DNS server. SmartDNS accepts DNS query requests from local clients, obtains DNS query results from multiple upstream DNS servers, and returns the fastest access results to clients.
+      Avoiding DNS pollution and improving network access speed, supports high-performance ad filtering.
+      Unlike dnsmasq's all-servers, smartdns returns the fastest access resolution.
+    '';
+    homepage = "https://github.com/pymumu/smartdns";
+    maintainers = [ maintainers.lexuge ];
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index ad0159345cdd..0a0f325e21f1 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -6507,6 +6507,8 @@ in
     conf = config.slstatus.conf or null;
   };
 
+  smartdns = callPackage ../tools/networking/smartdns { };
+
   smartmontools = callPackage ../tools/system/smartmontools {
     inherit (darwin.apple_sdk.frameworks) IOKit ApplicationServices;
   };