1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-17 19:21:04 +00:00
nixpkgs/pkgs/servers/dns/knot-resolver/default.nix

112 lines
3.5 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl
# native deps.
, runCommand, pkgconfig, meson, ninja, makeWrapper
# build+runtime deps.
, knot-dns, luajitPackages, libuv, gnutls, lmdb, systemd, dns-root-data
# test-only deps.
, cmocka, which, cacert
, extraFeatures ? false /* catch-all if defaults aren't enough */
}:
let # un-indented, over the whole file
result = if extraFeatures then wrapped-full else unwrapped;
inherit (stdenv.lib) optional optionals concatStringsSep;
lua = luajitPackages;
# FIXME: remove these usages once resolving
# https://github.com/NixOS/nixpkgs/pull/63108#issuecomment-508670438
exportLuaPathsFor = luaPkgs: ''
export LUA_PATH='${ concatStringsSep ";" (map lua.getLuaPath luaPkgs)}'
export LUA_CPATH='${concatStringsSep ";" (map lua.getLuaCPath luaPkgs)}'
'';
unwrapped = stdenv.mkDerivation rec {
pname = "knot-resolver";
version = "4.3.0";
src = fetchurl {
url = "https://secure.nic.cz/files/knot-resolver/${pname}-${version}.tar.xz";
sha256 = "0ca0f171ae2b2d76830967a5150eb0fa496b48b2a48f41b2be65d3743aaece25";
};
outputs = [ "out" "dev" ];
preConfigure = ''
patchShebangs scripts/
''
+ stdenv.lib.optionalString doInstallCheck (exportLuaPathsFor [ lua.cqueues lua.basexx ]);
nativeBuildInputs = [ pkgconfig meson ninja ];
# http://knot-resolver.readthedocs.io/en/latest/build.html#requirements
buildInputs = [ knot-dns lua.lua libuv gnutls lmdb ]
++ optional stdenv.isLinux systemd # passing sockets, sd_notify
## optional dependencies; TODO: libedit, dnstap
;
mesonFlags = [
"-Dkeyfile_default=${dns-root-data}/root.ds"
"-Droot_hints=${dns-root-data}/root.hints"
"-Dinstall_kresd_conf=disabled" # not really useful; examples are inside share/doc/
"--default-library=static" # not used by anyone
]
++ optional doInstallCheck "-Dunit_tests=enabled"
++ optional (doInstallCheck && !stdenv.isDarwin) "-Dconfig_tests=enabled"
#"-Dextra_tests=enabled" # not suitable as in-distro tests; many deps, too.
;
postInstall = ''
rm "$out"/lib/libkres.a
'';
doInstallCheck = with stdenv; hostPlatform == buildPlatform;
installCheckInputs = [ cmocka which cacert ];
installCheckPhase = ''
meson test --print-errorlogs
'';
meta = with stdenv.lib; {
description = "Caching validating DNS resolver, from .cz domain registry";
homepage = https://knot-resolver.cz;
license = licenses.gpl3Plus;
platforms = 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)
2019-06-13 12:01:10 +01:00
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;
}
(exportLuaPathsFor luaPkgs
+ ''
mkdir -p "$out"/{bin,share}
makeWrapper '${unwrapped}/bin/kresd' "$out"/bin/kresd \
--set LUA_PATH "$LUA_PATH" \
--set LUA_CPATH "$LUA_CPATH"
ln -sr '${unwrapped}/share/man' "$out"/share/
ln -sr "$out"/{bin,sbin}
echo "Checking that 'http' module loads, i.e. lua search paths work:"
echo "modules.load('http')" > test-http.lua
echo -e 'quit()' | env -i "$out"/bin/kresd -a 127.0.0.1#53535 -c test-http.lua
'');
in result