summaryrefslogtreecommitdiffstats
path: root/doc/languages-frameworks
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2024-03-28 12:01:21 +0000
committerGitHub <noreply@github.com>2024-03-28 12:01:21 +0000
commit69de1e1beb4fa322688a2bac5761e59a2b17e15e (patch)
tree2c672557314d0e6073b8235691454e54cfade688 /doc/languages-frameworks
parent6ee3a444b9388293ae70d82534c8a4dd8f9f53e7 (diff)
parent203f07f4070816be84c376d1ae0dc88f91ab1fef (diff)
Merge master into staging-next
Diffstat (limited to 'doc/languages-frameworks')
-rw-r--r--doc/languages-frameworks/agda.section.md5
-rw-r--r--doc/languages-frameworks/android.section.md26
-rw-r--r--doc/languages-frameworks/beam.section.md8
-rw-r--r--doc/languages-frameworks/bower.section.md14
-rw-r--r--doc/languages-frameworks/chicken.section.md6
-rw-r--r--doc/languages-frameworks/crystal.section.md6
-rw-r--r--doc/languages-frameworks/cuda.section.md18
-rw-r--r--doc/languages-frameworks/cuelang.section.md4
-rw-r--r--doc/languages-frameworks/dhall.section.md10
-rw-r--r--doc/languages-frameworks/dotnet.section.md4
-rw-r--r--doc/languages-frameworks/gnome.section.md48
-rw-r--r--doc/languages-frameworks/go.section.md82
-rw-r--r--doc/languages-frameworks/idris.section.md4
-rw-r--r--doc/languages-frameworks/java.section.md36
-rw-r--r--doc/languages-frameworks/javascript.section.md70
-rw-r--r--doc/languages-frameworks/lisp.section.md20
-rw-r--r--doc/languages-frameworks/lua.section.md41
-rw-r--r--doc/languages-frameworks/maven.section.md2
-rw-r--r--doc/languages-frameworks/ocaml.section.md1
-rw-r--r--doc/languages-frameworks/perl.section.md74
-rw-r--r--doc/languages-frameworks/php.section.md6
-rw-r--r--doc/languages-frameworks/pkg-config.section.md6
-rw-r--r--doc/languages-frameworks/python.section.md116
-rw-r--r--doc/languages-frameworks/ruby.section.md2
-rw-r--r--doc/languages-frameworks/rust.section.md70
-rw-r--r--doc/languages-frameworks/swift.section.md28
-rw-r--r--doc/languages-frameworks/vim.section.md16
27 files changed, 442 insertions, 281 deletions
diff --git a/doc/languages-frameworks/agda.section.md b/doc/languages-frameworks/agda.section.md
index cb1f12eec234..33fffc60c8db 100644
--- a/doc/languages-frameworks/agda.section.md
+++ b/doc/languages-frameworks/agda.section.md
@@ -114,7 +114,7 @@ This can be overridden by a different version of `ghc` as follows:
```nix
agda.withPackages {
- pkgs = [ ... ];
+ pkgs = [ /* ... */ ];
ghc = haskell.compiler.ghcHEAD;
}
```
@@ -180,6 +180,7 @@ To add an Agda package to `nixpkgs`, the derivation should be written to `pkgs/d
```nix
{ mkDerivation, standard-library, fetchFromGitHub }:
+{}
```
Note that the derivation function is called with `mkDerivation` set to `agdaPackages.mkDerivation`, therefore you
@@ -193,7 +194,7 @@ mkDerivation {
version = "1.5.0";
pname = "iowa-stdlib";
- src = ...
+ src = <...>;
libraryFile = "";
libraryName = "IAL-1.3";
diff --git a/doc/languages-frameworks/android.section.md b/doc/languages-frameworks/android.section.md
index 6f9717ca09cc..1c5687f8ebf1 100644
--- a/doc/languages-frameworks/android.section.md
+++ b/doc/languages-frameworks/android.section.md
@@ -104,18 +104,20 @@ pull from:
repo.json to the Nix store based on the given repository XMLs.
```nix
-repoXmls = {
- packages = [ ./xml/repository2-1.xml ];
- images = [
- ./xml/android-sys-img2-1.xml
- ./xml/android-tv-sys-img2-1.xml
- ./xml/android-wear-sys-img2-1.xml
- ./xml/android-wear-cn-sys-img2-1.xml
- ./xml/google_apis-sys-img2-1.xml
- ./xml/google_apis_playstore-sys-img2-1.xml
- ];
- addons = [ ./xml/addon2-1.xml ];
-};
+{
+ repoXmls = {
+ packages = [ ./xml/repository2-1.xml ];
+ images = [
+ ./xml/android-sys-img2-1.xml
+ ./xml/android-tv-sys-img2-1.xml
+ ./xml/android-wear-sys-img2-1.xml
+ ./xml/android-wear-cn-sys-img2-1.xml
+ ./xml/google_apis-sys-img2-1.xml
+ ./xml/google_apis_playstore-sys-img2-1.xml
+ ];
+ addons = [ ./xml/addon2-1.xml ];
+ };
+}
```
When building the above expression with:
diff --git a/doc/languages-frameworks/beam.section.md b/doc/languages-frameworks/beam.section.md
index 992149090c63..3653cdb337d1 100644
--- a/doc/languages-frameworks/beam.section.md
+++ b/doc/languages-frameworks/beam.section.md
@@ -117,6 +117,7 @@ If there are git dependencies.
- From the mix_deps.nix file, remove the dependencies that had git versions and pass them as an override to the import function.
```nix
+{
mixNixDeps = import ./mix.nix {
inherit beamPackages lib;
overrides = (final: prev: {
@@ -138,8 +139,9 @@ If there are git dependencies.
# you can re-use the same beamDeps argument as generated
beamDeps = with final; [ prometheus ];
};
- });
-};
+ });
+ };
+}
```
You will need to run the build process once to fix the hash to correspond to your new git src.
@@ -153,11 +155,13 @@ Practical steps
- start with the following argument to mixRelease
```nix
+{
mixFodDeps = fetchMixDeps {
pname = "mix-deps-${pname}";
inherit src version;
hash = lib.fakeHash;
};
+}
```
The first build will complain about the hash value, you can replace with the suggested value after that.
diff --git a/doc/languages-frameworks/bower.section.md b/doc/languages-frameworks/bower.section.md
index fceb6aaccb6d..20c142dad5b9 100644
--- a/doc/languages-frameworks/bower.section.md
+++ b/doc/languages-frameworks/bower.section.md
@@ -28,7 +28,7 @@ buildEnv { name = "bower-env"; ignoreCollisions = true; paths = [
(fetchbower "angular" "1.5.3" "~1.5.0" "1749xb0firxdra4rzadm4q9x90v6pzkbd7xmcyjk6qfza09ykk9y")
(fetchbower "bootstrap" "3.3.6" "~3.3.6" "1vvqlpbfcy0k5pncfjaiskj3y6scwifxygfqnw393sjfxiviwmbv")
(fetchbower "jquery" "2.2.2" "1.9.1 - 2" "10sp5h98sqwk90y4k6hbdviwqzvzwqf47r3r51pakch5ii2y7js1")
-];
+]; }
```
Using the `bower2nix` command line arguments, the output can be redirected to a file. A name like `bower-packages.nix` would be fine.
@@ -42,11 +42,13 @@ The function is implemented in [pkgs/development/bower-modules/generic/default.n
### Example buildBowerComponents {#ex-buildBowerComponents}
```nix
-bowerComponents = buildBowerComponents {
- name = "my-web-app";
- generated = ./bower-packages.nix; # note 1
- src = myWebApp; # note 2
-};
+{
+ bowerComponents = buildBowerComponents {
+ name = "my-web-app";
+ generated = ./bower-packages.nix; # note 1
+ src = myWebApp; # note 2
+ };
+}
```
In ["buildBowerComponents" example](#ex-buildBowerComponents) the following arguments are of special significance to the function:
diff --git a/doc/languages-frameworks/chicken.section.md b/doc/languages-frameworks/chicken.section.md
index 72c2642a6478..16b00b3f5b5d 100644
--- a/doc/languages-frameworks/chicken.section.md
+++ b/doc/languages-frameworks/chicken.section.md
@@ -13,10 +13,12 @@ done in the typical Nix fashion. For example, to include support for [SRFI
might write:
```nix
+{
buildInputs = [
chicken
chickenPackages.chickenEggs.srfi-189
];
+}
```
Both `chicken` and its eggs have a setup hook which configures the environment
@@ -67,12 +69,12 @@ let
chickenEggs = super.chickenEggs.overrideScope' (eggself: eggsuper: {
srfi-180 = eggsuper.srfi-180.overrideAttrs {
# path to a local copy of srfi-180
- src = ...
+ src = <...>;
};
});
});
in
# Here, `myChickenPackages.chickenEggs.json-rpc`, which depends on `srfi-180` will use
# the local copy of `srfi-180`.
-# ...
+<...>
```
diff --git a/doc/languages-frameworks/crystal.section.md b/doc/languages-frameworks/crystal.section.md
index b97e75a58da1..9953f357048a 100644
--- a/doc/languages-frameworks/crystal.section.md
+++ b/doc/languages-frameworks/crystal.section.md
@@ -33,22 +33,26 @@ crystal.buildCrystalPackage rec {
# Insert the path to your shards.nix file here
shardsFile = ./shards.nix;
- ...
+ # ...
}
```
This won't build anything yet, because we haven't told it what files build. We can specify a mapping from binary names to source files with the `crystalBinaries` attribute. The project's compilation instructions should show this. For Mint, the binary is called "mint", which is compiled from the source file `src/mint.cr`, so we'll specify this as follows:
```nix
+{
crystalBinaries.mint.src = "src/mint.cr";
# ...
+}
```
Additionally you can override the default `crystal build` options (which are currently `--release --progress --no-debug --verbose`) with
```nix
+{
crystalBinaries.mint.options = [ "--release" "--verbose" ];
+}
```
Depending on the project, you might need additional steps to get it to compile successfully. In Mint's case, we need to link against openssl, so in the end the Nix file looks as follows:
diff --git a/doc/languages-frameworks/cuda.section.md b/doc/languages-frameworks/cuda.section.md
index 09af824531a2..9791018c7f5f 100644
--- a/doc/languages-frameworks/cuda.section.md
+++ b/doc/languages-frameworks/cuda.section.md
@@ -16,24 +16,28 @@ To use one or more CUDA packages in an expression, give the expression a `cudaPa
, cudaSupport ? config.cudaSupport
, cudaPackages ? { }
, ...
-}:
+}: {}
```
When using `callPackage`, you can choose to pass in a different variant, e.g.
when a different version of the toolkit suffices
```nix
-mypkg = callPackage { cudaPackages = cudaPackages_11_5; }
+{
+ mypkg = callPackage { cudaPackages = cudaPackages_11_5; };
+}
```
If another version of say `cudnn` or `cutensor` is needed, you can override the
package set to make it the default. This guarantees you get a consistent package
set.
```nix
-mypkg = let
- cudaPackages = cudaPackages_11_5.overrideScope (final: prev: {
- cudnn = prev.cudnn_8_3;
- }});
-in callPackage { inherit cudaPackages; };
+{
+ mypkg = let
+ cudaPackages = cudaPackages_11_5.overrideScope (final: prev: {
+ cudnn = prev.cudnn_8_3;
+ });
+ in callPackage { inherit cudaPackages; };
+}
```
The CUDA NVCC compiler requires flags to determine which hardware you
diff --git a/doc/languages-frameworks/cuelang.section.md b/doc/languages-frameworks/cuelang.section.md
index 86304208aa20..70329b15fd7d 100644
--- a/doc/languages-frameworks/cuelang.section.md
+++ b/doc/languages-frameworks/cuelang.section.md
@@ -26,7 +26,7 @@ Cuelang schemas are similar to JSON, here is a quick cheatsheet:
Nixpkgs provides a `pkgs.writeCueValidator` helper, which will write a validation script based on the provided Cuelang schema.
Here is an example:
-```
+```nix
pkgs.writeCueValidator
(pkgs.writeText "schema.cue" ''
#Def1: {
@@ -42,7 +42,7 @@ pkgs.writeCueValidator
`document` : match your input data against this fragment of structure or definition, e.g. you may use the same schema file but different documents based on the data you are validating.
Another example, given the following `validator.nix` :
-```
+```nix
{ pkgs ? import <nixpkgs> {} }:
let
genericValidator = version:
diff --git a/doc/languages-frameworks/dhall.section.md b/doc/languages-frameworks/dhall.section.md
index 83567ab17ace..8d85c9f1daf7 100644
--- a/doc/languages-frameworks/dhall.section.md
+++ b/doc/languages-frameworks/dhall.section.md
@@ -187,6 +187,7 @@ wish to specify `source = true` for all Dhall packages, then you can amend the
Dhall overlay like this:
```nix
+{
dhallOverrides = self: super: {
# Enable source for all Dhall packages
buildDhallPackage =
@@ -194,6 +195,7 @@ Dhall overlay like this:
true = self.callPackage ./true.nix { };
};
+}
```
… and now the Prelude will contain the fully decoded result of interpreting
@@ -429,22 +431,26 @@ $ dhall-to-nixpkgs github https://github.com/dhall-lang/dhall-lang.git \
the Prelude globally for all packages, like this:
```nix
+{
dhallOverrides = self: super: {
true = self.callPackage ./true.nix { };
Prelude = self.callPackage ./Prelude.nix { };
};
+}
```
… or selectively overriding the Prelude dependency for just the `true` package,
like this:
```nix
+{
dhallOverrides = self: super: {
true = self.callPackage ./true.nix {
Prelude = self.callPackage ./Prelude.nix { };
};
};
+}
```
## Overrides {#ssec-dhall-overrides}
@@ -454,11 +460,13 @@ You can override any of the arguments to `buildDhallGitHubPackage` or
For example, suppose we wanted to selectively enable `source = true` just for the Prelude. We can do that like this:
```nix
+{
dhallOverrides = self: super: {
Prelude = super.Prelude.overridePackage { source = true; };
- …
+ # ...
};
+}
```
[semantic-integrity-checks]: https://docs.dhall-lang.org/tutorials/Language-Tour.html#installing-packages
diff --git a/doc/languages-frameworks/dotnet.section.md b/doc/languages-frameworks/dotnet.section.md
index 7466c8cdc228..a4e9d6cf9a6c 100644
--- a/doc/languages-frameworks/dotnet.section.md
+++ b/doc/languages-frameworks/dotnet.section.md
@@ -134,7 +134,7 @@ Here is an example `default.nix`, using some of the previously discussed argumen
{ lib, buildDotnetModule, dotnetCorePackages, ffmpeg }:
let
- referencedProject = import ../../bar { ... };
+ referencedProject = import ../../bar { /* ... */ };
in buildDotnetModule rec {
pname = "someDotnetApplication";
version = "0.1";
@@ -236,7 +236,7 @@ the packages inside the `out` directory.
$ nuget-to-nix out > deps.nix
```
Which `nuget-to-nix` will generate an output similar to below
-```
+```nix
{ fetchNuGet }: [
(fetchNuGet { pname = "FosterFramework"; version = "0.1.15-alpha"; sha256 = "0pzsdfbsfx28xfqljcwy100xhbs6wyx0z1d5qxgmv3l60di9xkll"; })
(fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.linux-x64"; version = "8.0.1"; sha256 = "1gjz379y61ag9whi78qxx09bwkwcznkx2mzypgycibxk61g11da1"; })
diff --git a/doc/languages-frameworks/gnome.section.md b/doc/languages-frameworks/gnome.section.md
index 5208f1013cbd..6bf867b21abe 100644
--- a/doc/languages-frameworks/gnome.section.md
+++ b/doc/languages-frameworks/gnome.section.md
@@ -47,6 +47,7 @@ When an application uses icons, an icon theme should be available in `XDG_DATA_D
In the rare case you need to use icons from dependencies (e.g. when an app forces an icon theme), you can use the following to pick them up:
```nix
+{
buildInputs = [
pantheon.elementary-icon-theme
];
@@ -56,6 +57,7 @@ In the rare case you need to use icons from dependencies (e.g. when an app force
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS"
)
'';
+}
```
To avoid costly file system access when locating icons, GTK, [as well as Qt](https://woboq.com/blog/qicon-reads-gtk-icon-cache-in-qt57.html), can rely on `icon-theme.cache` files from the themes' top-level directories. These files are generated using `gtk-update-icon-cache`, which is expected to be run whenever an icon is added or removed to an icon theme (typically an application icon into `hicolor` theme) and some programs do indeed run this after icon installation. However, since packages are installed into their own prefix by Nix, this would lead to conflicts. For that reason, `gtk3` provides a [setup hook](#ssec-gnome-hooks-gtk-drop-icon-theme-cache) that will clean the file from installation. Since most applications only ship their own icon that will be loaded on start-up, it should not affect them too much. On the other hand, icon themes are much larger and more widely used so we need to cache them. Because we recommend installing icon themes globally, we will generate the cache files from all packages in a profile using a NixOS module. You can enable the cache generation using `gtk.iconCache.enable` option if your desktop environment does not already do that.
@@ -85,17 +87,19 @@ If your application uses [GStreamer](https://gstreamer.freedesktop.org/) or [Gri
Given the requirements above, the package expression would become messy quickly:
```nix
-preFixup = ''
- for f in $(find $out/bin/ $out/libexec/ -type f -executable); do
- wrapProgram "$f" \
- --prefix GIO_EXTRA_MODULES : "${getLib dconf}/lib/gio/modules" \
- --prefix XDG_DATA_DIRS : "$out/share" \
- --prefix XDG_DATA_DIRS : "$out/share/gsettings-schemas/${name}" \
- --prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" \
- --prefix XDG_DATA_DIRS : "${hicolor-icon-theme}/share" \
- --prefix GI_TYPELIB_PATH : "${lib.makeSearchPath "lib/girepository-1.0" [ pango json-glib ]}"
- done
-'';
+{
+ preFixup = ''
+ for f in $(find $out/bin/ $out/libexec/ -type f -executable); do
+ wrapProgram "$f" \
+ --prefix GIO_EXTRA_MODULES : "${getLib dconf}/lib/gio/modules" \
+ --prefix XDG_DATA_DIRS : "$out/share" \
+ --prefix XDG_DATA_DIRS : "$out/share/gsettings-schemas/${name}" \
+ --prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" \
+ --prefix XDG_DATA_DIRS : "${hicolor-icon-theme}/share" \
+ --prefix GI_TYPELIB_PATH : "${lib.makeSearchPath "lib/girepository-1.0" [ pango json-glib ]}"
+ done
+ '';
+}
```
Fortunately, there is [`wrapGAppsHook`]{#ssec-gnome-hooks-wrapgappshook}. It works in conjunction with other setup hooks that populate environment variables, and it will then wrap all executables in `bin` and `libexec` directories using said variables.
@@ -121,14 +125,16 @@ For convenience, it also adds `dconf.lib` for a GIO module implementing a GSetti
You can also pass additional arguments to `makeWrapper` using `gappsWrapperArgs` in `preFixup` hook:
```nix
-preFixup = ''
- gappsWrapperArgs+=(
- # Thumbnailers
- --prefix XDG_DATA_DIRS : "${gdk-pixbuf}/share"
- --prefix XDG_DATA_DIRS : "${librsvg}/share"
- --prefix XDG_DATA_DIRS : "${shared-mime-info}/share"
- )
-'';
+{
+ preFixup = ''
+ gappsWrapperArgs+=(
+ # Thumbnailers
+ --prefix XDG_DATA_DIRS : "${gdk-pixbuf}/share"
+ --prefix XDG_DATA_DIRS : "${librsvg}/share"
+ --prefix XDG_DATA_DIRS : "${shared-mime-info}/share"
+ )
+ '';
+}
```
## Updating GNOME packages {#ssec-gnome-updating}
@@ -159,7 +165,7 @@ python3.pkgs.buildPythonApplication {
nativeBuildInputs = [
wrapGAppsHook
gobject-introspection
- ...
+ # ...
];
dontWrapGApps = true;
@@ -181,7 +187,7 @@ mkDerivation {
nativeBuildInputs = [
wrapGAppsHook
qmake
- ...
+ # ...
];
dontWrapGApps = true;
diff --git a/doc/languages-frameworks/go.section.md b/doc/languages-frameworks/go.section.md
index 369eb88d331f..6db0e73505d2 100644
--- a/doc/languages-frameworks/go.section.md
+++ b/doc/languages-frameworks/go.section.md
@@ -38,24 +38,26 @@ The `buildGoModule` function accepts the following parameters in addition to the
The following is an example expression using `buildGoModule`:
```nix
-pet = buildGoModule rec {
- pname = "pet";
- version = "0.3.4";
-
- src = fetchFromGitHub {
- owner = "knqyf263";
- repo = "pet";
- rev = "v${version}";
- hash = "sha256-Gjw1dRrgM8D3G7v6WIM2+50r4HmTXvx0Xxme2fH9TlQ=";
- };
+{
+ pet = buildGoModule rec {
+ pname = "pet";
+ version = "0.3.4";
+
+ src = fetchFromGitHub {
+ owner = "knqyf263";
+ repo = "pet";
+ rev = "v${version}";
+ hash = "sha256-Gjw1dRrgM8D3G7v6WIM2+50r4HmTXvx0Xxme2fH9TlQ=";
+ };
- vendorHash = "sha256-ciBIR+a1oaYH+H1PcC8cD8ncfJczk1IiJ8iYNM+R6aA=";
+ vendorHash = "sha256-ciBIR+a1oaYH+H1PcC8cD8ncfJczk1IiJ8iYNM+R6aA=";
- meta = {
- description = "Simple command-line snippet manager, written in Go";
- homepage = "https://github.com/knqyf263/pet";
- license = lib.licenses.mit;
- maintainers = with lib.maintainers; [ kalbasit ];
+ meta = {
+ description = "Simple command-line snippet manager, written in Go";
+ homepage = "https://github.com/knqyf263/pet";
+ license = lib.licenses.mit;
+ maintainers = with lib.maintainers; [ kalbasit ];
+ };
};
}
```
@@ -72,20 +74,22 @@ In the following is an example expression using `buildGoPackage`, the following
- `goDeps` is where the Go dependencies of a Go program are listed as a list of package source identified by Go import path. It could be imported as a separate `deps.nix` file for readability. The dependency data structure is described below.
```nix
-deis = buildGoPackage rec {
- pname = "deis";
- version = "1.13.0";
-
- goPackagePath = "github.com/deis/deis";
+{
+ deis = buildGoPackage rec {
+ pname = "deis";
+ version = "1.13.0";
+
+ goPackagePath = "github.com/deis/deis";
+
+ src = fetchFromGitHub {
+ owner = "deis";
+ repo = "deis";
+ rev = "v${version}";
+ hash = "sha256-XCPD4LNWtAd8uz7zyCLRfT8rzxycIUmTACjU03GnaeM=";
+ };
- src = fetchFromGitHub {
- owner = "deis";
- repo = "deis";
- rev = "v${version}";
- hash = "sha256-XCPD4LNWtAd8uz7zyCLRfT8rzxycIUmTACjU03GnaeM=";
+ goDeps = ./deps.nix;
};
-
- goDeps = ./deps.nix;
}
```
@@ -153,10 +157,12 @@ A string list of flags to pass to the Go linker tool via the `-ldflags` argument
The most common use case for this argument is to make the resulting executable aware of its own version by injecting the value of string variable using the `-X` flag. For example:
```nix
+{
ldflags = [
"-X main.Version=${version}"
"-X main.Commit=${version}"
];
+}
```
### `tags` {#var-go-tags}
@@ -164,16 +170,20 @@ The most common use case for this argument is to make the resulting executable a
A string list of [Go build tags (also called build constraints)](https://pkg.go.dev/cmd/go#hdr-Build_constraints) that are passed via the `-tags` argument of `go build`. These constraints control whether Go files from the source should be included in the build. For example:
```nix
+{
tags = [
"production"
"sqlite"
];
+}
```
Tags can also be set conditionally:
```nix
+{
tags = [ "production" ] ++ lib.optionals withSqlite [ "sqlite" ];
+}
```
### `deleteVendor` {#var-go-deleteVendor}
@@ -188,10 +198,12 @@ Many Go projects keep the main package in a `cmd` directory.
Following example could be used to only build the example-cli and example-server binaries:
```nix
-subPackages = [
- "cmd/example-cli"
- "cmd/example-server"
-];
+{
+ subPackages = [
+ "cmd/example-cli"
+ "cmd/example-server"
+ ];
+}
```
### `excludedPackages` {#var-go-excludedPackages}
@@ -213,10 +225,12 @@ on a per package level using build tags (`tags`). In case CGO is disabled, these
When a Go program depends on C libraries, place those dependencies in `buildInputs`:
```nix
+{
buildInputs = [
libvirt
libxml2
];
+}
```
`CGO_ENABLED` defaults to `1`.
@@ -245,15 +259,18 @@ This is done with the [`-skip` or `-run`](https://pkg.go.dev/cmd/go#hdr-Testing_
For example, only a selection of tests could be run with:
```nix
+{
# -run and -skip accept regular expressions
checkFlags = [
"-run=^Test(Simple|Fast)$"
];
+}
```
If a larger amount of tests should be skipped, the following pattern can be used:
```nix
+{
checkFlags =
let
# Skip tests that require network access
@@ -264,6 +281,7 @@ If a larger amount of tests should be skipped, the following pattern can be used
];
in
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
+}
```
To disable tests altogether, set `doCheck = false;`.
diff --git a/doc/languages-frameworks/idris.section.md b/doc/languages-frameworks/idris.section.md
index e30a849dd456..0fa828825749 100644
--- a/doc/languages-frameworks/idris.section.md
+++ b/doc/languages-frameworks/idris.section.md
@@ -134,9 +134,9 @@ For example you could set
```nix
build-idris-package {
- idrisBuildOptions = [ "--log" "1" "--verbose" ]
+ idrisBuildOptions = [ "--log" "1" "--verbose" ];
- ...
+ # ...
}
```
diff --git a/doc/languages-frameworks/java.section.md b/doc/languages-frameworks/java.section.md
index 0ce1442cca68..6d56ffcd4503 100644
--- a/doc/languages-frameworks/java.section.md
+++ b/doc/languages-frameworks/java.section.md
@@ -7,7 +7,7 @@ stdenv.mkDerivation {
pname = "...";
version = "...";
- src = fetchurl { ... };
+ src = fetchurl { /* ... */ };
nativeBuildInputs = [
ant
@@ -48,8 +48,10 @@ installs a JAR named `foo.jar` in its `share/java` directory, and
another package declares the attribute
```nix
-buildInputs = [ libfoo ];
-nativeBuildInputs = [ jdk ];
+{
+ buildInputs = [ libfoo ];
+ nativeBuildInputs = [ jdk ];
+}
```
then `CLASSPATH` will be set to
@@ -62,13 +64,15 @@ If your Java package provides a program, you need to generate a wrapper
script to run it using a JRE. You can use `makeWrapper` for this:
```nix
-nativeBuildInputs = [ makeWrapper ];
+{
+ nativeBuildInputs = [ makeWrapper ];
-installPhase = ''
- mkdir -p $out/bin
- makeWrapper ${jre}/bin/java $out/bin/foo \
- --add-flags "-cp $out/share/java/foo.jar org.foo.Main"
-'';
+ installPhase = ''
+ mkdir -p $out/bin
+ makeWrapper ${jre}/bin/java $out/bin/foo \
+ --add-flags "-cp $out/share/java/foo.jar org.foo.Main"
+ '';
+}
```
Since the introduction of the Java Platform Module System in Java 9,
@@ -92,16 +96,18 @@ let
something = (pkgs.something.override { jre = my_jre; });
other = (pkgs.other.override { jre = my_jre; });
in
- ...
+ <...>
```
You can also specify what JDK your JRE should be based on, for example
selecting a 'headless' build to avoid including a link to GTK+:
```nix
-my_jre = pkgs.jre_minimal.override {
- jdk = jdk11_headless;
-};
+{
+ my_jre = pkgs.jre_minimal.override {
+ jdk = jdk11_headless;
+ };
+}
```
Note all JDKs passthru `home`, so if your application requires
@@ -116,7 +122,9 @@ It is possible to use a different Java compiler than `javac` from the
OpenJDK. For instance, to use the GNU Java Compiler:
```nix
-nativeBuildInputs = [ gcj ant ];
+{
+ nativeBuildInputs = [ gcj ant ];
+}
```
Here, Ant will automatically use `gij` (the GNU Java Runtime) instead of
diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md
index d553444d53b0..b0da08d022c0 100644
--- a/doc/languages-frameworks/javascript.section.md
+++ b/doc/languages-frameworks/javascript.section.md
@@ -76,11 +76,13 @@ Exceptions to this rule are:
when you need to override a package.json. It's nice to use the one from the upstream source and do some explicit override. Here is an example:
```nix
- patchedPackageJSON = final.runCommand "package.json" { } ''
- ${jq}/bin/jq '.version = "0.4.0" |
- .devDependencies."@jsdoc/cli" = "^0.2.5"
- ${sonar-src}/package.json > $out
- '';
+ {
+ patchedPackageJSON = final.runCommand "package.json" { } ''
+ ${jq}/bin/jq '.version = "0.4.0" |
+ .devDependencies."@jsdoc/cli" = "^0.2.5"
+ ${sonar-src}/package.json > $out
+ '';
+ }
```
You will still need to commit the modified version of the lock files, but at least the overrides are explicit for everyone to see.
@@ -115,10 +117,12 @@ After you have identified the correct system, you need to override your package
For example, `dat` requires `node-gyp-build`, so we override its expression in [pkgs/development/node-packages/overrides.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/overrides.nix):
```nix
+ {
dat = prev.dat.overr