From 53b5a47c12e45bcc55a1115429e231e8c325fd1e Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Mon, 5 Dec 2022 16:24:52 +0100 Subject: [PATCH 1/3] document Import From Derivation (IFD) policy --- doc/contributing/coding-conventions.chapter.md | 15 +++++++++++++++ doc/languages-frameworks/javascript.section.md | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/contributing/coding-conventions.chapter.md b/doc/contributing/coding-conventions.chapter.md index d6f6cfe2358d..134c0ca93cae 100644 --- a/doc/contributing/coding-conventions.chapter.md +++ b/doc/contributing/coding-conventions.chapter.md @@ -670,3 +670,18 @@ stdenv.mkDerivation { ... } ``` + +### Import From Derivation {#ssec-import-from-derivation} + +Import From Derivation (IFD) is disallowed in Nixpkgs for performance reasons: +[Hydra] evaluates the entire package set, and sequential builds during evalation would increase evaluation times to become impractical. + +[Hydra]: https://github.com/NixOS/hydra + +Import From Derivation can be worked around in some cases by committing generated intermediate files to version control and reading those instead. + + + +See also [NixOS Wiki: Import From Derivation]. + +[NixOS Wiki: Import From Derivation]: https://nixos.wiki/wiki/Import_From_Derivation diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index 5a17c124a8e1..cea0ede2d5be 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -332,7 +332,7 @@ mkYarnPackage rec { ## Outside of nixpkgs {#javascript-outside-nixpkgs} -There are some other options available that can't be used inside nixpkgs. Those other options are written in Nix. Importing them in nixpkgs will require moving the source code into nixpkgs. Using [Import From Derivation](https://nixos.wiki/wiki/Import_From_Derivation) is not allowed in Hydra at present. If you are packaging something outside nixpkgs, those can be considered +There are some other options available that can't be used inside nixpkgs. Those other options are written in Nix. Importing them in nixpkgs will require moving the source code into nixpkgs. Using [Import From Derivation](#ssec-import-from-derivation) is not allowed in Hydra at present. If you are packaging something outside nixpkgs, those can be considered ### npmlock2nix {#javascript-npmlock2nix} From db1a83aaa4e5cfdf054146a48304bcfc0ec48ce3 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Mon, 5 Dec 2022 16:26:52 +0100 Subject: [PATCH 2/3] docs: fixup wording and formatting on JavaScript --- doc/contributing/coding-conventions.chapter.md | 4 ++-- doc/languages-frameworks/javascript.section.md | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/contributing/coding-conventions.chapter.md b/doc/contributing/coding-conventions.chapter.md index 134c0ca93cae..a8cea4493cc2 100644 --- a/doc/contributing/coding-conventions.chapter.md +++ b/doc/contributing/coding-conventions.chapter.md @@ -487,12 +487,12 @@ Preferred source hash type is sha256. There are several ways to get it. - `lib.fakeHash` - `lib.fakeSha256` - `lib.fakeSha512` - + in the package expression, attempt build and extract correct hash from error messages. ::: {.warning} You must use one of these four fake hashes and not some arbitrarily-chosen hash. - + See [](#sec-source-hashes-security). ::: diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index cea0ede2d5be..e4e6643dd66a 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -330,13 +330,16 @@ mkYarnPackage rec { - The `echo 9` steps comes from this answer: - Exporting the headers in `npm_config_nodedir` comes from this issue: -## Outside of nixpkgs {#javascript-outside-nixpkgs} +## Outside Nixpkgs {#javascript-outside-nixpkgs} -There are some other options available that can't be used inside nixpkgs. Those other options are written in Nix. Importing them in nixpkgs will require moving the source code into nixpkgs. Using [Import From Derivation](#ssec-import-from-derivation) is not allowed in Hydra at present. If you are packaging something outside nixpkgs, those can be considered +There are some other tools available, which are written in the Nix language. +These that can't be used inside Nixpkgs because they require [Import From Derivation](#ssec-import-from-derivation), which is not allowed in Nixpkgs. + +If you are packaging something outside Nixpkgs, consider the following: ### npmlock2nix {#javascript-npmlock2nix} -[npmlock2nix](https://github.com/nix-community/npmlock2nix) aims at building node_modules without code generation. It hasn't reached v1 yet, the API might be subject to change. +[npmlock2nix](https://github.com/nix-community/npmlock2nix) aims at building `node_modules` without code generation. It hasn't reached v1 yet, the API might be subject to change. #### Pitfalls {#javascript-npmlock2nix-pitfalls} @@ -344,7 +347,7 @@ There are some [problems with npm v7](https://github.com/tweag/npmlock2nix/issue ### nix-npm-buildpackage {#javascript-nix-npm-buildpackage} -[nix-npm-buildpackage](https://github.com/serokell/nix-npm-buildpackage) aims at building node_modules without code generation. It hasn't reached v1 yet, the API might change. It supports both package-lock.json and yarn.lock. +[nix-npm-buildpackage](https://github.com/serokell/nix-npm-buildpackage) aims at building `node_modules` without code generation. It hasn't reached v1 yet, the API might change. It supports both `package-lock.json` and yarn.lock. #### Pitfalls {#javascript-nix-npm-buildpackage-pitfalls} From d9f9ead58a390545e9b508cbfb71e56cd5824199 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Sat, 10 Dec 2022 11:46:53 +0100 Subject: [PATCH 3/3] Update doc/contributing/coding-conventions.chapter.md Co-authored-by: Mostly Void --- doc/contributing/coding-conventions.chapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/contributing/coding-conventions.chapter.md b/doc/contributing/coding-conventions.chapter.md index a8cea4493cc2..275a3c7af5d2 100644 --- a/doc/contributing/coding-conventions.chapter.md +++ b/doc/contributing/coding-conventions.chapter.md @@ -674,7 +674,7 @@ stdenv.mkDerivation { ### Import From Derivation {#ssec-import-from-derivation} Import From Derivation (IFD) is disallowed in Nixpkgs for performance reasons: -[Hydra] evaluates the entire package set, and sequential builds during evalation would increase evaluation times to become impractical. +[Hydra] evaluates the entire package set, and sequential builds during evaluation would increase evaluation times to become impractical. [Hydra]: https://github.com/NixOS/hydra