Skip to content

Commit

Permalink
Merge pull request #210 from tweag/fix-named-arg-for-file-140
Browse files Browse the repository at this point in the history
Fix call to `repository_ctx.file` using `nix_file_content` with `nixpkgs_local_repository`
  • Loading branch information
mergify[bot] authored Apr 1, 2022
2 parents 9cfa583 + 31056d7 commit c9a0897
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ nixpkgs_local_repository(
nix_file_deps = ["//:nixpkgs.json"],
)

# same as @nixpkgs but using the `nix_file_content` parameter
nixpkgs_local_repository(
name = "nixpkgs_content",
nix_file_content = "import ./nixpkgs.nix",
nix_file_deps = ["//:nixpkgs.nix", "//:nixpkgs.json"],
)

# This is the commit introducing a Nix version working in the Bazel
# sandbox
nixpkgs_git_repository(
Expand All @@ -72,6 +79,12 @@ nixpkgs_package(
repositories = {"nixpkgs": "@remote_nixpkgs"},
)

nixpkgs_package(
name = "nixpkgs-local-repository-test",
nix_file_content = "with import <nixpkgs> {}; hello",
repositories = {"nixpkgs": "@nixpkgs_content"},
)

nixpkgs_package(
name = "hello",
# Deliberately not repository, to test whether repositories works.
Expand Down
4 changes: 2 additions & 2 deletions core/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def _nixpkgs_local_repository_impl(repository_ctx):
bool(repository_ctx.attr.nix_file_content):
fail("Specify one of 'nix_file' or 'nix_file_content' (but not both).")
if repository_ctx.attr.nix_file_content:
target = "default.nix"
repository_ctx.file(
path = "default.nix",
target,
content = repository_ctx.attr.nix_file_content,
executable = False,
)
target = repository_ctx.path("default.nix")
else:
target = cp(repository_ctx, repository_ctx.attr.nix_file)

Expand Down
1 change: 1 addition & 0 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ expand_location_unit_test_suite()
"nix-file-test",
"nix-file-deps-test",
"nixpkgs-git-repository-test",
"nixpkgs-local-repository-test",
"relative-imports",
]
] + [
Expand Down

0 comments on commit c9a0897

Please sign in to comment.