doc: fix various `nix` snippets

+7 -7
doc/build-helpers/dev-shell-tools.chapter.md
···
```nix
devShellTools.valueToString (builtins.toFile "foo" "bar")
-
=> "/nix/store/...-foo"
+
# => "/nix/store/...-foo"
```
```nix
devShellTools.valueToString false
-
=> ""
+
# => ""
```
:::
···
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.
+2 -2
doc/build-helpers/special/makesetuphook.section.md
···
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}
···
}
preConfigureHooks+=(_printHelloHook)
''
-
);
+
)
```
## Attributes {#sec-pkgs.makeSetupHook-attributes}
+6 -4
doc/hooks/memcached-test-hook.section.md
···
If you use a custom `checkPhase`, remember to add the `runHook` calls:
```nix
-
checkPhase ''
+
{
+
checkPhase = ''
runHook preCheck
# ... your tests
runHook postCheck
-
''
+
'';
+
}
```
## Variables {#sec-memcachedTestHook-variables}
···
];
preCheck = ''
-
memcachedTestPort=1234
-
''
+
memcachedTestPort=1234;
+
'';
}
+6 -4
doc/hooks/redis-test-hook.section.md
···
If you use a custom `checkPhase`, remember to add the `runHook` calls:
```nix
-
checkPhase ''
+
{
+
checkPhase = ''
runHook preCheck
# ... your tests
runHook postCheck
-
''
+
'';
+
}
```
## Variables {#sec-redisTestHook-variables}
···
];
preCheck = ''
-
redisTestPort=6390
-
''
+
redisTestPort=6390;
+
'';
}
+6
doc/languages-frameworks/android.section.md
···
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
+6 -2
doc/languages-frameworks/astal.section.md
···
pname = "hyprpanel";
version = "1.0.0";
-
src = fetchFromGitHub { ... };
+
src = fetchFromGitHub {
+
#...
+
};
# change your entry file (default is `app.ts`)
entry = "app.ts";
···
# GTK 4 support is opt-in
enableGtk4 = true;
-
meta = { ... };
+
meta = {
+
#...
+
};
}
```
+1 -1
doc/languages-frameworks/factor.section.md
···
version = "1.0";
src = fetchurl {
-
url = "https://some-forge.org/foo-${finalAttrs.version}.tar.gz"
+
url = "https://some-forge.org/foo-${finalAttrs.version}.tar.gz";
};
})
```
+20 -8
doc/languages-frameworks/javascript.section.md
···
npmRoot = ./.;
fetcherOpts = {
# Pass 'curlOptsList' to 'pkgs.fetchurl' while fetching 'axios'
-
{ "node_modules/axios" = { curlOptsList = [ "--verbose" ]; }; }
+
"node_modules/axios" = { curlOptsList = [ "--verbose" ]; };
};
};
···
pname = "foo";
version = "0-unstable-1980-01-01";
-
src = ...;
+
src = {
+
#...
+
};
nativeBuildInputs = [
nodejs
···
pname = "foo";
version = "0-unstable-1980-01-01";
-
src = ...;
+
src = {
+
# ...
+
};
pnpmInstallFlags = [ "--shamefully-hoist" ];
···
```
```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}
···
For example:
```nix
-
...
+
{
+
# ...
pnpmWorkspaces = [ "@astrojs/language-server" ];
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pnpmWorkspaces;
-
...
+
#...
+
};
}
```
···
Usually in such cases, you'd want to use `pnpm --filter=<pnpm workspace name> 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
···
runHook postBuild
'';
+
}
```
#### Additional PNPM Commands and settings {#javascript-pnpm-extraCommands}
···
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.
+2 -2
doc/languages-frameworks/maven.section.md
···
# old mvnHash of 1.2.0 maven dependencies
mvnHash = "sha256-N9XC1pg6Y4sUiBWIQUf16QSXCuiAPpXEHGlgApviF4I=";
-
});
+
})
```
:::
···
"org.apache.maven.surefire:surefire-junit-platform:3.1.2"
"org.junit.platform:junit-platform-launcher:1.10.0"
];
-
};
+
}
```
:::
+8
doc/languages-frameworks/neovim.section.md
···
For instance:
```nix
+
{
rtp-nvim = neovimUtils.buildNeovimPlugin {
luaAttr = luaPackages.rtp-nvim;
};
+
}
```
To update these packages, you should use the lua updater rather than vim's.
···
To only check a specific module, add it manually to the plugin definition [overrides](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";
};
+
}
```
Some plugins will have lua modules that require a user configuration to function properly or can contain optional lua modules that we dont want to test requiring.
We can skip specific modules using `nvimSkipModules`. Similar to `nvimRequireCheck`, it accepts a list of strings.
- `nvimSkipModules = [ MODULE1 MODULE2 ];`
```nix
+
{
asyncrun-vim = super.asyncrun-vim.overrideAttrs {
nvimSkipModules = [
# vim plugin with optional toggleterm integration
···
"asyncrun.toggleterm2"
];
};
+
}
```
In rare cases, we might not want to actually test loading lua modules for a plugin. In those cases, we can disable `neovimRequireCheck` with `doCheck = false;`.
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
+
{
vim-test = super.vim-test.overrideAttrs {
# Vim plugin with a test lua file
doCheck = false;
};
+
}
```