Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix repositories argument being required (bump 0.3.1) #37

Merged
merged 1 commit into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/).

## [0.3.1] - 2018-10-24

### Fixed

* `repositories` is no longer a required argument to `nixpkgs_package`.

## [0.3] - 2018-10-23

### Added
Expand Down
3 changes: 2 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ nixpkgs_package(

nixpkgs_package(
name = "hello",
repositories = { "nixpkgs": "//:nixpkgs.nix" }
# deliberately not repositories, to test whether repository still works
repository = "//:nixpkgs.nix"
)

nixpkgs_package(
Expand Down
24 changes: 14 additions & 10 deletions nixpkgs/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,22 @@ _nixpkgs_package = repository_rule(
local = True,
)

def nixpkgs_package(repositories, *args, **kwargs):
# Because of https://github.com/bazelbuild/bazel/issues/5356 we can't
# directly pass a dict from strings to labels to the rule (which we'd like
# for the `repositories` arguments), but we can pass a dict from labels to
# strings. So we swap the keys and the values (assuming they all are
# distinct).
inversed_repositories = { value: key for (key, value) in repositories.items() }
def nixpkgs_package(*args, **kwargs):
# Because of https://github.com/bazelbuild/bazel/issues/5356 we can't
# directly pass a dict from strings to labels to the rule (which we'd like
# for the `repositories` arguments), but we can pass a dict from labels to
# strings. So we swap the keys and the values (assuming they all are
# distinct).
if "repositories" in kwargs:
inversed_repositories = { value: key for (key, value) in kwargs["repositories"].items() }
kwargs.pop("repositories")
_nixpkgs_package(
repositories = inversed_repositories,
*args,
**kwargs
repositories = inversed_repositories,
*args,
**kwargs
)
else:
_nixpkgs_package(*args, **kwargs)

def _symlink_children(target_dir, rep_ctx):
"""Create a symlink to all children of `target_dir` in the current
Expand Down