Skip to content

Commit

Permalink
Undeprecate the repository attribute
Browse files Browse the repository at this point in the history
PR #29 introduced the `repositories` attribute. But specifying
a single repository is a common enough use case that we should
continue to support it as before, without extra verbosity.
  • Loading branch information
mboes committed Nov 13, 2018
1 parent f92d52a commit cf28908
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Make the content of a Nixpkgs package available in the Bazel workspace.
```bzl
nixpkgs_package(
name, attribute_path, nix_file, nix_file_deps, nix_file_content,
repositories, build_file, build_file_content,
repository, repositories, build_file, build_file_content,
)
```

Expand Down Expand Up @@ -160,7 +160,8 @@ nixpkgs clone in `nix_file` or `nix_file_content`.
<td><code>repository</code></td>
<td>
<p><code>Label; optional</code></p>
<p>Deprecated, use `repositories` instead.</p>
<p>A repository label identifying which Nixpkgs to use.
Equivalent to `repositories = { "nixpkgs": ...}`</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -261,7 +262,8 @@ nixpkgs_cc_configure(repository = "@nixpkgs//:default.nix")
<td><code>repository</code></td>
<td>
<p><code>Label; optional</code></p>
<p>A repository label identifying which Nixpkgs to use.</p>
<p>A repository label identifying which Nixpkgs to use.
Equivalent to `repositories = { "nixpkgs": ...}`</p>
</td>
</tr>
<tr>
Expand Down
21 changes: 8 additions & 13 deletions nixpkgs/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ nixpkgs_git_repository = repository_rule(
)

def _nixpkgs_package_impl(repository_ctx):
repositories = None
if repository_ctx.attr.repositories:
repositories = repository_ctx.attr.repositories
repository = repository_ctx.attr.repository
repositories = repository_ctx.attr.repositories

if repository_ctx.attr.repository:
print("The 'repository' attribute is deprecated, use 'repositories' instead")
repositories = { repository_ctx.attr.repository: "nixpkgs" } + \
(repositories if repositories else {})
if repository and repositories or not repository and not repositories:
fail("Specify one of 'repository' or 'repositories' (but not both).")
elif repository:
repositories = { repository_ctx.attr.repository: "nixpkgs" }

if repository_ctx.attr.build_file and repository_ctx.attr.build_file_content:
fail("Specify one of 'build_file' or 'build_file_content', but not both.")
Expand Down Expand Up @@ -182,7 +181,7 @@ _nixpkgs_cc_autoconf = repository_rule(

def nixpkgs_cc_configure(
repository = None,
repositories = None,
repositories = {},
nix_file_content = """
with import <nixpkgs> {}; buildEnv {
name = "bazel-cc-toolchain";
Expand All @@ -196,13 +195,9 @@ def nixpkgs_cc_configure(
this rule to specific explicitly which commands the toolchain should
use.
"""
if repository and repositories or not repository and not repositories:
fail("Specify one of repository or repositories (but not both).")
elif repository:
repositories = {"nixpkgs": repository}

nixpkgs_package(
name = "nixpkgs_cc_toolchain",
repository = repository,
repositories = repositories,
nix_file_content = nix_file_content,
build_file_content = """exports_files(glob(["bin/*"]))""",
Expand Down

0 comments on commit cf28908

Please sign in to comment.