diff --git a/pkgs/development/tools/misc/distcc/default.nix b/pkgs/development/tools/misc/distcc/default.nix index 8af8e0ca8001..6101650c6def 100644 --- a/pkgs/development/tools/misc/distcc/default.nix +++ b/pkgs/development/tools/misc/distcc/default.nix @@ -1,13 +1,12 @@ -{ stdenv, fetchurl, popt, avahi, pkgconfig, python, gtk +{ stdenv, fetchurl, popt, avahi, pkgconfig, python, gtk, runCommand, gcc , sysconfDir ? "" # set this parameter to override the default value $out/etc , static ? false }: -let name = "distcc"; - version = "3.1"; -in - -stdenv.mkDerivation { +let +name = "distcc"; +version = "3.1"; +distcc = stdenv.mkDerivation { name = "${name}-${version}"; src = fetchurl { url = "http://distcc.googlecode.com/files/${name}-${version}.tar.bz2"; @@ -36,6 +35,32 @@ stdenv.mkDerivation { # The test suite fails because it uses hard-coded paths, i.e. /usr/bin/gcc. doCheck = false; + passthru = { + # A derivation that provides gcc and g++ commands, but that + # will end up calling distcc for the given cacheDir + links = extraConfig : (runCommand "distcc-links" + { inherit (gcc) langC langCC; } + '' + mkdir -p $out/bin + if [ $langC -eq 1 ]; then + cat > $out/bin/gcc << EOF + #!/bin/sh + ${extraConfig} + exec ${distcc}/bin/distcc gcc "\$@" + EOF + chmod +x $out/bin/gcc + fi + if [ $langCC -eq 1 ]; then + cat > $out/bin/g++ << EOF + #!/bin/sh + ${extraConfig} + exec ${distcc}/bin/distcc g++ "\$@" + EOF + chmod +x $out/bin/g++ + fi + ''); + }; + meta = { description = "a fast, free distributed C/C++ compiler"; homepage = "http://distcc.org"; @@ -44,4 +69,6 @@ stdenv.mkDerivation { platforms = stdenv.lib.platforms.linux; maintainers = [ stdenv.lib.maintainers.simons ]; }; -} +}; +in +distcc diff --git a/pkgs/development/tools/misc/distcc/masq.nix b/pkgs/development/tools/misc/distcc/masq.nix new file mode 100644 index 000000000000..117480670c39 --- /dev/null +++ b/pkgs/development/tools/misc/distcc/masq.nix @@ -0,0 +1,41 @@ +{ stdenv, gccRaw, binutils }: + +stdenv.mkDerivation { + name = "distcc-masq-${gccRaw.name}"; + + phases = [ "installPhase" ]; + installPhase = '' + ensureDir $out/bin + + bin=${gccRaw}/bin + + shopt -s nullglob + if [ -f $bin/gcc ]; then + ln -s $bin/gcc $out/bin + else + for a in $bin/*-gcc; do + ln -s $bin/*-gcc $out/bin/gcc + ln -s $bin/*-gcc $out/bin/cc + done + fi + + if [ -f $bin/g++ ]; then + ln -s $bin/g++ $out/bin + else + for a in $bin/*-g++; do + ln -sf $bin/*-g++ $out/bin/g++ + ln -sf $bin/*-g++ $out/bin/c++ + done + fi + + bbin=${binutils}/bin + if [ -f $bbin/as ]; then + ln -s $bbin/as $out/bin + else + for a in $bbin/*-as; do + ln -sf $bbin/*-as $out/bin/as + done + fi + + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b251c703e8ba..5b50a494de3c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3075,6 +3075,28 @@ let distcc = callPackage ../development/tools/misc/distcc { }; + # distccWrapper: wrapper that works as gcc or g++ + # It can be used by setting in nixpkgs config like this, for example: + # replaceStdenv = { pkgs }: pkgs.distccStdenv; + # But if you build in chroot, a default 'nix' will create + # a new net namespace, and won't have network access. + # You can use an override in packageOverrides to set extraConfig: + # packageOverrides = pkgs: { + # distccWrapper = pkgs.distccWrapper.override { + # extraConfig = '' + # DISTCC_HOSTS="myhost1 myhost2" + # ''; + # }; + # + distccWrapper = makeOverridable ({ extraConfig ? "" }: + wrapGCC (distcc.links extraConfig)) {}; + distccStdenv = lowPrio (overrideGCC stdenv distccWrapper); + + distccMasquerade = callPackage ../development/tools/misc/distcc/masq.nix { + gccRaw = gcc.gcc; + binutils = binutils; + }; + docutils = builderDefsPackage (import ../development/tools/documentation/docutils) { inherit python pil makeWrapper; };