Skip to content

Clarify in documentation which configurations of host, exec and target are supported. #398

@uri-canva

Description

@uri-canva

@aherrmann in #209 (comment) you clarify that two major use cases are supported by rules_nixpkgs:

  1. Nix provides Bazel and perhaps other development tools AND rules_nixpkgs imports system dependencies from Nix into Bazel.
  2. Vanilla Bazel AND "bindist" or Bazel built system dependencies. I.e. no Nix involved at all.

Translating these into host, exec and target it implies that rules_nixpkgs supports:

  1. host = nix, exec = nix, target = nix
  2. host = non-nix, exec = non-nix, target = non-nix

It does not support any other combinations. I think this limits the value of rules_nixpkgs a lot: if host, exec, and target are all nix, then one might want to use buildBazelPackage from nixpkgs. If host, exec, and target are all non-nix, then one does not need to use rules_nixpkgs at all. With this narrow focusrules_nixpkgs seems to fit into a very niche usecase of a nix centric development model that needs to support windows, so that buildBazelPackage becomes tricky to keep in sync with the windows specific bazel setup.

In practice I don't know how many people are using rules_nixpkgs like that. Personally I can say the way we've been using it fits into:

  1. host = nix, exec = nix, target = non-nix
  2. host = nix, exec = non-nix, target = non-nix

Given https://github.com/digital-asset/daml/blob/9cbe57b073444a0087e3bc8cc26c57cacd037257/bazel_tools/packaging/package-app.sh, I believe the use case for that repo is 3 as well, since if the target was a nix system, patching the binaries to remove references to the nix store would not be necessary.

However this use case has been hitting a lot of challenges both in rules_nixpkgs and upstream nixpkgs. For example upstream bazel is built in a way that target must be a nix system, since it hardcodes some nix store paths in shebangs in parts of the target code (for example the python stub).

Discussion in #180 highlights the challenges of not clarifying the "nixness" of a particular platform, specifically the exec one. The suggestions are wildly different depending on whether we want exec to be nix or not: when not using remote execution, then 3 is a very common setup, since we have nix on the host anyway, and the exec is the host. However once you put remote execution in the mix, it's much more likely that you'll end up wanting 4 instead.

Note that I've been referring to host, exec and target since that's what bazel calls them. In nix they would map to build, host and target respectively. See https://nixos.org/manual/nixpkgs/unstable/#chap-cross for more details. nixpkgs does not make which platforms are nix and which are non-nix very clear, but it does have at least some very clear non-nix platforms, like ios and android.

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