My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nomicon/pkgs/servers/dns/knot-resolver/default.nix

107 lines
3.1 KiB

{ stdenv, fetchurl, fetchpatch, runCommand, pkgconfig, hexdump, which
, knot-dns, luajit, libuv, lmdb, gnutls, nettle
, cmocka, systemd, dns-root-data, makeWrapper
, extraFeatures ? false /* catch-all if defaults aren't enough */
, luajitPackages
}:
let # un-indented, over the whole file
result = if extraFeatures then wrapped-full else unwrapped;
inherit (stdenv.lib) optional;
unwrapped = stdenv.mkDerivation rec {
name = "knot-resolver-${version}";
version = "3.2.1";
src = fetchurl {
url = "https://secure.nic.cz/files/knot-resolver/${name}.tar.xz";
sha256 = "d1396888ec3a63f19dccdf2b7dbcb0d16a5d8642766824b47f4c21be90ce362b";
};
patches = [
(fetchpatch {
name = "support-libzscanner-2.8.diff";
url = "https://gitlab.labs.nic.cz/knot/knot-resolver/commit/186f263.diff";
sha256 = "19zqigvc7m2a4j6bk9whx7gj0v009568rz5qwk052z7pzfikr8mk";
})
];
# Short-lived cross fix, as upstream is migrating to meson anyway.
postPatch = ''
substituteInPlace platform.mk --replace "objdump" "$OBJDUMP"
'';
outputs = [ "out" "dev" ];
configurePhase = "patchShebangs scripts/";
nativeBuildInputs = [ pkgconfig which hexdump ];
# http://knot-resolver.readthedocs.io/en/latest/build.html#requirements
buildInputs = [ knot-dns luajit libuv gnutls nettle lmdb ]
++ optional stdenv.isLinux systemd # sd_notify
## optional dependencies; TODO: libedit, dnstap
;
checkInputs = [ cmocka ];
makeFlags = [
"PREFIX=$(out)"
"ROOTHINTS=${dns-root-data}/root.hints"
"KEYFILE_DEFAULT=${dns-root-data}/root.ds"
];
CFLAGS = [ "-O2" "-DNDEBUG" ];
enableParallelBuilding = true;
doCheck = true;
doInstallCheck = false; # FIXME
preInstallCheck = ''
patchShebangs tests/config/runtest.sh
'';
postInstall = ''
rm "$out"/etc/knot-resolver/root.hints # using system-wide instead
'';
meta = with stdenv.lib; {
description = "Caching validating DNS resolver, from .cz domain registry";
homepage = https://knot-resolver.cz;
license = licenses.gpl3Plus;
# Platforms using negative pointers for stack won't work ATM due to LuaJIT impl.
platforms = filter (p: p != "aarch64-linux") platforms.unix;
maintainers = [ maintainers.vcunat /* upstream developer */ ];
};
};
# FIXME: revert this back after resolving
# https://github.com/NixOS/nixpkgs/pull/63108#issuecomment-508670438
wrapped-full =
with stdenv.lib;
with luajitPackages;
let
luaPkgs = [
luasec luasocket # trust anchor bootstrap, prefill module
luaPackages: Replace all rockspec packages with generated ones luaPackages replaced by generated ones: - bit32 - compat53 - cqueues - luacyrussasl -> cyrussasl (luarocks name) - luaexpat - luadbi -> luadbi front-end module + separate backend modules luadbi-{mysql,postgresql,sqlite3} - luafilesystem - luaossl - luasec - luasocket - luastdlib -> stdlib (luarocks name) - lrexlib -> lrexlib-pcre (we already have lrexlib-gnu and lrexlib-posix, lrexlib-pcre however appears to be the variant used in mudlet, which is the only current dep in nixpkgs) - luasqlite -> luasql-sqlite3 (luarocks name) - lfs -> luafilesytem (we literally had two manually written luafilesystem expressions, under different names) Changes and additions to overrides to generated luarocks packgaes, including: - busted: Install bash completions along with the zsh ones - cqueues: - Perform minor surgery on the rockspec to allow using a single rockspec to build for all supported Lua versions - Add a patch by @vcunat to work around a build issue - luuid: Wrote a tiny patch to allow for Lua 5.1/Luajit compatibility - General changes: - Sorted the packages - Attempted to make the formatting consistent - Preferenced `.override` instead of `.overrideAttrs` wherever possible Minor changes to other packages to adjust for the Lua package changes: - luakit expression simplified - prosody expression simplified; but users will now need to specify the luadbi backend module they intend to use in withExtraLibs - knot-resolver inputs correctd - mudlet inputs corrected (although this package was and should still be broken)
5 years ago
luafilesystem # prefill module
http # for http module; brings lots of deps; some are useful elsewhere
cqueues fifo lpeg lpeg_patterns luaossl compat53 basexx binaryheap
];
in runCommand unwrapped.name
{
nativeBuildInputs = [ makeWrapper ];
preferLocalBuild = true;
allowSubstitutes = false;
}
''
mkdir -p "$out"/{bin,share}
makeWrapper '${unwrapped}/bin/kresd' "$out"/bin/kresd \
--set LUA_PATH '${concatStringsSep ";" (map getLuaPath luaPkgs)}' \
--set LUA_CPATH '${concatStringsSep ";" (map getLuaCPath luaPkgs)}'
ln -sr '${unwrapped}/share/man' "$out"/share/
ln -sr "$out"/{bin,sbin}
'';
in result