[Feature]: Allow specifying a different architecture
Is your feature request related to a problem you're trying to solve? Please describe.
Some packages (mongo 4.4 for example) don't have working builds for aarch64-darwin. MacOS has good support for x86 binaries via rosseta and it would be useful to be able to specify x86 binaries on aarch64 machines.
Describe the solution you'd like
Packages already have platforms and excluded_platforms fields, another field specifying some kind of actual_system:packages_system mapping would work (I'm not tied to this exact naming or syntax). In this example mongo would use the x86 version on both x86 and aarch64 darwin machines, linux machines would behave as normal.
{
"packages": {
"mongodb-4_4": {
"version": "latest",
"cross_system": { "aarch64-darwin": "x86-darwin" },
}
}
}
Describe alternatives you've considered
- installing from nixpkgs as a flake
github:nixos/nixpkgs/nixos-unstable#legacyPackages.x86_64-darwin.mongodb-4_4(doesn't work)- in the previous version of devbox I was using this would work for "free" packages, but mongo has an unFree license, and I was unable to set
config.allowUnfree - on the current version I have (
0.6.0) the generated flake.devbox/gen/flake/flake.nixit now does setconfig.allowUnfreefor packages, but now it overridessystemto match the host system.
- in the previous version of devbox I was using this would work for "free" packages, but mongo has an unFree license, and I was unable to set
- create a local flake this works and is my current work around, but it's a lot of boiler plate just to set the system arch. I also really value hiding nix lang from my team (so they don't have to learn it), IMO it's one of the best features of devbox.
Additional context AFAIK this hasn't been requested before
I think this would be great to support. I've been running into the same requirement when trying to reproduce system-specific bugs.
I'm wondering if consolidating the platform fields would be a good idea. Instead of platforms and excluded_platforms we could make platforms a mapping of systems as you suggested.
If a key matches the host system, then the corresponding value will be used when installing the package. If the value doesn't match a nix system, then the package isn't installed. The special key "default" would specify what to do if the host system doesn't match any other key.
Examples of what I'm thinking:
// No special behavior. The package installs for the host system.
"mongodb-4_4": { }
// Don't install the package on any system except for aarch64-darwin and
// aarch64-linux. This is what the platforms field does today.
"mongodb-4_4": {
"platforms": {
"default": "none",
"aarch64-darwin": "aarch64-darwin",
"aarch64-linux": "aarch64-linux",
}
}
// Don't install the package on aarch64-darwin. This is what the
// excluded_platforms field does today.
"mongodb-4_4": {
"platforms": {
"aarch64-darwin": "none"
}
}
// Install the x86_64-darwin package on aarch64-darwin.
"mongodb-4_4": {
"platforms": {
"aarch64-darwin": "x86_64-darwin"
}
}
@Lagoja wondering if you have any thoughts on this too.
@gcurtis I quite like it!
Your suggested syntax looks nicer to me too. Happy with either though - I'd understand if you didn't want to make a breaking change to the syntax.
Is implementing this on the roadmap?