From 3dae8fdd0a1c1888d5b032e1676236d3b43d241a Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Thu, 15 Jan 2026 14:03:15 +0200 Subject: [PATCH 1/5] samba: consistently use isCross using lib.systems.equal --- pkgs/servers/samba/4.x.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/servers/samba/4.x.nix b/pkgs/servers/samba/4.x.nix index 502dff10a6f9..55664fb5418d 100644 --- a/pkgs/servers/samba/4.x.nix +++ b/pkgs/servers/samba/4.x.nix @@ -76,6 +76,7 @@ let } .${stdenv.hostPlatform.system} or (throw "Need pre-generated answers file to compile for ${stdenv.hostPlatform.system}"); + isCross = !lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform; in stdenv.mkDerivation (finalAttrs: { pname = "samba"; @@ -129,7 +130,7 @@ stdenv.mkDerivation (finalAttrs: { ++ optionals stdenv.hostPlatform.isLinux [ buildPackages.stdenv.cc ] - ++ optional (stdenv.buildPlatform != stdenv.hostPlatform) samba # asn1_compile/compile_et + ++ optional isCross samba # asn1_compile/compile_et ++ optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ]; @@ -193,7 +194,7 @@ stdenv.mkDerivation (finalAttrs: { patchShebangs ./buildtools/bin '' - + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + + lib.optionalString isCross '' substituteInPlace wscript source3/wscript nsswitch/wscript_build lib/replace/wscript source4/ntvfs/sysdep/wscript_configure --replace-fail 'sys.platform' '"${stdenv.hostPlatform.parsed.kernel.name}"' ''; @@ -314,9 +315,9 @@ stdenv.mkDerivation (finalAttrs: { done ''; - disallowedReferences = lib.optionals ( - buildPackages.python3Packages.python != python3Packages.python - ) [ buildPackages.python3Packages.python ]; + disallowedReferences = lib.optionals isCross [ + buildPackages.python3Packages.python + ]; passthru.tests = { samba = nixosTests.samba; From b78fd11bc695c145b4ad27a9cbb4df31998c0ae6 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Thu, 15 Jan 2026 15:26:59 +0200 Subject: [PATCH 2/5] samba.tests.cross: make it fail due to disallowed references --- pkgs/servers/samba/4.x.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/servers/samba/4.x.nix b/pkgs/servers/samba/4.x.nix index 55664fb5418d..2b0a7f76eab3 100644 --- a/pkgs/servers/samba/4.x.nix +++ b/pkgs/servers/samba/4.x.nix @@ -317,6 +317,7 @@ stdenv.mkDerivation (finalAttrs: { disallowedReferences = lib.optionals isCross [ buildPackages.python3Packages.python + buildPackages.runtimeShellPackage ]; passthru.tests = { From 4d577acbc242a86397dda59502b44ab630eb1d41 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Thu, 15 Jan 2026 15:27:29 +0200 Subject: [PATCH 3/5] samba: use substitutionInPlace instead of sed in fixup substituteInPlace is more reliable as sed won't print any warning or error when it does nothing. --- pkgs/servers/samba/4.x.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/servers/samba/4.x.nix b/pkgs/servers/samba/4.x.nix index 2b0a7f76eab3..6d68a2b8b44e 100644 --- a/pkgs/servers/samba/4.x.nix +++ b/pkgs/servers/samba/4.x.nix @@ -311,7 +311,10 @@ stdenv.mkDerivation (finalAttrs: { # Samba does its own shebang patching, but uses build Python find $out/bin -type f -executable | while read file; do isScript "$file" || continue - sed -i 's^${lib.getBin buildPackages.python3Packages.python}^${lib.getBin python3Packages.python}^' "$file" + substituteInPlace "$file" \ + --replace-fail \ + ${lib.getBin buildPackages.python3Packages.python} \ + ${lib.getBin python3Packages.python} done ''; From 9291bd92f6caeb98cead84977ab91c7cd3e6d221 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Thu, 15 Jan 2026 16:18:34 +0200 Subject: [PATCH 4/5] samba: set strictDeps It doesn't fix the cross compilation issues related to the surrounding commits, but it is a good idea to set it anyway. Also, `libtasn1` needs to be added nativeBuildInputs for `asn1Parser` to be detected properly and for `bin/dumpmscat` script to be added. --- pkgs/servers/samba/4.x.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/servers/samba/4.x.nix b/pkgs/servers/samba/4.x.nix index 6d68a2b8b44e..de5a3b225876 100644 --- a/pkgs/servers/samba/4.x.nix +++ b/pkgs/servers/samba/4.x.nix @@ -122,6 +122,7 @@ stdenv.mkDerivation (finalAttrs: { perl.pkgs.ParseYapp perl.pkgs.JSON libxslt + libtasn1 # Needed also natively for `asn1Parser` program docbook_xsl docbook_xml_dtd_45 cmocka @@ -267,6 +268,8 @@ stdenv.mkDerivation (finalAttrs: { tdb ]; + strictDeps = true; + preBuild = '' export MAKEFLAGS="-j $NIX_BUILD_CORES" ''; From 19cbbeae0fc7bbf9a20d8f590f866aa00b7eb3e4 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 18 Jan 2026 02:26:30 +0200 Subject: [PATCH 5/5] samba: avoid shebang patching by using correct pythonWrap As explained in #480392, the shebangs need fixing not because of samba's build system, but because our `wrapPythonPrograms` is buggy. --- pkgs/servers/samba/4.x.nix | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pkgs/servers/samba/4.x.nix b/pkgs/servers/samba/4.x.nix index de5a3b225876..1dbfd1528467 100644 --- a/pkgs/servers/samba/4.x.nix +++ b/pkgs/servers/samba/4.x.nix @@ -35,6 +35,7 @@ rpcsvc-proto, bash, python3Packages, + pkgsHostTarget, nixosTests, libiconv, testers, @@ -113,7 +114,10 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ python3Packages.python - python3Packages.wrapPython + # Not `python3Packages.wrapPython` to workaround + # `python3Packages.wrapPython.__spliced.buildHost` having the wrong + # `pythonHost`. See https://github.com/NixOS/nixpkgs/issues/434307 + pkgsHostTarget.python3Packages.wrapPython wafHook pkg-config bison @@ -310,15 +314,6 @@ stdenv.mkDerivation (finalAttrs: { # Fix PYTHONPATH for some tools wrapPythonPrograms - - # Samba does its own shebang patching, but uses build Python - find $out/bin -type f -executable | while read file; do - isScript "$file" || continue - substituteInPlace "$file" \ - --replace-fail \ - ${lib.getBin buildPackages.python3Packages.python} \ - ${lib.getBin python3Packages.python} - done ''; disallowedReferences = lib.optionals isCross [