Skip to content

Commit

Permalink
Merge pull request tweag#100 from tweag/99_warn_nix_singlefile_output
Browse files Browse the repository at this point in the history
Fail when nixpkgs_package output is a single file
  • Loading branch information
Profpatsch authored Dec 4, 2019
2 parents 786c57a + 817a4a5 commit c6dee7b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ nixpkgs_package(
repository = "@nixpkgs",
)

# This bazel build @output-derivation-is-a-file//... must fail
# See https://github.com/tweag/rules_nixpkgs/issues/99 for details
nixpkgs_package(
name = "output-derivation-is-a-file",
attribute_path = "",
nix_file_content = """let pkgs = import <nixpkgs> { config = {}; overlays = []; }; in pkgs.writeText "foo" "bar" """,
nix_file_deps = [
"//:nixpkgs.json",
"//:nixpkgs.nix",
"//tests:relative_imports/nixpkgs.nix",
],
repository = "@nixpkgs",
)

nixpkgs_cc_configure(repository = "@remote_nixpkgs")

nixpkgs_python_configure(repository = "@remote_nixpkgs")
Expand Down
8 changes: 8 additions & 0 deletions nixpkgs/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ def _nixpkgs_package_impl(repository_ctx):
)
output_path = exec_result.stdout.splitlines()[-1]

# ensure that the output is a directory
test_path = repository_ctx.which("test")
_execute_or_fail(repository_ctx, [test_path, "-d", output_path],
failure_message = "nixpkgs_package '@{}' outputs a single file which is not supported by rules_nixpkgs. Please only use directories.".format(
repository_ctx.name
),
)

# Build a forest of symlinks (like new_local_package() does) to the
# Nix store.
for target in _find_children(repository_ctx, output_path):
Expand Down

0 comments on commit c6dee7b

Please sign in to comment.