A modern, delicious implementation of the Nix package manager, focused on correctness, usability, and growth — and committed to doing right by its community https://lix.systems
Find a file
Matthew Bauer 4b9acf4e21 Use posix_spawn_setbinpref_np to advise which architecture to run
When running universal binaries like /bin/bash, Darwin XNU will choose
which architecture of the binary to use based on "binary preferences".
This change sets that to the current platform for aarch64 and x86_64
builds. In addition it now uses posix_spawn instead of the usual
execve. Note, that this does not prevent the other architecture from
being run, just advises which to use.

Unfortunately, posix_spawnattr_setbinpref_np does not appear to be
inherited by child processes in x86_64 Rosetta 2 translations, meaning
that this will not always work as expected.

For example:

  {
    arm = derivation {
      name = "test";
      system = "aarch64-darwin";
      builder = "/bin/bash";
      args = [ "-e" (builtins.toFile "test" ''
        set -x
        /usr/sbin/sysctl sysctl.proc_translated
        /usr/sbin/sysctl sysctl.proc_native
        [ "$(/usr/bin/arch)" = arm64 ]
        /usr/bin/touch $out
      '') ];
    };
    rosetta = derivation {
      name = "test";
      system = "x86_64-darwin";
      builder = "/bin/bash";
      args = [ "-e" (builtins.toFile "test" ''
        set -x
        /usr/sbin/sysctl sysctl.proc_translated
        /usr/sbin/sysctl sysctl.proc_native
        [ "$(/usr/bin/arch)" = i386 ]
        echo It works!
        /usr/bin/touch $out
      '') ];
    };
  }

`arm' fails on x86_64-compiled Nix, but `arm' and `rosetta' succeed on
aarch64-compiled Nix. I suspect there is a way to fix this since:

  $ /usr/bin/arch -arch x86_64 /bin/bash \
    -c '/usr/bin/arch -arch arm64e /bin/bash -c /usr/bin/arch'
  arm64

seems to work correctly. We may need to wait for Apple to update
system_cmds in opensource.apple.com to find out how though.
2020-12-03 15:41:59 -06:00
.github Bump cachix/install-nix-action from v11 to v12 (#4237) 2020-11-09 23:21:55 +00:00
config update config/config.{sub,guess} 2018-08-13 20:00:17 +00:00
contrib function-trace: always show the trace 2019-09-18 23:23:21 +02:00
corepkgs fix typo in comment in fetchurl.nix 2020-11-18 11:20:50 +07:00
doc/manual Fix macOS sandbox build 2020-11-23 17:40:17 +01:00
m4 autoconf: Fix C++17 detection not working on Ubuntu 16.04. 2019-07-03 04:32:25 +02:00
maintainers set Content-Type to "text/plain" for install script 2020-08-20 13:21:22 +02:00
misc Add some missing clean-files 2020-10-18 20:32:59 +02:00
mk Make a better -lz hack 2020-10-15 20:13:01 +00:00
nix-rust rust: small patches 2020-10-08 13:40:47 +02:00
perl Return signatures in Perl path info 2020-11-21 22:06:15 +00:00
scripts installer: simplify the per-build installation 2020-11-21 19:56:46 +01:00
src Use posix_spawn_setbinpref_np to advise which architecture to run 2020-12-03 15:41:59 -06:00
tests Merge pull request #4284 from tweag/fixed-output-depending-on-ca 2020-12-01 20:25:41 +01:00
.dir-locals.el .dir-locals.el: Set c-block-comment-prefix 2020-07-10 11:21:06 +02:00
.editorconfig Add .editorconfig 2017-06-05 22:57:28 +01:00
.gitignore Update .gitignore 2020-10-18 20:32:46 +02:00
.version Revert "Bump version to 3.0" 2020-10-26 11:30:18 +01:00
bootstrap.sh bootstrap: Simplify & make more robust. 2011-09-06 12:11:05 +00:00
configure.ac Make a better -lz hack 2020-10-15 20:13:01 +00:00
COPYING * Change this to LGPL to keep the government happy. 2006-04-25 16:41:06 +00:00
default.nix Simplify shell.nix and default.nix 2020-06-17 19:21:46 +02:00
flake.lock flake.lock: Update 2020-10-18 21:20:35 +02:00
flake.nix installer: simplify the per-build installation 2020-11-21 19:56:46 +01:00
local.mk mk/precompiled-headers.mk: Remove special handling for clang 2020-10-06 13:27:09 +02:00
Makefile Disable FORTIFY_SOURCE when compiling without optims 2020-09-22 10:04:25 +02:00
Makefile.config.in Remove references to xmllint 2020-07-23 18:26:48 +02:00
precompiled-headers.h Config: Use nlohmann/json 2020-08-20 11:02:16 +02:00
README.md Fix a typo (#4073) 2020-09-26 11:33:04 +00:00
shell.nix Add back flake-compat shell.nix 2020-07-17 14:58:59 +00:00

Nix

Open Collective supporters Test

Nix is a powerful package manager for Linux and other Unix systems that makes package management reliable and reproducible. Please refer to the Nix manual for more details.

Installation

On Linux and macOS the easiest way to install Nix is to run the following shell command (as a user other than root):

$ curl -L https://nixos.org/nix/install | sh

Information on additional installation methods is available on the Nix download page.

Building And Developing

See our Hacking guide in our manual for instruction on how to build nix from source with nix-build or how to get a development environment.

Additional Resources

License

Nix is released under the LGPL v2.1.