rules_nixpkgs icon indicating copy to clipboard operation
rules_nixpkgs copied to clipboard

Respect `--platforms` passed into the various targets to get platform specific versions of nix packages

Open aaomidi opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

Currently, I use rules_nixpkgs to bring in binaries that I end up consuming in different ways. For example, you can imagine me consuming a binary to create an OCI image. However, this falls for multi-arch builds.

Describe the solution you'd like

I'd like rules_nixpkgs_core to understand the --platforms flag and bring appropriate packages for me. For example, imagine I have:

nix_pkg.attr(
    attr = "mysql84",
)

If I'm on a macOS system, but provide a platform for linux x86_64, I'd like the mysql84 binary that comes in to be for linux x86_64.

Describe alternatives you've considered

Manually define the platform in nixopts. However, this comes with its own gotchas, namely that I'd have to define these packages multiple times, for each target platform I'd want to build for. This gets a bit messy.

nix_pkg.attr(
    attr = "mysql84",
    nixopts = [
        "--system", "x86_64-linux",
        "--option", "system", "x86_64-linux",
    ],
)

aaomidi avatar Nov 07 '24 17:11 aaomidi

Related to the packages part of https://github.com/tweag/rules_nixpkgs/issues/347

aherrmann avatar Nov 08 '24 09:11 aherrmann