From 51ffa11b12f57b9a0289f08d8ace2319a8a20937 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 17 Apr 2025 20:46:20 +0200 Subject: [PATCH] doc: fix various nix snippets --- doc/build-helpers/dev-shell-tools.chapter.md | 14 +++++----- .../special/makesetuphook.section.md | 4 +-- doc/languages-frameworks/android.section.md | 6 ++++ .../javascript.section.md | 28 +++++++++++++------ doc/languages-frameworks/vim.section.md | 2 ++ 5 files changed, 37 insertions(+), 17 deletions(-) diff --git a/doc/build-helpers/dev-shell-tools.chapter.md b/doc/build-helpers/dev-shell-tools.chapter.md index 0168ea39f7aa..606ee97c28c5 100644 --- a/doc/build-helpers/dev-shell-tools.chapter.md +++ b/doc/build-helpers/dev-shell-tools.chapter.md @@ -20,12 +20,12 @@ Converts Nix values to strings in the way the [`derivation` built-in function](h ```nix devShellTools.valueToString (builtins.toFile "foo" "bar") -=> "/nix/store/...-foo" +# => "/nix/store/...-foo" ``` ```nix devShellTools.valueToString false -=> "" +# => "" ``` ::: @@ -47,11 +47,11 @@ devShellTools.unstructuredDerivationInputEnv { args = [ "-c" "${./builder.sh}" ]; }; } -=> { - name = "foo"; - buildInputs = "/nix/store/...-hello /nix/store/...-figlet"; - builder = "/nix/store/...-bash"; -} +# => { +# name = "foo"; +# buildInputs = "/nix/store/...-hello /nix/store/...-figlet"; +# builder = "/nix/store/...-bash"; +# } ``` Note that `args` is not included, because Nix does not added it to the builder process environment. diff --git a/doc/build-helpers/special/makesetuphook.section.md b/doc/build-helpers/special/makesetuphook.section.md index 179d8d456372..7b83653296eb 100644 --- a/doc/build-helpers/special/makesetuphook.section.md +++ b/doc/build-helpers/special/makesetuphook.section.md @@ -9,7 +9,7 @@ pkgs.makeSetupHook { name = "something-hook"; propagatedBuildInputs = [ pkgs.commandsomething ]; depsTargetTargetPropagated = [ pkgs.libsomething ]; -} ./script.sh; +} ./script.sh ``` ### setup hook that depends on the hello package and runs hello and @shell@ is substituted with path to bash {#sec-pkgs.makeSetupHook-usage-example} @@ -42,7 +42,7 @@ pkgs.makeSetupHook } preConfigureHooks+=(_printHelloHook) '' - ); + ) ``` ## Attributes {#sec-pkgs.makeSetupHook-attributes} diff --git a/doc/languages-frameworks/android.section.md b/doc/languages-frameworks/android.section.md index db4aea04e5e0..bdc479c31629 100644 --- a/doc/languages-frameworks/android.section.md +++ b/doc/languages-frameworks/android.section.md @@ -8,23 +8,29 @@ supporting features. Use the `android-studio-full` attribute for a very complete Android SDK, including system images: ```nix +{ buildInputs = [ android-studio-full ]; +} ``` This is identical to: ```nix +{ buildInputs = [ androidStudioPackages.stable.full ]; +} ``` Alternatively, you can pass composeAndroidPackages to the `withSdk` passthru: ```nix +{ buildInputs = [ (android-studio.withSdk (androidenv.composeAndroidPackages { includeNDK = true; }).androidsdk) ]; +} ``` These will export ANDROID_SDK_ROOT and ANDROID_NDK_ROOT to the SDK and NDK directories diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index 9acfd4181108..275b1920ad11 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -323,7 +323,7 @@ buildNpmPackage { npmRoot = ./.; fetcherOpts = { # Pass 'curlOptsList' to 'pkgs.fetchurl' while fetching 'axios' - { "node_modules/axios" = { curlOptsList = [ "--verbose" ]; }; } + "node_modules/axios" = { curlOptsList = [ "--verbose" ]; }; }; }; @@ -410,7 +410,9 @@ stdenv.mkDerivation (finalAttrs: { pname = "foo"; version = "0-unstable-1980-01-01"; - src = ...; + src = { + # ...; + }; nativeBuildInputs = [ nodejs @@ -439,7 +441,9 @@ stdenv.mkDerivation (finalAttrs: { pname = "foo"; version = "0-unstable-1980-01-01"; - src = ...; + src = { + # ...; + }; pnpmInstallFlags = [ "--shamefully-hoist" ]; @@ -466,14 +470,16 @@ Assuming the following directory structure, we can define `sourceRoot` and `pnpm ``` ```nix - ... +{ + # ... pnpmDeps = pnpm.fetchDeps { - ... + # ... sourceRoot = "${finalAttrs.src.name}/frontend"; }; # by default the working directory is the extracted source pnpmRoot = "frontend"; +} ``` #### PNPM Workspaces {#javascript-pnpm-workspaces} @@ -484,11 +490,13 @@ which will make PNPM only install dependencies for those workspace packages. For example: ```nix -... +{ +# ... pnpmWorkspaces = [ "@astrojs/language-server" ]; pnpmDeps = pnpm.fetchDeps { inherit (finalAttrs) pnpmWorkspaces; - ... + # ... +}; } ``` @@ -498,6 +506,7 @@ Note that you do not need to set `sourceRoot` to make this work. Usually in such cases, you'd want to use `pnpm --filter= build` to build your project, as `npmHooks.npmBuildHook` probably won't work. A `buildPhase` based on the following example will probably fit most workspace projects: ```nix +{ buildPhase = '' runHook preBuild @@ -505,6 +514,7 @@ buildPhase = '' runHook postBuild ''; +} ``` #### Additional PNPM Commands and settings {#javascript-pnpm-extraCommands} @@ -513,13 +523,15 @@ If you require setting an additional PNPM configuration setting (such as `dedupe set `prePnpmInstall` to the right commands to run. For example: ```nix +{ prePnpmInstall = '' pnpm config set dedupe-peer-dependants false ''; pnpmDeps = pnpm.fetchDeps { inherit (finalAttrs) prePnpmInstall; - ... + # ... }; +} ``` In this example, `prePnpmInstall` will be run by both `pnpm.configHook` and by the `pnpm.fetchDeps` builder. diff --git a/doc/languages-frameworks/vim.section.md b/doc/languages-frameworks/vim.section.md index c79fd3a55df9..01326441e9bd 100644 --- a/doc/languages-frameworks/vim.section.md +++ b/doc/languages-frameworks/vim.section.md @@ -239,10 +239,12 @@ Finally, there are some plugins that are also packaged in nodePackages because t This can be manually added through plugin definition overrides in the [overrides.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/overrides.nix). ```nix +{ gitsigns-nvim = super.gitsigns-nvim.overrideAttrs { dependencies = [ self.plenary-nvim ]; nvimRequireCheck = "gitsigns"; }; +} ``` ### Plugin optional configuration {#vim-plugin-required-snippet}