nix-community / napalm

Support for building npm packages in Nix and lightweight npm registry [maintainer=?]
MIT License
104 stars 18 forks source link

How to pass custom pinned Node.js #17

Closed paluh closed 2 years ago

paluh commented 4 years ago

Hi,

Sorry for this basic question - I'm still learning Nix/NixOS and I've not used niv at all. I want to pass my custom and pinned nodejs and build a Node.js package based on that.

Let me start with signature reading.

The main napalm signature is:

 { pkgs ? import ./nix {} }:

I'm not able to easily deduce what are the real inputs for napalm from that and how to pass nodejs. In ./nix/default.nix I find this expression:

let
  sources = import ./sources.nix;
  pkgs = import sources.nixpkgs {};
in
  pkgs // { inherit sources; nodejs = pkgs.nodejs-10_x; }

Which again doesn't say me more what are the inputs (it even includes the whole custom nixpkgs) but provides a hint about nodejs.

  1. Can I assume that sources together with sources.nixpkgs are the internal napalm dependencies and that I should not really care about them?

Going back to the question. I was able to pass nodejs to napalm by using this code:

let
  napalmSrc = pkgs.fetchFromGitHub {
    rev = "...";
    owner = "nmattia";
    repo = "napalm";
    sha256 = "...";
  };
  napalmNix = import "${naplmSrc}/nix" {};
  napalm = import napalmSrc { pkgs = napalmNix // { nodejs = myNodejs; }; };
in
  napalm.buildPackage ./. {}
  1. Is the above the correct way to pass my custom nodejs version? Is it be possible to sipmlify it somehow?

Thanks again for building this nice tool!

paluh commented 4 years ago

P.S. Maybe we can extract nodejs argument into a separate one like this in napalm default.nix:

{ pkgs? import ./nix, nodejs? pkgs.nodejs }:

Do you think it is sensible proposition?

jtojnar commented 2 years ago

This was implemented in https://github.com/nix-community/napalm/pull/38:

napalm.buildPackage ./. {
  nodejs = …;
}