tweag/rules_nixpkgs

pkgsStatic.coreutils is no longer available on MacOS with recent nixpkgs

aherrmann opened this issue · 1 comments

Describe the bug
Updating the nixpkgs revision from NixOS/nixpkgs@ea4c80b (NixOS 22.11) to NixOS/nixpkgs@6500b45 (nixos-unstable at the time of writing) breaks the import of pkgsStatic.coreutils on MacOS 11 on x86_64, see this CI failure.

  error:
         … while calling the 'derivationStrict' builtin
  
           at /builtin/derivation.nix:9:12: (source not available)
  
         … while evaluating derivation 'coreutils-static-x86_64-apple-darwin-9.3'
           whose name attribute is located at /nix/store/i6hq63805y784dml4j8pgkrz3lryxzld-source/pkgs/stdenv/generic/make-derivation.nix:300:7
...
           at /nix/store/i6hq63805y784dml4j8pgkrz3lryxzld-source/pkgs/top-level/all-packages.nix:21811:69:
  
          21810|
          21811|   libcCross = assert stdenv.targetPlatform != stdenv.buildPlatform; libcCrossChooser stdenv.targetPlatform.libc;
               |                                                                     ^
          21812|
  
         … while calling 'libcCrossChooser'
  
           at /nix/store/i6hq63805y784dml4j8pgkrz3lryxzld-source/pkgs/top-level/all-packages.nix:21785:22:
  
          21784|   # We can choose:
          21785|   libcCrossChooser = name:
               |                      ^
          21786|     # libc is hackily often used from the previous stage. This `or`
  
         error: don't yet have a `targetPackages.darwin.LibsystemCross for x86_64-apple-darwin`
  INFO: Repository coreutils_static instantiated at:
    /Users/runner/work/rules_nixpkgs/rules_nixpkgs/WORKSPACE:45:16: in <toplevel>
    /private/var/tmp/_bazel_runner/a4a3182e50c9460fa52b8c6c1e6f916f/external/rules_nixpkgs_core/nixpkgs.bzl:723:21: in nixpkgs_package
  Repository rule _nixpkgs_package defined at:
    /private/var/tmp/_bazel_runner/a4a3182e50c9460fa52b8c6c1e6f916f/external/rules_nixpkgs_core/nixpkgs.bzl:591:35: in <toplevel>
  ERROR: An error occurred during the fetch of repository 'coreutils_static':
     Traceback (most recent call last):
  	File "/private/var/tmp/_bazel_runner/a4a3182e50c9460fa52b8c6c1e6f916f/external/rules_nixpkgs_core/nixpkgs.bzl", line 589, column 31, in _nixpkgs_package_impl
  		_nixpkgs_build_and_symlink(repository_ctx, [nix_build_path], expr_args, build_file_content)
  	File "/private/var/tmp/_bazel_runner/a4a3182e50c9460fa52b8c6c1e6f916f/external/rules_nixpkgs_core/nixpkgs.bzl", line 447, column 34, in _nixpkgs_build_and_symlink
  		exec_result = execute_or_fail(
  	File "/private/var/tmp/_bazel_runner/a4a3182e50c9460fa52b8c6c1e6f916f/external/rules_nixpkgs_core/util.bzl", line 97, column 13, in execute_or_fail
  		fail("""
  Error in fail: 
    Cannot build Nix derivation for package '@coreutils_static'.
      Command: "/nix/store/x5wfa3afc4l2rc7zx3wiiwcm5j3j4lbc-nix-2.17.0/bin/nix-build" "-I" "nixpkgs=/private/var/tmp/_bazel_runner/a4a3182e50c9460fa52b8c6c1e6f916f/external/nixpkgs/nixpkgs" "-E" "import <nixpkgs> { config = {}; overlays = []; }" "-A" "pkgsStatic.coreutils" "--out-link" "bazel-support/nix-out-link"
      Return code: 1
...

The same tests succeed on an arm64 MacOS machine.

To Reproduce
Update the nixpkgs revision used in the rules_nixpkgs tests as described above and run the tests in the top-level WORKSPACE on MacOS 11 x86_64.

Expected behavior
The tests should pass on MacOS x86_64 with pkgsStatic.coreutils as they did before the nixpkgs update. This may very well be an upstream nixpkgs issue. However, at this point I don't have enough information to raise a meaningful issue on nixpkgs itself. So, I'm opening this issue first.

Environment

  • OS name + version: MacOS 11 (GitHub actions)
  • Version of the code: 7e627d7 (master)

Additional context
This issue surfaced in the context of #423 and can be worked around by not using pkgsStatic on MacOS.

avdv commented

Opened an upstream issue: NixOS/nixpkgs#270375

This seems to be caused by this PR NixOS/nixpkgs#235990 which is (somewhat ironically) titled "nixStatic: Fix darwin".

The bottom line is that before that change coreutils and pkgsStatic.coreutils were exactly the same on Darwin:

$ nix-shell -I nixpkgs=./. --pure -p which pkgsStatic.coreutils --run 'which tsort'
/nix/store/3acj5l3cwmliiihig0hm6y4p0nsk8jgi-coreutils-9.1/bin/tsort
$ nix-shell -I nixpkgs=./. --pure -p which coreutils --run 'which tsort'
/nix/store/3acj5l3cwmliiihig0hm6y4p0nsk8jgi-coreutils-9.1/bin/tsort