1 { lib, stdenv, fetchurl, pkg-config, dbus, nettle, fetchpatch
2 , libidn, libnetfilter_conntrack, buildPackages }:
6 copts = concatStringsSep " " ([
9 ] ++ optionals stdenv.isLinux [
14 stdenv.mkDerivation rec {
19 url = "http://www.thekelleys.org.uk/dnsmasq/${pname}-${version}.tar.xz";
20 sha256 = "sha256-YDGVxktzE3YJsH4QJK4LN/ZSsvX+Rn3OZphbPRhQBQw=";
23 postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
24 sed '1i#include <linux/sockios.h>' -i src/dhcp.c
28 makeFlagsArray=("COPTS=${copts}")
35 "LOCALEDIR=$(out)/share/locale"
36 "PKG_CONFIG=${buildPackages.pkg-config}/bin/${buildPackages.pkg-config.targetPrefix}pkg-config"
39 hardeningEnable = [ "pie" ];
41 postBuild = optionalString stdenv.isLinux ''
42 make -C contrib/lease-tools
45 # XXX: Does the systemd service definition really belong here when our NixOS
46 # module can create it in Nix-land?
48 install -Dm644 trust-anchors.conf $out/share/dnsmasq/trust-anchors.conf
49 '' + optionalString stdenv.isDarwin ''
50 install -Dm644 contrib/MacOSX-launchd/uk.org.thekelleys.dnsmasq.plist \
51 $out/Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
52 substituteInPlace $out/Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist \
53 --replace "/usr/local/sbin" "$out/bin"
54 '' + optionalString stdenv.isLinux ''
55 install -Dm644 dbus/dnsmasq.conf $out/share/dbus-1/system.d/dnsmasq.conf
56 install -Dm755 contrib/lease-tools/dhcp_lease_time $out/bin/dhcp_lease_time
57 install -Dm755 contrib/lease-tools/dhcp_release $out/bin/dhcp_release
58 install -Dm755 contrib/lease-tools/dhcp_release6 $out/bin/dhcp_release6
60 mkdir -p $out/share/dbus-1/system-services
61 cat <<END > $out/share/dbus-1/system-services/uk.org.thekelleys.dnsmasq.service
63 Name=uk.org.thekelleys.dnsmasq
64 Exec=$out/bin/dnsmasq -k -1
66 SystemdService=dnsmasq.service
70 nativeBuildInputs = [ pkg-config ];
71 buildInputs = [ nettle libidn ]
72 ++ optionals stdenv.isLinux [ dbus libnetfilter_conntrack ];
75 description = "An integrated DNS, DHCP and TFTP server for small networks";
76 homepage = "http://www.thekelleys.org.uk/dnsmasq/doc.html";
77 license = licenses.gpl2;
78 platforms = with platforms; linux ++ darwin;
79 maintainers = with maintainers; [ eelco fpletz globin ];