jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.83k stars 187 forks source link

Unable to run Nix Flake on MacBook Pro M1 #2155

Closed munjalpatel closed 2 weeks ago

munjalpatel commented 2 weeks ago

What happened?

I am using MacBook M1 and was expecting bun@1.1.13 for aarch64-darwin properly installed.

However, I am getting error:

Error: error installing package path:flakes/runtime#bun
source: nix: command error: nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' path-info 'path:/Users/mp/workspace/com/proj/flakes/runtime#bun' --json --impure: Unknown CPU type: darwin: exit code 1

Steps to reproduce

I am using the following flake to setup bun@1.1.13 since that version is not yet available in Nix Store.

{
  description = "Runtimes required by Platform";

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
  };

  outputs = { self, nixpkgs }: {
    packages = let
      bunVersion = "1.1.13";

      getBun = { system, sha256 }: let
        pkgs = import nixpkgs { inherit system; };
        bunSrc = pkgs.fetchurl {
          url = "https://github.com/oven-sh/bun/releases/download/bun-v${bunVersion}/bun-${system}.zip";
          inherit sha256;
        };

      in pkgs.stdenv.mkDerivation {
        pname = "bun";
        version = bunVersion;

        src = bunSrc;

        nativeBuildInputs = [ pkgs.unzip ];

        installPhase = ''
          mkdir -p $out/bin
          unzip $src -d $out/bin
          chmod +x $out/bin/bun
        '';

        meta = with pkgs.lib; {
          description = "Bun - JavaScript runtime";
          homepage = "https://bun.sh/";
          license = licenses.mit;
          platforms = platforms.all;
        };
      };

      bun_darwin_aarch64 = getBun { system = "darwin-aarch64"; sha256 = "144bvn34v26shi50ykrfvwm439qnqn7z2v903dxm0wzbwqpsf3m6"; };

      bun_darwin_x64 = getBun { system = "darwin-x64"; sha256 = "1h6p9sb9dyx3i5dw3xfm20np6wh0p0blm2204fpig4dph5chdrim"; };

      bun_linux_aarch64 = getBun { system = "linux-x64"; sha256 = "1xwq9n7gpbpz8dyvcpavlr9i4lrl7kxkxwc84a0jnqnid2qrsbj0"; };

    in {
      aarch64-darwin.bun = bun_darwin_aarch64;
      x86_64-darwin.bun = bun_darwin_x64;
      x86_64-linux.bun = bun_linux_aarch64;
    };
  };
}

Command

shell

devbox.json

{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.11.1/.schema/devbox.schema.json",
  "packages": [
    "nodejs@22.2.0",
    "erlang_26@26.2.5",
    "elixir@1.16.3",
    "elixir-ls@0.21.3",
    "gum@0.14.1",
    "path:flakes/runtime#bun"
  ],
  "env": {
    "ERL_AFLAGS":                  "-kernel shell_history enabled",
    "MIX_HOME":                    "$PWD/.nix-mix",
    "HEX_HOME":                    "$PWD/.nix-hex",
    "DEVBOX_COREPACK_ENABLED":     "true",
    "POWERLEVEL9K_INSTANT_PROMPT": "quiet"
  },
  "shell": {
    "init_hook": [
      "./scripts/init.sh"
    ],
    "scripts": {}
  }
}

Devbox version

0.11.1

Nix version

nix (Nix) 2.18.1

What system does this bug occur on?

macOS (Apple Silicon)

Debug logs

