@@ -7,6 +7,7 @@
77, withManual ? true
88, pythonSupport ? true
99, sendEmailSupport
10+, darwin
1011}:
1112
1213let
@@ -42,7 +43,9 @@ stdenv.mkDerivation {
4243 buildInputs = [curl openssl zlib expat gettext cpio makeWrapper libiconv perl]
4344 ++ stdenv.lib.optionals withManual [ asciidoc texinfo xmlto docbook2x
4445 docbook_xsl docbook_xml_dtd_45 libxslt ]
45− ++ stdenv.lib.optionals guiSupport [tcl tk];
46+ ++ stdenv.lib.optionals guiSupport [tcl tk]
47+ ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.Security ];
48+
4649
4750 # required to support pthread_cancel()
4851 NIX_LDFLAGS = stdenv.lib.optionalString (!stdenv.cc.isClang) "-lgcc_s"
@@ -51,11 +54,17 @@ stdenv.mkDerivation {
5154 # without this, git fails when trying to check for /etc/gitconfig existence
5255 propagatedSandboxProfile = stdenv.lib.sandbox.allowDirectoryList "/etc";
5356
54− makeFlags = "prefix=\${out} sysconfdir=/etc/ PERL_PATH=${perl}/bin/perl SHELL_PATH=${stdenv.shell} "
57+ makeFlags = "prefix=\${out} PERL_PATH=${perl}/bin/perl SHELL_PATH=${stdenv.shell} "
5558 + (if pythonSupport then "PYTHON_PATH=${python}/bin/python" else "NO_PYTHON=1")
5659 + (if stdenv.isSunOS then " INSTALL=install NO_INET_NTOP= NO_INET_PTON=" else "")
57− + (if stdenv.isDarwin then " NO_APPLE_COMMON_CRYPTO=1" else "");
60+ + (if stdenv.isDarwin then " NO_APPLE_COMMON_CRYPTO=1" else " sysconfdir=/etc/ ");
5861
62+ # build git-credential-osxkeychain if darwin
63+ postBuild = stdenv.lib.optionalString stdenv.isDarwin ''
64+ pushd $PWD/contrib/credential/osxkeychain/
65+ make
66+ popd
67+ '';
5968
6069 # FIXME: "make check" requires Sparse; the Makefile must be tweaked
6170 # so that `SPARSE_FLAGS' corresponds to the current architecture...
@@ -63,6 +72,11 @@ stdenv.mkDerivation {
6372
6473 installFlags = "NO_INSTALL_HARDLINKS=1";
6574
75+ preInstall = stdenv.lib.optionalString stdenv.isDarwin ''
76+ mkdir -p $out/bin
77+ mv $PWD/contrib/credential/osxkeychain/git-credential-osxkeychain $out/bin
78+ '';
79+
6680 postInstall =
6781 ''
6882 notSupported() {
@@ -157,7 +171,15 @@ stdenv.mkDerivation {
157171 for prog in bin/gitk libexec/git-core/git-gui; do
158172 notSupported "$out/$prog"
159173 done
160− '');
174+ '')
175+ + stdenv.lib.optionalString stdenv.isDarwin ''
176+ # enable git-credential-osxkeychain by default if darwin
177+ cat > $out/etc/gitconfig << EOF
178+[credential]
179+ helper = osxkeychain
180+EOF
181+ '';
182+
161183
162184 enableParallelBuilding = true;
163185