Skip to content

Commit 8bd1c48

Browse files
committed
Allow repository rule to check for sha
1 parent 7e455ad commit 8bd1c48

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_git_repository", "
2929
nixpkgs_git_repository(
3030
name = "nixpkgs",
3131
revision = "17.09", # Any tag or commit hash
32+
sha256 = "" # fill in with the sha that bazel will compute for you
3233
)
3334

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

4647
```bzl
47-
nixpkgs_git_repository(name, revision)
48+
nixpkgs_git_repository(name, revision, sha256)
4849
```
4950

5051
<table class="table table-condensed table-bordered table-params">
@@ -73,6 +74,13 @@ nixpkgs_git_repository(name, revision)
7374
to use.</p>
7475
</td>
7576
</tr>
77+
<tr>
78+
<td><code>sha256</code></td>
79+
<td>
80+
<p><code>String; required</code></p>
81+
<p>The SHA256 used to verify the integrity of the repository</p>
82+
</td>
83+
</tr>
7684
</tbody>
7785
</table>
7886

WORKSPACE

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ load("//nixpkgs:nixpkgs.bzl", "nixpkgs_git_repository", "nixpkgs_package")
77
nixpkgs_git_repository(
88
name = "nixpkgs",
99
revision = "17.09",
10+
sha256 = "405f1d6ba523630c83fbabef93f0da11ea388510a576adf2ded26a744fbf793e",
1011
)
1112

1213
nixpkgs_package(name = "hello", repository = "@nixpkgs")

nixpkgs/nixpkgs.bzl

+2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ def _nixpkgs_git_repository_impl(ctx):
77
ctx.download_and_extract(
88
url = "https://github.com/NixOS/nixpkgs/archive/%s.tar.gz" % ctx.attr.revision,
99
stripPrefix = "nixpkgs-" + ctx.attr.revision,
10+
sha256 = ctx.attr.sha256,
1011
)
1112

1213
nixpkgs_git_repository = repository_rule(
1314
implementation = _nixpkgs_git_repository_impl,
1415
attrs = {
1516
"revision": attr.string(),
17+
"sha256": attr.string(),
1618
},
1719
local = False,
1820
)

0 commit comments

Comments
 (0)