technitium-dns-server: build from source instead of binary

This commit is contained in:
FabianRig 2024-04-05 08:28:38 +02:00
parent a95dd6aa93
commit 7002413a6b
3 changed files with 55 additions and 24 deletions

View File

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

View File

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

View File

@ -1,39 +1,60 @@
{ {
lib, lib,
stdenvNoCC, buildDotnetModule,
fetchurl, fetchFromGitHub,
makeWrapper, dotnetCorePackages,
dotnet-sdk_8,
nixosTests, 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"; pname = "technitium-dns-server";
version = "12.1"; version = "12.1";
src = fetchurl { src = fetchFromGitHub {
url = "https://download.technitium.com/dns/archive/${version}/DnsServerPortable.tar.gz"; owner = "TechnitiumSoftware";
hash = "sha256-G0M2xuYBZA3XXXaPs4pLrJmzAMbVJhiqISAvuCw3iZo="; 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 = '' projectFile = [ "DnsServerApp/DnsServerApp.csproj" ];
runHook preInstall
mkdir -p $out/{bin,share/${pname}-${version}} # move dependencies from TechnitiumLibrary to the expected directory
cp -r * $out/share/${pname}-${version}/. preBuild = ''
rm $out/share/${pname}-${version}/start.{sh,bat} mkdir -p ../TechnitiumLibrary/bin
rm $out/share/${pname}-${version}/DnsServerApp.exe cp -r ${technitium-library}/lib/TechnitiumLibrary/* ../TechnitiumLibrary/bin/
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 \ postFixup = ''
--add-flags "$out/share/${pname}-${version}/DnsServerApp.dll" mv $out/bin/DnsServerApp $out/bin/technitium-dns-server
runHook postInstall
''; '';
passthru.tests = { passthru.tests = {
@ -47,6 +68,6 @@ stdenvNoCC.mkDerivation rec {
license = lib.licenses.gpl3Only; license = lib.licenses.gpl3Only;
mainProgram = "technitium-dns-server"; mainProgram = "technitium-dns-server";
maintainers = with lib.maintainers; [ fabianrig ]; maintainers = with lib.maintainers; [ fabianrig ];
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; platforms = lib.platforms.linux;
}; };
} }