Unverified Commit a9fad5b3 authored by Pol Dellaiera's avatar Pol Dellaiera Committed by GitHub
Browse files

Merge pull request #301739 from FabianRig/technitium-dns-build-from-source

technitium-dns-server: build from source instead of binary
parents 045f8630 7002413a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
# This file was automatically generated by passthru.fetch-deps.
# Please dont edit it manually, your changes might get overwritten!

{ fetchNuGet }: [
]
+5 −0
Original line number Diff line number Diff line
# This file was automatically generated by passthru.fetch-deps.
# Please dont edit it manually, your changes might get overwritten!

{ fetchNuGet }: [
]
+45 −24
Original line number Diff line number Diff line
{
  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 = ".";
  dotnet-sdk = dotnetCorePackages.sdk_8_0;
  dotnet-runtime = dotnetCorePackages.aspnetcore_8_0;

  nativeBuildInputs = [ makeWrapper ];
  nugetDeps = ./nuget-deps.nix;

  installPhase = ''
    runHook preInstall
  projectFile = [ "DnsServerApp/DnsServerApp.csproj" ];

    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

    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;
  };
}