Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure: nixStatic (bash: Argument list too long) #357949

Open
heywoodlh opened this issue Nov 21, 2024 · 5 comments
Open

Build failure: nixStatic (bash: Argument list too long) #357949

heywoodlh opened this issue Nov 21, 2024 · 5 comments
Labels
0.kind: build failure A package fails to build

Comments

@heywoodlh
Copy link
Contributor

How does one actually build nixStatic without a full installation of Nix, such as with the Nix official docker image? It'd be nice to do a multi-stage Docker build like so:

FROM docker.io/nixos/nix AS nix-static-builder

RUN nix --extra-experimental-features "flakes nix-command" build -o /tmp/nix nixpkgs#nixStatic

FROM alpine

COPY --from=nix-static-builder /tmp/nix/bin/nix /usr/bin/nix

Also, is there any predictable URL to grab the static binary besides directly from Hydra? This seems to work for me:

nix run "nixpkgs#curl" -- -L https://hydra.nixos.org/job/nix/maintenance-$(nix --version | nix run "nixpkgs#gawk" -- '{print $3}' | cut -d'.' -f1-2)/buildStatic.nix.$(nix run "nixpkgs#busybox" -- arch)-linux/latest/download-by-type/file/binary-dist -o /nix-bin \
    && chmod +x /nix-bin

😄

Steps To Reproduce

Steps to reproduce the behavior:

  1. Attempt to build nixStatic without downloading from the binary cache, i.e. docker run -it --rm docker.io/nixos/nix nix --extra-experimental-features 'nix-command flakes' build -o /tmp/nix nixpkgs#nixStatic

  2. My laptop running NixOS seems to build it just fine -- but I suspect it's pulling down from the binary cache

Build log

Build Log

(I can get the entire log if desired/needed -- I don't think it's necessary for this example)

❯ docker run -it --rm docker.io/nixos/nix nix --extra-experimental-features 'nix-command flakes' build -o /tmp/nix nixpkgs#nixStatic
error: builder for '/nix/store/28d5l059yypca26g7iria6yixg70q4rp-nix-static-x86_64-unknown-linux-musl-2.24.10.drv' failed with exit code 2;
       last 25 log lines:
       >   AR     src/libmain/libnixmain.a
       >   LD     src/libflake/libnixflake.a
       >   AR     src/libfetchers/libnixfetchers.a
       >   AR     src/libflake/libnixflake.a
       >   LD     src/libcmd/libnixcmd.a
       >   LD     tests/unit/libutil-support/libnixutil-test-support.a
       >   AR     tests/unit/libutil-support/libnixutil-test-support.a
       >   LD     src/libutil-c/libnixutilc.a
       >   AR     src/libutil-c/libnixutilc.a
       >   LD     tests/unit/libstore-support/libnixstore-test-support.a
       >   LD     src/libstore-c/libnixstorec.a
       >   AR     src/libstore-c/libnixstorec.a
       >   LD     tests/unit/libexpr-support/libnixexpr-test-support.a
       >   AR     tests/unit/libexpr-support/libnixexpr-test-support.a
       >   LD     src/libexpr-c/libnixexprc.a
       >   AR     tests/unit/libstore-support/libnixstore-test-support.a
       >   LD     tests/unit/libutil/libnixutil-tests
       >   AR     src/libcmd/libnixcmd.a
       >   AR     src/libexpr-c/libnixexprc.a
       >   LD     src/libexpr/libnixexpr.a
       >   AR     src/libexpr/libnixexpr.a
       >   LD     src/libstore/libnixstore.a
       >   AR     src/libstore/libnixstore.a
       > make: /nix/store/0irlcqx2n3qm6b1pc9rsd2i8qpvcccaj-bash-5.2p37/bin/bash: Argument list too long
       > make: *** [mk/lib.mk:85: src/nix/nix] Error 127
       For full logs, run 'nix log /nix/store/28d5l059yypca26g7iria6yixg70q4rp-nix-static-x86_64-unknown-linux-musl-2.24.10.drv'.

Additional context

Metadata

Notify maintainers

@edolstra
@lovesegfault
@Artturin


Note for maintainers: Please tag this issue in your PR.


Add a 👍 reaction to issues you find important.

@heywoodlh heywoodlh added the 0.kind: build failure A package fails to build label Nov 21, 2024
@celesrenata
Copy link

I get this failure in 24.05 when trying to upgrade, or from unstable trying to install 24.11, distributive builds also fail on this package.

@celesrenata
Copy link

Looks like our error is showing up in hydra.

https://hydra.nixos.org/build/278785914/nixlog/1

@Artturin
Copy link
Member

Artturin commented Nov 23, 2024

Since it seems to be a musl only thing and nix has completely replaced autoconf with meson(not in nixpkgs yet) I won't look further in to it.

If someone wants to look in to it then probably start at
https://github.com/NixOS/nix/blob/278e02c0efc83bdaec0c93bb8315560528516ab0/mk/lib.mk#L85
https://github.com/NixOS/nix/blob/278e02c0efc83bdaec0c93bb8315560528516ab0/mk/programs.mk#L34

@Artturin
Copy link
Member

Artturin commented Nov 24, 2024

You can attempt to build nix-everything-static in NixOS/nix

EDIT:
That attempts to build the perl bindings and perl static is broken in their nixpkgs revision so comment everything nix-perl-bindings in ./packaging/everything.nix

Perl cross-compiles on master(and 24.11 probably) so the bindings should be fixed after NixOS/nix#11566

@ShamrockLee
Copy link
Contributor

How does one actually build nixStatic without a full installation of Nix, such as with the Nix official docker image?

The Hydra job nix:master:buildStatic.x86_64-linux (for the Nix project, building the Nix master branch) builds the static Nix binary on Nix master. This URL downloads the binary: https://hydra.nixos.org/job/nix/master/buildStatic.x86_64-linux/latest/download-by-type/file/binary-dist As Eelco Dolstra suggested in the NixOS Discourse reply: https://discourse.nixos.org/t/building-a-statically-linked-nix-for-hpc-environments/10865/16

The Hydra jobs nixpkgs:trunk:nixStatic.x86_64-linux and nixos:release-24.05:nixpkgs.nixStatic.x86_64-linux builds the nixStatic package from Nixpkgs release-24.05 and master, respectively. The Nixpkgs 24.11 one is failing due to this issue. It's a bit more complicated to get the binary without a working nix command. Here's a way provided by Felix Uhl: https://discourse.nixos.org/t/where-can-i-get-a-statically-built-nix/34253/6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: build failure A package fails to build
Projects
None yet
Development

No branches or pull requests

4 participants