NixOS / bundlers

MIT License
93 stars 12 forks source link

nix bundle fails on macos #16

Open peacememories opened 7 months ago

peacememories commented 7 months ago

Describe the bug

When running e.g. nix bundle nixpkgs#hello on aarch64-darwin, it fails with the following error:

error: attribute 'aarch64-darwin' missing

       at /nix/store/1rc10ydlf4c2aphrg2z2dxaaikbggba0-source/flake.nix:12:20:

           11|       nix-bundle = { program, system }: let
           12|         nixpkgs' = nixpkgs.legacyPackages.${system};
             |                    ^
           13|         nix-bundle = import self { nixpkgs = nixpkgs'; };

Steps To Reproduce

  1. Use a macOS system with Apple Silicon
  2. Enable the nix-command and flakes experimental features
  3. Run nix bundle nixpkgs#hello
  4. See error

Expected behavior

I would expect a self-extracting zip with the hello command to be created.

nix-env --version output

nix-env (Nix) 2.13.6

Additional context

Trying something like

nix bundle nixpkgs#legacyPackages.x86_64-linux.hello results in the same error. I was originally trying to bundle murmur for linux (using a build server which is set up) from my macOS machine when I ran into this error.

tomberek commented 7 months ago

The upstream default bundler does not support aarch64-darwin: https://github.com/matthewbauer/nix-bundle/blob/master/flake.nix#L7 . This is very likely due to nix-user-chroot requiring linux namespaces... and well, not available on darwin.

It would be great to have this and to have "cross-bundling" better supported.

peacememories commented 7 months ago

That would make it hard to support darwin, true 😅 Although it would still be nice to be able to start the bundling from my mac and have it run on the build server in the background. I did also run into the problem with namespaces when trying to run a completed bundle on an old CentOS7 machine, but that's a different problem altogether^^