Skip to content

Commit c653798

Browse files
authored
Merge pull request #37 from tweag/fix-mandatory-repositories
Fix repositories argument being required (bump 0.3.1)
2 parents d8d2018 + 8788250 commit c653798

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

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

7+
## [0.3.1] - 2018-10-24
8+
9+
### Fixed
10+
11+
* `repositories` is no longer a required argument to `nixpkgs_package`.
12+
713
## [0.3] - 2018-10-23
814

915
### Added

WORKSPACE

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ nixpkgs_package(
1919

2020
nixpkgs_package(
2121
name = "hello",
22-
repositories = { "nixpkgs": "//:nixpkgs.nix" }
22+
# deliberately not repositories, to test whether repository still works
23+
repository = "//:nixpkgs.nix"
2324
)
2425

2526
nixpkgs_package(

nixpkgs/nixpkgs.bzl

+14-10
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,22 @@ _nixpkgs_package = repository_rule(
124124
local = True,
125125
)
126126

127-
def nixpkgs_package(repositories, *args, **kwargs):
128-
# Because of https://github.com/bazelbuild/bazel/issues/5356 we can't
129-
# directly pass a dict from strings to labels to the rule (which we'd like
130-
# for the `repositories` arguments), but we can pass a dict from labels to
131-
# strings. So we swap the keys and the values (assuming they all are
132-
# distinct).
133-
inversed_repositories = { value: key for (key, value) in repositories.items() }
127+
def nixpkgs_package(*args, **kwargs):
128+
# Because of https://github.com/bazelbuild/bazel/issues/5356 we can't
129+
# directly pass a dict from strings to labels to the rule (which we'd like
130+
# for the `repositories` arguments), but we can pass a dict from labels to
131+
# strings. So we swap the keys and the values (assuming they all are
132+
# distinct).
133+
if "repositories" in kwargs:
134+
inversed_repositories = { value: key for (key, value) in kwargs["repositories"].items() }
135+
kwargs.pop("repositories")
134136
_nixpkgs_package(
135-
repositories = inversed_repositories,
136-
*args,
137-
**kwargs
137+
repositories = inversed_repositories,
138+
*args,
139+
**kwargs
138140
)
141+
else:
142+
_nixpkgs_package(*args, **kwargs)
139143

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

0 commit comments

Comments
 (0)