Open expipiplus1 opened 4 years ago
I'd be pretty interested in this. You can probably just wrap yarn2nix
in a function which takes in the package-lock.json
& transforms it with yarn import
via a derivation
This would be very cool, but I'm running into some issues that seem to come from not being able to download files from npm:
With yarn import --offline
:
json2csv-yarn-imported> unpacking sources
json2csv-yarn-imported> unpacking source archive /nix/store/1b67pxmzy9lk35ip9nxc16z5bqc9455v-source
json2csv-yarn-imported> source root is source
json2csv-yarn-imported> configuring
json2csv-yarn-imported> building
json2csv-yarn-imported> yarn import v1.22.10
json2csv-yarn-imported> info found npm package-lock.json, converting to yarn.lock
json2csv-yarn-imported> warning Import of "commander@^6.1.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "jsonparse@^1.3.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "lodash.get@^4.4.2" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "@babel/core@^7.3.3" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "@babel/preset-env@^7.3.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "coveralls@^3.0.3" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "docpress@^0.8.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "eslint@^6.1.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "gh-pages@^2.0.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "in-publish@^2.0.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "nyc@^14.1.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup@^1.11.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup-plugin-babel@^4.3.2" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup-plugin-commonjs@^10.0.2" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup-plugin-node-builtins@^2.1.2" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup-plugin-node-globals@^1.2.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup-plugin-node-resolve@^5.2.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "standard-version@^8.0.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "tap-spec@^5.0.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "tape@^4.10.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> error Couldn't find any versions for "commander" that matches "^6.1.0" in our cache (possible versions are ""). This is usually caused by a missing entry in the lockfile, running Yarn without the --offline flag may help fix this issue.
json2csv-yarn-imported> info Visit https://yarnpkg.com/en/docs/cli/import for documentation about this command.
json2csv-yarn-imported>
builder for '/nix/store/na5x9gz0dz7nghyx45v8fqzfmq25spyf-json2csv-yarn-imported.drv' failed with exit code 1; last 10 log lines:
warning Import of "rollup-plugin-commonjs@^10.0.2" for "json2csv" failed, resolving normally.
warning Import of "rollup-plugin-node-builtins@^2.1.2" for "json2csv" failed, resolving normally.
warning Import of "rollup-plugin-node-globals@^1.2.1" for "json2csv" failed, resolving normally.
warning Import of "rollup-plugin-node-resolve@^5.2.0" for "json2csv" failed, resolving normally.
warning Import of "standard-version@^8.0.1" for "json2csv" failed, resolving normally.
warning Import of "tap-spec@^5.0.0" for "json2csv" failed, resolving normally.
warning Import of "tape@^4.10.1" for "json2csv" failed, resolving normally.
error Couldn't find any versions for "commander" that matches "^6.1.0" in our cache (possible versions are ""). This is usually caused by a missing entry in the lockfile, running Yarn without the --offline flag may help fix this issue.
info Visit https://yarnpkg.com/en/docs/cli/import for documentation about this command.
[0 built (1 failed)]
error: build of '/nix/store/na5x9gz0dz7nghyx45v8fqzfmq25spyf-json2csv-yarn-imported.drv' failed
Without the --offline
:
json2csv-yarn-imported> unpacking sources
json2csv-yarn-imported> unpacking source archive /nix/store/1b67pxmzy9lk35ip9nxc16z5bqc9455v-source
json2csv-yarn-imported> source root is source
json2csv-yarn-imported> configuring
json2csv-yarn-imported> building
json2csv-yarn-imported> yarn import v1.22.10
json2csv-yarn-imported> warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
json2csv-yarn-imported> info found npm package-lock.json, converting to yarn.lock
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
json2csv-yarn-imported> warning Import of "commander@^6.1.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> error An unexpected error occurred: "https://registry.yarnpkg.com/commander: getaddrinfo ENOTFOUND registry.yarnpkg.com".
json2csv-yarn-imported> info If you think this is a bug, please open a bug report with the information provided in "/build/source/yarn-error.log".
json2csv-yarn-imported> info Visit https://yarnpkg.com/en/docs/cli/import for documentation about this command.
json2csv-yarn-imported> warning Import of "jsonparse@^1.3.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "lodash.get@^4.4.2" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "@babel/core@^7.3.3" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "@babel/preset-env@^7.3.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "coveralls@^3.0.3" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "docpress@^0.8.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "eslint@^6.1.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
json2csv-yarn-imported> warning Import of "gh-pages@^2.0.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "in-publish@^2.0.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "nyc@^14.1.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup@^1.11.0" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup-plugin-babel@^4.3.2" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup-plugin-commonjs@^10.0.2" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup-plugin-node-builtins@^2.1.2" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> warning Import of "rollup-plugin-node-globals@^1.2.1" for "json2csv" failed, resolving normally.
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
json2csv-yarn-imported> info There appears to be trouble with your network connection. Retrying...
[1/0/1 built, 0.0 MiB DL]
error: interrupted by the user
Here's the default.nix
file that I'm using, I tried to build the yarnLock attribute in it with `nix build -L '((import
{ fetchFromGitHub, stdenv, nodejs, yarn2nix-moretea, runCommand, writeText, callPackage, ... }:
let
inherit (yarn2nix-moretea) mkYarnPackage mkYarnNix yarn;
name = "json2csv";
src = fetchFromGitHub {
owner = "zemirco";
repo = "json2csv";
rev = "f0ca2c236b31503b12886c9c5e8239988885315f";
sha256 = "1pn00n1d7girvj3427q2nnvr4w09pli5cg19n45vyyxqjrwny65r";
fetchSubmodules = true;
};
yarnLock = stdenv.mkDerivation {
inherit src;
name = "${name}-yarn-imported";
phases = ["unpackPhase" "configurePhase" "buildPhase"];
buildInputs = [ yarn nodejs ];
configurePhase = ''
# Yarn writes cache directories etc to $HOME.
export HOME=$PWD/yarn_home
'';
buildPhase = ''
yarn import --offline
cp ./yarn.lock $out
'';
};
packageJSON = "${src}/package.json";
yarnNix = mkYarnNix { inherit yarnLock; };
yarnNixHeader = writeText "yarn-nix-header.nix" ''
## To refresh the ./yarn.nix file run this in the current directory
## $ cp -f $(nix-build . -A builtYarnNix --no-out-link) ./yarn.nix
'';
builtYarnNix = runCommand "yarn.nix" { inherit srcYarnNix; } ''
cat ${yarnNixHeader} ${srcYarnNix} > $out
'';
in mkYarnPackage {
inherit name src yarnLock packageJSON;
yarnNix = ./yarn.nix;
passthru = {
yarnDeps = callPackage ./yarn.nix { };
inherit builtYarnNix yarnLock src;
};
}
Thanks for this very useful program!
At the moment I've been having good success using yarn2nix instead of node2nix by running
yarn import
to generate ayarn.lock
file frompackage-lock.json
. (I think another tool to do this issynp
but I've not tried it).I wonder if it would be possible to use this functionality in this project in a less ad-hoc way than I've currently been doing.