bphenriques / dotfiles

dotfiles using Nix
MIT License
9 stars 0 forks source link

Apple Silicon: Smoother integration #6

Closed bphenriques closed 2 years ago

bphenriques commented 3 years ago

Had to manually remove IntelliJ and Docker from Homebrew.

Most likely need to review if some packages can now be fetched from nixpkgs and not from Homebrew.

bphenriques commented 2 years ago

Also use pkgs.stdenv.hostPlatform.isAarch64 to check

bphenriques commented 2 years ago

Reference:

bphenriques commented 2 years ago

How to override some packages:

      x86-packages = final: prev: (optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
        inherit (final.pkgs-x86);
        # google-cloud-sdk
        # ngrok;
      });
      apple-silicon = final: prev: optionalAttrs (prev.stdenv.system == "aarch64-darwin") {
        # Add access to x86 packages system is running Apple Silicon
        pkgs-x86 = import inputs.nixpkgs-unstable {
          system = "x86_64-darwin";
          inherit (nixpkgsConfig) config;
        };
      };
bphenriques commented 2 years ago

Not sure if this is actually needed:

          nix.extraOptions = ''
            auto-optimise-store = true
            experimental-features = nix-command flakes
          '' + lib.optionalString (pkgs.system == "aarch64-darwin") ''
            extra-platforms = x86_64-darwin aarch64-darwin
          '';

Reason: I think I saw a PR/commit where the extra-platforms is set automatically on nix-darwin.

bphenriques commented 2 years ago

This might be needed to setup Rosetta on macos:

$ /usr/sbin/softwareupdate --install-rosetta --agree-to-license
bphenriques commented 2 years ago
CPU=$(uname -p)
if [[ "$CPU" == "arm" ]]; then
    eval $(/opt/homebrew/bin/brew shellenv)
else
    eval $(/opt/homebrew/bin/brew shellenv)
    eval $(/usr/local/bin/brew shellenv)
fi