From a150b5db213e2fd9474ff7f4a6f639b22ece63ef Mon Sep 17 00:00:00 2001 From: Gabor X Toth <*@tg-x.net> Date: Thu, 6 Oct 2016 16:01:48 +0000 Subject: [PATCH] nix: debug build, ccache --- default.nix | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index 4e4a117c2..ef3ed2c6d 100644 --- a/default.nix +++ b/default.nix @@ -34,8 +34,23 @@ # c) use nixpkgs at a given path # --arg pkgs /path/to/nixpkgs # +## CCACHE +# +# To enable ccache, use the following: +# +# --argstr ccache_dir /var/cache/ccache -{ pkgs ? null }: +# or when using nix-shell: +# --argstr ccache_dir ~/.ccache +# +# and make sure the given directory is writable by the nixpkgs group when using nix-build or nix-env -i, +# or the current user when using nix-shell +# + +{ + pkgs ? null, + ccache_dir ? "", +}: let syspkgs = import { }; @@ -54,13 +69,14 @@ let import { } else import pkgs {}; + stdenv = usepkgs.stdenvAdapters.keepDebugInfo usepkgs.stdenv; -in with usepkgs; usepkgs.stdenv.mkDerivation rec { +in with usepkgs; stdenv.mkDerivation rec { src = ./.; name = "gnunet-dev"; buildInputs = [ - makeWrapper pkgconfig + makeWrapper pkgconfig autoconf automake ccache adns curl gettext gmp gnutls gss ncurses openldap zlib sqlite mariadb postgresql libextractor libgcrypt libgnurl libidn libmicrohttpd libpsl libtool libunistring libxml2 @@ -70,6 +86,8 @@ in with usepkgs; usepkgs.stdenv.mkDerivation rec { test -e Makefile && make distclean ''; + NIX_CFLAGS_COMPILE = "-ggdb -O0"; + configureFlags = [ "--enable-gcc-hardening" "--enable-linker-hardening" @@ -82,6 +100,13 @@ in with usepkgs; usepkgs.stdenv.mkDerivation rec { preConfigure = '' ./bootstrap configureFlags="$configureFlags --with-nssdir=$out/lib" + + if [ -n "${ccache_dir}" ]; then + export CC='ccache gcc' + export CCACHE_COMPRESS=1 + export CCACHE_DIR="${ccache_dir}" + export CCACHE_UMASK=007 + fi ''; doCheck = false; -- 2.25.1