Skip to content

Instantly share code, notes, and snippets.

@mbr

mbr/console Secret

Last active March 11, 2021 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbr/d447c321897e07d5d43c6a2ebaa79573 to your computer and use it in GitHub Desktop.
Save mbr/d447c321897e07d5d43c6a2ebaa79573 to your computer and use it in GitHub Desktop.
$ cat crossShell.nix
with import <nixpkgs> {
crossSystem = {
config = "x86_64-apple-darwin";
};
};
mkShell {
buildInputs = [ ];
}
$ nix-shell crossShell.nix
error: Package ‘libtapi-1000.10.8’ in /nix/store/51drxa59xkrkma7r5gi022jv6iwngh0g-nixos-20.09.3418.89a06218ca0/nixos/pkgs/os-specific/darwin/libtapi/default.nix:4 is marked as broken, refusing to evaluate.
a) For `nixos-rebuild` you can set
{ nixpkgs.config.allowBroken = true; }
in configuration.nix to override this.
b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
{ allowBroken = true; }
to ~/.config/nixpkgs/config.nix.
(use '--show-trace' to show detailed location information)
$ env NIXPKGS_ALLOW_BROKEN=1 nix-shell crossShell.nix
these derivations will be built:
/nix/store/7k31xjah2a51b9gsg6ikgpzzzh2fbf10-Xcode.app.drv
/nix/store/lys33vrqawynf0lks70v658jahvbp75h-x86_64-apple-darwin-binutils-2.31.1.drv
/nix/store/44y9dw1sfii312rk922f7lvykqyy87fw-libtapi-1000.10.8.drv
/nix/store/xn0qxkj3d7y5d6pxhjz88zjvkd7zqi6v-x86_64-apple-darwin-cctools-port.drv
/nix/store/g2asa78cqy44i5hgqlkvww5h40cpnxbq-x86_64-apple-darwin-cctools-binutils-darwin-927.0.2.drv
/nix/store/4rn7g2v4242q5x4b301d7kizj18h271d-x86_64-apple-darwin-cctools-binutils-darwin-wrapper-927.0.2.drv
/nix/store/fqfkgsriz3fjb9iyx0hlbszvryjwsclm-x86_64-apple-darwin-stage-final-gcc-debug-9.3.0.drv
/nix/store/nhakbykzrswwyhwyyqc6xhq3n3yl7isk-x86_64-apple-darwin-stage-final-gcc-debug-wrapper-9.3.0.drv
/nix/store/42z6hbgli7g5kp77ql98whikfzfh1rp0-stdenv-linux.drv
building '/nix/store/7k31xjah2a51b9gsg6ikgpzzzh2fbf10-Xcode.app.drv'...
building '/nix/store/lys33vrqawynf0lks70v658jahvbp75h-x86_64-apple-darwin-binutils-2.31.1.drv'...
building '/nix/store/44y9dw1sfii312rk922f7lvykqyy87fw-libtapi-1000.10.8.drv'...
***
Unfortunately, we cannot download Xcode.app automatically.
Please go to https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_10.3/Xcode_10.3.xip
to download it yourself, and add it to the Nix store by running the following commands.
Note: download (~ 5GB), extraction and storing of Xcode will take a while
open -W Xcode_10.3.xip
rm -rf Xcode_10.3.xip
nix-store --add-fixed --recursive sha256 Xcode.app
rm -rf Xcode.app
***
builder for '/nix/store/7k31xjah2a51b9gsg6ikgpzzzh2fbf10-Xcode.app.drv' failed with exit code 1
cannot build derivation '/nix/store/nhakbykzrswwyhwyyqc6xhq3n3yl7isk-x86_64-apple-darwin-stage-final-gcc-debug-wrapper-9.3.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/42z6hbgli7g5kp77ql98whikfzfh1rp0-stdenv-linux.drv': 1 dependencies couldn't be built
error: build of '/nix/store/42z6hbgli7g5kp77ql98whikfzfh1rp0-stdenv-linux.drv' failed
# The instructions are for Mac OS X, so I looked at
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/darwin/xcode/default.nix
# and wrote the following script:
$ cat -p build_xip.sh
#!/usr/bin/env nix-shell
#! nix-shell -p xar pbzx -i /bin/sh
set -x
set -eu
XIP=$1
xar -xf "${XIP}"
rm -rf "${XIP}"
pbzx -n Content | cpio -i
rm Content Metadata
nix-store --add-fixed --recursive sha256 Xcode.app
# Ran this in an empty directory on the downloaded XCode XIP, which added something to the store,
# but it seems to have the wrong hash.
# This is what ended up in my store:
# /nix/store/ra3rsnd6v7izjrz7rdmk8ps7nr6zx53f-Xcode.app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment