[Nix-dev] Overriding a node package

Colin Putney colin at wiresong.com
Wed Apr 1 07:06:40 CEST 2015


This happens when you have dependencies in package.json that are not
supplied by the dependencies passed to buildNodePackage.

The build process involves running npm, which will read the package.json
file and attempt to download and install any missing dependencies. That
introduces an impurity to the nix build, so buildNodePackage runs npm with
--registry example.com, which causes the download to fail with the sort of
error you encountered.

Once you've got a nix expression that properly supplies all the necessary
dependencies, npm will not attempt any downloads and the build will succeed.

Hope this helps,

Colin

On Mon, Mar 9, 2015 at 6:38 AM, Kirill Elagin <kirelagin at gmail.com> wrote:

> I have a package (`pkgs.keybase-node-client` to be precise) which is
> generated by `nodePackages.buildNodePackage`. I want to install it from my
> local git repo.
>
> I have no idea how node stuff works in nixpkgs (and not in nixpkgs,
> actually), so I tried the obvious thing:
>
> ~~~~
>   packageOverrides = pkgs_: {
>     keybase-node-client = lib.overrideDerivation pkgs_.keybase-node-client
>       (drv: {
>         src = fetchgit {
>           url = "/home/kirrun/proj/keybase/node-client";
>           <...>
>         };
>       });
>   };
> ~~~~
>
> but this gives me a super-weird error when I try to install it:
>
> ~~~~
> replacing old ‘keybase-node-client-0.7.7’
> installing ‘keybase-node-client-0.7.7’
> these derivations will be built:
>   /nix/store/qsdsxcvnmn6hxs4kpi2mymmplwjq5kig-keybase-node-client-0.7.7.drv
> building path(s)
> ‘/nix/store/16pd9zjj1dh9pc2lpij5p5xqji0b88ag-keybase-node-client-0.7.7’
> building
> /nix/store/16pd9zjj1dh9pc2lpij5p5xqji0b88ag-keybase-node-client-0.7.7
> unpacking sources
> unpacking source archive
> /nix/store/m33g6lw3dg6455bqfnshhn73rn8710yz-node-client-7888c0d
> source root is node-client-7888c0d
> patching sources
> configuring
> 'node_modules/iced-coffee-script' ->
> '/nix/store/jhqn9ph542b8fc8ig8akq22sphbpi2ff-iced-coffee-script-1.7.1-g/lib/node_modules/iced-coffee-script'
> <... (more lines like that) ...>
> 'node_modules/request' ->
> '/nix/store/56b058k267wsf5nhb9n7cw89gi4l90km-node-request-2.30.0/lib/node_modules/request'
> building
> npm ERR! registry error parsing json
> npm ERR! SyntaxError: Unexpected token <
> npm ERR! <!doctype html>
> npm ERR! <html>
> npm ERR! <head>
> npm ERR!     <title>Example Domain</title>
> npm ERR!
> npm ERR!     <meta charset="utf-8" />
> npm ERR!     <meta http-equiv="Content-type" content="text/html;
> charset=utf-8" />
> npm ERR!     <meta name="viewport" content="width=device-width,
> initial-scale=1" />
> npm ERR!     <style type="text/css">
> <... (strip boring CSS) ...>
> npm ERR! <body>
> npm ERR! <div>
> npm ERR!     <h1>Example Domain</h1>
> npm ERR!     <p>This domain is established to be used for illustrative
> examples in documents. You may use this
> npm ERR!     domain in examples without prior coordination or asking for
> permission.</p>
> npm ERR!     <p><a href="http://www.iana.org/domains/example">More
> information...</a></p>
> npm ERR! </div>
> npm ERR! </body>
> npm ERR! </html>
> npm ERR!
> npm ERR!     at Object.parse (native)
> npm ERR!     at RegClient.<anonymous>
> (/nix/store/liq47hvqy92ha47q123y0106pwv404j2-nodejs-0.10.33/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:274:23)
> npm ERR!     at Request._callback
> (/nix/store/liq47hvqy92ha47q123y0106pwv404j2-nodejs-0.10.33/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:246:65)
> npm ERR!     at Request.self.callback
> (/nix/store/liq47hvqy92ha47q123y0106pwv404j2-nodejs-0.10.33/lib/node_modules/npm/node_modules/request/request.js:236:22)
> npm ERR!     at Request.emit (events.js:98:17)
> npm ERR!     at Request.<anonymous>
> (/nix/store/liq47hvqy92ha47q123y0106pwv404j2-nodejs-0.10.33/lib/node_modules/npm/node_modules/request/request.js:1142:14)
> npm ERR!     at Request.emit (events.js:117:20)
> npm ERR!     at IncomingMessage.<anonymous>
> (/nix/store/liq47hvqy92ha47q123y0106pwv404j2-nodejs-0.10.33/lib/node_modules/npm/node_modules/request/request.js:1096:12)
> npm ERR!     at IncomingMessage.emit (events.js:117:20)
> npm ERR!     at _stream_readable.js:943:16
> npm ERR! If you need help, you may report this *entire* log,
> npm ERR! including the npm and node versions, at:
> npm ERR!     <http://github.com/npm/npm/issues>
>
> npm ERR! System Linux 3.18.2-gentookirNote
> npm ERR! command
> "/nix/store/liq47hvqy92ha47q123y0106pwv404j2-nodejs-0.10.33/bin/node"
> "/nix/store/liq47hvqy92ha47q123y0106pwv404j2-nodejs-0.10.33/bin/npm"
> "--registry" "http://www.example.com"
> "--nodedir=/nix/store/5r47h9ipnlrpp05miaj6d3jzw9s7rdna-node-sources"
> "install"
> "/tmp/nix-build-keybase-node-client-0.7.7.drv-0/node-client-7888c0d"
> npm ERR! cwd
> /tmp/nix-build-keybase-node-client-0.7.7.drv-0/node-client-7888c0d/build-dir
> npm ERR! node -v v0.10.33
> npm ERR! npm -v 1.4.28
> npm ERR! type unexpected_token
> npm ERR! not ok code 0
> builder for
> ‘/nix/store/qsdsxcvnmn6hxs4kpi2mymmplwjq5kig-keybase-node-client-0.7.7.drv’
> failed with exit code 1
> error: build of
> ‘/nix/store/qsdsxcvnmn6hxs4kpi2mymmplwjq5kig-keybase-node-client-0.7.7.drv’
> failed
> ~~~~
>
> So errr… looks like something is trying to download something from
> example.com?
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20150331/54ac423b/attachment-0001.html 


More information about the nix-dev mailing list