-
Notifications
You must be signed in to change notification settings - Fork 3
Conversation
pkgs/buildNpmPackage/default.nix
Outdated
echo making cache | ||
node ${./mkcache.js} ${npm-cache-input lock} | ||
echo installing | ||
npm ci --cache=./npm-cache --offline --script-shell=${shellWrap}/bin/npm-shell-wrap.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to tell you to use full command names instead of abbreviations in scripts, but it turns out npm ci
is the full command name. Cue traditional npm-inspired facepalm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will take another pass a bit later.
@@ -16,6 +16,8 @@ in | |||
rev = "76dc0f06d21f6063cb7b7d2291b8623da24affa9"; | |||
}) {}; | |||
|
|||
buildNpmPackage = callPackage ./buildNpmPackage {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nicer if this were a separate repo, I don't think it's right to commit JS code into a closure which is supposed to mostly point to stuff.
pkgs/buildNpmPackage/default.nix
Outdated
let | ||
inherit (builtins) fromJSON toJSON readFile split head elemAt foldl'; | ||
|
||
deps-to-fetches = base: deps: builtins.foldl' (a: b: a // (dep-to-fetch b)) base (builtins.attrValues deps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
builtins.foldl'
-> foldl'
, builtins.attrValues
-> attrValues
, deps-to-fetches
-> depsToFetches
pkgs/buildNpmPackage/default.nix
Outdated
@@ -0,0 +1,58 @@ | |||
{ stdenvNoCC, writeShellScriptBin, writeText, stdenv, fetchurl, makeWrapper, nodejs-10_x }: | |||
let | |||
inherit (builtins) fromJSON toJSON readFile split head elemAt foldl'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with lib;
in | ||
args @ { lockfile, src, buildInputs ? [], ... }: | ||
let lock = fromJSON (readFile lockfile); in | ||
stdenv.mkDerivation ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stdenv.mkDerivation ({ /* ... */ })
-> stdenv.mkDerivation { /* ... */ }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is stdenv.mkDerivation ({ ... } // { ... } // { ... })
pkgs/buildNpmPackage/default.nix
Outdated
''; | ||
in | ||
args @ { lockfile, src, buildInputs ? [], ... }: | ||
let lock = fromJSON (readFile lockfile); in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let
lock = fromJSON (readFile lockFile);
in
pkgs/buildNpmPackage/default.nix
Outdated
"${resolved}" = fetchurl { | ||
url = resolved; | ||
"${hashtype}" = hash; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should rather return nameValuePair
.
pkgs/buildNpmPackage/default.nix
Outdated
}; | ||
|
||
dep-to-fetch = args @ { resolved ? null, dependencies ? {}, ... }: | ||
deps-to-fetches (if isNull resolved then {} else dep-own-fetch args) dependencies; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fromDeps (optionalAttrs (resolved != null) (dep2thing args)) dependencies
pkgs/buildNpmPackage/mkcache.js
Outdated
module.paths.push(path.join(process.argv[0], "../../lib/node_modules/npm/node_modules")) | ||
const pacote = require('pacote') | ||
|
||
function forall_deps(pkg, fn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
traverseDeps
, walkDeps
? forall
typically doesn't presume tree traversal.
pkgs/buildNpmPackage/default.nix
Outdated
buildPhase = '' | ||
echo making cache | ||
node ${./mkcache.js} ${npm-cache-input lock} | ||
echo installing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is install, everything below it should go into installPhase
instead.
pkgs/buildNpmPackage/default.nix
Outdated
XDG_CONFIG_DIRS = "."; | ||
NO_UPDATE_NOTIFIER = true; | ||
buildPhase = '' | ||
echo making cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derivations shouldn't print that, it's phases
job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this does not follow Nixpkgs style guidelines, and variable names could be better.
@yegortimoshenko Please re-review
…On Thu, Sep 27, 2018 at 4:02 PM Yegor Timoshenko ***@***.***> wrote:
***@***.**** commented on this pull request.
Overall, this does not follow Nixpkgs style guidelines, and variable names
could be better.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAnfpAsNwMqh_eBV7OFD_tpwIE791I8pks5ufNprgaJpZM4W7H0t>
.
|
exec bash "$@" | ||
''; | ||
in | ||
args @ { lockfile, src, buildInputs ? [], npmFlags ? [], ... }: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is lockfile
set?
inherit (builtins) fromJSON toJSON split; | ||
|
||
depsToFetches = deps: concatMap depToFetch (attrValues deps); | ||
depFetchOwn = { resolved, integrity, ... }: let |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you also getting non-production dependencies here?
# unpack the .tgz into output directory and add npm wrapper | ||
installPhase = '' | ||
mkdir -p $out/bin | ||
tar xzvf ./${lock.name}-${lock.version}.tgz -C $out --strip-components=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use ${name}
(= "${lock.name}-${lock.version}"
) here.
I suggest closing this in favor of a PR that uses serokell/nix-npm-buildpackage#2 when that's done. |
Closing in favor of #5 |
No description provided.