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

Allow repository rule to check for sha #19

Merged
merged 1 commit into from
Jun 30, 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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_git_repository", "
nixpkgs_git_repository(
name = "nixpkgs",
revision = "17.09", # Any tag or commit hash
sha256 = "" # optional sha to verify package integrity!
)

nixpkgs_package(
Expand All @@ -44,7 +45,7 @@ nixpkgs_package(
Name a specific revision of Nixpkgs on GitHub or a local checkout.

```bzl
nixpkgs_git_repository(name, revision)
nixpkgs_git_repository(name, revision, sha256)
```

<table class="table table-condensed table-bordered table-params">
Expand Down Expand Up @@ -73,6 +74,13 @@ nixpkgs_git_repository(name, revision)
to use.</p>
</td>
</tr>
<tr>
<td><code>sha256</code></td>
<td>
<p><code>String; optional</code></p>
<p>The SHA256 used to verify the integrity of the repository</p>
</td>
</tr>
</tbody>
</table>

Expand Down
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ load("//nixpkgs:nixpkgs.bzl", "nixpkgs_git_repository", "nixpkgs_package")
nixpkgs_git_repository(
name = "nixpkgs",
revision = "17.09",
sha256 = "405f1d6ba523630c83fbabef93f0da11ea388510a576adf2ded26a744fbf793e",
)

nixpkgs_package(name = "hello", repository = "@nixpkgs")
Expand Down
4 changes: 4 additions & 0 deletions nixpkgs/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ def _nixpkgs_git_repository_impl(ctx):
ctx.download_and_extract(
url = "https://github.com/NixOS/nixpkgs/archive/%s.tar.gz" % ctx.attr.revision,
stripPrefix = "nixpkgs-" + ctx.attr.revision,
sha256 = ctx.attr.sha256,
)

nixpkgs_git_repository = repository_rule(
implementation = _nixpkgs_git_repository_impl,
attrs = {
"revision": attr.string(),
"sha256": attr.string(
default = "",
),
},
local = False,
)
Expand Down