[Nix-dev] Re: libiconv on non-GNU systems

Ludovic Courtès ludo at gnu.org
Tue Oct 19 10:03:03 CEST 2010


Hi,

"Yury G. Kudryashov" <urkud+nix at ya.ru> writes:

> # grep libiconv all-packages.nix
>     libiconv = if stdenv.isDarwin then libiconv else null;
>       zlib curl gd postgresql openssl pkgconfig sqlite getConfig libiconv 
> libjpeg libpng;
>     libiconv = if (stdenv.system == "i686-freebsd") then libiconv else null;
>       libiconv = if stdenv.system == "i686-freebsd" then libiconv else null;
>       libiconv = if stdenv.system == "i686-freebsd" then libiconv else null;
>   libiconv = callPackage ../development/libraries/libiconv { };
>
> Which test should be used instead of all these?

On IRC I suggested ‘stdenv ? glibc’, with the caveat that it may not
work as expected on impure GNU/Linux systems, because ‘stdenvNative’
lacks it.

Actually, the Right Thing may be to use a feature test, like this:

--8<---------------cut here---------------start------------->8---
  have_iconv = import ((stdenv.mkDerivation {
    name = "test-have-iconv";
    phases = "buildPhase";
    buildPhase =
      '' cat > foo.c <<EOF
           #include <iconv.h>
           int main () { iconv_open (0, 0); return 0; }
EOF
         ensureDir "$out"
         if gcc foo.c
         then
             echo "true" > "$out/have-iconv"
         else
             echo "false" > "$out/have-iconv"
         fi
      '';
  }).outPath + "/have-iconv");
--8<---------------cut here---------------end--------------->8---

WDYT?

Thanks,
Ludo’.




More information about the nix-dev mailing list