You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to source a nixpkgs_package and use it as a tool in a genrule. I couldn't find doc about this, but I found (correctly?) that a nixpkgs_package named foo gets bound to the target //external:foo. So I try to directly build from bazel command-line such package (ghc in the example), or depend on one in a rule (hello in the example). But I get errors about non-visibility of some nix expressions.
This is odd, since ghc is surely picked up by rules_haskell as it works. But maybe Skylark code has different visibility restrictions? Not sure.
I didn't try adding the exports to the BUILD files as suggested by the warnings, since I don't know if this is a red herring. You likely have a better guess. It's also possible I'm doing something silly.
$ bazel build //external:ghc
Starting local Bazel server and connecting to it...
ERROR: ...29/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl:136:5:
no such target '//:ghc.nix': target 'ghc.nix' not declared in package '';
however, a source file of this name exists.
(Perhaps add 'exports_files(["ghc.nix"])' to /BUILD?)
ERROR: ...29/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl:136:5:
no such target '@nixpkgs//:default.nix': target 'default.nix' not declared in package '';
however, a source file of this name exists.
(Perhaps add 'exports_files(["default.nix"])' to /BUILD?)
ERROR: ...29/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl:136:5:
no such target '@io_tweag_rules_haskell//haskell:ghc.BUILD': target 'ghc.BUILD' not declared in package 'haskell';
however, a source file of this name exists.
(Perhaps add 'exports_files(["ghc.BUILD"])' to haskell/BUILD?)
ERROR: Analysis of target '//external:ghc' failed; build aborted: Analysis failed
Trying on just hello:
$ bazel build :hi
ERROR: ..29/external/io_tweag_rules_nixpkgs/nixpkgs/nixpkgs.bzl:177:9: no such target '@nixpkgs//:default.nix': target 'default.nix' not declared in package ''; however, a source file of this name exists. (Perhaps add 'exports_files(["default.nix"])' to /BUILD?) defined by /home/ron/.cache/bazel/_bazel_ron/dea833c6b6c799258fdcca8ca5a2e429/external/nixpkgs/BUILD and referenced by '//external:hello'
ERROR: Analysis of target '//:hi' failed; build aborted: Analysis failed
Edit: in context of NixOS/nixpkgs#50765, wanting to add bazel tools from nix.
The text was updated successfully, but these errors were encountered:
The external/ directory is where bazel puts all its repositories.
What you want is not "//external:hello" (if that works that is kind of weird and maybe a bazel bug‽), rather "@hello//:bin" to reference the hello binary files.
In practice nixpkgs_package creates a folder named by the name attribute and populates it with symlinks to the store files of the referenced nixpkgs attribute (which is the same as name if you omit the attribute_path argument). Then we add a default BUILD file to that folder, which exports a few basic targets, like the contents of bin (see the documentation of build_file in the README for how that works).
You can also export your own subset of files from the package, by doing something like
I try to source a
nixpkgs_package
and use it as a tool in agenrule
. I couldn't find doc about this, but I found (correctly?) that anixpkgs_package
namedfoo
gets bound to the target//external:foo
. So I try to directly build from bazel command-line such package (ghc
in the example), or depend on one in a rule (hello
in the example). But I get errors about non-visibility of some nix expressions.This is odd, since
ghc
is surely picked up byrules_haskell
as it works. But maybe Skylark code has different visibility restrictions? Not sure.I didn't try adding the exports to the BUILD files as suggested by the warnings, since I don't know if this is a red herring. You likely have a better guess. It's also possible I'm doing something silly.
WORKSPACE
:BUILD:
Failure when trying to access ghc.
Trying on just
hello
:Edit: in context of NixOS/nixpkgs#50765, wanting to add bazel tools from nix.
The text was updated successfully, but these errors were encountered: