Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
philderbeast opened this issue Aug 26, 2018 · 2 comments
Closed

Comments

@philderbeast
Copy link
Contributor

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.

@mboes
Copy link
Member

mboes commented Aug 27, 2018

This is rules_nixpkgs specific. Does the nix_file_deps attribute help (see tweag/rules_nixpkgs#18)? If not, this might be a dupe of tweag/rules_nixpkgs#21.

@philderbeast
Copy link
Contributor Author

Yes thanks, the nix_file_deps does help.

nixpkgs_package(
    name = "ghc",
    build_file = "@io_tweag_rules_haskell//haskell:ghc.BUILD",
    nix_file_deps = [
            "//nix:overlays.nix",
            "//nix:uom-plugin.nix",
        ],
    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]
  )
  """

@mboes mboes closed this as completed Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants