about summary refs log tree commit diff
path: root/pkgs/by-name/te/technitium-dns-server/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/te/technitium-dns-server/package.nix')
-rw-r--r--pkgs/by-name/te/technitium-dns-server/package.nix69
1 files changed, 45 insertions, 24 deletions
diff --git a/pkgs/by-name/te/technitium-dns-server/package.nix b/pkgs/by-name/te/technitium-dns-server/package.nix
index 47ff83663d99..b369a4586951 100644
--- a/pkgs/by-name/te/technitium-dns-server/package.nix
+++ b/pkgs/by-name/te/technitium-dns-server/package.nix
@@ -1,39 +1,60 @@
 {
   lib,
-  stdenvNoCC,
-  fetchurl,
-  makeWrapper,
-  dotnet-sdk_8,
+  buildDotnetModule,
+  fetchFromGitHub,
+  dotnetCorePackages,
   nixosTests,
 }:
-stdenvNoCC.mkDerivation rec {
+let
+  technitium-library = buildDotnetModule rec {
+    pname = "TechnitiumLibrary";
+    version = "40a7bc7a52cf5d2c371215ea7f5f6fdf71dc1d9c";
+
+    src = fetchFromGitHub {
+      owner = "TechnitiumSoftware";
+      repo = "TechnitiumLibrary";
+      rev = version;
+      hash = "sha256-FNCZH8LZXYyrz5SRIV8P7MruN+t6Qvl96Aa73q3InMI=";
+      name = "${pname}-${version}";
+    };
+
+    dotnet-sdk = dotnetCorePackages.sdk_8_0;
+
+    nugetDeps = ./library-nuget-deps.nix;
+
+    projectFile = [
+      "TechnitiumLibrary.ByteTree/TechnitiumLibrary.ByteTree.csproj"
+      "TechnitiumLibrary.Net/TechnitiumLibrary.Net.csproj"
+    ];
+  };
+in
+buildDotnetModule rec {
   pname = "technitium-dns-server";
   version = "12.1";
 
-  src = fetchurl {
-    url = "https://download.technitium.com/dns/archive/${version}/DnsServerPortable.tar.gz";
-    hash = "sha256-G0M2xuYBZA3XXXaPs4pLrJmzAMbVJhiqISAvuCw3iZo=";
+  src = fetchFromGitHub {
+    owner = "TechnitiumSoftware";
+    repo = "DnsServer";
+    rev = "refs/tags/v${version}";
+    hash = "sha256-TfVWGomvKV7QeJUyFMNDAnHKY3YTEwWPxTlW6RhmsR4=";
+    name = "${pname}-${version}";
   };
 
-  sourceRoot = ".";
-
-  nativeBuildInputs = [ makeWrapper ];
+  dotnet-sdk = dotnetCorePackages.sdk_8_0;
+  dotnet-runtime = dotnetCorePackages.aspnetcore_8_0;
 
-  installPhase = ''
-    runHook preInstall
+  nugetDeps = ./nuget-deps.nix;
 
-    mkdir -p $out/{bin,share/${pname}-${version}}
-    cp -r * $out/share/${pname}-${version}/.
-    rm $out/share/${pname}-${version}/start.{sh,bat}
-    rm $out/share/${pname}-${version}/DnsServerApp.exe
-    rm $out/share/${pname}-${version}/env-vars
-    # Remove systemd.service in favor of a separate module (including firewall configuration).
-    rm $out/share/${pname}-${version}/systemd.service
+  projectFile = [ "DnsServerApp/DnsServerApp.csproj" ];
 
-    makeWrapper "${dotnet-sdk_8}/bin/dotnet" $out/bin/technitium-dns-server \
-      --add-flags "$out/share/${pname}-${version}/DnsServerApp.dll"
+  # move dependencies from TechnitiumLibrary to the expected directory
+  preBuild = ''
+    mkdir -p ../TechnitiumLibrary/bin
+    cp -r ${technitium-library}/lib/TechnitiumLibrary/* ../TechnitiumLibrary/bin/
+  '';
 
-    runHook postInstall
+  postFixup = ''
+    mv $out/bin/DnsServerApp $out/bin/technitium-dns-server
   '';
 
   passthru.tests = {
@@ -47,6 +68,6 @@ stdenvNoCC.mkDerivation rec {
     license = lib.licenses.gpl3Only;
     mainProgram = "technitium-dns-server";
     maintainers = with lib.maintainers; [ fabianrig ];
-    sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
+    platforms = lib.platforms.linux;
   };
 }