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

nix: add binaryTarball derivation #51626

Closed
wants to merge 1 commit into from
Closed

nix: add binaryTarball derivation #51626

wants to merge 1 commit into from

Conversation

ju1m
Copy link
Contributor

@ju1m ju1m commented Dec 6, 2018

Copy (and adapt a little) the binaryTarball derivation found in nix's release.nix:
https://github.com/NixOS/nix/blob/4aee93d5ce6cf77e314e93074b9da1dcff8979e9/release.nix#L115

binaryTarball is useful for cross-compiling nix:

nix build nixpkgs.pkgsCross.armv7l-hf-multiplatform.nix.binaryTarball

Which builds a result/nix-2.1.3-armv7a-linux.tar.bz2
packing an install script which will create a nix store
and most importantly register in it the closure of the nix package
(using nix-store --load-db).

NOTE: the tarball can be quite bigger than expected (~450Mo), mainly because gcc is not stripped by default when cross-compiling.

Motivation for this change

Cross-compiling nix (eg. for ARM) and packing everything needed to install it in a tarball.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy (and adapt a little) the `binaryTarball` derivation found in `nix`'s `release.nix`:
https://github.com/NixOS/nix/blob/4aee93d5ce6cf77e314e93074b9da1dcff8979e9/release.nix#L115

`binaryTarball` is useful for cross-compiling `nix`:
```
nix build nixpkgs.pkgsCross.armv7l-hf-multiplatform.nix.binaryTarball
```
Which builds a `result/nix-2.1.3-armv7a-linux.tar.bz2`
packing an `install` script which will create a nix store
and most importantly register in it the closure of the `nix` package
(using `nix-store --load-db`).
@ju1m
Copy link
Contributor Author

ju1m commented Dec 7, 2018

Unfortunately there is a problem with the cross-compiling: some packages have binaries for the host platform.

Packages of the tarball with host platform binaries:

$ find nix-2.1.3-armv7a-linux -type f -executable -exec file {} \; | grep x86-64, >x86-64.list
$ <x86-64.list sed -ne 's:^[^/]*/store/[^/-]*-\([^/]*\)/.*:\1:p' | sort -u
armv7a-unknown-linux-gnueabihf-binutils-2.30
armv7a-unknown-linux-gnueabihf-stage-final-gcc-debug-7.3.0
armv7a-unknown-linux-gnueabihf-stage-final-gcc-debug-7.3.0-lib
armv7a-unknown-linux-gnueabihf-stage-static-gcc-debug-7.3.0
armv7a-unknown-linux-gnueabihf-stage-static-gcc-debug-7.3.0-lib
bash-4.4-p23
bzip2-1.0.6.0.1
bzip2-1.0.6.0.1-bin
coreutils-8.29
expand-response-params
gcc-7.3.0
gcc-7.3.0-lib
glibc-2.27
glibc-2.27-bin
gmp-6.1.2
gnutar-1.30
gzip-1.9
isl-0.17.1
libmpc-1.1.0
mpfr-4.0.1
xz-5.2.4
xz-5.2.4-bin
zlib-1.2.11

Packages of the tarball with target platform binaries:

$ find nix-2.1.3-armv7a-linux -type f -executable -exec file {} \; | grep ARM, >arm.list
$ <arm.list sed -ne 's:^[^/]*/store/[^/-]*-\([^/]*\)/.*:\1:p' | sort -u 
armv7a-unknown-linux-gnueabihf-stage-final-gcc-debug-7.3.0
boehm-gc-7.6.6-armv7a-unknown-linux-gnueabihf
busybox-1.29.3-armv7a-unknown-linux-gnueabihf
bzip2-1.0.6.0.1-armv7a-unknown-linux-gnueabihf
curl-7.59.0-armv7a-unknown-linux-gnueabihf
curl-7.62.0-armv7a-unknown-linux-gnueabihf
glibc-2.27-armv7a-unknown-linux-gnueabihf
glibc-2.27-armv7a-unknown-linux-gnueabihf-bin
keyutils-1.5.10-armv7a-unknown-linux-gnueabihf-lib
libseccomp-2.3.3-armv7a-unknown-linux-gnueabihf-lib
libsodium-1.0.16-armv7a-unknown-linux-gnueabihf
libssh2-1.8.0-armv7a-unknown-linux-gnueabihf
nghttp2-1.32.0-armv7a-unknown-linux-gnueabihf-lib
nix-2.1.3-armv7a-unknown-linux-gnueabihf
openssl-1.0.2p-armv7a-unknown-linux-gnueabihf
sqlite-3.24.0-armv7a-unknown-linux-gnueabihf
xz-5.2.4-armv7a-unknown-linux-gnueabihf
zlib-1.2.11-armv7a-unknown-linux-gnueabihf

Note also that curl appears two times.

@nixos-discourse
Copy link

This pull request has been mentioned on Nix community. There might be relevant details there:

https://discourse.nixos.org/t/how-to-install-nix-package-manager-on-raspbian/2035/9

@edolstra
Copy link
Member

edolstra commented Feb 5, 2019

IMHO this is not the right approach since:

  • It duplicates code from Nix's release.nix.

  • It adds a non-package derivation to Nixpkgs, so it clutters the package list (e.g. nix-binary-tarball will show up in nix-env -qa).

@matthewbauer
Copy link
Member

Ok closing for now. Thanks for the contribution but I think there is a better way. I've opened a PR at Nix to add some binary tarballs for armv6 & armv7:

NixOS/nix#2667

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants