2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv
|
2021-08-05 21:33:18 +00:00
|
|
|
, buildPackages
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchurl
|
2024-04-21 15:54:59 +00:00
|
|
|
, fetchpatch
|
2021-08-05 21:33:18 +00:00
|
|
|
, wafHook
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
, bison
|
|
|
|
, flex
|
|
|
|
, perl
|
|
|
|
, libxslt
|
|
|
|
, docbook_xsl
|
|
|
|
, fixDarwinDylibNames
|
|
|
|
, docbook_xml_dtd_45
|
|
|
|
, readline
|
|
|
|
, popt
|
2020-12-25 13:55:36 +00:00
|
|
|
, dbus
|
2020-04-24 23:36:52 +00:00
|
|
|
, libbsd
|
|
|
|
, libarchive
|
|
|
|
, zlib
|
|
|
|
, liburing
|
|
|
|
, gnutls
|
|
|
|
, systemd
|
2022-11-21 17:40:18 +00:00
|
|
|
, samba
|
2023-02-16 17:41:37 +00:00
|
|
|
, talloc
|
2020-04-24 23:36:52 +00:00
|
|
|
, jansson
|
2023-02-16 17:41:37 +00:00
|
|
|
, ldb
|
2020-04-24 23:36:52 +00:00
|
|
|
, libtasn1
|
|
|
|
, tdb
|
2023-02-16 17:41:37 +00:00
|
|
|
, tevent
|
2022-11-21 17:40:18 +00:00
|
|
|
, libxcrypt
|
2024-01-02 11:29:13 +00:00
|
|
|
, libxcrypt-legacy
|
2020-04-24 23:36:52 +00:00
|
|
|
, cmocka
|
2020-10-16 20:44:37 +00:00
|
|
|
, rpcsvc-proto
|
2022-09-09 14:08:57 +00:00
|
|
|
, bash
|
2021-06-04 09:07:49 +00:00
|
|
|
, python3Packages
|
2020-05-29 06:06:01 +00:00
|
|
|
, nixosTests
|
2022-12-02 08:20:57 +00:00
|
|
|
, libiconv
|
2024-04-21 15:54:59 +00:00
|
|
|
, testers
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
, enableLDAP ? false, openldap
|
|
|
|
, enablePrinting ? false, cups
|
|
|
|
, enableProfiling ? true
|
|
|
|
, enableMDNS ? false, avahi
|
|
|
|
, enableDomainController ? false, gpgme, lmdb
|
|
|
|
, enableRegedit ? true, ncurses
|
2021-12-06 16:07:01 +00:00
|
|
|
, enableCephFS ? false, ceph
|
2020-04-24 23:36:52 +00:00
|
|
|
, enableGlusterFS ? false, glusterfs, libuuid
|
|
|
|
, enableAcl ? (!stdenv.isDarwin), acl
|
2023-01-11 07:51:40 +00:00
|
|
|
, enableLibunwind ? (!stdenv.isDarwin), libunwind
|
2020-04-24 23:36:52 +00:00
|
|
|
, enablePam ? (!stdenv.isDarwin), pam
|
|
|
|
}:
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
with lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
let
|
|
|
|
# samba-tool requires libxcrypt-legacy algorithms
|
|
|
|
python = python3Packages.python.override {
|
|
|
|
libxcrypt = libxcrypt-legacy;
|
|
|
|
};
|
|
|
|
wrapPython = python3Packages.wrapPython.override {
|
|
|
|
inherit python;
|
|
|
|
};
|
|
|
|
in
|
2024-04-21 15:54:59 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "samba";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "4.20.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2024-04-21 15:54:59 +00:00
|
|
|
url = "mirror://samba/pub/samba/stable/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
|
2024-05-15 15:35:15 +00:00
|
|
|
hash = "sha256-+Tw69SlTQNCBBsfA3PuF5PhQV9/RRYeqiBe+sxr/iPc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "man" ];
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./4.x-no-persistent-install.patch
|
|
|
|
./patch-source3__libads__kerberos_keytab.c.patch
|
|
|
|
./4.x-no-persistent-install-dynconfig.patch
|
|
|
|
./4.x-fix-makeflags-parsing.patch
|
2021-08-05 21:33:18 +00:00
|
|
|
./build-find-pre-built-heimdal-build-tools-in-case-of-.patch
|
2024-04-21 15:54:59 +00:00
|
|
|
(fetchpatch {
|
|
|
|
# workaround for https://github.com/NixOS/nixpkgs/issues/303436
|
|
|
|
name = "samba-reproducible-builds.patch";
|
|
|
|
url = "https://gitlab.com/raboof/samba/-/commit/9995c5c234ece6888544cdbe6578d47e83dea0b5.patch";
|
|
|
|
hash = "sha256-TVKK/7wGsfP1pVf8o1NwazobiR8jVJCCMj/FWji3f2A=";
|
|
|
|
})
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2021-08-05 21:33:18 +00:00
|
|
|
python3Packages.python
|
|
|
|
wafHook
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
bison
|
|
|
|
flex
|
|
|
|
perl
|
|
|
|
perl.pkgs.ParseYapp
|
2022-11-21 17:40:18 +00:00
|
|
|
perl.pkgs.JSON
|
2020-04-24 23:36:52 +00:00
|
|
|
libxslt
|
|
|
|
docbook_xsl
|
|
|
|
docbook_xml_dtd_45
|
|
|
|
cmocka
|
2020-10-16 20:44:37 +00:00
|
|
|
rpcsvc-proto
|
2023-01-11 07:51:40 +00:00
|
|
|
] ++ optionals stdenv.isLinux [
|
|
|
|
buildPackages.stdenv.cc
|
2022-11-21 17:40:18 +00:00
|
|
|
] ++ optional (stdenv.buildPlatform != stdenv.hostPlatform) samba # asn1_compile/compile_et
|
|
|
|
++ optionals stdenv.isDarwin [
|
2020-04-24 23:36:52 +00:00
|
|
|
fixDarwinDylibNames
|
|
|
|
];
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
wafPath = "buildtools/bin/waf";
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = [
|
2022-09-09 14:08:57 +00:00
|
|
|
bash
|
2024-01-02 11:29:13 +00:00
|
|
|
wrapPython
|
|
|
|
python
|
2020-04-24 23:36:52 +00:00
|
|
|
readline
|
|
|
|
popt
|
2020-12-25 13:55:36 +00:00
|
|
|
dbus
|
2020-04-24 23:36:52 +00:00
|
|
|
jansson
|
|
|
|
libbsd
|
|
|
|
libarchive
|
|
|
|
zlib
|
|
|
|
gnutls
|
|
|
|
libtasn1
|
|
|
|
tdb
|
2022-11-21 17:40:18 +00:00
|
|
|
libxcrypt
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ optionals stdenv.isLinux [ liburing systemd ]
|
2022-12-02 08:20:57 +00:00
|
|
|
++ optionals stdenv.isDarwin [ libiconv ]
|
2021-06-04 09:07:49 +00:00
|
|
|
++ optionals enableLDAP [ openldap.dev python3Packages.markdown ]
|
2023-03-24 00:07:29 +00:00
|
|
|
++ optionals (!enableLDAP && stdenv.isLinux) [ ldb talloc tevent ]
|
2020-04-24 23:36:52 +00:00
|
|
|
++ optional (enablePrinting && stdenv.isLinux) cups
|
|
|
|
++ optional enableMDNS avahi
|
2021-06-04 09:07:49 +00:00
|
|
|
++ optionals enableDomainController [ gpgme lmdb python3Packages.dnspython ]
|
2020-04-24 23:36:52 +00:00
|
|
|
++ optional enableRegedit ncurses
|
2021-12-06 16:07:01 +00:00
|
|
|
++ optional (enableCephFS && stdenv.isLinux) (lib.getDev ceph)
|
2020-04-24 23:36:52 +00:00
|
|
|
++ optionals (enableGlusterFS && stdenv.isLinux) [ glusterfs libuuid ]
|
|
|
|
++ optional enableAcl acl
|
2023-01-11 07:51:40 +00:00
|
|
|
++ optional enableLibunwind libunwind
|
2020-04-24 23:36:52 +00:00
|
|
|
++ optional enablePam pam;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# Removes absolute paths in scripts
|
|
|
|
sed -i 's,/sbin/,,g' ctdb/config/functions
|
|
|
|
|
|
|
|
# Fix the XML Catalog Paths
|
|
|
|
sed -i "s,\(XML_CATALOG_FILES=\"\),\1$XML_CATALOG_FILES ,g" buildtools/wafsamba/wafsamba.py
|
|
|
|
|
|
|
|
patchShebangs ./buildtools/bin
|
|
|
|
'';
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
preConfigure = ''
|
|
|
|
export PKGCONFIG="$PKG_CONFIG"
|
2022-11-21 17:40:18 +00:00
|
|
|
export PYTHONHASHSEED=1
|
2021-08-05 21:33:18 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
wafConfigureFlags = [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--with-static-modules=NONE"
|
|
|
|
"--with-shared-modules=ALL"
|
|
|
|
"--enable-fhs"
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--localstatedir=/var"
|
|
|
|
"--disable-rpath"
|
2020-08-20 17:08:02 +00:00
|
|
|
] ++ optional (!enableDomainController)
|
|
|
|
"--without-ad-dc"
|
|
|
|
++ optionals (!enableLDAP) [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--without-ldap"
|
|
|
|
"--without-ads"
|
2023-03-24 00:07:29 +00:00
|
|
|
] ++ optionals (!enableLDAP && stdenv.isLinux) [
|
2023-02-16 17:41:37 +00:00
|
|
|
"--bundled-libraries=!ldb,!pyldb-util!talloc,!pytalloc-util,!tevent,!tdb,!pytdb"
|
2023-01-11 07:51:40 +00:00
|
|
|
] ++ optional enableLibunwind "--with-libunwind"
|
|
|
|
++ optional enableProfiling "--with-profiling-data"
|
2020-04-24 23:36:52 +00:00
|
|
|
++ optional (!enableAcl) "--without-acl-support"
|
2021-08-05 21:33:18 +00:00
|
|
|
++ optional (!enablePam) "--without-pam"
|
|
|
|
++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
|
|
|
"--bundled-libraries=!asn1_compile,!compile_et"
|
2024-06-20 14:57:18 +00:00
|
|
|
"--cross-compile"
|
|
|
|
"--cross-execute=${stdenv.hostPlatform.emulator buildPackages}"
|
2024-02-29 20:09:43 +00:00
|
|
|
] ++ optionals stdenv.buildPlatform.is32bit [
|
|
|
|
# By default `waf configure` spawns as many as available CPUs. On
|
|
|
|
# 32-bit systems with many CPUs (like `i686` chroot on `x86_64`
|
|
|
|
# kernel) it can easily exhaust 32-bit address space and hang up:
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/287339#issuecomment-1949462057
|
|
|
|
# https://bugs.gentoo.org/683148
|
|
|
|
# Limit the job count down to the minimal on system with limited address
|
|
|
|
# space.
|
2021-08-18 13:19:15 +00:00
|
|
|
"--jobs 1"
|
2021-08-05 21:33:18 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# python-config from build Python gives incorrect values when cross-compiling.
|
|
|
|
# If python-config is not found, the build falls back to using the sysconfig
|
|
|
|
# module, which works correctly in all cases.
|
|
|
|
PYTHON_CONFIG = "/invalid";
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
pythonPath = [ python3Packages.dnspython python3Packages.markdown tdb ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
export MAKEFLAGS="-j $NIX_BUILD_CORES"
|
|
|
|
'';
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
# Save asn1_compile and compile_et so they are available to run on the build
|
|
|
|
# platform when cross-compiling
|
|
|
|
postInstall = optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
|
|
|
|
mkdir -p "$dev/bin"
|
|
|
|
cp bin/asn1_compile bin/compile_et "$dev/bin"
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# Some libraries don't have /lib/samba in RPATH but need it.
|
|
|
|
# Use find -type f -executable -exec echo {} \; -exec sh -c 'ldd {} | grep "not found"' \;
|
|
|
|
# Looks like a bug in installer scripts.
|
|
|
|
postFixup = ''
|
2023-01-11 07:51:40 +00:00
|
|
|
export SAMBA_LIBS="$(find $out -type f -regex '.*\${stdenv.hostPlatform.extensions.sharedLibrary}\(\..*\)?' -exec dirname {} \; | sort | uniq)"
|
2020-04-24 23:36:52 +00:00
|
|
|
read -r -d "" SCRIPT << EOF || true
|
|
|
|
[ -z "\$SAMBA_LIBS" ] && exit 1;
|
|
|
|
BIN='{}';
|
2023-01-11 07:51:40 +00:00
|
|
|
'' + lib.optionalString stdenv.isLinux ''
|
2020-04-24 23:36:52 +00:00
|
|
|
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";
|
2023-01-11 07:51:40 +00:00
|
|
|
'' + 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
|
|
|
|
'' + ''
|
2020-04-24 23:36:52 +00:00
|
|
|
EOF
|
2023-01-11 07:51:40 +00:00
|
|
|
find $out -type f -regex '.*\${stdenv.hostPlatform.extensions.sharedLibrary}\(\..*\)?' -exec $SHELL -c "$SCRIPT" \;
|
|
|
|
find $out/bin -type f -exec $SHELL -c "$SCRIPT" \;
|
2021-08-05 21:33:18 +00:00
|
|
|
|
|
|
|
# Fix PYTHONPATH for some tools
|
|
|
|
wrapPythonPrograms
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
# Samba does its own shebang patching, but uses build Python
|
|
|
|
find $out/bin -type f -executable | while read file; do
|
|
|
|
isScript "$file" || continue
|
2024-01-02 11:29:13 +00:00
|
|
|
sed -i 's^${lib.getBin buildPackages.python3Packages.python}^${lib.getBin python}^' "$file"
|
2022-09-09 14:08:57 +00:00
|
|
|
done
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
disallowedReferences =
|
|
|
|
lib.optionals (buildPackages.python3Packages.python != python3Packages.python)
|
|
|
|
[ buildPackages.python3Packages.python ];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
passthru.tests = {
|
|
|
|
samba = nixosTests.samba;
|
|
|
|
pkg-config = testers.hasPkgConfigModules {
|
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
};
|
|
|
|
version = testers.testVersion {
|
|
|
|
command = "${finalAttrs.finalPackage}/bin/smbd -V";
|
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
};
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://www.samba.org";
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Standard Windows interoperability suite of programs for Linux and Unix";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.gpl3;
|
|
|
|
platforms = platforms.unix;
|
2023-01-11 07:51:40 +00:00
|
|
|
broken = enableGlusterFS;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ aneeshusa ];
|
2024-04-21 15:54:59 +00:00
|
|
|
pkgConfigModules = [
|
|
|
|
"dcerpc_samr"
|
|
|
|
"dcerpc"
|
|
|
|
"ndr_krb5pac"
|
|
|
|
"ndr_nbt"
|
|
|
|
"ndr_standard"
|
|
|
|
"ndr"
|
|
|
|
"netapi"
|
|
|
|
"samba-credentials"
|
|
|
|
"samba-hostconfig"
|
|
|
|
"samba-util"
|
|
|
|
"samdb"
|
|
|
|
"smbclient"
|
|
|
|
"wbclient"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
})
|