title: How can I access the output of a bazel rule from another rule without using a relative path?
body: <p>I am attempting to use Bazel to compile a dhall program based on dhall-kubernetes to generate a Kubernetes YAML file.</p>
  
  <p>The <a href="https://github.com/humphrej/dhall-bazel/tree/master/examples/basic" rel="nofollow noreferrer">basic dhall compile</a> without dhall-kubernetes using a simple bazel macro works ok.</p>
  
  <p>I have made an example using dhall's dependency resolution to download dhall-kubernetes - see <a href="https://github.com/humphrej/dhall-bazel/tree/master/examples/k8s_network_dependency" rel="nofollow noreferrer">here</a>.  This also works but is very slow (I think because dhall downloads each remote file separately), and introduces a network dependency to the bazel rule execution, which I would prefer to avoid.</p>
  
  <p>My preferred approach is to use Bazel to download an archive release version of dhall-kubernetes, then have the rule access it locally (see <a href="https://github.com/humphrej/dhall-bazel/tree/master/examples/k8s" rel="nofollow noreferrer">here</a>). My solution requires a relative path in Prelude.dhall and package.dhall for the examples/k8s package to reference dhall-kubernetes.  While it works, I am concerned that this is subverting the Bazel sandbox by requiring special knowledge of the folder structure used internally by Bazel. Is there a better way?</p>
  
  <p>Prelude.dhall:</p>
  
  <pre><code>../../external/dhall-kubernetes/1.17/Prelude.dhall 
  </code></pre>
  
  <p>WORKSPACE:</p>
  
  <pre><code>workspace(name = "dhall")
  
  load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
  
  DHALL_KUBERNETES_VERSION = "4.0.0"
  
  http_archive(
      name = "dhall-kubernetes",
      sha256 = "0bc2b5d2735ca60ae26d388640a4790bd945abf326da52f7f28a66159e56220d",
      url = "https://github.com/dhall-lang/dhall-kubernetes/archive/v%s.zip" % DHALL_KUBERNETES_VERSION,
      strip_prefix = "dhall-kubernetes-4.0.0",
      build_file = "@//:BUILD.dhall-kubernetes",
  )
  </code></pre>
  
  <p>BUILD.dhall-kubernetes:</p>
  
  <pre><code>package(default_visibility=['//visibility:public'])
  
  filegroup(
      name = "dhall-k8s-1.17",
      srcs = glob([
          "1.17/**/*",
      ]),
  )
  </code></pre>
  
  <p>examples/k8s/BUILD:</p>
  
  <pre><code>package(default_visibility = ["//visibility:public"])
  
  genrule(
      name = "special_ingress",
      srcs = ["ingress.dhall",
              "Prelude.dhall",
              "package.dhall",
          "@dhall-kubernetes//:dhall-k8s-1.17"
      ],
      outs = ["ingress.yaml"],
      cmd = "dhall-to-yaml --file $(location ingress.dhall) &gt; $@",
      visibility = [
          "//visibility:public"
      ]
  )
  </code></pre>