Skip to content

Commit

Permalink
Add exec_constraints attribute to POSIX toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
aherrmann committed Apr 14, 2022
1 parent 40fe0c0 commit f1f135d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ default is <code>None</code>
### nixpkgs_sh_posix_configure

<pre>
nixpkgs_sh_posix_configure(<a href="#nixpkgs_sh_posix_configure-name">name</a>, <a href="#nixpkgs_sh_posix_configure-packages">packages</a>, <a href="#nixpkgs_sh_posix_configure-kwargs">kwargs</a>)
nixpkgs_sh_posix_configure(<a href="#nixpkgs_sh_posix_configure-name">name</a>, <a href="#nixpkgs_sh_posix_configure-packages">packages</a>, <a href="#nixpkgs_sh_posix_configure-exec_constraints">exec_constraints</a>, <a href="#nixpkgs_sh_posix_configure-kwargs">kwargs</a>)
</pre>

Create a POSIX toolchain from nixpkgs.
Expand Down Expand Up @@ -1539,6 +1539,20 @@ default is <code>["stdenv.initialPath"]</code>

List of Nix attribute paths to draw Unix tools from.

</p>
</td>
</tr>
<tr id="nixpkgs_sh_posix_configure-exec_constraints">
<td><code>exec_constraints</code></td>
<td>

optional.
default is <code>None</code>

<p>

Constraints for the execution platform.

</p>
</td>
</tr>
Expand Down
5 changes: 5 additions & 0 deletions toolchains/posix/posix.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ create_posix_toolchain()
def _nixpkgs_sh_posix_toolchain_impl(repository_ctx):
exec_constraints, _ = ensure_constraints_pure(
default_constraints = default_constraints(repository_ctx),
exec_constraints = repository_ctx.attr.exec_constraints,
)
repository_ctx.file("BUILD", executable = False, content = """
toolchain(
Expand All @@ -129,12 +130,14 @@ _nixpkgs_sh_posix_toolchain = repository_rule(
_nixpkgs_sh_posix_toolchain_impl,
attrs = {
"workspace": attr.string(),
"exec_constraints": attr.string_list(),
},
)

def nixpkgs_sh_posix_configure(
name = "nixpkgs_sh_posix_config",
packages = ["stdenv.initialPath"],
exec_constraints = None,
**kwargs):
"""Create a POSIX toolchain from nixpkgs.
Expand All @@ -148,6 +151,7 @@ def nixpkgs_sh_posix_configure(
Args:
name: Name prefix for the generated repositories.
packages: List of Nix attribute paths to draw Unix tools from.
exec_constraints: Constraints for the execution platform.
nix_file_deps: See nixpkgs_package.
repositories: See nixpkgs_package.
repository: See nixpkgs_package.
Expand All @@ -157,6 +161,7 @@ def nixpkgs_sh_posix_configure(
nixpkgs_sh_posix_config(
name = name,
packages = packages,
exec_constraints = exec_constraints,
**kwargs
)

Expand Down

0 comments on commit f1f135d

Please sign in to comment.