From 854c5a54607f34084cc545611c0bfbba1b33b887 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Tue, 30 Sep 2025 08:48:38 +0200 Subject: [PATCH] doc: remove optional builtins prefixes from prelude functions Remove optional builtins prefixes from prelude functions by running: builtins=( abort baseNameOf break derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true ) fd --type file . doc --exec-batch sed --in-place --regexp-extended " s/\/\1/g " nix fmt --- doc/build-helpers/fetchers.chapter.md | 2 +- .../trivial-build-helpers.chapter.md | 6 +++--- doc/doc-support/lib-function-locations.nix | 18 +++++++++--------- doc/languages-frameworks/dhall.section.md | 2 +- doc/languages-frameworks/javascript.section.md | 2 +- doc/languages-frameworks/maven.section.md | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/build-helpers/fetchers.chapter.md b/doc/build-helpers/fetchers.chapter.md index 866bde570f8a..df261e995a4a 100644 --- a/doc/build-helpers/fetchers.chapter.md +++ b/doc/build-helpers/fetchers.chapter.md @@ -3,7 +3,7 @@ Building software with Nix often requires downloading source code and other files from the internet. To this end, we use functions that we call _fetchers_, which obtain remote sources via various protocols and services. -Nix provides built-in fetchers such as [`builtins.fetchTarball`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchTarball). +Nix provides built-in fetchers such as [`fetchTarball`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-fetchTarball). Nixpkgs provides its own fetchers, which work differently: - A built-in fetcher will download and cache files at evaluation time and produce a [store path](https://nixos.org/manual/nix/stable/glossary#gloss-store-path). diff --git a/doc/build-helpers/trivial-build-helpers.chapter.md b/doc/build-helpers/trivial-build-helpers.chapter.md index 7b4f14c63325..6f1c4dfba278 100644 --- a/doc/build-helpers/trivial-build-helpers.chapter.md +++ b/doc/build-helpers/trivial-build-helpers.chapter.md @@ -163,7 +163,7 @@ Nixpkgs provides the following functions for producing derivations which write t They are useful for creating files from Nix expression, and are all implemented as convenience wrappers around `writeTextFile`. Each of these functions will cause a derivation to be produced. -When you coerce the result of each of these functions to a string with [string interpolation](https://nixos.org/manual/nix/stable/language/string-interpolation) or [`builtins.toString`](https://nixos.org/manual/nix/stable/language/builtins#builtins-toString), it will evaluate to the [store path](https://nixos.org/manual/nix/stable/store/store-path) of this derivation. +When you coerce the result of each of these functions to a string with [string interpolation](https://nixos.org/manual/nix/stable/language/string-interpolation) or [`toString`](https://nixos.org/manual/nix/stable/language/builtins#builtins-toString), it will evaluate to the [store path](https://nixos.org/manual/nix/stable/store/store-path) of this derivation. :::: {.note} Some of these functions will put the resulting files within a directory inside the [derivation output](https://nixos.org/manual/nix/stable/language/derivations#attr-outputs). @@ -344,7 +344,7 @@ Write a text file to the Nix store. `allowSubstitutes` (Bool, _optional_) : Whether to allow substituting from a binary cache. - Passed through to [`allowSubstitutes`](https://nixos.org/manual/nix/stable/language/advanced-attributes#adv-attr-allowSubstitutes) of the underlying call to `builtins.derivation`. + Passed through to [`allowSubstitutes`](https://nixos.org/manual/nix/stable/language/advanced-attributes#adv-attr-allowSubstitutes) of the underlying call to `derivation`. It defaults to `false`, as running the derivation's simple `builder` executable locally is assumed to be faster than network operations. Set it to true if the `checkPhase` step is expensive. @@ -355,7 +355,7 @@ Write a text file to the Nix store. : Whether to prefer building locally, even if faster [remote build machines](https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-substituters) are available. - Passed through to [`preferLocalBuild`](https://nixos.org/manual/nix/stable/language/advanced-attributes#adv-attr-preferLocalBuild) of the underlying call to `builtins.derivation`. + Passed through to [`preferLocalBuild`](https://nixos.org/manual/nix/stable/language/advanced-attributes#adv-attr-preferLocalBuild) of the underlying call to `derivation`. It defaults to `true` for the same reason `allowSubstitutes` defaults to `false`. diff --git a/doc/doc-support/lib-function-locations.nix b/doc/doc-support/lib-function-locations.nix index 0bc79d7a639d..64a320f3f0cc 100644 --- a/doc/doc-support/lib-function-locations.nix +++ b/doc/doc-support/lib-function-locations.nix @@ -24,19 +24,19 @@ let libset = toplib: - builtins.map (subsetname: { + map (subsetname: { subsetname = subsetname; functions = libDefPos [ ] toplib.${subsetname}; - }) (builtins.map (x: x.name) libsets); + }) (map (x: x.name) libsets); flattenedLibSubset = { subsetname, functions }: - builtins.map (fn: { + map (fn: { name = "lib.${subsetname}.${fn.name}"; value = fn.location; }) functions; - locatedlibsets = libs: builtins.map flattenedLibSubset (libset libs); + locatedlibsets = libs: map flattenedLibSubset (libset libs); removeFilenamePrefix = prefix: filename: let @@ -46,7 +46,7 @@ let in substr; - removeNixpkgs = removeFilenamePrefix (builtins.toString nixpkgsPath); + removeNixpkgs = removeFilenamePrefix (toString nixpkgsPath); liblocations = builtins.filter (elem: elem.value != null) (lib.lists.flatten (locatedlibsets lib)); @@ -59,19 +59,19 @@ let }; }; - relativeLocs = (builtins.map fnLocationRelative liblocations); + relativeLocs = (map fnLocationRelative liblocations); sanitizeId = builtins.replaceStrings [ "'" ] [ "-prime" ]; urlPrefix = "https://github.com/NixOS/nixpkgs/blob/${revision}"; jsonLocs = builtins.listToAttrs ( - builtins.map ( + map ( { name, value }: { name = sanitizeId name; value = let - text = "${value.file}:${builtins.toString value.line}"; - target = "${urlPrefix}/${value.file}#L${builtins.toString value.line}"; + text = "${value.file}:${toString value.line}"; + target = "${urlPrefix}/${value.file}#L${toString value.line}"; in "[${text}](${target}) in ``"; } diff --git a/doc/languages-frameworks/dhall.section.md b/doc/languages-frameworks/dhall.section.md index 5e896aaacb6c..7c91078770ff 100644 --- a/doc/languages-frameworks/dhall.section.md +++ b/doc/languages-frameworks/dhall.section.md @@ -89,7 +89,7 @@ buildDhallPackage { # ./example.nix let - nixpkgs = builtins.fetchTarball { + nixpkgs = fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/94b2848559b12a8ed1fe433084686b2a81123c99.tar.gz"; hash = "sha256-B4Q3c6IvTLg3Q92qYa8y+i4uTaphtFdjp+Ir3QQjdN0="; }; diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index 811b0687bbdd..12507a5e5d5f 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -316,7 +316,7 @@ buildNpmPackage { `importNpmLock` uses the following fetchers: - `pkgs.fetchurl` for `http(s)` dependencies -- `builtins.fetchGit` for `git` dependencies +- `fetchGit` for `git` dependencies It is possible to provide additional arguments to individual fetchers as needed: diff --git a/doc/languages-frameworks/maven.section.md b/doc/languages-frameworks/maven.section.md index 09f7a786d52d..095eaba4e648 100644 --- a/doc/languages-frameworks/maven.section.md +++ b/doc/languages-frameworks/maven.section.md @@ -374,7 +374,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "maven-demo"; version = "1.0"; - src = builtins.fetchTarball "https://github.com/fzakaria/nixos-maven-example/archive/main.tar.gz"; + src = fetchTarball "https://github.com/fzakaria/nixos-maven-example/archive/main.tar.gz"; buildInputs = [ maven ]; buildPhase = '' @@ -445,7 +445,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "maven-demo"; version = "1.0"; - src = builtins.fetchTarball "https://github.com/fzakaria/nixos-maven-example/archive/main.tar.gz"; + src = fetchTarball "https://github.com/fzakaria/nixos-maven-example/archive/main.tar.gz"; nativeBuildInputs = [ makeWrapper ]; buildInputs = [ maven ]; @@ -538,7 +538,7 @@ stdenv.mkDerivation (finalAttrs: { pname = "maven-demo"; version = "1.0"; - src = builtins.fetchTarball "https://github.com/fzakaria/nixos-maven-example/archive/main.tar.gz"; + src = fetchTarball "https://github.com/fzakaria/nixos-maven-example/archive/main.tar.gz"; nativeBuildInputs = [ makeWrapper ]; buildInputs = [ maven ];