Skip to content

How to reference project relative nix files in nix_file_content? #420

Closed
@philderbeast

Description

@philderbeast

With overrides and overlays, external .nix files are often referenced.

https://nixos.org/nixpkgs/manual/#how-to-create-nix-builds-for-your-own-private-haskell-packages
https://nixos.org/nixpkgs/manual/#sec-pkg-override

How would I do that with rules_haskell in a WORKSPACE file?

nixpkgs_package(
    name = "ghc",
    build_file = "@io_tweag_rules_haskell//haskell:ghc.BUILD",
    nix_file_content = """
  let pkgs = import <nixpkgs> {
          overlays = [ (import ./nix/overlays.nix) ];
      }; in
  pkgs.haskell.packages.ghc822.ghcWithPackages (p: with p;
    [newtype scientific aeson cassava template-haskell]
  )
  """,
    repository = "@nixpkgs",
)

It seems that bazel is referencing files relative to a temporary build folder and not relative to the project that I'm building.

flare-timing-bazel> bazel build //...
INFO: Build options have changed, discarding analysis cache.
error: getting status of '/private/var/tmp/_bazel_pdejoux/729fadfaa2051173dd27a953445384ed/external/ghc/nix/overlays.nix': No such file or directory
ERROR: /.../detour-via-sci/BUILD.bazel:6:1: no such package '@ghc//': Cannot build Nix attribute ghc. and referenced by '//detour-via-sci:ghc-impl'
ERROR: Analysis of target '//detour-via-sci:ghc-impl' failed; build aborted: no such package '@ghc//': Cannot build Nix attribute ghc.
INFO: Elapsed time: 0.337s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (5 packages loaded)

I'm trying to avoid uom-plugin-0.2.0.1 that is brought in with ghc822.ghcWithPackages and depend instead on uom-plugin-0.3.0.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions