Using a derivation on an unsupported platform?

I’m currently working on a project with another person who’s using an Apple M1. The project has a simple Docker setup (nothing fancy, just a web service and a database), to which I’ve added a Nix setup that allows me (a NixOS with an amd64 system who doesn’t like using Docker) to easily work on it. The project is a simple web project that’s currently deployed on a Debian system (not using Docker or any containerization).

Now I’d like to unify all this to simplify maintenance by getting rid of the docker setup, going full Nix and deploying on NixOS. Deploying to NixOS shouldn’t be a problem since I already have a working dev environment using Nix, and I can probably set up a CD to build the system. The main issue I’m facing is that we’re using some libraries that only target linux platforms, which means my colleague is unable to install them in his environment.

So my question is: what are my options here?

Here’s what I could think of (not sure any of these would actually work):

  • Set up a VM somehow and create the Nix dev environment in the VM? (but ideally it should be as easy as vagrant up (and I guess I can’t just nixos-rebuild build-vm))
  • Use docker but with buildLayeredImage and invoke it from the CD so my colleague can get a usable image? Not sure there would be any advantage on the current situation though
  • Convince my colleague to get a different computer ^^

Do you have any opinion on these options? Do you have other ideas? Any input would be very welcome! :pray:

Option 1

Make them set up an aarch64-linux NixOS VM via UTM or similar. They can then run nixos-rebuild switch -I nixos-config=/path/to/your/config/repo --target-host nixos@<address of VM> --use-remote-sudo on the mac with Nix installed (they might need --build-host too).

Option 2

Make those libraries work on Darwin. Most can be made to work with a little bit of work (some only require you to just allow the build via meta.platforms even) and if you’re out of wits, you could even pay someone to do it for you. @wegank has been porting stuff to aarch64-darwin like a madman in the past few months for example but I don’t know whether they offer that as a service :wink:

I just tried building or-tools on aarch64-darwin with NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 and it builds but can’t find its library in the tests. Probably a rather simple patch.

Actually, someone did that already for that package: or-tools: add darwin support by sdedovic · Pull Request #201136 · NixOS/nixpkgs · GitHub. It appears to be broken in other ways too though.

Actually, someone did that already for that package

Hi, I’m that someone. OR-Tools has been… difficult to build properly. I have the PR open and it did start passing tests but some changes in the master branch are causing problems that I haven’t been able to track down. If you’re able to help out, it would be much appreciated!

I believe the compilation and linking is mostly working but there are issues with the Python packaging stage. Also, I think the project has changes structure a bit causing ~5 tests to permanently fail. I don’t understand why, though.

One option is (as mentioned in my PR) to use fixdarwindylibnames (to get rid of pesky @rpath on the dynlib files, and similarly path the testing binaries (something the fixdarwindylibnames tool can’t handle out-of-box).

Again, I would love help with Option 2 as I’ve been struggling to get this library working properly. Maybe I take another pass this weekend…

1 Like

That’s good news! The last time I checked, or-tools wouldn’t even compile on M1 chips, but the issue seems to have been fixed since then. I’d be glad to help but I’ll need to get my hands on a Mac first. ^^ I’ll see what I can do!

@sephi Sorry this took so long… I have gotten a successful build on my M1 mac. The PR has been updated and there are a few others commenting as well. I hope this can be merged soon.

Also all tests are passing which means it does function on the M1 chips.

It looks like the PR has been merged. :slight_smile: Thanks for your work!