Skip to content

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

@aaomidi

Description

@aaomidi

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",
    ],
)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions