Sorry, I thought you missed the code in my OP.
I created a small test flake.nix that can reproduce the issue. I also found out ~/Applications/Home Manager Apps/Emacs.app/Contents/MacOS/Emacs
is actually a bash script, which calls:
/nix/store/b6nbzyagfbq2spg7fm62rqv3rpcs92rv-emacs-with-packages-28.2/Applications/Emacs.app/Contents/MacOS/Emacs
which in turn is a bash script that calls:
/nix/store/rf6l3szx7c0p876xdkr5pdjd6jx31bv1-emacs-28.2/Applications/Emacs.app/Contents/MacOS/Emacs
Which is an arm64 executable, and if I directly executes it, I can open emacs without the rosetta prompt.
flake.nix
{
inputs = {
nixpkgs.url = "nixpkgs";
utils.url = "flake-utils";
home-manager = {
url = "home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nix-darwin, home-manager, ... }: {
darwinConfigurations."hgl-laptop" = nix-darwin.lib.darwinSystem {
modules = [
home-manager.darwinModules.home-manager
({ pkgs, lib, config, ... }: {
nix.settings.auto-optimise-store = true;
nix.extraOptions = ''
keep-outputs = true
keep-derivations = true
experimental-features = nix-command flakes
'';
services.nix-daemon.enable = true;
nixpkgs.hostPlatform = "aarch64-darwin";
system.stateVersion = 4;
programs.fish = {
enable = true;
useBabelfish = true;
babelfishPackage = pkgs.babelfish;
};
environment.shells = with pkgs; [ bashInteractive fish ];
programs.fish.shellInit = ''
for p in (string split : ${config.environment.systemPath})
if not contains $p $fish_user_paths
set -g fish_user_paths $fish_user_paths $p
end
end
'';
users.users.hgl = {
description = "Glen Huang";
home = "/Users/hgl";
shell = pkgs.fish;
};
home-manager.users.hgl = { pkgs, lib, config, ... }: {
programs.emacs = {
enable = true;
package =
(pkgs.emacsPackagesFor pkgs.emacsNativeComp).emacsWithPackages
(epkgs: [ epkgs.vterm ]);
};
home.stateVersion = "22.11";
};
})
];
};
};
}
And flake.lock:
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1691672736,
"narHash": "sha256-HNPA/dKHerA0p4OsToEcW/DtTSXBcK5gFRsy/yPgV/Y=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "6e1eff9aac0e8d84bda7f2d60ba6108eea9b7e79",
"type": "github"
},
"original": {
"id": "home-manager",
"type": "indirect"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1691640097,
"narHash": "sha256-6vPsJYjtt2hs4mkiR46yt8c/Spdm/UiUKoSCIlc7iJw=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "426d38710b656b0a31f8eaae6e0002206a3b96d7",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1691625043,
"narHash": "sha256-IiiOwgRTQm9W1QHe8qme7qYxDbAT2MYxbIJMfPEltN0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3d6ebeb283be256f008541ce2b089eb5fb0e4e01",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github"
},
"original": {
"id": "flake-utils",
"type": "indirect"
}
}
},
"root": "root",
"version": 7
}
And the rosetta message