juspay / nix-health

REPO MOVED https://github.com/juspay/omnix/tree/main/crates/nix_health
https://github.com/juspay/omnix/tree/main/crates/nix_rs
28 stars 2 forks source link

False negative on rosetta check #19

Open srid opened 1 month ago

srid commented 1 month ago

This user installed Nix the official way on M1 mac, but as x86_64 binary:

$ file /nix/var/nix/profiles/default/bin/nix
/nix/var/nix/profiles/default/bin/nix: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>

image image
srid commented 1 month ago

We are detecting the wrong arch.

MacOS {
    nix_darwin: false,
    arch: Other(
        Some(
            "x86_64",
        ),
    ),
}

This suggests that os_info.architecture() is returning wrong value.

The crate is using uname -m: https://github.com/stanislav-tkach/os_info/blob/782e7564e62252f267a066adbb4bf4809d61fa77/os_info/src/architecture.rs#L6-L7

Which returns x86_64 on Rosetta terminal. However, the difference seems to lie in the architecture of the process that uses that crate. For native process, the result is correct; for Rosetta binary (of nix-health), the result is inaccurate.

srid commented 1 month ago

I'm able to reproduce this on a macOS VM running in Parallels

  1. Toggle Rosetta for builtin Terminal app
  2. Open rosetta terminal
  3. Install Nix using official instructions
  4. Nix binary should be x86_64, and running nix-health should fail to catch rosetta use:
image