Docs, and rebuild dist

This commit is contained in:
Stéphan Kochen
2020-08-25 22:37:48 +02:00
parent fcba68fd6f
commit ccfc83af5d
3 changed files with 19 additions and 7 deletions
+17 -6
View File
@@ -2,20 +2,30 @@
**WORK IN PROGRESS** **WORK IN PROGRESS**
Generates a Nix expression to build a Yarn v2 package. Generates a Nix expression to build a Yarn v2 project (not using zero-install).
## Usage ## Usage
```sh ```sh
yarn plugin import https://raw.githubusercontent.com/stephank/yarn-plugin-nixify/main/dist/yarn-plugin-nixify.js yarn plugin import https://raw.githubusercontent.com/stephank/yarn-plugin-nixify/main/dist/yarn-plugin-nixify.js
yarn yarn
yarn nixify
nix-build nix-build
``` ```
The `yarn nixify` command always updates `yarn-project.nix`, but only writes a Running `yarn` with this plugin enabled will generate two files:
(minimal) `default.nix` if it doesn't exist yet. The `default.nix` is intended
to be customized, for example: - `yarn-project.nix`: This file is always overwritten, and contains a basic
derivation for your project.
- `default.nix`: Only generated if it does not exist yet. This file is intended
to be customized with any project-specific logic you need.
When building the basic derivation without any customization, it'll run `yarn`
inside your project, copy your project to `$out/libexec/<name>`, and setup
wrappers in `$out/bin` for any executables declared in the `bin` field of your
top-level `package.json`.
Some examples of how to customize your build from within `default.nix`:
```nix ```nix
{ pkgs ? import <nixpkgs> { } }: { pkgs ? import <nixpkgs> { } }:
@@ -62,4 +72,5 @@ yarn build-dev
yarn plugin import /path/to/yarn-plugin-nixify/dist/yarn-plugin-nixify.dev.js yarn plugin import /path/to/yarn-plugin-nixify/dist/yarn-plugin-nixify.dev.js
``` ```
(Alternatively, add a direct reference in `.yarnrc.yml`.) (Alternatively, add a direct reference in `.yarnrc.yml`. This will likely only
work if the Nix sandbox is disabled.)
+1 -1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -34,6 +34,7 @@ export default async (project: Project, cache: Cache, report: Report) => {
const yarnPathAbs = configuration.get(`yarnPath`); const yarnPathAbs = configuration.get(`yarnPath`);
const cacheFolderAbs = configuration.get(`cacheFolder`); const cacheFolderAbs = configuration.get(`cacheFolder`);
// Sanity checks.
let yarnPath = ppath.relative(cwd, yarnPathAbs); let yarnPath = ppath.relative(cwd, yarnPathAbs);
if (yarnPath.startsWith(`../`)) { if (yarnPath.startsWith(`../`)) {
yarnPath = yarnPathAbs; yarnPath = yarnPathAbs;