2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv
|
2020-10-03 23:02:46 +00:00
|
|
|
, buildPackages
|
2020-03-24 06:59:16 +00:00
|
|
|
, fetchurl
|
2024-04-13 11:22:34 +00:00
|
|
|
, fetchpatch
|
2023-09-03 00:24:44 +00:00
|
|
|
, wafHook
|
2021-01-19 06:50:56 +00:00
|
|
|
, pkg-config
|
2020-03-25 09:53:38 +00:00
|
|
|
, bison
|
|
|
|
, flex
|
2020-03-24 06:59:16 +00:00
|
|
|
, perl
|
|
|
|
, libxslt
|
|
|
|
, docbook_xsl
|
2019-06-16 19:59:06 +00:00
|
|
|
, fixDarwinDylibNames
|
2020-03-25 09:53:38 +00:00
|
|
|
, docbook_xml_dtd_45
|
2020-03-24 06:59:16 +00:00
|
|
|
, readline
|
|
|
|
, popt
|
2020-09-29 02:18:57 +00:00
|
|
|
, dbus
|
2020-03-24 06:59:16 +00:00
|
|
|
, libbsd
|
|
|
|
, libarchive
|
|
|
|
, zlib
|
|
|
|
, liburing
|
|
|
|
, gnutls
|
|
|
|
, systemd
|
2022-11-13 22:38:56 +00:00
|
|
|
, samba
|
2023-01-02 09:41:12 +00:00
|
|
|
, talloc
|
2020-03-24 06:59:16 +00:00
|
|
|
, jansson
|
2023-01-02 09:41:12 +00:00
|
|
|
, ldb
|
2020-03-25 09:53:38 +00:00
|
|
|
, libtasn1
|
|
|
|
, tdb
|
2023-01-02 09:41:12 +00:00
|
|
|
, tevent
|
2022-11-13 22:38:56 +00:00
|
|
|
, libxcrypt
|
2023-11-24 13:31:19 +00:00
|
|
|
, libxcrypt-legacy
|
2020-03-25 09:53:38 +00:00
|
|
|
, cmocka
|
2020-08-12 21:24:15 +00:00
|
|
|
, rpcsvc-proto
|
2022-07-23 02:27:01 +00:00
|
|
|
, bash
|
2021-05-31 16:41:25 +00:00
|
|
|
, python3Packages
|
2020-05-19 12:20:34 +00:00
|
|
|
, nixosTests
|
2022-11-23 08:15:00 +00:00
|
|
|
, libiconv
|
2024-04-06 11:15:55 +00:00
|
|
|
, testers
|
2024-11-22 22:58:25 +00:00
|
|
|
, pkgsCross
|
2015-06-01 13:28:05 +00:00
|
|
|
|
2020-03-25 08:28:36 +00:00
|
|
|
, enableLDAP ? false, openldap
|
|
|
|
, enablePrinting ? false, cups
|
2020-03-25 10:23:36 +00:00
|
|
|
, enableProfiling ? true
|
2020-03-25 08:28:36 +00:00
|
|
|
, enableMDNS ? false, avahi
|
|
|
|
, enableDomainController ? false, gpgme, lmdb
|
|
|
|
, enableRegedit ? true, ncurses
|
2021-11-07 15:13:06 +00:00
|
|
|
, enableCephFS ? false, ceph
|
2020-03-25 08:28:36 +00:00
|
|
|
, enableGlusterFS ? false, glusterfs, libuuid
|
|
|
|
, enableAcl ? (!stdenv.hostPlatform.isDarwin), acl
|
2023-01-03 22:16:35 +00:00
|
|
|
, enableLibunwind ? (!stdenv.hostPlatform.isDarwin), libunwind
|
2020-03-25 08:28:36 +00:00
|
|
|
, enablePam ? (!stdenv.hostPlatform.isDarwin), pam
|
2015-01-03 05:21:34 +00:00
|
|
|
}:
|
|
|
|
|
2023-11-24 13:31:19 +00:00
|
|
|
let
|
|
|
|
# samba-tool requires libxcrypt-legacy algorithms
|
|
|
|
python = python3Packages.python.override {
|
2024-08-02 11:10:35 +00:00
|
|
|
self = python;
|
2023-11-24 13:31:19 +00:00
|
|
|
libxcrypt = libxcrypt-legacy;
|
|
|
|
};
|
|
|
|
wrapPython = python3Packages.wrapPython.override {
|
|
|
|
inherit python;
|
|
|
|
};
|
2024-05-13 19:55:28 +00:00
|
|
|
|
|
|
|
inherit (lib) optional optionals;
|
2023-11-24 13:31:19 +00:00
|
|
|
in
|
2024-04-06 11:15:55 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "samba";
|
2024-07-19 05:45:30 +00:00
|
|
|
version = "4.20.4";
|
2015-01-03 05:21:34 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2024-07-13 00:17:48 +00:00
|
|
|
url = "mirror://samba/pub/samba/stable/samba-${finalAttrs.version}.tar.gz";
|
2024-07-19 05:45:30 +00:00
|
|
|
hash = "sha256-OpLpfq6zRbazIjL1A+FNNPA6eqZMRR/owlihG72pCOU=";
|
2015-01-03 05:21:34 +00:00
|
|
|
};
|
|
|
|
|
2016-09-19 13:37:59 +00:00
|
|
|
outputs = [ "out" "dev" "man" ];
|
|
|
|
|
2019-09-13 18:54:14 +00:00
|
|
|
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
|
2024-11-21 20:27:49 +00:00
|
|
|
./build-find-pre-built-heimdal-build-tools-in-case-of-.patch
|
2024-04-13 11:22:34 +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=";
|
|
|
|
})
|
2019-09-13 18:54:14 +00:00
|
|
|
];
|
2015-06-01 13:28:05 +00:00
|
|
|
|
2020-03-24 06:59:16 +00:00
|
|
|
nativeBuildInputs = [
|
2023-11-28 08:46:07 +00:00
|
|
|
python3Packages.python
|
2023-09-03 00:24:44 +00:00
|
|
|
wafHook
|
2021-01-19 06:50:56 +00:00
|
|
|
pkg-config
|
2020-03-25 09:53:38 +00:00
|
|
|
bison
|
|
|
|
flex
|
2020-03-24 06:59:16 +00:00
|
|
|
perl
|
|
|
|
perl.pkgs.ParseYapp
|
2022-11-10 13:23:56 +00:00
|
|
|
perl.pkgs.JSON
|
2020-03-24 06:59:16 +00:00
|
|
|
libxslt
|
|
|
|
docbook_xsl
|
2020-03-25 09:53:38 +00:00
|
|
|
docbook_xml_dtd_45
|
|
|
|
cmocka
|
2020-08-12 21:24:15 +00:00
|
|
|
rpcsvc-proto
|
2023-01-03 22:16:35 +00:00
|
|
|
] ++ optionals stdenv.hostPlatform.isLinux [
|
|
|
|
buildPackages.stdenv.cc
|
2022-11-13 22:38:56 +00:00
|
|
|
] ++ optional (stdenv.buildPlatform != stdenv.hostPlatform) samba # asn1_compile/compile_et
|
|
|
|
++ optionals stdenv.hostPlatform.isDarwin [
|
2020-03-24 06:59:16 +00:00
|
|
|
fixDarwinDylibNames
|
|
|
|
];
|
2019-04-17 20:50:08 +00:00
|
|
|
|
2022-11-13 22:38:56 +00:00
|
|
|
wafPath = "buildtools/bin/waf";
|
|
|
|
|
2019-09-13 18:54:14 +00:00
|
|
|
buildInputs = [
|
2022-07-23 02:27:01 +00:00
|
|
|
bash
|
2023-11-24 13:31:19 +00:00
|
|
|
wrapPython
|
|
|
|
python
|
2020-03-24 06:59:16 +00:00
|
|
|
readline
|
|
|
|
popt
|
2020-09-29 02:18:57 +00:00
|
|
|
dbus
|
2020-03-24 06:59:16 +00:00
|
|
|
jansson
|
|
|
|
libbsd
|
|
|
|
libarchive
|
|
|
|
zlib
|
|
|
|
gnutls
|
2020-03-25 09:53:38 +00:00
|
|
|
libtasn1
|
|
|
|
tdb
|
2022-11-13 22:38:56 +00:00
|
|
|
libxcrypt
|
2020-03-25 08:53:04 +00:00
|
|
|
] ++ optionals stdenv.hostPlatform.isLinux [ liburing systemd ]
|
2022-11-23 08:15:00 +00:00
|
|
|
++ optionals stdenv.hostPlatform.isDarwin [ libiconv ]
|
2021-05-31 16:41:25 +00:00
|
|
|
++ optionals enableLDAP [ openldap.dev python3Packages.markdown ]
|
2023-03-17 21:50:16 +00:00
|
|
|
++ optionals (!enableLDAP && stdenv.hostPlatform.isLinux) [ ldb talloc tevent ]
|
2024-10-25 08:35:56 +00:00
|
|
|
++ optional enablePrinting cups
|
2015-06-01 13:28:05 +00:00
|
|
|
++ optional enableMDNS avahi
|
2021-05-31 16:41:25 +00:00
|
|
|
++ optionals enableDomainController [ gpgme lmdb python3Packages.dnspython ]
|
2015-06-01 13:28:05 +00:00
|
|
|
++ optional enableRegedit ncurses
|
2021-11-07 15:13:06 +00:00
|
|
|
++ optional (enableCephFS && stdenv.hostPlatform.isLinux) (lib.getDev ceph)
|
2019-09-13 18:54:14 +00:00
|
|
|
++ optionals (enableGlusterFS && stdenv.hostPlatform.isLinux) [ glusterfs libuuid ]
|
2018-06-11 01:15:09 +00:00
|
|
|
++ optional enableAcl acl
|
2023-01-03 22:16:35 +00:00
|
|
|
++ optional enableLibunwind libunwind
|
2018-06-11 01:15:09 +00:00
|
|
|
++ optional enablePam pam;
|
2015-01-03 05:21:34 +00:00
|
|
|
|
2015-03-13 00:34:22 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Removes absolute paths in scripts
|
|
|
|
sed -i 's,/sbin/,,g' ctdb/config/functions
|
2015-04-03 00:43:47 +00:00
|
|
|
|
|
|
|
# Fix the XML Catalog Paths
|
|
|
|
sed -i "s,\(XML_CATALOG_FILES=\"\),\1$XML_CATALOG_FILES ,g" buildtools/wafsamba/wafsamba.py
|
2018-12-24 04:37:01 +00:00
|
|
|
|
|
|
|
patchShebangs ./buildtools/bin
|
2015-03-13 00:34:22 +00:00
|
|
|
'';
|
|
|
|
|
2020-10-03 23:02:46 +00:00
|
|
|
preConfigure = ''
|
|
|
|
export PKGCONFIG="$PKG_CONFIG"
|
2022-11-13 22:38:56 +00:00
|
|
|
export PYTHONHASHSEED=1
|
2020-10-03 23:02:46 +00:00
|
|
|
'';
|
|
|
|
|
2023-09-03 01:46:02 +00:00
|
|
|
wafConfigureFlags = [
|
2019-09-13 18:54:14 +00:00
|
|
|
"--with-static-modules=NONE"
|
|
|
|
"--with-shared-modules=ALL"
|
|
|
|
"--enable-fhs"
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--localstatedir=/var"
|
|
|
|
"--disable-rpath"
|
2024-11-21 22:51:26 +00:00
|
|
|
# otherwise third_party/waf/waflib/Tools/python.py would
|
|
|
|
# get the wrong pythondir from build platform python
|
|
|
|
"--pythondir=${placeholder "out"}/${python.sitePackages}"
|
2024-10-25 08:35:56 +00:00
|
|
|
(lib.enableFeature enablePrinting "cups")
|
2020-04-16 10:04:22 +00:00
|
|
|
] ++ optional (!enableDomainController)
|
|
|
|
"--without-ad-dc"
|
|
|
|
++ optionals (!enableLDAP) [
|
2020-03-24 06:59:16 +00:00
|
|
|
"--without-ldap"
|
|
|
|
"--without-ads"
|
2023-03-17 21:50:16 +00:00
|
|
|
] ++ optionals (!enableLDAP && stdenv.hostPlatform.isLinux) [
|
2023-01-02 09:41:12 +00:00
|
|
|
"--bundled-libraries=!ldb,!pyldb-util!talloc,!pytalloc-util,!tevent,!tdb,!pytdb"
|
2023-01-03 22:16:35 +00:00
|
|
|
] ++ optional enableLibunwind "--with-libunwind"
|
|
|
|
++ optional enableProfiling "--with-profiling-data"
|
2020-03-25 10:23:36 +00:00
|
|
|
++ optional (!enableAcl) "--without-acl-support"
|
2020-10-03 23:02:46 +00:00
|
|
|
++ optional (!enablePam) "--without-pam"
|
|
|
|
++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
|
|
|
"--bundled-libraries=!asn1_compile,!compile_et"
|
wafHook: don't add cross compilation flags
These flags are not part of waf, they're custom flags that are not
widely implemented. More packages are broken because of these flags
being added than actually recognise them.
Of the packages in Nixpkgs that directly depend on wafHook that we can
attempt to cross compile (i.e. all their dependencies cross compile),
5 already successfully cross compile and recognise these flags, 2
already successfully cross compile because they have been opted out of
these flags, 3 don't cross compile successfully for reasons unrelated
to these flags, and for the remaining 7, the only thing stopping them
cross compiling successfully is that they are being passed these flags
that they don't recognise.
All of the five successfully cross-compiling packages that do
recognise these flags are samba projects: ldb, talloc, tdb, tevent,
and samba4. So this isn't a general waf convention, just a samba one.
It therefore doesn't make sense to set these flags by default. They
should just be included in the expressions for each samba project,
like all the other quirks common to samba build systems.
This change fixes cross compilation of the following packages:
blockhash ganv ndn-cxx mda_lv2 pflask raul saldl
2024-05-09 16:41:48 +00:00
|
|
|
"--cross-compile"
|
|
|
|
"--cross-execute=${stdenv.hostPlatform.emulator buildPackages}"
|
pkgsi686Linux.samba: don't configure `waf` in parallel on 32-bit systems
Without the change `waf configure` hung on `i686Linux.samba` on systems
with large amount of host CPUs (for me it's 16).
This happens because one of the worker processes gets `-ENOMEM` and does
not recover from it:
2084476 mmap2(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = -1 ENOMEM (Cannot allocate memory)
2084476 munmap(0xf2b5c000, 16384) = 0
2084476 rt_sigprocmask(SIG_BLOCK, ~[RT_1], NULL, 8) = 0
2084476 madvise(0x1ff000, 8372224, MADV_DONTNEED) = 0
2084476 exit(0) = ?
2084476 +++ exited with 0 +++
THe change extends 32-bit arm workaround to limit to one thread to all
32-bit systems.
2024-02-16 23:14:39 +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-16 08:10:18 +00:00
|
|
|
"--jobs 1"
|
2020-10-03 23:02:46 +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";
|
2015-03-04 21:46:20 +00:00
|
|
|
|
2023-11-24 13:31:19 +00:00
|
|
|
pythonPath = [ python3Packages.dnspython python3Packages.markdown tdb ];
|
2021-08-03 16:07:23 +00:00
|
|
|
|
2018-12-24 04:37:01 +00:00
|
|
|
preBuild = ''
|
2019-09-13 18:54:14 +00:00
|
|
|
export MAKEFLAGS="-j $NIX_BUILD_CORES"
|
2018-12-24 04:37:01 +00:00
|
|
|
'';
|
2015-01-03 05:21:34 +00:00
|
|
|
|
2022-11-13 22:38:56 +00:00
|
|
|
# Save asn1_compile and compile_et so they are available to run on the build
|
|
|
|
# platform when cross-compiling
|
2024-05-13 19:55:28 +00:00
|
|
|
postInstall = lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
|
2022-11-13 22:38:56 +00:00
|
|
|
mkdir -p "$dev/bin"
|
|
|
|
cp bin/asn1_compile bin/compile_et "$dev/bin"
|
|
|
|
'';
|
|
|
|
|
2016-02-27 20:18:31 +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.
|
2015-03-13 00:34:22 +00:00
|
|
|
postFixup = ''
|
2023-01-03 22:16:35 +00:00
|
|
|
export SAMBA_LIBS="$(find $out -type f -regex '.*\${stdenv.hostPlatform.extensions.sharedLibrary}\(\..*\)?' -exec dirname {} \; | sort | uniq)"
|
2015-06-10 23:22:37 +00:00
|
|
|
read -r -d "" SCRIPT << EOF || true
|
2015-03-13 00:34:22 +00:00
|
|
|
[ -z "\$SAMBA_LIBS" ] && exit 1;
|
|
|
|
BIN='{}';
|
2023-01-03 22:16:35 +00:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isLinux ''
|
2015-03-13 00:34:22 +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-03 22:16:35 +00:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.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
|
|
|
|
'' + ''
|
2015-03-13 00:34:22 +00:00
|
|
|
EOF
|
2023-01-03 22:16:35 +00:00
|
|
|
find $out -type f -regex '.*\${stdenv.hostPlatform.extensions.sharedLibrary}\(\..*\)?' -exec $SHELL -c "$SCRIPT" \;
|
|
|
|
find $out/bin -type f -exec $SHELL -c "$SCRIPT" \;
|
2020-10-03 23:02:46 +00:00
|
|
|
|
2021-08-03 16:07:23 +00:00
|
|
|
# Fix PYTHONPATH for some tools
|
|
|
|
wrapPythonPrograms
|
2022-07-23 02:27:01 +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
|
2023-11-24 13:31:19 +00:00
|
|
|
sed -i 's^${lib.getBin buildPackages.python3Packages.python}^${lib.getBin python}^' "$file"
|
2022-07-23 02:27:01 +00:00
|
|
|
done
|
2015-03-13 00:34:22 +00:00
|
|
|
'';
|
|
|
|
|
2022-07-23 02:27:01 +00:00
|
|
|
disallowedReferences =
|
2023-11-28 08:46:07 +00:00
|
|
|
lib.optionals (buildPackages.python3Packages.python != python3Packages.python)
|
2022-07-23 02:27:01 +00:00
|
|
|
[ buildPackages.python3Packages.python ];
|
|
|
|
|
2024-04-06 11:15:55 +00:00
|
|
|
passthru.tests = {
|
|
|
|
samba = nixosTests.samba;
|
2024-11-22 22:58:25 +00:00
|
|
|
cross = pkgsCross.aarch64-multiplatform.samba;
|
2024-04-06 11:15:55 +00:00
|
|
|
pkg-config = testers.hasPkgConfigModules {
|
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
};
|
|
|
|
version = testers.testVersion {
|
|
|
|
command = "${finalAttrs.finalPackage}/bin/smbd -V";
|
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
};
|
2020-05-19 12:20:34 +00:00
|
|
|
};
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-09-13 18:54:14 +00:00
|
|
|
homepage = "https://www.samba.org";
|
2015-01-03 05:21:34 +00:00
|
|
|
description = "Standard Windows interoperability suite of programs for Linux and Unix";
|
|
|
|
license = licenses.gpl3;
|
|
|
|
platforms = platforms.unix;
|
2023-01-03 22:16:35 +00:00
|
|
|
broken = enableGlusterFS;
|
2018-12-24 04:37:01 +00:00
|
|
|
maintainers = with maintainers; [ aneeshusa ];
|
2024-04-06 11:15:55 +00:00
|
|
|
pkgConfigModules = [
|
|
|
|
"dcerpc_samr"
|
|
|
|
"dcerpc"
|
|
|
|
"ndr_krb5pac"
|
|
|
|
"ndr_nbt"
|
|
|
|
"ndr_standard"
|
|
|
|
"ndr"
|
|
|
|
"netapi"
|
|
|
|
"samba-credentials"
|
|
|
|
"samba-hostconfig"
|
|
|
|
"samba-util"
|
|
|
|
"samdb"
|
|
|
|
"smbclient"
|
|
|
|
"wbclient"
|
|
|
|
];
|
2015-01-03 05:21:34 +00:00
|
|
|
};
|
2024-04-06 11:15:55 +00:00
|
|
|
})
|