On Nixpkgs f2f805d6d8a370379d89972d45b16d008112b56a, pkgsStatic.busybox does not build. The buildPhase seems fine and the issue seems to be in the installPhase.
$ nix-build -A pkgsStatic.busybox
<...>
/nix/store/2wkwpm0qhkwwy393n55d0ag64mbhp9vw-x86_64-unknown-linux-musl-binutils-2.30/bin/x86_64-unknown-linux-musl-ld:INSTALL: file format not recognized; treating as linker script
/nix/store/2wkwpm0qhkwwy393n55d0ag64mbhp9vw-x86_64-unknown-linux-musl-binutils-2.30/bin/x86_64-unknown-linux-musl-ld:INSTALL:2: syntax error
collect2: error: ld returned 1 exit status
builder for '/nix/store/14wlq7nxfx2s4ay7j0l17b43b6ffbvlf-musl-1.1.20-x86_64-unknown-linux-musl.drv' failed with exit code 1
cannot build derivation '/nix/store/4kq0f9icgk481ayy8pbb9k3dzbab74p2-busybox-1.29.3-x86_64-unknown-linux-musl.drv': 1 dependencies couldn't be built
error: build of '/nix/store/4kq0f9icgk481ayy8pbb9k3dzbab74p2-busybox-1.29.3-x86_64-unknown-linux-musl.drv' failed
"x86_64-linux"Linux 4.19.4, NixOS, 18.09.1420.5d4a1a3897e (Jellyfish)yesyesnix-env (Nix) 2.1.3"nixos-18.09.1420.5d4a1a3897e"/nix/var/nix/profiles/per-user/root/channels/nixos/cc @Ericson2314 @matthewbauer
Yeah what's happening is that the musl hacks get in the way of an actual musl build. I think the solution is just to remove the musl hacks and use pkgsStatic.busybox whenever this is needed.
This should work:
diff --git a/pkgs/os-specific/linux/busybox/default.nix b/pkgs/os-specific/linux/busybox/default.nix
index 5f4efe943ca..f0bca240e71 100644
--- a/pkgs/os-specific/linux/busybox/default.nix
+++ b/pkgs/os-specific/linux/busybox/default.nix
@@ -1,7 +1,7 @@
{ stdenv, lib, buildPackages, fetchurl
, enableStatic ? false
, enableMinimal ? false
-, useMusl ? stdenv.hostPlatform.libc == "musl", musl
+, useMusl ? stdenv.hostPlatform.libc == "musl"
, extraConfig ? ""
}:
@@ -88,10 +88,6 @@ stdenv.mkDerivation rec {
runHook postConfigure
'';
- postConfigure = lib.optionalString useMusl ''
- makeFlagsArray+=("CC=${stdenv.cc.targetPrefix}cc -isystem ${musl.dev}/include -B${musl}/lib -L${musl}/lib")
- '';
-
depsBuildBuild = [ buildPackages.stdenv.cc ];
buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ];
The buildInputs can also removed. All that is what we did and if worked!
The buildInputs thing would still be needed if you are building static with glibc (see #51966).
Fair. But now that https://github.com/NixOS/nixpkgs/pull/51966 is merged, isn't that again not needed?
Should this be made a PR? Still fails to build, FWIW.
For anyone looking, this seems to work:
nix-build -E 'with import <nixos>{}; pkgs.pkgsStatic.busybox.overrideAttrs (old:{postConfigure="";})'
Most helpful comment
Should this be made a PR? Still fails to build, FWIW.