summary refs log tree commit diff
path: root/pkgs/servers/samba
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2023-01-03 23:16:35 +0100
committerGitHub <noreply@github.com>2023-01-03 23:16:35 +0100
commit5f40e9e178ca5ab04e7342c35193990ca638dd0f (patch)
treec3d621199bb557f5968f90fef7cc83d1d9d15b6a /pkgs/servers/samba
parentc4abc231be36b38e14a9182846e9de928d0dd921 (diff)
downloadnixpkgs-5f40e9e178ca5ab04e7342c35193990ca638dd0f.tar
nixpkgs-5f40e9e178ca5ab04e7342c35193990ca638dd0f.tar.gz
nixpkgs-5f40e9e178ca5ab04e7342c35193990ca638dd0f.tar.bz2
nixpkgs-5f40e9e178ca5ab04e7342c35193990ca638dd0f.tar.lz
nixpkgs-5f40e9e178ca5ab04e7342c35193990ca638dd0f.tar.xz
nixpkgs-5f40e9e178ca5ab04e7342c35193990ca638dd0f.tar.zst
nixpkgs-5f40e9e178ca5ab04e7342c35193990ca638dd0f.zip
samba: add darwin support (#207465)
Diffstat (limited to 'pkgs/servers/samba')
-rw-r--r--pkgs/servers/samba/4.x.nix29
1 files changed, 18 insertions, 11 deletions
diff --git a/pkgs/servers/samba/4.x.nix b/pkgs/servers/samba/4.x.nix
index 46867aa19e7..df235abe98c 100644
--- a/pkgs/servers/samba/4.x.nix
+++ b/pkgs/servers/samba/4.x.nix
@@ -18,7 +18,6 @@
 , zlib
 , liburing
 , gnutls
-, libunwind
 , systemd
 , samba
 , jansson
@@ -41,6 +40,7 @@
 , enableCephFS ? false, ceph
 , enableGlusterFS ? false, glusterfs, libuuid
 , enableAcl ? (!stdenv.isDarwin), acl
+, enableLibunwind ? (!stdenv.isDarwin), libunwind
 , enablePam ? (!stdenv.isDarwin), pam
 }:
 
@@ -75,11 +75,12 @@ stdenv.mkDerivation rec {
     perl.pkgs.ParseYapp
     perl.pkgs.JSON
     libxslt
-    buildPackages.stdenv.cc
     docbook_xsl
     docbook_xml_dtd_45
     cmocka
     rpcsvc-proto
+  ] ++ optionals stdenv.isLinux [
+    buildPackages.stdenv.cc
   ] ++ optional (stdenv.buildPlatform != stdenv.hostPlatform) samba # asn1_compile/compile_et
     ++ optionals stdenv.isDarwin [
     fixDarwinDylibNames
@@ -98,7 +99,6 @@ stdenv.mkDerivation rec {
     libbsd
     libarchive
     zlib
-    libunwind
     gnutls
     libtasn1
     tdb
@@ -113,6 +113,7 @@ stdenv.mkDerivation rec {
     ++ optional (enableCephFS && stdenv.isLinux) (lib.getDev ceph)
     ++ optionals (enableGlusterFS && stdenv.isLinux) [ glusterfs libuuid ]
     ++ optional enableAcl acl
+    ++ optional enableLibunwind libunwind
     ++ optional enablePam pam;
 
   postPatch = ''
@@ -133,7 +134,6 @@ stdenv.mkDerivation rec {
   wafConfigureFlags = [
     "--with-static-modules=NONE"
     "--with-shared-modules=ALL"
-    "--with-libunwind"
     "--enable-fhs"
     "--sysconfdir=/etc"
     "--localstatedir=/var"
@@ -143,7 +143,8 @@ stdenv.mkDerivation rec {
   ++ optionals (!enableLDAP) [
     "--without-ldap"
     "--without-ads"
-  ] ++ optional enableProfiling "--with-profiling-data"
+  ] ++ optional enableLibunwind "--with-libunwind"
+    ++ optional enableProfiling "--with-profiling-data"
     ++ optional (!enableAcl) "--without-acl-support"
     ++ optional (!enablePam) "--without-pam"
     ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
@@ -175,16 +176,25 @@ stdenv.mkDerivation rec {
   # Use find -type f -executable -exec echo {} \; -exec sh -c 'ldd {} | grep "not found"' \;
   # Looks like a bug in installer scripts.
   postFixup = ''
-    export SAMBA_LIBS="$(find $out -type f -regex '.*\.so\(\..*\)?' -exec dirname {} \; | sort | uniq)"
+    export SAMBA_LIBS="$(find $out -type f -regex '.*\${stdenv.hostPlatform.extensions.sharedLibrary}\(\..*\)?' -exec dirname {} \; | sort | uniq)"
     read -r -d "" SCRIPT << EOF || true
     [ -z "\$SAMBA_LIBS" ] && exit 1;
     BIN='{}';
+  '' + lib.optionalString stdenv.isLinux ''
     OLD_LIBS="\$(patchelf --print-rpath "\$BIN" 2>/dev/null | tr ':' '\n')";
     ALL_LIBS="\$(echo -e "\$SAMBA_LIBS\n\$OLD_LIBS" | sort | uniq | tr '\n' ':')";
     patchelf --set-rpath "\$ALL_LIBS" "\$BIN" 2>/dev/null || exit $?;
     patchelf --shrink-rpath "\$BIN";
+  '' + lib.optionalString stdenv.isDarwin ''
+    install_name_tool -id \$BIN \$BIN
+    for old_rpath in \$(otool -L \$BIN | grep /private/tmp/ | awk '{print \$1}'); do
+      new_rpath=\$(find \$SAMBA_LIBS -name \$(basename \$old_rpath) | head -n 1)
+      install_name_tool -change \$old_rpath \$new_rpath \$BIN
+    done
+  '' + ''
     EOF
-    find $out -type f -regex '.*\.so\(\..*\)?' -exec $SHELL -c "$SCRIPT" \;
+    find $out -type f -regex '.*\${stdenv.hostPlatform.extensions.sharedLibrary}\(\..*\)?' -exec $SHELL -c "$SCRIPT" \;
+    find $out/bin -type f -exec $SHELL -c "$SCRIPT" \;
 
     # Fix PYTHONPATH for some tools
     wrapPythonPrograms
@@ -209,10 +219,7 @@ stdenv.mkDerivation rec {
     description = "The standard Windows interoperability suite of programs for Linux and Unix";
     license = licenses.gpl3;
     platforms = platforms.unix;
-    # N.B. enableGlusterFS does not build
-    # TODO: darwin support needs newer SDK for "_futimens" and "_utimensat"
-    # see https://github.com/NixOS/nixpkgs/issues/101229
-    broken = stdenv.isDarwin || enableGlusterFS;
+    broken = enableGlusterFS;
     maintainers = with maintainers; [ aneeshusa ];
   };
 }