Skip to content
This repository has been archived by the owner on May 20, 2021. It is now read-only.

Add tarball and var outputs #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,12 @@ Converts `yarn.lock` files into nix expression.
2. Create an isolated environment `cd /tmp; nix-shell --pure -p bash`.
3. `/nix/store/some-path-to-frontend/bin/weave-demo-frontend`

## Front-end packages

The default output of mkYarnPackage includes `bin` and `node_modules`
directories, and is most useful for packages that provide binaries, such as
command-line tools or servers. For packages in which only the generated files
are an interesting result, you can use the `var` output

## License
`yarn2nix` is released under the terms of the GPL-3.0 license.
14 changes: 8 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ in
(dep: ''
# ensure any existing scope directory is not a symlink
linkDirToDirLinks "$(dirname node_modules/${dep.pname})"
mkdir -p node_modules/${dep.pname}
tar -xf ${dep}/tarballs/${dep.name}.tgz --directory node_modules/${dep.pname} --strip-components=1
cp -R ${dep.var} node_modules/${dep.pname}
'')
workspaceDependenciesTransitive);
in stdenv.mkDerivation (builtins.removeAttrs attrs ["pkgConfig" "workspaceDependencies"] // {
Expand Down Expand Up @@ -265,8 +264,6 @@ in
runHook postConfigure
'';

# Replace this phase on frontend packages where only the generated
# files are an interesting output.
installPhase = attrs.installPhase or ''
runHook preInstall

Expand All @@ -284,15 +281,20 @@ in

doDist = true;
distPhase = ''
mkdir -p $out/tarballs/
yarn pack --ignore-scripts --filename $out/tarballs/${baseName}.tgz
cp ${packageJSON} ./package.json
mkdir -p $tarball
yarn pack --ignore-scripts --filename $tarball/package.tgz
mkdir -p $var
tar -xf $tarball/package.tgz --directory $var --strip-components=1
'';

passthru = {
inherit pname package packageJSON deps;
workspaceDependencies = workspaceDependenciesTransitive;
} // (attrs.passthru or {});

outputs = [ "out" "tarball" "var" ];

# TODO: populate meta automatically
});

Expand Down