DeterminateSystems / zero-to-nix

Zero to Nix is your guide to learning Nix and flakes. Created by Determinate Systems.

Home Page:https://zero-to-nix.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why it setup `x86_64-darwin` in M1?

mamcx opened this issue · comments

I have a lot of problems because I tried to install aarch64-darwin packages but look like the setup with this in set to x86_64-darwin, despite I'm running in M1.

How I can set the correct arch.?

Could you point to a specific place in the tutorials where this happened?

I just run the tutorial as-is:

➜ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
info: downloading installer https://install.determinate.systems/nix/tag/v0.11.0/nix-installer-aarch64-darwin
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...

, then generate the flake nix flake init -t nix-darwin and get:

{
  description = "Example Darwin system flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    nix-darwin.url = "github:LnL7/nix-darwin";
    nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs@{ self, nix-darwin, nixpkgs }:
  let
    configuration = { pkgs, ... }: {
      # List packages installed in system profile. To search by name, run:
      # $ nix-env -qaP | grep wget
      environment.systemPackages =
        [ pkgs.vim
        ];

      # Auto upgrade nix package and the daemon service.
      services.nix-daemon.enable = true;
      # nix.package = pkgs.nix;

      # Necessary for using flakes on this system.
      nix.settings.experimental-features = "nix-command flakes";

      # Create /etc/zshrc that loads the nix-darwin environment.
      programs.zsh.enable = true;  # default shell on catalina
      # programs.fish.enable = true;

      # Set Git commit hash for darwin-version.
      system.configurationRevision = self.rev or self.dirtyRev or null;

      # Used for backwards compatibility, please read the changelog before changing.
      # $ darwin-rebuild changelog
      system.stateVersion = 4;

      # The platform the configuration will be used on.
      nixpkgs.hostPlatform = "x86_64-darwin";
    };
  in
  {
    # Build darwin flake using:
    # $ darwin-rebuild build --flake .#mandalorian
    darwinConfigurations."mandalorian" = nix-darwin.lib.darwinSystem {
      modules = [ configuration ];
    };

    # Expose the package set, including overlays, for convenience.
    darwinPackages = self.darwinConfigurations."mandalorian".pkgs;
  };
}

Change nixpkgs.hostPlatform = "x86_64-darwin"; to aarch64-darwin cause the error:

➜     nix --extra-experimental-features "nix-command flakes" \
        run nix-darwin -- switch --flake .#mandalorian
warning: creating lock file '/Users/mamcx/Proyectos/basura/cli/flake.lock'
building the system configuration...
error: a 'aarch64-darwin' with features {} is required to build '/nix/store/asa4mb1q7clvavanjkxmbgbb92j54dgs-builder.pl.drv', but I am a 'x86_64-darwin' with features {benchmark, big-parallel, nixos-test}

Adding it to the global config also get the same error:

# WARNING: this file is generated from the nix.* options in
# your nix-darwin configuration. Do not edit it!
allowed-users = *
auto-optimise-store = true
# WARNING: this file is generated from the nix.* options in
# your nix-darwin configuration. Do not edit it!
allowed-users = *
system = aarch64-darwin
....

This is an issue with that specific flake template, not with the instructions in Zero to Nix. I'd recommend submitting an issue to the nix-darwin project, potentially requesting multiple flake templates supporting different macOS architectures.

Also, please note that when you install using the Determinate Nix Installer, flakes should already be enabled, so you don't need to attach the -extra-experimental-features "nix-command flakes" option to your commands.