Skip to content

Commit

Permalink
pure darwin stdenv
Browse files Browse the repository at this point in the history
  • Loading branch information
Jude Taylor committed Jun 18, 2015
1 parent 5e63669 commit fa9c81f
Show file tree
Hide file tree
Showing 19 changed files with 436 additions and 133 deletions.
2 changes: 1 addition & 1 deletion pkgs/development/compilers/llvm/3.6/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ pkgs, newScope, stdenv, isl, fetchurl, overrideCC, wrapCC }:
let
callPackage = newScope (self // { inherit isl version fetch; });
callPackage = newScope (self // { inherit stdenv isl version fetch; });

version = "3.6.1";

Expand Down
11 changes: 11 additions & 0 deletions pkgs/development/interpreters/perl/5.16/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ stdenv.mkDerivation rec {
++ lib.optional stdenv.isSunOS ./ld-shared.patch
++ lib.optional stdenv.isDarwin [ ./cpp-precomp.patch ./no-libutil.patch ] ;

# There's an annoying bug on sandboxed Darwin in Perl's Cwd.pm where it looks for pwd
# in /bin/pwd and /usr/bin/pwd and then falls back on just "pwd" if it can't get them
# while at the same time erasing the PATH environment variable so it unconditionally
# fails. The code in question is guarded by a check for Mac OS, but the patch below
# doesn't have any runtime effect on other platforms.
postPatch = ''
pwd="$(type -P pwd)"
substituteInPlace dist/Cwd/Cwd.pm \
--replace "pwd_cmd = 'pwd'" "pwd_cmd = '$pwd'"
'';

# Build a thread-safe Perl with a dynamic libperls.o. We need the
# "installstyle" option to ensure that modules are put under
# $out/lib/perl5 - this is the general default, but because $out
Expand Down
11 changes: 11 additions & 0 deletions pkgs/development/interpreters/perl/5.20/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ stdenv.mkDerivation rec {
++ optional stdenv.isSunOS ./ld-shared.patch
++ stdenv.lib.optional stdenv.isDarwin [ ./cpp-precomp.patch ./no-libutil.patch ] ;

# There's an annoying bug on sandboxed Darwin in Perl's Cwd.pm where it looks for pwd
# in /bin/pwd and /usr/bin/pwd and then falls back on just "pwd" if it can't get them
# while at the same time erasing the PATH environment variable so it unconditionally
# fails. The code in question is guarded by a check for Mac OS, but the patch below
# doesn't have any runtime effect on other platforms.
postPatch = ''
pwd="$(type -P pwd)"
substituteInPlace dist/PathTools/Cwd.pm \
--replace "pwd_cmd = 'pwd'" "pwd_cmd = '$pwd'"
'';

# Build a thread-safe Perl with a dynamic libperls.o. We need the
# "installstyle" option to ensure that modules are put under
# $out/lib/perl5 - this is the general default, but because $out
Expand Down
4 changes: 4 additions & 0 deletions pkgs/development/interpreters/python/2.7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ let
for i in Lib/plat-*/regen; do
substituteInPlace $i --replace /usr/include/ ${stdenv.cc.libc}/include/
done
'' + optionalString stdenv.isDarwin ''
substituteInPlace configure --replace '`/usr/bin/arch`' '"i386"'
'';

configureFlags = [
Expand All @@ -72,6 +74,8 @@ let
"--with-system-ffi"
"--with-system-expat"
"ac_cv_func_bind_textdomain_codeset=yes"
] ++ optionals stdenv.isDarwin [
"--disable-toolbox-glue"
];

postConfigure = if stdenv.isCygwin then ''
Expand Down
7 changes: 6 additions & 1 deletion pkgs/development/libraries/gettext/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ stdenv.mkDerivation (rec {
"--with-included-gettext"
"--with-included-glib"
"--with-included-libcroco"
]);
])
# avoid retaining reference to CF during stdenv bootstrap
++ (stdenv.lib.optionals stdenv.isDarwin [
"gt_cv_func_CFPreferencesCopyAppValue=no"
"gt_cv_func_CFLocaleCopyCurrent=no"
]);

# On cross building, gettext supposes that the wchar.h from libc
# does not fulfill gettext needs, so it tries to work with its
Expand Down
5 changes: 5 additions & 0 deletions pkgs/development/libraries/icu/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ stdenv.mkDerivation {
configureFlags = "--disable-debug" +
stdenv.lib.optionalString stdenv.isDarwin " --enable-rpath";

# remove dependency on bootstrap-tools in early stdenv build
postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
sed -i 's/INSTALL_CMD=.*install/INSTALL_CMD=install/' $out/lib/icu/${version}/pkgdata.inc
'';

enableParallelBuilding = true;

meta = with stdenv.lib; {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/libedit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
] else null;

postInstall = ''
sed -i ${stdenv.lib.optionalString (stdenv.isDarwin && stdenv.cc.nativeTools) "''"} s/-lncurses/-lncursesw/g $out/lib/pkgconfig/libedit.pc
sed -i s/-lncurses/-lncursesw/g $out/lib/pkgconfig/libedit.pc
'';

configureFlags = [ "--enable-widec" ];
Expand Down
7 changes: 7 additions & 0 deletions pkgs/development/libraries/zlib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ stdenv.mkDerivation (rec {
sha256 = "039agw5rqvqny92cpkrfn243x2gd4xn13hs3xi6isk55d2vqqr9n";
};

postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace configure \
--replace '/usr/bin/libtool' 'ar' \
--replace 'AR="libtool"' 'AR="ar"' \
--replace 'ARFLAGS="-o"' 'ARFLAGS="-r"'
'';

configureFlags = if static then "" else "--shared";

preConfigure = ''
Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/tools/misc/binutils/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
, cross ? null, gold ? true, bison ? null
}:

assert !stdenv.isDarwin;

let basename = "binutils-2.23.1"; in

with { inherit (stdenv.lib) optional optionals optionalString; };
Expand Down Expand Up @@ -56,7 +54,9 @@ stdenv.mkDerivation rec {

# As binutils takes part in the stdenv building, we don't want references
# to the bootstrap-tools libgcc (as uses to happen on arm/mips)
NIX_CFLAGS_COMPILE = "-static-libgcc";
NIX_CFLAGS_COMPILE = if stdenv.isDarwin
then "-Wno-string-plus-int -Wno-deprecated-declarations"
else "-static-libgcc";

configureFlags =
[ "--enable-shared" "--enable-deterministic-archives" ]
Expand Down
29 changes: 29 additions & 0 deletions pkgs/os-specific/darwin/adv_cmds/locale.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
name = "locale-${version}";
version = "153";

src = fetchurl {
url = "http://opensource.apple.com/tarballs/adv_cmds/adv_cmds-${version}.tar.gz";
sha256 = "174v6a4zkcm2pafzgdm6kvs48z5f911zl7k49hv7kjq6gm58w99v";
};

buildPhase = ''
cd locale
c++ -Os -Wall -o locale locale.cc
'';

installPhase = ''
mkdir -p $out/bin $out/share/man/man1
cp locale $out/bin/locale
cp locale.1 $out/share/man/man1
'';


meta = {
platforms = stdenv.lib.platforms.darwin;
maintainers = with stdenv.lib.maintainers; [ gridaphobe ];
};
}
39 changes: 39 additions & 0 deletions pkgs/os-specific/darwin/binutils/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{ stdenv, binutils-raw, cctools }:

stdenv.mkDerivation {
name = "cctools-binutils-darwin";
buildCommand = ''
mkdir -p $out/bin $out/include
ln -s ${binutils-raw}/bin/c++filt $out/bin/c++filt
# We specifically need:
# - ld: binutils doesn't provide it on darwin
# - as: as above
# - ar: the binutils one prodices .a files that the cctools ld doesn't like
# - ranlib: for compatibility with ar
# - dsymutil: soon going away once it goes into LLVM (this one is fake anyway)
# - otool: we use it for some of our name mangling
# - install_name_tool: we use it to rewrite stuff in our bootstrap tools
# - strip: the binutils one seems to break mach-o files
# - lipo: gcc build assumes it exists
# - nm: the gnu one doesn't understand many new load commands
for i in ar ranlib as dsymutil install_name_tool ld strip otool lipo nm strings size; do
ln -sf "${cctools}/bin/$i" "$out/bin/$i"
done
for i in ${binutils-raw}/include/*.h; do
ln -s "$i" "$out/include/$(basename $i)"
done
for i in ${cctools}/include/*; do
ln -s "$i" "$out/include/$(basename $i)"
done
# FIXME: this will give us incorrect man pages for bits of cctools
ln -s ${binutils-raw}/share $out/share
ln -s ${binutils-raw}/lib $out/lib
ln -s ${cctools}/libexec $out/libexec
'';
}
Loading

0 comments on commit fa9c81f

Please sign in to comment.