From fcc95ff8172cc68a0d2d52aa1e8ef2120d2904ec Mon Sep 17 00:00:00 2001 From: Janne Heß Date: Wed, 27 Mar 2024 19:10:27 +0100 Subject: 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. --- doc/build-helpers/fetchers.chapter.md | 10 ++-- doc/build-helpers/images/dockertools.section.md | 1 + .../special/checkpoint-build.section.md | 12 +++-- doc/build-helpers/testers.chapter.md | 54 +++++++++++++--------- doc/build-helpers/trivial-build-helpers.chapter.md | 34 +++++++------- 5 files changed, 64 insertions(+), 47 deletions(-) (limited to 'doc/build-helpers') diff --git a/doc/build-helpers/fetchers.chapter.md b/doc/build-helpers/fetchers.chapter.md index e8521861208fe..123585c6dd2da 100644 --- a/doc/build-helpers/fetchers.chapter.md +++ b/doc/build-helpers/fetchers.chapter.md @@ -30,7 +30,7 @@ For example, consider the following fetcher: fetchurl { url = "http://www.example.org/hello-1.0.tar.gz"; hash = "sha256-lTeyxzJNQeMdu1IVdovNMtgn77jRIhSybLdMbTkf2Ww="; -}; +} ``` A common mistake is to update a fetcher’s URL, or a version parameter, without updating the hash. @@ -39,7 +39,7 @@ A common mistake is to update a fetcher’s URL, or a version parameter, without fetchurl { url = "http://www.example.org/hello-1.1.tar.gz"; hash = "sha256-lTeyxzJNQeMdu1IVdovNMtgn77jRIhSybLdMbTkf2Ww="; -}; +} ``` **This will reuse the old contents**. @@ -49,7 +49,7 @@ Remember to invalidate the hash argument, in this case by setting the `hash` att fetchurl { url = "http://www.example.org/hello-1.1.tar.gz"; hash = ""; -}; +} ``` Use the resulting error message to determine the correct hash. @@ -123,7 +123,7 @@ Here is an example of `fetchDebianPatch` in action: buildPythonPackage rec { pname = "pysimplesoap"; version = "1.16.2"; - src = ...; + src = "..."; patches = [ (fetchDebianPatch { @@ -134,7 +134,7 @@ buildPythonPackage rec { }) ]; - ... + # ... } ``` diff --git a/doc/build-helpers/images/dockertools.section.md b/doc/build-helpers/images/dockertools.section.md index 001d5695290ed..527e623e78987 100644 --- a/doc/build-helpers/images/dockertools.section.md +++ b/doc/build-helpers/images/dockertools.section.md @@ -1177,6 +1177,7 @@ dockerTools.buildImage { hello dockerTools.binSh ]; +} ``` After building the image and loading it in Docker, we can create a container based on it and enter a shell inside the container. diff --git a/doc/build-helpers/special/checkpoint-build.section.md b/doc/build-helpers/special/checkpoint-build.section.md index f60afe801ed4c..a1ce5608f246d 100644 --- a/doc/build-helpers/special/checkpoint-build.section.md +++ b/doc/build-helpers/special/checkpoint-build.section.md @@ -9,13 +9,17 @@ However, we can tell Nix explicitly what the previous build state was, by repres To change a normal derivation to a checkpoint based build, these steps must be taken: - apply `prepareCheckpointBuild` on the desired derivation, e.g. ```nix -checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox); +{ + checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox); +} ``` - change something you want in the sources of the package, e.g. use a source override: ```nix -changedVBox = pkgs.virtualbox.overrideAttrs (old: { - src = path/to/vbox/sources; -}); +{ + changedVBox = pkgs.virtualbox.overrideAttrs (old: { + src = path/to/vbox/sources; + }); +} ``` - use `mkCheckpointBuild changedVBox checkpointArtifacts` - enjoy shorter build times diff --git a/doc/build-helpers/testers.chapter.md b/doc/build-helpers/testers.chapter.md index 35f9290ecbfb9..b734cbbbd4e29 100644 --- a/doc/build-helpers/testers.chapter.md +++ b/doc/build-helpers/testers.chapter.md @@ -14,11 +14,13 @@ If the `moduleNames` argument is omitted, `hasPkgConfigModules` will use `meta.p # Check that `pkg-config` modules are exposed using default values ```nix -passthru.tests.pkg-config = testers.hasPkgConfigModules { - package = finalAttrs.finalPackage; -}; +{ + passthru.tests.pkg-config = testers.hasPkgConfigModules { + package = finalAttrs.finalPackage; + }; -meta.pkgConfigModules = [ "libfoo" ]; + meta.pkgConfigModules = [ "libfoo" ]; +} ``` ::: @@ -28,10 +30,12 @@ meta.pkgConfigModules = [ "libfoo" ]; # Check that `pkg-config` modules are exposed using explicit module names ```nix -passthru.tests.pkg-config = testers.hasPkgConfigModules { - package = finalAttrs.finalPackage; - moduleNames = [ "libfoo" ]; -}; +{ + passthru.tests.pkg-config = testers.hasPkgConfigModules { + package = finalAttrs.finalPackage; + moduleNames = [ "libfoo" ]; + }; +} ``` ::: @@ -55,7 +59,9 @@ The default argument to the command is `--version`, and the version to be checke This example will run the command `hello --version`, and then check that the version of the `hello` package is in the output of the command. ```nix -passthru.tests.version = testers.testVersion { package = hello; }; +{ + passthru.tests.version = testers.testVersion { package = hello; }; +} ``` ::: @@ -70,13 +76,15 @@ This means that an output like "leetcode 0.4.21" would fail the tests, and an ou A common usage of the `version` attribute is to specify `version = "v${version}"`. ```nix -version = "0.4.2"; +{ + version = "0.4.2"; -passthru.tests.version = testers.testVersion { - package = leetcode-cli; - command = "leetcode -V"; - version = "leetcode ${version}"; -}; + passthru.tests.version = testers.testVersion { + package = leetcode-cli; + command = "leetcode -V"; + version = "leetcode ${version}"; + }; +} ``` ::: @@ -116,7 +124,7 @@ runCommand "example" { grep -F 'failing though' $failed/testBuildFailure.log [[ 3 = $(cat $failed/testBuildFailure.exit) ]] touch $out -''; +'' ``` ::: @@ -193,12 +201,14 @@ once to get a derivation hash, and again to produce the final fixed output deriv # Prevent nix from reusing the output of a fetcher ```nix -tests.fetchgit = testers.invalidateFetcherByDrvHash fetchgit { - name = "nix-source"; - url = "https://github.com/NixOS/nix"; - rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a"; - hash = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY="; -}; +{ + tests.fetchgit = testers.invalidateFetcherByDrvHash fetchgit { + name = "nix-source"; + url = "https://github.com/NixOS/nix"; + rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a"; + hash = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY="; + }; +} ``` ::: diff --git a/doc/build-helpers/trivial-build-helpers.chapter.md b/doc/build-helpers/trivial-build-helpers.chapter.md index c9985bda79238..4f2754903f9b3 100644 --- a/doc/build-helpers/trivial-build-helpers.chapter.md +++ b/doc/build-helpers/trivial-build-helpers.chapter.md @@ -76,12 +76,14 @@ If you need to refer to the resulting files somewhere else in a Nix expression, For example, if the file destination is a directory: ```nix -my-file = writeTextFile { - name = "my-file"; - text = '' - Contents of File - ''; - destination = "/share/my-file"; +{ + my-file = writeTextFile { + name = "my-file"; + text = '' + Contents of File + ''; + destination = "/share/my-file"; + }; } ``` @@ -90,7 +92,7 @@ Remember to append "/share/my-file" to the resulting store path when using it el ```nix writeShellScript "evaluate-my-file.sh" '' cat ${my-file}/share/my-file -''; +'' ``` :::: @@ -287,7 +289,7 @@ writeTextFile { }; allowSubstitutes = true; preferLocalBuild = false; -}; +} ``` ::: @@ -351,7 +353,7 @@ Write the string `Contents of File` to `/nix/store/`: writeText "my-file" '' Contents of File - ''; + '' ``` ::: @@ -391,7 +393,7 @@ Write the string `Contents of File` to `/nix/store//share/my-file`: writeTextDir "share/my-file" '' Contents of File - ''; + '' ``` ::: @@ -433,7 +435,7 @@ Write the string `Contents of File` to `/nix/store/` and make the fi writeScript "my-file" '' Contents of File - ''; + '' ``` ::: @@ -475,7 +477,7 @@ The store path will include the the name, and it will be a directory. writeScriptBin "my-script" '' echo "hi" - ''; + '' ``` ::: @@ -519,7 +521,7 @@ This function is almost exactly like [](#trivial-builder-writeScript), except th writeShellScript "my-script" '' echo "hi" - ''; + '' ``` ::: @@ -562,7 +564,7 @@ This function is a combination of [](#trivial-builder-writeShellScript) and [](# writeShellScriptBin "my-script" '' echo "hi" - ''; + '' ``` ::: @@ -674,7 +676,7 @@ writeClosure [ (writeScriptBin "hi" ''${hello}/bin/hello'') ] produces an output path `/nix/store/-runtime-deps` containing -```nix +``` /nix/store/-hello-2.10 /nix/store/-hi /nix/store/-libidn2-2.3.0 @@ -700,7 +702,7 @@ writeDirectReferencesToFile (writeScriptBin "hi" ''${hello}/bin/hello'') produces an output path `/nix/store/-runtime-references` containing -```nix +``` /nix/store/-hello-2.10 ``` -- cgit 1.4.1