Commit Graph

38 Commits

Author SHA1 Message Date
Janne Heß
fcc95ff817 treewide: Fix all Nix ASTs in all markdown files
This allows for correct highlighting and maybe future automatic
formatting. The AST was verified to work with nixfmt only.
2024-03-28 09:28:12 +01:00
Eli Flanagan
f6b397eed0
doc: improve javascript conventions (#298127)
I created newlines per the <https://github.com/NixOS/nixpkgs/blob/master/doc/README.md#documentation-conventions> guide.

This paves the way for future contributions to not be distracted by expected conventions.
2024-03-22 14:36:09 -07:00
Doron Behar
290c16532c doc/mkYarnPackage: document better distPhase and doDist 2024-03-18 11:29:47 +02:00
adisbladis
434df3c94b
Merge pull request #289231 from adisbladis/fetchnpmlock
importNpmLock: init
2024-03-08 15:14:37 +13:00
Anderson Torres
e671d3bbbd Nix docs: remove with lib; from example code
Following [Best Practices](https://nix.dev/guides/best-practices#with-scopes),
`with` is a problematic language construction and should be avoided.

Usually it is employed like a "factorization": `[ X.A X.B X.C X.D ]` is written
`with X; [ A B C D ]`.

However, as shown in the link above, the syntatical rules of `with` are not so
intuitive, and this "distributive rule" is very selective, in the sense that
`with X; [ A B C D ]` is not equivalent to `[ X.A X.B X.C X.D ]`.

However, this factorization is still useful to "squeeze" some code, especially
in lists like `meta.maintainers`.

On the other hand, it becomes less justifiable in bigger scopes. This is
especially true in cases like `with lib;` in the top of expression and in sets
like `meta = with lib; { . . . }`.

That being said, this patch removes most of example code in the current
documentation.

The exceptions are, for now
- doc/functions/generators.section.md
- doc/languages-frameworks/coq.section.md

because, well, they are way more complicated, and I couldn't parse them
mentally - yet another reason why `with` should be avoided!
2024-03-06 11:40:09 -03:00
adisbladis
b6e4b86809 importNpmLock: init
This is an alternative to `fetchNpmDeps` that is notably different in that it uses metadata from `package.json` & `package-lock.json` instead of specifying a fixed-output hash.

Notable features:
- IFD free.
- Only fetches a node dependency once. No massive FODs.
- Support for URL, Git and path dependencies.
- Uses most of the existing `npmHooks`

`importNpmLock` can be used _only_ in the cases where we need to check in a `package-lock.json` in the tree.
Currently this means that we have 13 packages that would be candidates to use this function, though I expect most usage to be in private repositories.

This is upstreaming the builder portion of https://github.com/adisbladis/buildNodeModules into nixpkgs (different naming but the code is the same).
I will archive this repository and consider nixpkgs the new upstream once it's been merged.

For more explanations and rationale see https://discourse.nixos.org/t/buildnodemodules-the-dumbest-node-to-nix-packaging-tool-yet/35733

Example usage:
``` nix
stdenv.mkDerivation {
  pname = "my-nodejs-app";
  version = "0.1.0";

  src = ./.;

  nativeBuildInputs = [
    importNpmLock.hooks.npmConfigHook
    nodejs
    nodejs.passthru.python # for node-gyp
    npmHooks.npmBuildHook
    npmHooks.npmInstallHook
  ];

  npmDeps = buildNodeModules.fetchNodeModules {
    npmRoot = ./.;
  };
}
```
2024-03-05 12:23:28 +13:00
Midnight Veil
c1678c2567
doc: mkYarnPackage/mkYarnModules should use offlineCache to prevent IFD
This is not mentioned elsewhere, and can be confusing.
2023-12-09 17:54:22 +11:00
happysalada
7fb490674f buildNpmPackage: allow passing npmDeps 2023-11-16 11:57:48 +00:00
Fabian
cfd0999b5a
docs/javascript/introduction: fix GitHub search link 2023-11-12 19:32:37 +01:00
Yt
5aaeafbe26
buildNpmPackage: make nodejs overridable (#265171)
* buildNpmPackage: allow nodejs to be passed as argument

* Update doc/languages-frameworks/javascript.section.md

Co-authored-by: Lily Foster <lily@lily.flowers>

---------

Co-authored-by: Lily Foster <lily@lily.flowers>
2023-11-09 16:19:24 +00:00
Doron Behar
fc96f6d0fd buildNpmPackage: support makeWrapperArgs 2023-10-07 14:09:05 +03:00
Doron Behar
d6521ce186 docs/javascript/buildNpmPackage: Document fetchNpmDeps
Co-authored-by: Lily Foster <lily@lily.flowers>
2023-10-07 14:09:05 +03:00
Doron Behar
384b1e5b91 docs/javascript/buildNpmPackage: Document bin, man and npm pack behavior 2023-10-07 14:09:05 +03:00
Wout Mertens
00de2104fc corepack: PR review updates
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Sandro Jaeckel <sandro.jaeckel@gmail.com>
2023-09-20 17:27:05 +02:00
Wout Mertens
724f6bcb77 nodejs: corepack wrappers package 2023-09-20 10:10:51 +02:00
Lily Foster
3990bb5b5e
doc/languages-frameworks/javascript: add npmWorkspace and npmPruneFlags args 2023-06-29 07:43:12 -04:00
Lily Foster
59713b5555
Merge pull request #230157 from teutat3s/buildnpmpackage-docs
buildNpmPackage: document dontNpmBuild option
2023-06-28 18:33:02 -04:00
teutat3s
3a2cf5b3f5
buildNpmPackage: document dontNpmBuild option
document dontNpmInstall option
2023-06-28 23:49:29 +02:00
Andrew
1b6f640687
doc: correct typos and spelling (#237098) 2023-06-11 02:15:43 +02:00
Sandro Jäckel
aad577bd30 nodejs*: normalise names to better fit other packages
Versioned package attributes are usually named like $pname_$version
eg: nodejs-14_x -> nodejs_14
2023-04-25 11:28:17 +02:00
pennae
052bb41410 doc: assign ids to many headings
without stable ids on headings we cannot generate stable links to these
headings. nrd complains about this, but the current docbook workflow
does not.

a few generated ids remain, mostly in examples and footnotes. most of
the examples are generated by nixdoc (which has since gained MD export
functions, and the MD export does generate IDs).
2023-03-27 22:39:11 +02:00
Winter
f1292b31d6 doc/languages-frameworks/javascript: use --ignore-scripts flag in example
Presenting an example with a patch (without even providing that patch!) is not ideal. Since `npm pack` now obeys `--ignore-scripts`, we can use that instead.
2022-12-13 19:40:27 -05:00
Valentin Gagarin
db1a83aaa4 docs: fixup wording and formatting on JavaScript 2022-12-07 16:47:31 +01:00
Valentin Gagarin
53b5a47c12 document Import From Derivation (IFD) policy 2022-12-07 16:47:30 +01:00
Colin Arnott
bac379f30a
doc: use sri hash syntax
The nixpkgs manual contains references to both sri hash and explicit
sha256 attributes. This is at best confusing to new users. Since the
final destination is exclusive use of sri hashes, see nixos/rfcs#131,
might as well push new users in that direction gently.

Notable exceptions to sri hash support are builtins.fetchTarball,
cataclysm-dda, coq, dockerTools.pullimage, elixir.override, and
fetchCrate. None, other than builtins.fetchTarball, are fundamentally
incompatible, but all currently accept explicit sha256 attributes as
input. Because adding backwards compatibility is out of scope for this
change, they have been left intact, but migration to sri format has been
made for any using old hash formats.

All hashes have been manually tested to be accurate, and updates were
only made for missing upstream artefacts or bugs.
2022-12-04 06:12:18 +00:00
Winter
125bd1f0b5 doc/languages-frameworks/javascript: update deps hash in example 2022-11-23 20:52:08 -05:00
Winter
93334f5234 npmHooks.npmInstallHook: pass install flags to prune 2022-11-21 15:00:08 -05:00
Winter
16722903aa buildNpmPackage: init 2022-11-09 10:35:59 -05:00
Sandro Jäckel
d92f25a1f4
docs/javascript: advise to create less yarn.nix files 2022-07-30 19:29:31 +02:00
Malo Bourgon
ef3ed931d2 nodePackages: update/cleanup documentation 2022-05-14 11:30:21 -07:00
Austin Butler
5c105f9208 docs: document Javascript package updates in nixpkgs 2022-03-21 15:32:53 -04:00
Akshat
98a3230afa remove a mention of #node.section.md
node.section.md has been removed so this commit removes the reference of it inside javascript.section.md
2021-09-03 21:45:20 +09:00
Bill Ewanick
a2b179a3dc Update doc/languages-frameworks/javascript.section.md
Co-authored-by: Jonathan Ringer <jonringer@users.noreply.github.com>
2021-08-25 09:02:06 +09:00
Bill Ewanick
dabd16e7f2 Adding dependency override example 2021-08-25 09:02:06 +09:00
Bill Ewanick
e89b36e4cb Adding tips/searching section 2021-08-25 09:02:06 +09:00
Bill Ewanick
1b76da0cad Minor corrections 2021-08-25 09:02:06 +09:00
happysalada
71b36882e4 docs: move node section to javascript section 2021-08-21 16:21:59 +09:00
happysalada
9475d5339a docs: add javascript section 2021-08-21 16:21:59 +09:00