From 6adc09ed308e088481728c7f25ecabf609764254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 7 Feb 2020 15:21:12 +0000 Subject: [PATCH] knot: put runtime paths outside the nix store Otherwise knot tries to write to non-writable directories. This for example breaks dnssec signing. While it's possible to overwrite these path in the configuration, having a sane defaults is nicer. --- pkgs/servers/dns/knot-dns/default.nix | 19 +++++++++-- .../knot-dns/dont-create-run-time-dirs.patch | 32 +++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 pkgs/servers/dns/knot-dns/dont-create-run-time-dirs.patch diff --git a/pkgs/servers/dns/knot-dns/default.nix b/pkgs/servers/dns/knot-dns/default.nix index c3d63a54ac0d..234a39574506 100644 --- a/pkgs/servers/dns/knot-dns/default.nix +++ b/pkgs/servers/dns/knot-dns/default.nix @@ -1,5 +1,6 @@ { stdenv, fetchurl, pkgconfig, gnutls, liburcu, lmdb, libcap_ng, libidn2, libunistring , systemd, nettle, libedit, zlib, libiconv, libintl +, autoreconfHook }: let inherit (stdenv.lib) optional optionals; in @@ -16,7 +17,19 @@ stdenv.mkDerivation rec { outputs = [ "bin" "out" "dev" ]; - nativeBuildInputs = [ pkgconfig ]; + configureFlags = [ + "--with-configdir=/etc/knot" + "--with-rundir=/run/knot" + "--with-storage=/var/lib/knot" + ]; + + patches = [ + # Don't try to create directories like /var/lib/knot at build time. + # They are later created from NixOS itself. + ./dont-create-run-time-dirs.patch + ]; + + nativeBuildInputs = [ pkgconfig autoreconfHook ]; buildInputs = [ gnutls liburcu libidn2 libunistring nettle libedit @@ -33,7 +46,9 @@ stdenv.mkDerivation rec { doCheck = true; doInstallCheck = false; # needs pykeymgr? - postInstall = ''rm -r "$out"/var "$out"/lib/*.la''; + postInstall = '' + rm -r "$out"/lib/*.la + ''; meta = with stdenv.lib; { description = "Authoritative-only DNS server from .cz domain registry"; diff --git a/pkgs/servers/dns/knot-dns/dont-create-run-time-dirs.patch b/pkgs/servers/dns/knot-dns/dont-create-run-time-dirs.patch new file mode 100644 index 000000000000..9fe165e7681d --- /dev/null +++ b/pkgs/servers/dns/knot-dns/dont-create-run-time-dirs.patch @@ -0,0 +1,32 @@ +diff --git a/samples/Makefile.am b/samples/Makefile.am +index c253c91..107401d 100644 +--- a/samples/Makefile.am ++++ b/samples/Makefile.am +@@ -19,11 +19,6 @@ EXTRA_DIST = knot.sample.conf.in example.com.zone + + if HAVE_DAEMON + +-install-data-local: knot.sample.conf +- if [ \! -f $(DESTDIR)/$(config_dir)/knot.sample.conf ]; then \ +- $(INSTALL) -d $(DESTDIR)/$(config_dir); \ +- $(INSTALL_DATA) knot.sample.conf $(srcdir)/example.com.zone $(DESTDIR)/$(config_dir); \ +- fi + uninstall-local: + -rm -rf $(DESTDIR)/$(config_dir)/knot.sample.conf \ + $(DESTDIR)/$(config_dir)/example.com.zone +diff --git a/src/utils/Makefile.inc b/src/utils/Makefile.inc +index e6765d9..d859d23 100644 +--- a/src/utils/Makefile.inc ++++ b/src/utils/Makefile.inc +@@ -79,11 +79,6 @@ endif HAVE_DNSTAP + endif HAVE_UTILS + + if HAVE_DAEMON +-# Create storage and run-time directories +-install-data-hook: +- $(INSTALL) -d $(DESTDIR)/@config_dir@ +- $(INSTALL) -d $(DESTDIR)/@run_dir@ +- $(INSTALL) -d $(DESTDIR)/@storage_dir@ + + sbin_PROGRAMS = knotc knotd +