time=2024-06-16T06:44:06.284-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/dir.go:22 msg="finding devbox config" path=""
time=2024-06-16T06:44:06.285-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/dir.go:66 msg="finding devbox config" dir=/Users/mp/workspace/com/proj
time=2024-06-16T06:44:06.285-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/dir.go:22 msg="finding devbox config" path=""
time=2024-06-16T06:44:06.285-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/dir.go:66 msg="finding devbox config" dir=/Users/mp/workspace/com/proj
time=2024-06-16T06:44:06.334-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/nix.go:341 msg="nix --version --debug output" out="nix (Nix) 2.18.1\nSystem type: aarch64-darwin\nAdditional system types: x86_64-darwin\nFeatures: gc, signed-caches\nSystem configuration file: /etc/nix/nix.conf\nUser configuration files: /Users/mp/.config/nix/nix.conf:/etc/xdg/nix/nix.conf\nStore directory: /nix/store\nState directory: /nix/var/nix\nData directory: /nix/store/0pbq6wzr2f1jgpn5212knyxpwmkjgjah-nix-2.18.1/share\n"
time=2024-06-16T06:44:06.334-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:60 msg="nix command starting" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' eval --impure --raw --expr builtins.currentSystem" cmd.path=/nix/var/nix/profiles/default/bin/nix
time=2024-06-16T06:44:06.367-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:67 msg="nix command exited" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' eval --impure --raw --expr builtins.currentSystem" cmd.path=/nix/var/nix/profiles/default/bin/nix cmd.pid=22485 cmd.code=0 cmd.dur=33.169584ms
time=2024-06-16T06:44:06.367-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/dir.go:22 msg="finding devbox config" path=""
time=2024-06-16T06:44:06.367-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/dir.go:66 msg="finding devbox config" dir=/Users/mp/workspace/com/proj
Info: Ensuring packages are installed.
time=2024-06-16T06:44:06.368-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/plugin/plugin.go:85 msg="creating files for package" pkg=nodejs@22.2.0
time=2024-06-16T06:44:07.091-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:60 msg="nix command starting" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' store ping --store daemon --json" cmd.path=/nix/var/nix/profiles/default/bin/nix
time=2024-06-16T06:44:07.153-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:67 msg="nix command exited" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' store ping --store daemon --json" cmd.path=/nix/var/nix/profiles/default/bin/nix cmd.pid=22487 cmd.code=0 cmd.dur=62.254666ms
time=2024-06-16T06:44:07.153-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/providers/nixcache/setup.go:86 msg="nixcache: running setup: first time setup"
time=2024-06-16T06:44:07.280-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:60 msg="nix command starting" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' path-info 'path:/Users/mp/workspace/com/proj/flakes/runtime#bun' --json --impure" cmd.path=/nix/var/nix/profiles/default/bin/nix
time=2024-06-16T06:44:08.006-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/nix/command.go:67 msg="nix command exited" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' path-info 'path:/Users/mp/workspace/com/proj/flakes/runtime#bun' --json --impure" cmd.path=/nix/var/nix/profiles/default/bin/nix cmd.stderr="Unknown CPU type: darwin" cmd.pid=22490 cmd.code=1 cmd.dur=725.62675ms

Error: error installing package path:flakes/runtime#bun
source: nix: command error: nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' path-info 'path:/Users/mp/workspace/com/proj/flakes/runtime#bun' --json --impure: Unknown CPU type: darwin: exit code 1

time=2024-06-16T06:44:08.013-07:00 level=ERROR source=go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:68 msg="command error" stderr="warning: creating lock file '/Users/mp/workspace/com/proj/flakes/runtime/flake.lock'\nerror:\n       … while evaluating a branch condition\n\n         at /nix/store/qqwr649pc0qprc9lw2fmdsi1km6p7q2h-source/pkgs/stdenv/booter.nix:64:9:\n\n           63|       go = pred: n:\n           64|         if n == len\n             |         ^\n           65|         then rnul pred\n\n       … while calling the 'length' builtin\n\n         at /nix/store/qqwr649pc0qprc9lw2fmdsi1km6p7q2h-source/pkgs/stdenv/booter.nix:62:13:\n\n           61|     let\n           62|       len = builtins.length list;\n             |             ^\n           63|       go = pred: n:\n\n       (stack trace truncated; use '--show-trace' to show the full trace)\n\n       error: Unknown CPU type: darwin\n" execid=2c405b9044074b52bae001b4b81befe5 stack=<nil>
time=2024-06-16T06:44:08.013-07:00 level=ERROR source=go.jetpack.io/devbox/internal/boxcli/midcobra/debug.go:70 msg="command error" execid=2c405b9044074b52bae001b4b81befe5 stack=<nil>
time=2024-06-16T06:44:08.014-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/dir.go:22 msg="finding devbox config" path=""
time=2024-06-16T06:44:08.014-07:00 level=DEBUG source=go.jetpack.io/devbox/internal/devbox/dir.go:66 msg="finding devbox config" dir=/Users/mp/workspace/com/proj
djgoku commented 1 week ago
% devbox add github:nixos/nixpkgs/master#bun
Info: Adding package "github:nixos/nixpkgs/master#bun" to devbox.json
% devbox run bun --version
1.1.14