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

Support nixpkgs_node_configure #143

Open
epigramengineer opened this issue Sep 7, 2020 · 2 comments
Open

Support nixpkgs_node_configure #143

epigramengineer opened this issue Sep 7, 2020 · 2 comments

Comments

@epigramengineer
Copy link

Is your feature request related to a problem? Please describe.
using rules_node with the nixpkgs node is extremely painful and requires the workaround specified in bazel-contrib/rules_nodejs#464 / bazelbuild/bazel#2927

Specifically:

nixpkgs_package(
    name = "nixpkgs_nodejs",
    build_file_content = 'exports_files(glob(["nixpkgs_nodejs/**"]))',
    nix_file_content = """
    with import <nixpkgs> { config = {}; overlays = []; };
    runCommand "nodejs-build" { buildInputs = [ nodejs ]; } ''
      mkdir -p $out/nixpkgs_nodejs
      cd $out/nixpkgs_nodejs
      for i in ${nodejs}/*; do ln -s $i; done
      ''
    """,
    nixopts = [
        "--option",
        "sandbox",
        "false",
    ],
    repository = "@nixpkgs",
)

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")
node_repositories(
  vendored_node = "@nixpkgs_nodejs",
  package_json = [":package.json"],
)

Describe the solution you'd like
Ideally this is a solved with a call to nixpkgs_node_configure

Describe alternatives you've considered
^ workaround described above

Additional context
bazel-contrib/rules_nodejs#464
bazelbuild/bazel#2927

@aherrmann aherrmann added type: feature request P3 minor: not priorized labels Feb 8, 2022
@aherrmann
Copy link
Member

This would be great to have. With more recent versions of rules_nodejs the following setup works.

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "cfc289523cf1594598215901154a6c2515e8bf3671fd708264a6f6aefe02bf39",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.4.6/rules_nodejs-4.4.6.tar.gz"],
)

nixpkgs_package(
    name = "nix_node",
    build_file_content = 'exports_files(glob(["nix_node/bin/**"]))',
    nix_file_content = 'with import <nixpkgs> {}; linkFarm "nodejs" [ { name = "nix_node"; path = nodejs-10_x; }]',
    repository = "@nixpkgs",
)

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")

node_repositories(
    package_json = ["//typescript:package.json"],
    vendored_node = "@nix_node",
)

Having a nixpkgs_node_configure that captures that would still be great.

PRs to add this are welcome.

This should go into a separate file here or a dedicated component after #182 to not introduce a dependency on rules_nodejs to all users of rules_nixpkgs independent of whether they use this or not.

A test case would also be good. See here for a Go example.

@benradf
Copy link
Contributor

benradf commented Aug 22, 2022

I started looking into this but it seems like node_repositories changed quite drastically between 4.4.6 and 5.5.3. It no longer takes package_json and vendored_node parameters. I don't really have the knowledge needed to investigate this further so I'm going to unassign myself for now.

@benradf benradf removed their assignment Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants