Merge staging-next into staging

authored by github-actions[bot] and committed by GitHub 5b7fbb07 d3f2c41b

+715 -450
+16 -10
doc/Makefile
··· 1 MD_TARGETS=$(addsuffix .xml, $(basename $(shell find . -type f -regex '.*\.md$$' -not -name README.md))) 2 3 .PHONY: all 4 all: validate format out/html/index.html out/epub/manual.epub 5 ··· 39 mkdir -p out/html/highlightjs/ 40 cp -r highlightjs out/html/ 41 42 - cp -r media out/html/ 43 cp ./overrides.css out/html/ 44 cp ./style.css out/html/style.css 45 ··· 54 doc-support/result/epub.xsl \ 55 ./manual-full.xml 56 57 - cp -r media out/epub/scratch/OEBPS 58 cp ./overrides.css out/epub/scratch/OEBPS 59 cp ./style.css out/epub/scratch/OEBPS 60 mkdir -p out/epub/scratch/OEBPS/images/callouts/ ··· 89 ln -rfs ./doc-support/result/function-docs functions/library/generated 90 91 %.section.xml: %.section.md 92 - pandoc $^ -t docbook \ 93 - --extract-media=media \ 94 - --lua-filter=$(PANDOC_LUA_FILTERS_DIR)/diagram-generator.lua \ 95 - -f markdown+smart \ 96 | cat > $@ 97 98 %.chapter.xml: %.chapter.md 99 - pandoc $^ -t docbook \ 100 --top-level-division=chapter \ 101 - --extract-media=media \ 102 - --lua-filter=$(PANDOC_LUA_FILTERS_DIR)/diagram-generator.lua \ 103 - -f markdown+smart \ 104 | cat > $@
··· 1 MD_TARGETS=$(addsuffix .xml, $(basename $(shell find . -type f -regex '.*\.md$$' -not -name README.md))) 2 3 + PANDOC ?= pandoc 4 + 5 + pandoc_media_dir = media 6 + # TODO: Remove raw-attribute when we can get rid of DocBook altogether. 7 + pandoc_commonmark_enabled_extensions = +attributes+fenced_divs+footnotes+bracketed_spans+definition_lists+pipe_tables+raw_attribute 8 + pandoc_flags = --extract-media=$(pandoc_media_dir) \ 9 + --lua-filter=$(PANDOC_LUA_FILTERS_DIR)/diagram-generator.lua \ 10 + --lua-filter=labelless-link-is-xref.lua \ 11 + -f commonmark$(pandoc_commonmark_enabled_extensions)+smart 12 + 13 .PHONY: all 14 all: validate format out/html/index.html out/epub/manual.epub 15 ··· 49 mkdir -p out/html/highlightjs/ 50 cp -r highlightjs out/html/ 51 52 + cp -r $(pandoc_media_dir) out/html/ 53 cp ./overrides.css out/html/ 54 cp ./style.css out/html/style.css 55 ··· 64 doc-support/result/epub.xsl \ 65 ./manual-full.xml 66 67 + cp -r $(pandoc_media_dir) out/epub/scratch/OEBPS 68 cp ./overrides.css out/epub/scratch/OEBPS 69 cp ./style.css out/epub/scratch/OEBPS 70 mkdir -p out/epub/scratch/OEBPS/images/callouts/ ··· 99 ln -rfs ./doc-support/result/function-docs functions/library/generated 100 101 %.section.xml: %.section.md 102 + $(PANDOC) $^ -t docbook \ 103 + $(pandoc_flags) \ 104 | cat > $@ 105 106 %.chapter.xml: %.chapter.md 107 + $(PANDOC) $^ -t docbook \ 108 --top-level-division=chapter \ 109 + $(pandoc_flags) \ 110 | cat > $@
+12 -13
doc/builders/fetchers.chapter.md
··· 20 21 `fetchpatch` works very similarly to `fetchurl` with the same arguments expected. It expects patch files as a source and performs normalization on them before computing the checksum. For example it will remove comments or other unstable parts that are sometimes added by version control systems and can change over time. 22 23 - 24 Other fetcher functions allow you to add source code directly from a VCS such as subversion or git. These are mostly straightforward nambes based on the name of the command used with the VCS system. Because they give you a working repository, they act most like `fetchzip`. 25 26 - ## `fetchsvn` 27 28 Used with Subversion. Expects `url` to a Subversion directory, `rev`, and `sha256`. 29 30 - ## `fetchgit` 31 32 Used with Git. Expects `url` to a Git repo, `rev`, and `sha256`. `rev` in this case can be full the git commit id (SHA1 hash) or a tag name like `refs/tags/v1.0`. 33 34 Additionally the following optional arguments can be given: `fetchSubmodules = true` makes `fetchgit` also fetch the submodules of a repository. If `deepClone` is set to true, the entire repository is cloned as opposing to just creating a shallow clone. `deepClone = true` also implies `leaveDotGit = true` which means that the `.git` directory of the clone won't be removed after checkout. 35 36 - ## `fetchfossil` 37 38 Used with Fossil. Expects `url` to a Fossil archive, `rev`, and `sha256`. 39 40 - ## `fetchcvs` 41 42 Used with CVS. Expects `cvsRoot`, `tag`, and `sha256`. 43 44 - ## `fetchhg` 45 46 Used with Mercurial. Expects `url`, `rev`, and `sha256`. 47 48 A number of fetcher functions wrap part of `fetchurl` and `fetchzip`. They are mainly convenience functions intended for commonly used destinations of source code in Nixpkgs. These wrapper fetchers are listed below. 49 50 - ## `fetchFromGitHub` 51 52 `fetchFromGitHub` expects four arguments. `owner` is a string corresponding to the GitHub user or organization that controls this repository. `repo` corresponds to the name of the software repository. These are located at the top of every GitHub HTML page as `owner`/`repo`. `rev` corresponds to the Git commit hash or tag (e.g `v1.0`) that will be downloaded from Git. Finally, `sha256` corresponds to the hash of the extracted directory. Again, other hash algorithms are also available but `sha256` is currently preferred. 53 54 `fetchFromGitHub` uses `fetchzip` to download the source archive generated by GitHub for the specified revision. If `leaveDotGit`, `deepClone` or `fetchSubmodules` are set to `true`, `fetchFromGitHub` will use `fetchgit` instead. Refer to its section for documentation of these options. 55 56 - ## `fetchFromGitLab` 57 58 This is used with GitLab repositories. The arguments expected are very similar to fetchFromGitHub above. 59 60 - ## `fetchFromGitiles` 61 62 This is used with Gitiles repositories. The arguments expected are similar to fetchgit. 63 64 - ## `fetchFromBitbucket` 65 66 This is used with BitBucket repositories. The arguments expected are very similar to fetchFromGitHub above. 67 68 - ## `fetchFromSavannah` 69 70 This is used with Savannah repositories. The arguments expected are very similar to fetchFromGitHub above. 71 72 - ## `fetchFromRepoOrCz` 73 74 This is used with repo.or.cz repositories. The arguments expected are very similar to fetchFromGitHub above. 75 76 - ## `fetchFromSourcehut` 77 78 This is used with sourcehut repositories. The arguments expected are very similar to fetchFromGitHub above. Don't forget the tilde (~) in front of the user name!
··· 20 21 `fetchpatch` works very similarly to `fetchurl` with the same arguments expected. It expects patch files as a source and performs normalization on them before computing the checksum. For example it will remove comments or other unstable parts that are sometimes added by version control systems and can change over time. 22 23 Other fetcher functions allow you to add source code directly from a VCS such as subversion or git. These are mostly straightforward nambes based on the name of the command used with the VCS system. Because they give you a working repository, they act most like `fetchzip`. 24 25 + ## `fetchsvn` {#fetchsvn} 26 27 Used with Subversion. Expects `url` to a Subversion directory, `rev`, and `sha256`. 28 29 + ## `fetchgit` {#fetchgit} 30 31 Used with Git. Expects `url` to a Git repo, `rev`, and `sha256`. `rev` in this case can be full the git commit id (SHA1 hash) or a tag name like `refs/tags/v1.0`. 32 33 Additionally the following optional arguments can be given: `fetchSubmodules = true` makes `fetchgit` also fetch the submodules of a repository. If `deepClone` is set to true, the entire repository is cloned as opposing to just creating a shallow clone. `deepClone = true` also implies `leaveDotGit = true` which means that the `.git` directory of the clone won't be removed after checkout. 34 35 + ## `fetchfossil` {#fetchfossil} 36 37 Used with Fossil. Expects `url` to a Fossil archive, `rev`, and `sha256`. 38 39 + ## `fetchcvs` {#fetchcvs} 40 41 Used with CVS. Expects `cvsRoot`, `tag`, and `sha256`. 42 43 + ## `fetchhg` {#fetchhg} 44 45 Used with Mercurial. Expects `url`, `rev`, and `sha256`. 46 47 A number of fetcher functions wrap part of `fetchurl` and `fetchzip`. They are mainly convenience functions intended for commonly used destinations of source code in Nixpkgs. These wrapper fetchers are listed below. 48 49 + ## `fetchFromGitHub` {#fetchfromgithub} 50 51 `fetchFromGitHub` expects four arguments. `owner` is a string corresponding to the GitHub user or organization that controls this repository. `repo` corresponds to the name of the software repository. These are located at the top of every GitHub HTML page as `owner`/`repo`. `rev` corresponds to the Git commit hash or tag (e.g `v1.0`) that will be downloaded from Git. Finally, `sha256` corresponds to the hash of the extracted directory. Again, other hash algorithms are also available but `sha256` is currently preferred. 52 53 `fetchFromGitHub` uses `fetchzip` to download the source archive generated by GitHub for the specified revision. If `leaveDotGit`, `deepClone` or `fetchSubmodules` are set to `true`, `fetchFromGitHub` will use `fetchgit` instead. Refer to its section for documentation of these options. 54 55 + ## `fetchFromGitLab` {#fetchfromgitlab} 56 57 This is used with GitLab repositories. The arguments expected are very similar to fetchFromGitHub above. 58 59 + ## `fetchFromGitiles` {#fetchfromgitiles} 60 61 This is used with Gitiles repositories. The arguments expected are similar to fetchgit. 62 63 + ## `fetchFromBitbucket` {#fetchfrombitbucket} 64 65 This is used with BitBucket repositories. The arguments expected are very similar to fetchFromGitHub above. 66 67 + ## `fetchFromSavannah` {#fetchfromsavannah} 68 69 This is used with Savannah repositories. The arguments expected are very similar to fetchFromGitHub above. 70 71 + ## `fetchFromRepoOrCz` {#fetchfromrepoorcz} 72 73 This is used with repo.or.cz repositories. The arguments expected are very similar to fetchFromGitHub above. 74 75 + ## `fetchFromSourcehut` {#fetchfromsourcehut} 76 77 This is used with sourcehut repositories. The arguments expected are very similar to fetchFromGitHub above. Don't forget the tilde (~) in front of the user name!
+1 -1
doc/builders/images/appimagetools.section.md
··· 2 3 `pkgs.appimageTools` is a set of functions for extracting and wrapping [AppImage](https://appimage.org/) files. They are meant to be used if traditional packaging from source is infeasible, or it would take too long. To quickly run an AppImage file, `pkgs.appimage-run` can be used as well. 4 5 - ::: warning 6 The `appimageTools` API is unstable and may be subject to backwards-incompatible changes in the future. 7 ::: 8
··· 2 3 `pkgs.appimageTools` is a set of functions for extracting and wrapping [AppImage](https://appimage.org/) files. They are meant to be used if traditional packaging from source is infeasible, or it would take too long. To quickly run an AppImage file, `pkgs.appimage-run` can be used as well. 4 5 + ::: {.warning} 6 The `appimageTools` API is unstable and may be subject to backwards-incompatible changes in the future. 7 ::: 8
+2 -2
doc/builders/images/dockertools.section.md
··· 1 # pkgs.dockerTools {#sec-pkgs-dockerTools} 2 3 - `pkgs.dockerTools` is a set of functions for creating and manipulating Docker images according to the [ Docker Image Specification v1.2.0 ](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120). Docker itself is not used to perform any of the operations done by these functions. 4 5 ## buildImage {#ssec-pkgs-dockerTools-buildImage} 6 ··· 52 53 > **_NOTE:_** Using this parameter requires the `kvm` device to be available. 54 55 - - `config` is used to specify the configuration of the containers that will be started off the built image in Docker. The available options are listed in the [ Docker Image Specification v1.2.0 ](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions). 56 57 After the new layer has been created, its closure (to which `contents`, `config` and `runAsRoot` contribute) will be copied in the layer itself. Only new dependencies that are not already in the existing layers will be copied. 58
··· 1 # pkgs.dockerTools {#sec-pkgs-dockerTools} 2 3 + `pkgs.dockerTools` is a set of functions for creating and manipulating Docker images according to the [Docker Image Specification v1.2.0](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120). Docker itself is not used to perform any of the operations done by these functions. 4 5 ## buildImage {#ssec-pkgs-dockerTools-buildImage} 6 ··· 52 53 > **_NOTE:_** Using this parameter requires the `kvm` device to be available. 54 55 + - `config` is used to specify the configuration of the containers that will be started off the built image in Docker. The available options are listed in the [Docker Image Specification v1.2.0](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions). 56 57 After the new layer has been created, its closure (to which `contents`, `config` and `runAsRoot` contribute) will be copied in the layer itself. Only new dependencies that are not already in the existing layers will be copied. 58
+2 -2
doc/builders/images/snaptools.section.md
··· 14 15 The following expression packages GNU Hello as a Snapcraft snap. 16 17 - ```{#ex-snapTools-buildSnap-hello .nix} 18 let 19 inherit (import <nixpkgs> { }) snapTools hello; 20 in snapTools.makeSnap { ··· 35 36 Graphical programs require many more integrations with the host. This example uses Firefox as an example, because it is one of the most complicated programs we could package. 37 38 - ```{#ex-snapTools-buildSnap-firefox .nix} 39 let 40 inherit (import <nixpkgs> { }) snapTools firefox; 41 in snapTools.makeSnap {
··· 14 15 The following expression packages GNU Hello as a Snapcraft snap. 16 17 + ``` {#ex-snapTools-buildSnap-hello .nix} 18 let 19 inherit (import <nixpkgs> { }) snapTools hello; 20 in snapTools.makeSnap { ··· 35 36 Graphical programs require many more integrations with the host. This example uses Firefox as an example, because it is one of the most complicated programs we could package. 37 38 + ``` {#ex-snapTools-buildSnap-firefox .nix} 39 let 40 inherit (import <nixpkgs> { }) snapTools firefox; 41 in snapTools.makeSnap {
+3 -3
doc/builders/packages/cataclysm-dda.section.md
··· 1 # Cataclysm: Dark Days Ahead {#cataclysm-dark-days-ahead} 2 3 - ## How to install Cataclysm DDA 4 5 To install the latest stable release of Cataclysm DDA to your profile, execute 6 `nix-env -f "<nixpkgs>" -iA cataclysm-dda`. For the curses build (build ··· 34 } 35 ``` 36 37 - ## Important note for overriding packages 38 39 After applying `overrideAttrs`, you need to fix `passthru.pkgs` and 40 `passthru.withMods` attributes either manually or by using `attachPkgs`: ··· 69 goodExample2.withMods (_: []) # parallel building enabled 70 ``` 71 72 - ## Customizing with mods 73 74 To install Cataclysm DDA with mods of your choice, you can use `withMods` 75 attribute:
··· 1 # Cataclysm: Dark Days Ahead {#cataclysm-dark-days-ahead} 2 3 + ## How to install Cataclysm DDA {#how-to-install-cataclysm-dda} 4 5 To install the latest stable release of Cataclysm DDA to your profile, execute 6 `nix-env -f "<nixpkgs>" -iA cataclysm-dda`. For the curses build (build ··· 34 } 35 ``` 36 37 + ## Important note for overriding packages {#important-note-for-overriding-packages} 38 39 After applying `overrideAttrs`, you need to fix `passthru.pkgs` and 40 `passthru.withMods` attributes either manually or by using `attachPkgs`: ··· 69 goodExample2.withMods (_: []) # parallel building enabled 70 ``` 71 72 + ## Customizing with mods {#customizing-with-mods} 73 74 To install Cataclysm DDA with mods of your choice, you can use `withMods` 75 attribute:
+1 -1
doc/builders/packages/elm.section.md
··· 6 nix-shell -p elmPackages.elm elmPackages.elm-format 7 ``` 8 9 - To update the Elm compiler, see <filename>nixpkgs/pkgs/development/compilers/elm/README.md</filename>. 10 11 To package Elm applications, [read about elm2nix](https://github.com/hercules-ci/elm2nix#elm2nix).
··· 6 nix-shell -p elmPackages.elm elmPackages.elm-format 7 ``` 8 9 + To update the Elm compiler, see `nixpkgs/pkgs/development/compilers/elm/README.md`. 10 11 To package Elm applications, [read about elm2nix](https://github.com/hercules-ci/elm2nix#elm2nix).
+1 -1
doc/builders/packages/firefox.section.md
··· 1 # Firefox {#sec-firefox} 2 3 - ## Build wrapped Firefox with extensions and policies 4 5 The `wrapFirefox` function allows to pass policies, preferences and extension that are available to firefox. With the help of `fetchFirefoxAddon` this allows build a firefox version that already comes with addons pre-installed: 6
··· 1 # Firefox {#sec-firefox} 2 3 + ## Build wrapped Firefox with extensions and policies {#build-wrapped-firefox-with-extensions-and-policies} 4 5 The `wrapFirefox` function allows to pass policies, preferences and extension that are available to firefox. With the help of `fetchFirefoxAddon` this allows build a firefox version that already comes with addons pre-installed: 6
+2 -2
doc/builders/packages/opengl.section.md
··· 4 5 Broadly, we support both GL vendors: Mesa and NVIDIA. 6 7 - ## NixOS Desktop 8 9 The NixOS desktop or other non-headless configurations are the primary target for OpenGL libraries and applications. The current solution for discovering which drivers are available is based on [libglvnd](https://gitlab.freedesktop.org/glvnd/libglvnd). `libglvnd` performs "vendor-neutral dispatch", trying a variety of techniques to find the system's GL implementation. In practice, this will be either via standard GLX for X11 users or EGL for Wayland users, and supporting either NVIDIA or Mesa extensions. 10 11 - ## Nix on GNU/Linux 12 13 If you are using a non-NixOS GNU/Linux/X11 desktop with free software video drivers, consider launching OpenGL-dependent programs from Nixpkgs with Nixpkgs versions of `libglvnd` and `mesa.drivers` in `LD_LIBRARY_PATH`. For Mesa drivers, the Linux kernel version doesn't have to match nixpkgs. 14
··· 4 5 Broadly, we support both GL vendors: Mesa and NVIDIA. 6 7 + ## NixOS Desktop {#nixos-desktop} 8 9 The NixOS desktop or other non-headless configurations are the primary target for OpenGL libraries and applications. The current solution for discovering which drivers are available is based on [libglvnd](https://gitlab.freedesktop.org/glvnd/libglvnd). `libglvnd` performs "vendor-neutral dispatch", trying a variety of techniques to find the system's GL implementation. In practice, this will be either via standard GLX for X11 users or EGL for Wayland users, and supporting either NVIDIA or Mesa extensions. 10 11 + ## Nix on GNU/Linux {#nix-on-gnulinux} 12 13 If you are using a non-NixOS GNU/Linux/X11 desktop with free software video drivers, consider launching OpenGL-dependent programs from Nixpkgs with Nixpkgs versions of `libglvnd` and `mesa.drivers` in `LD_LIBRARY_PATH`. For Mesa drivers, the Linux kernel version doesn't have to match nixpkgs. 14
+13 -10
doc/builders/packages/steam.section.md
··· 20 ## Troubleshooting {#sec-steam-troub} 21 22 - **Steam fails to start. What do I do?** 23 Try to run 24 25 ```ShellSession ··· 32 33 - The `newStdcpp` parameter was removed since NixOS 17.09 and should not be needed anymore. 34 - Steam ships statically linked with a version of libcrypto that conflics with the one dynamically loaded by radeonsi_dri.so. If you get the error 35 ``` 36 steam.sh: line 713: 7842 Segmentation fault (core dumped) 37 ``` 38 have a look at [this pull request](https://github.com/NixOS/nixpkgs/pull/20269). 39 40 - **Java** 41 42 1. There is no java in steam chrootenv by default. If you get a message like 43 44 - ``` 45 - /home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found 46 - ``` 47 48 - You need to add 49 50 - ```nix 51 - steam.override { withJava = true; }; 52 - ``` 53 54 ## steam-run {#sec-steam-run} 55 ··· 57 58 ```nix 59 pkgs.steam.override ({ 60 - nativeOnly = true; 61 - newStdcpp = true; 62 - }).run 63 ``` 64 65 to your configuration, rebuild, and run the game with
··· 20 ## Troubleshooting {#sec-steam-troub} 21 22 - **Steam fails to start. What do I do?** 23 + 24 Try to run 25 26 ```ShellSession ··· 33 34 - The `newStdcpp` parameter was removed since NixOS 17.09 and should not be needed anymore. 35 - Steam ships statically linked with a version of libcrypto that conflics with the one dynamically loaded by radeonsi_dri.so. If you get the error 36 + 37 ``` 38 steam.sh: line 713: 7842 Segmentation fault (core dumped) 39 ``` 40 + 41 have a look at [this pull request](https://github.com/NixOS/nixpkgs/pull/20269). 42 43 - **Java** 44 45 1. There is no java in steam chrootenv by default. If you get a message like 46 47 + ``` 48 + /home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found 49 + ``` 50 51 + you need to add 52 53 + ```nix 54 + steam.override { withJava = true; }; 55 + ``` 56 57 ## steam-run {#sec-steam-run} 58 ··· 60 61 ```nix 62 pkgs.steam.override ({ 63 + nativeOnly = true; 64 + newStdcpp = true; 65 + }).run 66 ``` 67 68 to your configuration, rebuild, and run the game with
+4 -4
doc/builders/packages/xorg.section.md
··· 2 3 The Nix expressions for the X.org packages reside in `pkgs/servers/x11/xorg/default.nix`. This file is automatically generated from lists of tarballs in an X.org release. As such it should not be modified directly; rather, you should modify the lists, the generator script or the file `pkgs/servers/x11/xorg/overrides.nix`, in which you can override or add to the derivations produced by the generator. 4 5 - ## Katamari Tarballs 6 7 X.org upstream releases used to include [katamari](https://en.wiktionary.org/wiki/%E3%81%8B%E3%81%9F%E3%81%BE%E3%82%8A) releases, which included a holistic recommended version for each tarball, up until 7.7. To create a list of tarballs in a katamari release: 8 ··· 14 | sort > "tarballs-$release.list" 15 ``` 16 17 - ## Individual Tarballs 18 19 The upstream release process for [X11R7.8](https://x.org/wiki/Releases/7.8/) does not include a planned katamari. Instead, each component of X.org is released as its own tarball. We maintain `pkgs/servers/x11/xorg/tarballs.list` as a list of tarballs for each individual package. This list includes X.org core libraries and protocol descriptions, extra newer X11 interface libraries, like `xorg.libxcb`, and classic utilities which are largely unused but still available if needed, like `xorg.imake`. 20 21 - ## Generating Nix Expressions 22 23 The generator is invoked as follows: 24 ··· 29 30 For each of the tarballs in the `.list` files, the script downloads it, unpacks it, and searches its `configure.ac` and `*.pc.in` files for dependencies. This information is used to generate `default.nix`. The generator caches downloaded tarballs between runs. Pay close attention to the `NOT FOUND: $NAME` messages at the end of the run, since they may indicate missing dependencies. (Some might be optional dependencies, however.) 31 32 - ## Overriding the Generator 33 34 If the expression for a package requires derivation attributes that the generator cannot figure out automatically (say, `patches` or a `postInstall` hook), you should modify `pkgs/servers/x11/xorg/overrides.nix`.
··· 2 3 The Nix expressions for the X.org packages reside in `pkgs/servers/x11/xorg/default.nix`. This file is automatically generated from lists of tarballs in an X.org release. As such it should not be modified directly; rather, you should modify the lists, the generator script or the file `pkgs/servers/x11/xorg/overrides.nix`, in which you can override or add to the derivations produced by the generator. 4 5 + ## Katamari Tarballs {#katamari-tarballs} 6 7 X.org upstream releases used to include [katamari](https://en.wiktionary.org/wiki/%E3%81%8B%E3%81%9F%E3%81%BE%E3%82%8A) releases, which included a holistic recommended version for each tarball, up until 7.7. To create a list of tarballs in a katamari release: 8 ··· 14 | sort > "tarballs-$release.list" 15 ``` 16 17 + ## Individual Tarballs {#individual-tarballs} 18 19 The upstream release process for [X11R7.8](https://x.org/wiki/Releases/7.8/) does not include a planned katamari. Instead, each component of X.org is released as its own tarball. We maintain `pkgs/servers/x11/xorg/tarballs.list` as a list of tarballs for each individual package. This list includes X.org core libraries and protocol descriptions, extra newer X11 interface libraries, like `xorg.libxcb`, and classic utilities which are largely unused but still available if needed, like `xorg.imake`. 20 21 + ## Generating Nix Expressions {#generating-nix-expressions} 22 23 The generator is invoked as follows: 24 ··· 29 30 For each of the tarballs in the `.list` files, the script downloads it, unpacks it, and searches its `configure.ac` and `*.pc.in` files for dependencies. This information is used to generate `default.nix`. The generator caches downloaded tarballs between runs. Pay close attention to the `NOT FOUND: $NAME` messages at the end of the run, since they may indicate missing dependencies. (Some might be optional dependencies, however.) 31 32 + ## Overriding the Generator {#overriding-the-generator} 33 34 If the expression for a package requires derivation attributes that the generator cannot figure out automatically (say, `patches` or a `postInstall` hook), you should modify `pkgs/servers/x11/xorg/overrides.nix`.
+1 -1
doc/builders/trivial-builders.chapter.md
··· 37 38 Variant of `runCommand` that forces the derivation to be built locally, it is not substituted. This is intended for very cheap commands (<1s execution time). It saves on the network roundrip and can speed up a build. 39 40 - ::: note 41 This sets [`allowSubstitutes` to `false`](https://nixos.org/nix/manual/#adv-attr-allowSubstitutes), so only use `runCommandLocal` if you are certain the user will always have a builder for the `system` of the derivation. This should be true for most trivial use cases (e.g. just copying some files to a different location or adding symlinks), because there the `system` is usually the same as `builtins.currentSystem`. 42 ::: 43
··· 37 38 Variant of `runCommand` that forces the derivation to be built locally, it is not substituted. This is intended for very cheap commands (<1s execution time). It saves on the network roundrip and can speed up a build. 39 40 + ::: {.note} 41 This sets [`allowSubstitutes` to `false`](https://nixos.org/nix/manual/#adv-attr-allowSubstitutes), so only use `runCommandLocal` if you are certain the user will always have a builder for the `system` of the derivation. This should be true for most trivial use cases (e.g. just copying some files to a different location or adding symlinks), because there the `system` is usually the same as `builtins.currentSystem`. 42 ::: 43
+4 -4
doc/contributing/coding-conventions.chapter.md
··· 6 7 - Do not use tab characters, i.e. configure your editor to use soft tabs. For instance, use `(setq-default indent-tabs-mode nil)` in Emacs. Everybody has different tab settings so it’s asking for trouble. 8 9 - - Use `lowerCamelCase` for variable names, not `UpperCamelCase`. Note, this rule does not apply to package attribute names, which instead follow the rules in <xref linkend="sec-package-naming"/>. 10 11 - Function calls with attribute set arguments are written as 12 ··· 209 210 - Dashes in the package name _should_ be preserved in new variable names, rather than converted to underscores or camel cased — e.g., `http-parser` instead of `http_parser` or `httpParser`. The hyphenated style is preferred in all three package names. 211 212 - - If there are multiple versions of a package, this _should_ be reflected in the variable names in `all-packages.nix`, e.g. `json-c-0-9` and `json-c-0-11`. If there is an obvious “default” version, make an attribute like `json-c = json-c-0-9;`. See also <xref linkend="sec-versioning" /> 213 214 ## File naming and organisation {#sec-organisation} 215 ··· 462 463 For package updates it is enough to change one symbol to make hash fake. For new packages, you can use `lib.fakeSha256`, `lib.fakeSha512` or any other fake hash. 464 465 - This is last resort method when reconstructing source URL is non-trivial and `nix-prefetch-url -A` isn't applicable (for example, [one of `kodi` dependencies](https://github.com/NixOS/nixpkgs/blob/d2ab091dd308b99e4912b805a5eb088dd536adb9/pkgs/applications/video/kodi/default.nix#L73")). The easiest way then would be replace hash with a fake one and rebuild. Nix build will fail and error message will contain desired hash. 466 467 - ::: warning 468 This method has security problems. Check below for details. 469 ::: 470
··· 6 7 - Do not use tab characters, i.e. configure your editor to use soft tabs. For instance, use `(setq-default indent-tabs-mode nil)` in Emacs. Everybody has different tab settings so it’s asking for trouble. 8 9 + - Use `lowerCamelCase` for variable names, not `UpperCamelCase`. Note, this rule does not apply to package attribute names, which instead follow the rules in [](#sec-package-naming). 10 11 - Function calls with attribute set arguments are written as 12 ··· 209 210 - Dashes in the package name _should_ be preserved in new variable names, rather than converted to underscores or camel cased — e.g., `http-parser` instead of `http_parser` or `httpParser`. The hyphenated style is preferred in all three package names. 211 212 + - If there are multiple versions of a package, this _should_ be reflected in the variable names in `all-packages.nix`, e.g. `json-c-0-9` and `json-c-0-11`. If there is an obvious “default” version, make an attribute like `json-c = json-c-0-9;`. See also [](#sec-versioning) 213 214 ## File naming and organisation {#sec-organisation} 215 ··· 462 463 For package updates it is enough to change one symbol to make hash fake. For new packages, you can use `lib.fakeSha256`, `lib.fakeSha512` or any other fake hash. 464 465 + This is last resort method when reconstructing source URL is non-trivial and `nix-prefetch-url -A` isn’t applicable (for example, [one of `kodi` dependencies](https://github.com/NixOS/nixpkgs/blob/d2ab091dd308b99e4912b805a5eb088dd536adb9/pkgs/applications/video/kodi/default.nix#L73)). The easiest way then would be replace hash with a fake one and rebuild. Nix build will fail and error message will contain desired hash. 466 467 + ::: {.warning} 468 This method has security problems. Check below for details. 469 ::: 470
+76 -1
doc/contributing/contributing-to-documentation.chapter.md
··· 1 # Contributing to this documentation {#chap-contributing} 2 3 - The DocBook sources of the Nixpkgs manual are in the [doc](https://github.com/NixOS/nixpkgs/tree/master/doc) subdirectory of the Nixpkgs repository. 4 5 You can quickly check your edits with `make`: 6 ··· 22 ``` 23 24 If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`.
··· 1 # Contributing to this documentation {#chap-contributing} 2 3 + The sources of the Nixpkgs manual are in the [doc](https://github.com/NixOS/nixpkgs/tree/master/doc) subdirectory of the Nixpkgs repository. The manual is still partially written in DocBook but it is progressively being converted to [Markdown](#sec-contributing-markup). 4 5 You can quickly check your edits with `make`: 6 ··· 22 ``` 23 24 If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`. 25 + 26 + ## Syntax {#sec-contributing-markup} 27 + 28 + As per [RFC 0072](https://github.com/NixOS/rfcs/pull/72), all new documentation content should be written in [CommonMark](https://commonmark.org/) Markdown dialect. 29 + 30 + Additionally, the following syntax extensions are currently used: 31 + 32 + - []{#ssec-contributing-markup-anchors} 33 + Explicitly defined **anchors** on headings, to allow linking to sections. These should be always used, to ensure the anchors can be linked even when the heading text changes, and to prevent conflicts between [automatically assigned identifiers](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/auto_identifiers.md). 34 + 35 + It uses the widely compatible [header attributes](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md) syntax: 36 + 37 + ```markdown 38 + ## Syntax {#sec-contributing-markup} 39 + ``` 40 + 41 + - []{#ssec-contributing-markup-anchors-inline} 42 + **Inline anchors**, which allow linking arbitrary place in the text (e.g. individual list items, sentences…). 43 + 44 + They are defined using a hybrid of the link syntax with the attributes syntax known from headings, called [bracketed spans](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/bracketed_spans.md): 45 + 46 + ```markdown 47 + - []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`. 48 + ``` 49 + 50 + - []{#ssec-contributing-markup-automatic-links} 51 + If you **omit a link text** for a link pointing to a section, the text will be substituted automatically. For example, `[](#chap-contributing)` will result in [](#chap-contributing). 52 + 53 + This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing). 54 + 55 + - []{#ssec-contributing-markup-admonitions} 56 + **Admonitions**, set off from the text to bring attention to something. 57 + 58 + It uses pandoc’s [fenced `div`s syntax](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md): 59 + 60 + ```markdown 61 + ::: {.warning} 62 + This is a warning 63 + ::: 64 + ``` 65 + 66 + which renders as 67 + 68 + > ::: {.warning} 69 + > This is a warning. 70 + > ::: 71 + 72 + The following are supported: 73 + 74 + - [`caution`](https://tdg.docbook.org/tdg/5.0/caution.html) 75 + - [`important`](https://tdg.docbook.org/tdg/5.0/important.html) 76 + - [`note`](https://tdg.docbook.org/tdg/5.0/note.html) 77 + - [`tip`](https://tdg.docbook.org/tdg/5.0/tip.html) 78 + - [`warning`](https://tdg.docbook.org/tdg/5.0/warning.html) 79 + 80 + - []{#ssec-contributing-markup-definition-lists} 81 + [**Definition lists**](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/definition_lists.md), for defining a group of terms: 82 + 83 + ```markdown 84 + pear 85 + : green or yellow bulbous fruit 86 + 87 + watermelon 88 + : green fruit with red flesh 89 + ``` 90 + 91 + which renders as 92 + 93 + > pear 94 + > : green or yellow bulbous fruit 95 + > 96 + > watermelon 97 + > : green fruit with red flesh 98 + 99 + For contributing to the legacy parts, please see [DocBook: The Definitive Guide](https://tdg.docbook.org/) or the [DocBook rocks! primer](https://web.archive.org/web/20200816233747/https://docbook.rocks/).
+1 -1
doc/contributing/quick-start.chapter.md
··· 9 $ cd nixpkgs 10 ``` 11 12 - 2. Find a good place in the Nixpkgs tree to add the Nix expression for your package. For instance, a library package typically goes into `pkgs/development/libraries/pkgname`, while a web browser goes into `pkgs/applications/networking/browsers/pkgname`. See <xref linkend="sec-organisation" /> for some hints on the tree organisation. Create a directory for your package, e.g. 13 14 ```ShellSession 15 $ mkdir pkgs/development/libraries/libfoo
··· 9 $ cd nixpkgs 10 ``` 11 12 + 2. Find a good place in the Nixpkgs tree to add the Nix expression for your package. For instance, a library package typically goes into `pkgs/development/libraries/pkgname`, while a web browser goes into `pkgs/applications/networking/browsers/pkgname`. See [](#sec-organisation) for some hints on the tree organisation. Create a directory for your package, e.g. 13 14 ```ShellSession 15 $ mkdir pkgs/development/libraries/libfoo
+4 -1
doc/contributing/reviewing-contributions.chapter.md
··· 1 # Reviewing contributions {#chap-reviewing-contributions} 2 3 - ::: warning 4 The following section is a draft, and the policy for reviewing is still being discussed in issues such as [#11166](https://github.com/NixOS/nixpkgs/issues/11166) and [#20836](https://github.com/NixOS/nixpkgs/issues/20836). 5 ::: 6 ··· 35 - Building the package locally. 36 - pull requests are often targeted to the master or staging branch, and building the pull request locally when it is submitted can trigger many source builds. 37 - It is possible to rebase the changes on nixos-unstable or nixpkgs-unstable for easier review by running the following commands from a nixpkgs clone. 38 ```ShellSession 39 $ git fetch origin nixos-unstable 40 $ git fetch origin pull/PRNUMBER/head 41 $ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD 42 ``` 43 - The first command fetches the nixos-unstable branch. 44 - The second command fetches the pull request changes, `PRNUMBER` is the number at the end of the pull request title and `BASEBRANCH` the base branch of the pull request. 45 - The third command rebases the pull request changes to the nixos-unstable branch. 46 - The [nixpkgs-review](https://github.com/Mic92/nixpkgs-review) tool can be used to review a pull request content in a single command. `PRNUMBER` should be replaced by the number at the end of the pull request title. You can also provide the full github pull request url. 47 ```ShellSession 48 $ nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER" 49 ```
··· 1 # Reviewing contributions {#chap-reviewing-contributions} 2 3 + ::: {.warning} 4 The following section is a draft, and the policy for reviewing is still being discussed in issues such as [#11166](https://github.com/NixOS/nixpkgs/issues/11166) and [#20836](https://github.com/NixOS/nixpkgs/issues/20836). 5 ::: 6 ··· 35 - Building the package locally. 36 - pull requests are often targeted to the master or staging branch, and building the pull request locally when it is submitted can trigger many source builds. 37 - It is possible to rebase the changes on nixos-unstable or nixpkgs-unstable for easier review by running the following commands from a nixpkgs clone. 38 + 39 ```ShellSession 40 $ git fetch origin nixos-unstable 41 $ git fetch origin pull/PRNUMBER/head 42 $ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD 43 ``` 44 + 45 - The first command fetches the nixos-unstable branch. 46 - The second command fetches the pull request changes, `PRNUMBER` is the number at the end of the pull request title and `BASEBRANCH` the base branch of the pull request. 47 - The third command rebases the pull request changes to the nixos-unstable branch. 48 - The [nixpkgs-review](https://github.com/Mic92/nixpkgs-review) tool can be used to review a pull request content in a single command. `PRNUMBER` should be replaced by the number at the end of the pull request title. You can also provide the full github pull request url. 49 + 50 ```ShellSession 51 $ nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER" 52 ```
+3 -1
doc/contributing/submitting-changes.chapter.md
··· 71 - If a new version fixing the vulnerability has been released, update the package; 72 - If the security fix comes in the form of a patch and a CVE is available, then add the patch to the Nixpkgs tree, and apply it to the package. 73 The name of the patch should be the CVE identifier, so e.g. `CVE-2019-13636.patch`; If a patch is fetched the name needs to be set as well, e.g.: 74 ```nix 75 (fetchpatch { 76 name = "CVE-2019-11068.patch"; ··· 89 90 Before removing a package, one should try to find a new maintainer or fix smaller issues first. 91 92 - ### Steps to remove a package from Nixpkgs 93 94 We use jbidwatcher as an example for a discontinued project here. 95 ··· 100 1. Add an alias for the package name in `pkgs/top-level/aliases.nix` (There is also `pkgs/misc/vim-plugins/aliases.nix`. Package sets typically do not have aliases, so we can't add them there.) 101 102 For example in this case: 103 ``` 104 jbidwatcher = throw "jbidwatcher was discontinued in march 2021"; # added 2021-03-15 105 ```
··· 71 - If a new version fixing the vulnerability has been released, update the package; 72 - If the security fix comes in the form of a patch and a CVE is available, then add the patch to the Nixpkgs tree, and apply it to the package. 73 The name of the patch should be the CVE identifier, so e.g. `CVE-2019-13636.patch`; If a patch is fetched the name needs to be set as well, e.g.: 74 + 75 ```nix 76 (fetchpatch { 77 name = "CVE-2019-11068.patch"; ··· 90 91 Before removing a package, one should try to find a new maintainer or fix smaller issues first. 92 93 + ### Steps to remove a package from Nixpkgs {#steps-to-remove-a-package-from-nixpkgs} 94 95 We use jbidwatcher as an example for a discontinued project here. 96 ··· 101 1. Add an alias for the package name in `pkgs/top-level/aliases.nix` (There is also `pkgs/misc/vim-plugins/aliases.nix`. Package sets typically do not have aliases, so we can't add them there.) 102 103 For example in this case: 104 + 105 ``` 106 jbidwatcher = throw "jbidwatcher was discontinued in march 2021"; # added 2021-03-15 107 ```
+2 -2
doc/functions/library/attrsets.xml
··· 166 <xi:include href="./locations.xml" xpointer="lib.attrsets.getAttrFromPath" /> 167 168 <para> 169 - Like <xref linkend="function-library-lib.attrsets.attrByPath" /> except without a default, and it will throw if the value doesn't exist. 170 </para> 171 172 <variablelist> ··· 1480 <xi:include href="./locations.xml" xpointer="lib.attrsets.zipAttrs" /> 1481 1482 <para> 1483 - Merge sets of attributes and combine each attribute value in to a list. Similar to <xref linkend="function-library-lib.attrsets.zipAttrsWith" /> where the merge function returns a list of all values. 1484 </para> 1485 1486 <variablelist>
··· 166 <xi:include href="./locations.xml" xpointer="lib.attrsets.getAttrFromPath" /> 167 168 <para> 169 + Like [](#function-library-lib.attrsets.attrByPath) except without a default, and it will throw if the value doesn't exist. 170 </para> 171 172 <variablelist> ··· 1480 <xi:include href="./locations.xml" xpointer="lib.attrsets.zipAttrs" /> 1481 1482 <para> 1483 + Merge sets of attributes and combine each attribute value in to a list. Similar to [](#function-library-lib.attrsets.zipAttrsWith) where the merge function returns a list of all values. 1484 </para> 1485 1486 <variablelist>
+21 -14
doc/languages-frameworks/agda.section.md
··· 1 # Agda {#agda} 2 3 - ## How to use Agda 4 5 Agda is available as the [agda](https://search.nixos.org/packages?channel=unstable&show=agda&from=0&size=30&sort=relevance&query=agda) 6 package. ··· 43 ``` 44 45 You can also reference a GitHub repository 46 ```nix 47 agda.withPackages (p: [ 48 (p.standard-library.overrideAttrs (oldAttrs: { ··· 59 60 If you want to use a library not added to Nixpkgs, you can add a 61 dependency to a local library by calling `agdaPackages.mkDerivation`. 62 ```nix 63 agda.withPackages (p: [ 64 (p.mkDerivation { ··· 92 Agda will not by default use these libraries. To tell Agda to use a library we have some options: 93 94 * Call `agda` with the library flag: 95 - ```ShellSession 96 - $ agda -l standard-library -i . MyFile.agda 97 - ``` 98 * Write a `my-library.agda-lib` file for the project you are working on which may look like: 99 - ``` 100 - name: my-library 101 - include: . 102 - depend: standard-library 103 - ``` 104 * Create the file `~/.agda/defaults` and add any libraries you want to use by default. 105 106 More information can be found in the [official Agda documentation on library management](https://agda.readthedocs.io/en/v2.6.1/tools/package-system.html). 107 108 - ## Compiling Agda 109 Agda modules can be compiled using the GHC backend with the `--compile` flag. A version of `ghc` with `ieee754` is made available to the Agda program via the `--with-compiler` flag. 110 This can be overridden by a different version of `ghc` as follows: 111 ··· 116 } 117 ``` 118 119 - ## Writing Agda packages 120 To write a nix derivation for an Agda library, first check that the library has a `*.agda-lib` file. 121 122 A derivation can then be written using `agdaPackages.mkDerivation`. This has similar arguments to `stdenv.mkDerivation` with the following additions: ··· 140 } 141 ``` 142 143 - ### Building Agda packages 144 The default build phase for `agdaPackages.mkDerivation` simply runs `agda` on the `Everything.agda` file. 145 If something else is needed to build the package (e.g. `make`) then the `buildPhase` should be overridden. 146 Additionally, a `preBuild` or `configurePhase` can be used if there are steps that need to be done prior to checking the `Everything.agda` file. 147 `agda` and the Agda libraries contained in `buildInputs` are made available during the build phase. 148 149 - ### Installing Agda packages 150 The default install phase copies Agda source files, Agda interface files (`*.agdai`) and `*.agda-lib` files to the output directory. 151 This can be overridden. 152 153 By default, Agda sources are files ending on `.agda`, or literate Agda files ending on `.lagda`, `.lagda.tex`, `.lagda.org`, `.lagda.md`, `.lagda.rst`. The list of recognised Agda source extensions can be extended by setting the `extraExtensions` config variable. 154 155 - ## Adding Agda packages to Nixpkgs 156 157 To add an Agda package to `nixpkgs`, the derivation should be written to `pkgs/development/libraries/agda/${library-name}/` and an entry should be added to `pkgs/top-level/agda-packages.nix`. Here it is called in a scope with access to all other Agda libraries, so the top line of the `default.nix` can look like: 158 ··· 182 ''; 183 } 184 ``` 185 This library has a file called `.agda-lib`, and so we give an empty string to `libraryFile` as nothing precedes `.agda-lib` in the filename. This file contains `name: IAL-1.3`, and so we let `libraryName = "IAL-1.3"`. This library does not use an `Everything.agda` file and instead has a Makefile, so there is no need to set `everythingFile` and we set a custom `buildPhase`. 186 187 When writing an Agda package it is essential to make sure that no `.agda-lib` file gets added to the store as a single file (for example by using `writeText`). This causes Agda to think that the nix store is a Agda library and it will attempt to write to it whenever it typechecks something. See [https://github.com/agda/agda/issues/4613](https://github.com/agda/agda/issues/4613).
··· 1 # Agda {#agda} 2 3 + ## How to use Agda {#how-to-use-agda} 4 5 Agda is available as the [agda](https://search.nixos.org/packages?channel=unstable&show=agda&from=0&size=30&sort=relevance&query=agda) 6 package. ··· 43 ``` 44 45 You can also reference a GitHub repository 46 + 47 ```nix 48 agda.withPackages (p: [ 49 (p.standard-library.overrideAttrs (oldAttrs: { ··· 60 61 If you want to use a library not added to Nixpkgs, you can add a 62 dependency to a local library by calling `agdaPackages.mkDerivation`. 63 + 64 ```nix 65 agda.withPackages (p: [ 66 (p.mkDerivation { ··· 94 Agda will not by default use these libraries. To tell Agda to use a library we have some options: 95 96 * Call `agda` with the library flag: 97 + ```ShellSession 98 + $ agda -l standard-library -i . MyFile.agda 99 + ``` 100 * Write a `my-library.agda-lib` file for the project you are working on which may look like: 101 + ``` 102 + name: my-library 103 + include: . 104 + depend: standard-library 105 + ``` 106 * Create the file `~/.agda/defaults` and add any libraries you want to use by default. 107 108 More information can be found in the [official Agda documentation on library management](https://agda.readthedocs.io/en/v2.6.1/tools/package-system.html). 109 110 + ## Compiling Agda {#compiling-agda} 111 + 112 Agda modules can be compiled using the GHC backend with the `--compile` flag. A version of `ghc` with `ieee754` is made available to the Agda program via the `--with-compiler` flag. 113 This can be overridden by a different version of `ghc` as follows: 114 ··· 119 } 120 ``` 121 122 + ## Writing Agda packages {#writing-agda-packages} 123 + 124 To write a nix derivation for an Agda library, first check that the library has a `*.agda-lib` file. 125 126 A derivation can then be written using `agdaPackages.mkDerivation`. This has similar arguments to `stdenv.mkDerivation` with the following additions: ··· 144 } 145 ``` 146 147 + ### Building Agda packages {#building-agda-packages} 148 + 149 The default build phase for `agdaPackages.mkDerivation` simply runs `agda` on the `Everything.agda` file. 150 If something else is needed to build the package (e.g. `make`) then the `buildPhase` should be overridden. 151 Additionally, a `preBuild` or `configurePhase` can be used if there are steps that need to be done prior to checking the `Everything.agda` file. 152 `agda` and the Agda libraries contained in `buildInputs` are made available during the build phase. 153 154 + ### Installing Agda packages {#installing-agda-packages} 155 + 156 The default install phase copies Agda source files, Agda interface files (`*.agdai`) and `*.agda-lib` files to the output directory. 157 This can be overridden. 158 159 By default, Agda sources are files ending on `.agda`, or literate Agda files ending on `.lagda`, `.lagda.tex`, `.lagda.org`, `.lagda.md`, `.lagda.rst`. The list of recognised Agda source extensions can be extended by setting the `extraExtensions` config variable. 160 161 + ## Adding Agda packages to Nixpkgs {#adding-agda-packages-to-nixpkgs} 162 163 To add an Agda package to `nixpkgs`, the derivation should be written to `pkgs/development/libraries/agda/${library-name}/` and an entry should be added to `pkgs/top-level/agda-packages.nix`. Here it is called in a scope with access to all other Agda libraries, so the top line of the `default.nix` can look like: 164 ··· 188 ''; 189 } 190 ``` 191 + 192 This library has a file called `.agda-lib`, and so we give an empty string to `libraryFile` as nothing precedes `.agda-lib` in the filename. This file contains `name: IAL-1.3`, and so we let `libraryName = "IAL-1.3"`. This library does not use an `Everything.agda` file and instead has a Makefile, so there is no need to set `everythingFile` and we set a custom `buildPhase`. 193 194 When writing an Agda package it is essential to make sure that no `.agda-lib` file gets added to the store as a single file (for example by using `writeText`). This causes Agda to think that the nix store is a Agda library and it will attempt to write to it whenever it typechecks something. See [https://github.com/agda/agda/issues/4613](https://github.com/agda/agda/issues/4613).
+17 -16
doc/languages-frameworks/android.section.md
··· 3 The Android build environment provides three major features and a number of 4 supporting features. 5 6 - Deploying an Android SDK installation with plugins 7 - -------------------------------------------------- 8 The first use case is deploying the SDK with a desired set of plugins or subsets 9 of an SDK. 10 ··· 136 androidComposition.platform-tools 137 ``` 138 139 - Using predefined Android package compositions 140 - --------------------------------------------- 141 In addition to composing an Android package set manually, it is also possible 142 to use a predefined composition that contains all basic packages for a specific 143 Android version, such as version 9.0 (API-level 28). ··· 159 androidenv.androidPkgs_9_0.platform-tools 160 ``` 161 162 - Building an Android application 163 - ------------------------------- 164 In addition to the SDK, it is also possible to build an Ant-based Android 165 project and automatically deploy all the Android plugins that a project 166 requires. 167 168 ```nix 169 with import <nixpkgs> {}; ··· 199 installed on any Android device with a web browser by navigating to the build 200 result page. 201 202 - Spawning emulator instances 203 - --------------------------- 204 For testing purposes, it can also be quite convenient to automatically generate 205 scripts that spawn emulator instances with all desired configuration settings. 206 ··· 241 In addition to prebuilt APKs, you can also bind the APK parameter to a 242 `buildApp {}` function invocation shown in the previous example. 243 244 - Notes on environment variables in Android projects 245 - -------------------------------------------------- 246 * `ANDROID_SDK_ROOT` should point to the Android SDK. In your Nix expressions, this should be 247 `${androidComposition.androidsdk}/libexec/android-sdk`. Note that `ANDROID_HOME` is deprecated, 248 but if you rely on tools that need it, you can export it too. ··· 300 sdk.dir and ndk.dir values. This will ensure that the SDK and NDK directories will 301 both be correct when you run Android Studio inside nix-shell. 302 303 - Notes on improving build.gradle compatibility 304 - --------------------------------------------- 305 Ensure that your buildToolsVersion and ndkVersion match what is declared in androidenv. 306 If you are using cmake, make sure its declared version is correct too. 307 ··· 321 322 ``` 323 324 - Querying the available versions of each plugin 325 - ---------------------------------------------- 326 repo.json provides all the options in one file now. 327 328 A shell script in the `pkgs/development/mobile/androidenv/` subdirectory can be used to retrieve all ··· 334 335 The above command-line instruction queries all package versions in repo.json. 336 337 - Updating the generated expressions 338 - ---------------------------------- 339 repo.json is generated from XML files that the Android Studio package manager uses. 340 To update the expressions run the `generate.sh` script that is stored in the 341 `pkgs/development/mobile/androidenv/` subdirectory:
··· 3 The Android build environment provides three major features and a number of 4 supporting features. 5 6 + ## Deploying an Android SDK installation with plugins {#deploying-an-android-sdk-installation-with-plugins} 7 + 8 The first use case is deploying the SDK with a desired set of plugins or subsets 9 of an SDK. 10 ··· 136 androidComposition.platform-tools 137 ``` 138 139 + ## Using predefined Android package compositions {#using-predefined-android-package-compositions} 140 + 141 In addition to composing an Android package set manually, it is also possible 142 to use a predefined composition that contains all basic packages for a specific 143 Android version, such as version 9.0 (API-level 28). ··· 159 androidenv.androidPkgs_9_0.platform-tools 160 ``` 161 162 + ## Building an Android application {#building-an-android-application} 163 + 164 In addition to the SDK, it is also possible to build an Ant-based Android 165 project and automatically deploy all the Android plugins that a project 166 requires. 167 + 168 169 ```nix 170 with import <nixpkgs> {}; ··· 200 installed on any Android device with a web browser by navigating to the build 201 result page. 202 203 + ## Spawning emulator instances {#spawning-emulator-instances} 204 + 205 For testing purposes, it can also be quite convenient to automatically generate 206 scripts that spawn emulator instances with all desired configuration settings. 207 ··· 242 In addition to prebuilt APKs, you can also bind the APK parameter to a 243 `buildApp {}` function invocation shown in the previous example. 244 245 + ## Notes on environment variables in Android projects {#notes-on-environment-variables-in-android-projects} 246 + 247 * `ANDROID_SDK_ROOT` should point to the Android SDK. In your Nix expressions, this should be 248 `${androidComposition.androidsdk}/libexec/android-sdk`. Note that `ANDROID_HOME` is deprecated, 249 but if you rely on tools that need it, you can export it too. ··· 301 sdk.dir and ndk.dir values. This will ensure that the SDK and NDK directories will 302 both be correct when you run Android Studio inside nix-shell. 303 304 + ## Notes on improving build.gradle compatibility {#notes-on-improving-build.gradle-compatibility} 305 + 306 Ensure that your buildToolsVersion and ndkVersion match what is declared in androidenv. 307 If you are using cmake, make sure its declared version is correct too. 308 ··· 322 323 ``` 324 325 + ## Querying the available versions of each plugin {#querying-the-available-versions-of-each-plugin} 326 + 327 repo.json provides all the options in one file now. 328 329 A shell script in the `pkgs/development/mobile/androidenv/` subdirectory can be used to retrieve all ··· 335 336 The above command-line instruction queries all package versions in repo.json. 337 338 + ## Updating the generated expressions {#updating-the-generated-expressions} 339 + 340 repo.json is generated from XML files that the Android Studio package manager uses. 341 To update the expressions run the `generate.sh` script that is stored in the 342 `pkgs/development/mobile/androidenv/` subdirectory:
+5 -5
doc/languages-frameworks/beam.section.md
··· 4 5 In this document and related Nix expressions, we use the term, _BEAM_, to describe the environment. BEAM is the name of the Erlang Virtual Machine and, as far as we're concerned, from a packaging perspective, all languages that run on the BEAM are interchangeable. That which varies, like the build system, is transparent to users of any given BEAM package, so we make no distinction. 6 7 - ## Available versions and deprecations schedule 8 9 - ### Elixir 10 11 nixpkgs follows the [official elixir deprecation schedule](https://hexdocs.pm/elixir/compatibility-and-deprecations.html) and keeps the last 5 released versions of Elixir available. 12 ··· 68 69 `mixRelease` is used to make a release in the mix sense. Dependencies will need to be fetched with `fetchMixDeps` and passed to it. 70 71 - #### mixRelease - Elixir Phoenix example 72 73 Here is how your `default.nix` file would look. 74 ··· 148 - you can now `nix-build .` 149 - To run the release, set the `RELEASE_TMP` environment variable to a directory that your program has write access to. It will be used to store the BEAM settings. 150 151 - #### Example of creating a service for an Elixir - Phoenix project 152 153 In order to create a service with your release, you could add a `service.nix` 154 in your project with the following ··· 228 } 229 ``` 230 231 - #### Elixir - Phoenix project 232 233 Here is an example `shell.nix`. 234
··· 4 5 In this document and related Nix expressions, we use the term, _BEAM_, to describe the environment. BEAM is the name of the Erlang Virtual Machine and, as far as we're concerned, from a packaging perspective, all languages that run on the BEAM are interchangeable. That which varies, like the build system, is transparent to users of any given BEAM package, so we make no distinction. 6 7 + ## Available versions and deprecations schedule {#available-versions-and-deprecations-schedule} 8 9 + ### Elixir {#elixir} 10 11 nixpkgs follows the [official elixir deprecation schedule](https://hexdocs.pm/elixir/compatibility-and-deprecations.html) and keeps the last 5 released versions of Elixir available. 12 ··· 68 69 `mixRelease` is used to make a release in the mix sense. Dependencies will need to be fetched with `fetchMixDeps` and passed to it. 70 71 + #### mixRelease - Elixir Phoenix example {#mixrelease---elixir-phoenix-example} 72 73 Here is how your `default.nix` file would look. 74 ··· 148 - you can now `nix-build .` 149 - To run the release, set the `RELEASE_TMP` environment variable to a directory that your program has write access to. It will be used to store the BEAM settings. 150 151 + #### Example of creating a service for an Elixir - Phoenix project {#example-of-creating-a-service-for-an-elixir---phoenix-project} 152 153 In order to create a service with your release, you could add a `service.nix` 154 in your project with the following ··· 228 } 229 ``` 230 231 + #### Elixir - Phoenix project {#elixir---phoenix-project} 232 233 Here is an example `shell.nix`. 234
+1 -1
doc/languages-frameworks/bower.section.md
··· 149 150 ## Troubleshooting {#ssec-bower2nix-troubleshooting} 151 152 - ### ENOCACHE errors from buildBowerComponents 153 154 This means that Bower was looking for a package version which doesn't exist in the generated `bower-packages.nix`. 155
··· 149 150 ## Troubleshooting {#ssec-bower2nix-troubleshooting} 151 152 + ### ENOCACHE errors from buildBowerComponents {#enocache-errors-from-buildbowercomponents} 153 154 This means that Bower was looking for a package version which doesn't exist in the generated `bower-packages.nix`. 155
+2 -2
doc/languages-frameworks/coq.section.md
··· 1 # Coq and coq packages {#sec-language-coq} 2 3 - ## Coq derivation: `coq` 4 5 The Coq derivation is overridable through the `coq.override overrides`, where overrides is an attribute set which contains the arguments to override. We recommend overriding either of the following 6 ··· 8 * `customOCamlPackage` (optional, defaults to `null`, which lets Coq choose a version automatically), which can be set to any of the ocaml packages attribute of `ocaml-ng` (such as `ocaml-ng.ocamlPackages_4_10` which is the default for Coq 8.11 for example). 9 * `coq-version` (optional, defaults to the short version e.g. "8.10"), is a version number of the form "x.y" that indicates which Coq's version build behavior to mimic when using a source which is not a release. E.g. `coq.override { version = "d370a9d1328a4e1cdb9d02ee032f605a9d94ec7a"; coq-version = "8.10"; }`. 10 11 - ## Coq packages attribute sets: `coqPackages` 12 13 The recommended way of defining a derivation for a Coq library, is to use the `coqPackages.mkCoqDerivation` function, which is essentially a specialization of `mkDerivation` taking into account most of the specifics of Coq libraries. The following attributes are supported: 14
··· 1 # Coq and coq packages {#sec-language-coq} 2 3 + ## Coq derivation: `coq` {#coq-derivation-coq} 4 5 The Coq derivation is overridable through the `coq.override overrides`, where overrides is an attribute set which contains the arguments to override. We recommend overriding either of the following 6 ··· 8 * `customOCamlPackage` (optional, defaults to `null`, which lets Coq choose a version automatically), which can be set to any of the ocaml packages attribute of `ocaml-ng` (such as `ocaml-ng.ocamlPackages_4_10` which is the default for Coq 8.11 for example). 9 * `coq-version` (optional, defaults to the short version e.g. "8.10"), is a version number of the form "x.y" that indicates which Coq's version build behavior to mimic when using a source which is not a release. E.g. `coq.override { version = "d370a9d1328a4e1cdb9d02ee032f605a9d94ec7a"; coq-version = "8.10"; }`. 10 11 + ## Coq packages attribute sets: `coqPackages` {#coq-packages-attribute-sets-coqpackages} 12 13 The recommended way of defining a derivation for a Coq library, is to use the `coqPackages.mkCoqDerivation` function, which is essentially a specialization of `mkDerivation` taking into account most of the specifics of Coq libraries. The following attributes are supported: 14
+3 -1
doc/languages-frameworks/crystal.section.md
··· 1 # Crystal {#crystal} 2 3 - ## Building a Crystal package 4 5 This section uses [Mint](https://github.com/mint-lang/mint) as an example for how to build a Crystal package. 6 7 If the Crystal project has any dependencies, the first step is to get a `shards.nix` file encoding those. Get a copy of the project and go to its root directory such that its `shard.lock` file is in the current directory, then run `crystal2nix` in it 8 ```bash 9 $ git clone https://github.com/mint-lang/mint 10 $ cd mint ··· 15 This should have generated a `shards.nix` file. 16 17 Next create a Nix file for your derivation and use `pkgs.crystal.buildCrystalPackage` as follows: 18 ```nix 19 with import <nixpkgs> {}; 20 crystal.buildCrystalPackage rec {
··· 1 # Crystal {#crystal} 2 3 + ## Building a Crystal package {#building-a-crystal-package} 4 5 This section uses [Mint](https://github.com/mint-lang/mint) as an example for how to build a Crystal package. 6 7 If the Crystal project has any dependencies, the first step is to get a `shards.nix` file encoding those. Get a copy of the project and go to its root directory such that its `shard.lock` file is in the current directory, then run `crystal2nix` in it 8 + 9 ```bash 10 $ git clone https://github.com/mint-lang/mint 11 $ cd mint ··· 16 This should have generated a `shards.nix` file. 17 18 Next create a Nix file for your derivation and use `pkgs.crystal.buildCrystalPackage` as follows: 19 + 20 ```nix 21 with import <nixpkgs> {}; 22 crystal.buildCrystalPackage rec {
+7 -7
doc/languages-frameworks/dotnet.section.md
··· 1 - # Dotnet 2 3 - ## Local Development Workflow 4 5 For local development, it's recommended to use nix-shell to create a dotnet environment: 6 ··· 16 } 17 ``` 18 19 - ### Using many sdks in a workflow 20 21 It's very likely that more than one sdk will be needed on a given project. Dotnet provides several different frameworks (E.g dotnetcore, aspnetcore, etc.) as well as many versions for a given framework. Normally, dotnet is able to fetch a framework and install it relative to the executable. However, this would mean writing to the nix store in nixpkgs, which is read-only. To support the many-sdk use case, one can compose an environment using `dotnetCorePackages.combinePackages`: 22 ··· 37 38 This will produce a dotnet installation that has the dotnet 3.1, 3.0, and 2.1 sdk. The first sdk listed will have it's cli utility present in the resulting environment. Example info output: 39 40 - ```ShellSesssion 41 $ dotnet --info 42 .NET Core SDK (reflecting any global.json): 43 Version: 3.1.101 ··· 60 Microsoft.NETCore.App 3.1.1 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.NETCore.App] 61 ``` 62 63 - ## dotnet-sdk vs dotnetCorePackages.sdk 64 65 The `dotnetCorePackages.sdk_X_Y` is preferred over the old dotnet-sdk as both major and minor version are very important for a dotnet environment. If a given minor version isn't present (or was changed), then this will likely break your ability to build a project. 66 67 - ## dotnetCorePackages.sdk vs dotnetCorePackages.net vs dotnetCorePackages.netcore vs dotnetCorePackages.aspnetcore 68 69 The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given version. The `net`, `netcore` and `aspnetcore` packages are meant to serve as minimal runtimes to deploy alongside already built applications. For runtime versions >= .NET 5 `net` is used while `netcore` is used for older .NET Core runtime version. 70 71 - ## Packaging a Dotnet Application 72 73 Ideally, we would like to build against the sdk, then only have the dotnet runtime available in the runtime closure. 74
··· 1 + # Dotnet {#dotnet} 2 3 + ## Local Development Workflow {#local-development-workflow} 4 5 For local development, it's recommended to use nix-shell to create a dotnet environment: 6 ··· 16 } 17 ``` 18 19 + ### Using many sdks in a workflow {#using-many-sdks-in-a-workflow} 20 21 It's very likely that more than one sdk will be needed on a given project. Dotnet provides several different frameworks (E.g dotnetcore, aspnetcore, etc.) as well as many versions for a given framework. Normally, dotnet is able to fetch a framework and install it relative to the executable. However, this would mean writing to the nix store in nixpkgs, which is read-only. To support the many-sdk use case, one can compose an environment using `dotnetCorePackages.combinePackages`: 22 ··· 37 38 This will produce a dotnet installation that has the dotnet 3.1, 3.0, and 2.1 sdk. The first sdk listed will have it's cli utility present in the resulting environment. Example info output: 39 40 + ```ShellSession 41 $ dotnet --info 42 .NET Core SDK (reflecting any global.json): 43 Version: 3.1.101 ··· 60 Microsoft.NETCore.App 3.1.1 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.NETCore.App] 61 ``` 62 63 + ## dotnet-sdk vs dotnetCorePackages.sdk {#dotnet-sdk-vs-dotnetcorepackages.sdk} 64 65 The `dotnetCorePackages.sdk_X_Y` is preferred over the old dotnet-sdk as both major and minor version are very important for a dotnet environment. If a given minor version isn't present (or was changed), then this will likely break your ability to build a project. 66 67 + ## dotnetCorePackages.sdk vs dotnetCorePackages.net vs dotnetCorePackages.netcore vs dotnetCorePackages.aspnetcore {#dotnetcorepackages.sdk-vs-dotnetcorepackages.net-vs-dotnetcorepackages.netcore-vs-dotnetcorepackages.aspnetcore} 68 69 The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given version. The `net`, `netcore` and `aspnetcore` packages are meant to serve as minimal runtimes to deploy alongside already built applications. For runtime versions >= .NET 5 `net` is used while `netcore` is used for older .NET Core runtime version. 70 71 + ## Packaging a Dotnet Application {#packaging-a-dotnet-application} 72 73 Ideally, we would like to build against the sdk, then only have the dotnet runtime available in the runtime closure. 74
+6 -8
doc/languages-frameworks/emscripten.section.md
··· 27 * dev-shell for zlib implementation hacking: 28 * `nix-shell -A emscriptenPackages.zlib` 29 30 - 31 - ## Imperative usage 32 33 A few things to note: 34 35 * `export EMCC_DEBUG=2` is nice for debugging 36 * `~/.emscripten`, the build artifact cache sometimes creates issues and needs to be removed from time to time 37 38 - 39 - ## Declarative usage 40 41 Let's see two different examples from `pkgs/top-level/emscripten-packages.nix`: 42 ··· 50 * Use `export EMCC_DEBUG=2` from within a emscriptenPackage's `phase` to get more detailed debug output what is going wrong. 51 * ~/.emscripten cache is requiring us to set `HOME=$TMPDIR` in individual phases. This makes compilation slower but also makes it more deterministic. 52 53 - ### Usage 1: pkgs.zlib.override 54 55 This example uses `zlib` from nixpkgs but instead of compiling **C** to **ELF** it compiles **C** to **JS** since we were using `pkgs.zlib.override` and changed stdenv to `pkgs.emscriptenStdenv`. A few adaptions and hacks were set in place to make it working. One advantage is that when `pkgs.zlib` is updated, it will automatically update this package as well. However, this can also be the downside... 56 ··· 110 ''; 111 }); 112 113 - ### Usage 2: pkgs.buildEmscriptenPackage 114 115 This `xmlmirror` example features a emscriptenPackage which is defined completely from this context and no `pkgs.zlib.override` is used. 116 ··· 165 ''; 166 }; 167 168 - ### Declarative debugging 169 170 Use `nix-shell -I nixpkgs=/some/dir/nixpkgs -A emscriptenPackages.libz` and from there you can go trough the individual steps. This makes it easy to build a good `unit test` or list the files of the project. 171 ··· 177 6. `buildPhase` 178 7. ... happy hacking... 179 180 - ## Summary 181 182 Using this toolchain makes it easy to leverage `nix` from NixOS, MacOSX or even Windows (WSL+ubuntu+nix). This toolchain is reproducible, behaves like the rest of the packages from nixpkgs and contains a set of well working examples to learn and adapt from. 183
··· 27 * dev-shell for zlib implementation hacking: 28 * `nix-shell -A emscriptenPackages.zlib` 29 30 + ## Imperative usage {#imperative-usage} 31 32 A few things to note: 33 34 * `export EMCC_DEBUG=2` is nice for debugging 35 * `~/.emscripten`, the build artifact cache sometimes creates issues and needs to be removed from time to time 36 37 + ## Declarative usage {#declarative-usage} 38 39 Let's see two different examples from `pkgs/top-level/emscripten-packages.nix`: 40 ··· 48 * Use `export EMCC_DEBUG=2` from within a emscriptenPackage's `phase` to get more detailed debug output what is going wrong. 49 * ~/.emscripten cache is requiring us to set `HOME=$TMPDIR` in individual phases. This makes compilation slower but also makes it more deterministic. 50 51 + ### Usage 1: pkgs.zlib.override {#usage-1-pkgs.zlib.override} 52 53 This example uses `zlib` from nixpkgs but instead of compiling **C** to **ELF** it compiles **C** to **JS** since we were using `pkgs.zlib.override` and changed stdenv to `pkgs.emscriptenStdenv`. A few adaptions and hacks were set in place to make it working. One advantage is that when `pkgs.zlib` is updated, it will automatically update this package as well. However, this can also be the downside... 54 ··· 108 ''; 109 }); 110 111 + ### Usage 2: pkgs.buildEmscriptenPackage {#usage-2-pkgs.buildemscriptenpackage} 112 113 This `xmlmirror` example features a emscriptenPackage which is defined completely from this context and no `pkgs.zlib.override` is used. 114 ··· 163 ''; 164 }; 165 166 + ### Declarative debugging {#declarative-debugging} 167 168 Use `nix-shell -I nixpkgs=/some/dir/nixpkgs -A emscriptenPackages.libz` and from there you can go trough the individual steps. This makes it easy to build a good `unit test` or list the files of the project. 169 ··· 175 6. `buildPhase` 176 7. ... happy hacking... 177 178 + ## Summary {#summary} 179 180 Using this toolchain makes it easy to leverage `nix` from NixOS, MacOSX or even Windows (WSL+ubuntu+nix). This toolchain is reproducible, behaves like the rest of the packages from nixpkgs and contains a set of well working examples to learn and adapt from. 181
+1 -1
doc/languages-frameworks/gnome.section.md
··· 84 85 - []{#ssec-gnome-hooks-gobject-introspection} `gobject-introspection` setup hook populates `GI_TYPELIB_PATH` variable with `lib/girepository-1.0` directories of dependencies, which is then added to wrapper by `wrapGAppsHook`. It also adds `share` directories of dependencies to `XDG_DATA_DIRS`, which is intended to promote GIR files but it also [pollutes the closures](https://github.com/NixOS/nixpkgs/issues/32790) of packages using `wrapGAppsHook`. 86 87 - ::: warning 88 The setup hook [currently](https://github.com/NixOS/nixpkgs/issues/56943) does not work in expressions with `strictDeps` enabled, like Python packages. In those cases, you will need to disable it with `strictDeps = false;`. 89 ::: 90
··· 84 85 - []{#ssec-gnome-hooks-gobject-introspection} `gobject-introspection` setup hook populates `GI_TYPELIB_PATH` variable with `lib/girepository-1.0` directories of dependencies, which is then added to wrapper by `wrapGAppsHook`. It also adds `share` directories of dependencies to `XDG_DATA_DIRS`, which is intended to promote GIR files but it also [pollutes the closures](https://github.com/NixOS/nixpkgs/issues/32790) of packages using `wrapGAppsHook`. 86 87 + ::: {.warning} 88 The setup hook [currently](https://github.com/NixOS/nixpkgs/issues/56943) does not work in expressions with `strictDeps` enabled, like Python packages. In those cases, you will need to disable it with `strictDeps = false;`. 89 ::: 90
+2 -2
doc/languages-frameworks/go.section.md
··· 44 45 The function `buildGoPackage` builds legacy Go programs, not supporting Go modules. 46 47 - ### Example for `buildGoPackage` 48 49 In the following is an example expression using buildGoPackage, the following arguments are of special significance to the function: 50 ··· 140 141 ### `subPackages` {#var-go-subPackages} 142 143 - Limits the builder from building child packages that have not been listed. If <varname>subPackages</varname> is not specified, all child packages will be built.
··· 44 45 The function `buildGoPackage` builds legacy Go programs, not supporting Go modules. 46 47 + ### Example for `buildGoPackage` {#example-for-buildgopackage} 48 49 In the following is an example expression using buildGoPackage, the following arguments are of special significance to the function: 50 ··· 140 141 ### `subPackages` {#var-go-subPackages} 142 143 + Limits the builder from building child packages that have not been listed. If `subPackages` is not specified, all child packages will be built.
+14 -12
doc/languages-frameworks/idris.section.md
··· 1 # Idris {#idris} 2 3 - ## Installing Idris 4 5 The easiest way to get a working idris version is to install the `idris` attribute: 6 7 - ```ShellSesssion 8 $ # On NixOS 9 $ nix-env -i nixos.idris 10 $ # On non-NixOS ··· 21 22 And then: 23 24 - ```ShellSesssion 25 $ # On NixOS 26 $ nix-env -iA nixos.myIdris 27 $ # On non-NixOS ··· 29 ``` 30 31 To see all available Idris packages: 32 - ```ShellSesssion 33 $ # On NixOS 34 $ nix-env -qaPA nixos.idrisPackages 35 $ # On non-NixOS ··· 37 ``` 38 39 Similarly, entering a `nix-shell`: 40 - ```ShellSesssion 41 $ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])' 42 ``` 43 44 - ## Starting Idris with library support 45 46 To have access to these libraries in idris, call it with an argument `-p <library name>` for each library: 47 48 - ```ShellSesssion 49 $ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])' 50 [nix-shell:~]$ idris -p contrib -p pruviloj 51 ``` 52 53 A listing of all available packages the Idris binary has access to is available via `--listlibs`: 54 55 - ```ShellSesssion 56 $ idris --listlibs 57 00prelude-idx.ibc 58 pruviloj ··· 64 00contrib-idx.ibc 65 ``` 66 67 - ## Building an Idris project with Nix 68 69 As an example of how a Nix expression for an Idris package can be created, here is the one for `idrisPackages.yaml`: 70 ··· 105 106 Assuming this file is saved as `yaml.nix`, it's buildable using 107 108 - ```ShellSesssion 109 $ nix-build -E '(import <nixpkgs> {}).idrisPackages.callPackage ./yaml.nix {}' 110 ``` 111 ··· 121 122 in another file (say `default.nix`) to be able to build it with 123 124 - ```ShellSesssion 125 $ nix-build -A yaml 126 ``` 127 128 - ## Passing options to `idris` commands 129 130 The `build-idris-package` function provides also optional input values to set additional options for the used `idris` commands. 131
··· 1 # Idris {#idris} 2 3 + ## Installing Idris {#installing-idris} 4 5 The easiest way to get a working idris version is to install the `idris` attribute: 6 7 + ```ShellSession 8 $ # On NixOS 9 $ nix-env -i nixos.idris 10 $ # On non-NixOS ··· 21 22 And then: 23 24 + ```ShellSession 25 $ # On NixOS 26 $ nix-env -iA nixos.myIdris 27 $ # On non-NixOS ··· 29 ``` 30 31 To see all available Idris packages: 32 + 33 + ```ShellSession 34 $ # On NixOS 35 $ nix-env -qaPA nixos.idrisPackages 36 $ # On non-NixOS ··· 38 ``` 39 40 Similarly, entering a `nix-shell`: 41 + 42 + ```ShellSession 43 $ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])' 44 ``` 45 46 + ## Starting Idris with library support {#starting-idris-with-library-support} 47 48 To have access to these libraries in idris, call it with an argument `-p <library name>` for each library: 49 50 + ```ShellSession 51 $ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])' 52 [nix-shell:~]$ idris -p contrib -p pruviloj 53 ``` 54 55 A listing of all available packages the Idris binary has access to is available via `--listlibs`: 56 57 + ```ShellSession 58 $ idris --listlibs 59 00prelude-idx.ibc 60 pruviloj ··· 66 00contrib-idx.ibc 67 ``` 68 69 + ## Building an Idris project with Nix {#building-an-idris-project-with-nix} 70 71 As an example of how a Nix expression for an Idris package can be created, here is the one for `idrisPackages.yaml`: 72 ··· 107 108 Assuming this file is saved as `yaml.nix`, it's buildable using 109 110 + ```ShellSession 111 $ nix-build -E '(import <nixpkgs> {}).idrisPackages.callPackage ./yaml.nix {}' 112 ``` 113 ··· 123 124 in another file (say `default.nix`) to be able to build it with 125 126 + ```ShellSession 127 $ nix-build -A yaml 128 ``` 129 130 + ## Passing options to `idris` commands {#passing-options-to-idris-commands} 131 132 The `build-idris-package` function provides also optional input values to set additional options for the used `idris` commands. 133
+9 -8
doc/languages-frameworks/ios.section.md
··· 20 21 The Xcode build environment implements a number of features. 22 23 - Deploying a proxy component wrapper exposing Xcode 24 - -------------------------------------------------- 25 The first use case is deploying a Nix package that provides symlinks to the Xcode 26 installation on the host system. This package can be used as a build input to 27 any build function implemented in the Nix expression language that requires ··· 55 lrwxr-xr-x 1 sander staff 14 1 jan 1970 xcrun -> /usr/bin/xcrun 56 ``` 57 58 - Building an iOS application 59 - --------------------------- 60 We can build an iOS app executable for the simulator, or an IPA/xcarchive file 61 for release purposes, e.g. ad-hoc, enterprise or store installations, by 62 executing the `xcodeenv.buildApp {}` function: ··· 99 ``` 100 101 The above function takes a variety of parameters: 102 * The `name` and `src` parameters are mandatory and specify the name of the app 103 and the location where the source code resides 104 * `sdkVersion` specifies which version of the iOS SDK to use. ··· 151 `xcodeBaseDir` parameter can be overridden to refer to a different Xcode 152 version. 153 154 - Spawning simulator instances 155 - ---------------------------- 156 In addition to building iOS apps, we can also automatically spawn simulator 157 instances: 158 ··· 213 By providing the result of an `xcode.buildApp {}` function and configuring the 214 app bundle id, the app gets deployed automatically and started. 215 216 - Troubleshooting 217 - --------------- 218 In some rare cases, it may happen that after a failure, changes are not picked 219 up. Most likely, this is caused by a derived data cache that Xcode maintains. 220 To wipe it you can run:
··· 20 21 The Xcode build environment implements a number of features. 22 23 + ## Deploying a proxy component wrapper exposing Xcode {#deploying-a-proxy-component-wrapper-exposing-xcode} 24 + 25 The first use case is deploying a Nix package that provides symlinks to the Xcode 26 installation on the host system. This package can be used as a build input to 27 any build function implemented in the Nix expression language that requires ··· 55 lrwxr-xr-x 1 sander staff 14 1 jan 1970 xcrun -> /usr/bin/xcrun 56 ``` 57 58 + ## Building an iOS application {#building-an-ios-application} 59 + 60 We can build an iOS app executable for the simulator, or an IPA/xcarchive file 61 for release purposes, e.g. ad-hoc, enterprise or store installations, by 62 executing the `xcodeenv.buildApp {}` function: ··· 99 ``` 100 101 The above function takes a variety of parameters: 102 + 103 * The `name` and `src` parameters are mandatory and specify the name of the app 104 and the location where the source code resides 105 * `sdkVersion` specifies which version of the iOS SDK to use. ··· 152 `xcodeBaseDir` parameter can be overridden to refer to a different Xcode 153 version. 154 155 + ## Spawning simulator instances {#spawning-simulator-instances} 156 + 157 In addition to building iOS apps, we can also automatically spawn simulator 158 instances: 159 ··· 214 By providing the result of an `xcode.buildApp {}` function and configuring the 215 app bundle id, the app gets deployed automatically and started. 216 217 + ## Troubleshooting {#troubleshooting} 218 + 219 In some rare cases, it may happen that after a failure, changes are not picked 220 up. Most likely, this is caused by a derived data cache that Xcode maintains. 221 To wipe it you can run:
+33 -23
doc/languages-frameworks/lua.section.md
··· 1 - # User's Guide to Lua Infrastructure {#users-guide-to-lua-infrastructure} 2 3 - ## Using Lua 4 5 - ### Overview of Lua 6 7 Several versions of the Lua interpreter are available: luajit, lua 5.1, 5.2, 5.3. 8 The attribute `lua` refers to the default interpreter, it is also possible to refer to specific versions, e.g. `lua5_2` refers to Lua 5.2. ··· 17 `luaPackages` refers to `lua5_1.pkgs` and `lua52Packages` to 18 `lua5_2.pkgs`. 19 20 - ### Installing Lua and packages 21 22 - #### Lua environment defined in separate `.nix` file 23 24 Create a file, e.g. `build.nix`, with the following expression 25 ```nix 26 with import <nixpkgs> {}; 27 28 lua5_2.withPackages (ps: with ps; [ busted luafilesystem ]) 29 ``` 30 and install it in your profile with 31 ```shell 32 nix-env -if build.nix 33 ``` 34 Now you can use the Lua interpreter, as well as the extra packages (`busted`, 35 `luafilesystem`) that you added to the environment. 36 37 - #### Lua environment defined in `~/.config/nixpkgs/config.nix` 38 39 If you prefer to, you could also add the environment as a package override to the Nixpkgs set, e.g. 40 using `config.nix`, 41 ```nix 42 { # ... 43 ··· 46 }; 47 } 48 ``` 49 and install it in your profile with 50 ```shell 51 nix-env -iA nixpkgs.myLuaEnv 52 ``` 53 The environment is installed by referring to the attribute, and considering 54 the `nixpkgs` channel was used. 55 56 - #### Lua environment defined in `/etc/nixos/configuration.nix` 57 58 For the sake of completeness, here's another example how to install the environment system-wide. 59 ··· 66 } 67 ``` 68 69 - ### How to override a Lua package using overlays? 70 71 Use the following overlay template: 72 ··· 87 } 88 ``` 89 90 - ### Temporary Lua environment with `nix-shell` 91 92 93 There are two methods for loading a shell with Lua packages. The first and recommended method 94 is to create an environment with `lua.buildEnv` or `lua.withPackages` and load that. E.g. 95 ```sh 96 $ nix-shell -p 'lua.withPackages(ps: with ps; [ busted luafilesystem ])' 97 ``` 98 opens a shell from which you can launch the interpreter 99 ```sh 100 [nix-shell:~] lua 101 ``` 102 The other method, which is not recommended, does not create an environment and requires you to list the packages directly, 103 104 ```sh ··· 108 The Lua interpreter has the attribute `pkgs` which contains all Lua libraries for that specific interpreter. 109 110 111 - ## Developing with Lua 112 113 Now that you know how to get a working Lua environment with Nix, it is time 114 to go forward and start actually developing with Lua. There are two ways to ··· 116 of by the luarocks2nix converter or the packaging has to be done manually. 117 Let's present the luarocks way first and the manual one in a second time. 118 119 - ### Packaging a library on luarocks 120 121 [Luarocks.org](www.luarocks.org) is the main repository of lua packages. 122 The site proposes two types of packages, the rockspec and the src.rock ··· 135 Nix rely on luarocks to install lua packages, basically it runs: 136 `luarocks make --deps-mode=none --tree $out` 137 138 - #### Packaging a library manually 139 140 You can develop your package as you usually would, just don't forget to wrap it 141 within a `toLuaModule` call, for instance 142 ```nix 143 mynewlib = toLuaModule ( stdenv.mkDerivation { ... }); 144 ``` ··· 146 There is also the `buildLuaPackage` function that can be used when lua modules 147 are not packaged for luarocks. You can see a few examples at `pkgs/top-level/lua-packages.nix`. 148 149 - ## Lua Reference 150 151 - ### Lua interpreters 152 153 Versions 5.1, 5.2 and 5.3 of the lua interpreter are available as 154 respectively `lua5_1`, `lua5_2` and `lua5_3`. Luajit is available too. 155 The Nix expressions for the interpreters can be found in `pkgs/development/interpreters/lua-5`. 156 157 - 158 - #### Attributes on lua interpreters packages 159 160 Each interpreter has the following attributes: 161 ··· 164 - `withPackages`. Simpler interface to `buildEnv`. 165 - `pkgs`. Set of Lua packages for that specific interpreter. The package set can be modified by overriding the interpreter and passing `packageOverrides`. 166 167 - 168 - #### `buildLuarocksPackage` function 169 170 The `buildLuarocksPackage` function is implemented in `pkgs/development/interpreters/lua-5/build-lua-package.nix` 171 The following is an example: ··· 205 206 By default `meta.platforms` is set to the same value as the interpreter unless overridden otherwise. 207 208 - #### `buildLuaApplication` function 209 210 The `buildLuaApplication` function is practically the same as `buildLuaPackage`. 211 The difference is that `buildLuaPackage` by default prefixes the names of the packages with the version of the interpreter. 212 Because with an application we're not interested in multiple version the prefix is dropped. 213 214 - #### lua.withPackages function 215 216 The `lua.withPackages` takes a function as an argument that is passed the set of lua packages and returns the list of packages to be included in the environment. 217 Using the `withPackages` function, the previous example for the luafilesystem environment can be written like this: 218 ```nix 219 with import <nixpkgs> {}; 220 ··· 223 224 `withPackages` passes the correct package set for the specific interpreter version as an argument to the function. In the above example, `ps` equals `luaPackages`. 225 But you can also easily switch to using `lua5_2`: 226 ```nix 227 with import <nixpkgs> {}; 228 ··· 231 232 Now, `ps` is set to `lua52Packages`, matching the version of the interpreter. 233 234 - 235 - ### Possible Todos 236 237 * export/use version specific variables such as `LUA_PATH_5_2`/`LUAROCKS_CONFIG_5_2` 238 * let luarocks check for dependencies via exporting the different rocktrees in temporary config 239 240 - ### Lua Contributing guidelines 241 242 Following rules should be respected: 243
··· 1 + # User’s Guide to Lua Infrastructure {#users-guide-to-lua-infrastructure} 2 3 + ## Using Lua {#using-lua} 4 5 + ### Overview of Lua {#overview-of-lua} 6 7 Several versions of the Lua interpreter are available: luajit, lua 5.1, 5.2, 5.3. 8 The attribute `lua` refers to the default interpreter, it is also possible to refer to specific versions, e.g. `lua5_2` refers to Lua 5.2. ··· 17 `luaPackages` refers to `lua5_1.pkgs` and `lua52Packages` to 18 `lua5_2.pkgs`. 19 20 + ### Installing Lua and packages {#installing-lua-and-packages} 21 22 + #### Lua environment defined in separate `.nix` file {#lua-environment-defined-in-separate-.nix-file} 23 24 Create a file, e.g. `build.nix`, with the following expression 25 + 26 ```nix 27 with import <nixpkgs> {}; 28 29 lua5_2.withPackages (ps: with ps; [ busted luafilesystem ]) 30 ``` 31 + 32 and install it in your profile with 33 + 34 ```shell 35 nix-env -if build.nix 36 ``` 37 Now you can use the Lua interpreter, as well as the extra packages (`busted`, 38 `luafilesystem`) that you added to the environment. 39 40 + #### Lua environment defined in `~/.config/nixpkgs/config.nix` {#lua-environment-defined-in-.confignixpkgsconfig.nix} 41 42 If you prefer to, you could also add the environment as a package override to the Nixpkgs set, e.g. 43 using `config.nix`, 44 + 45 ```nix 46 { # ... 47 ··· 50 }; 51 } 52 ``` 53 + 54 and install it in your profile with 55 + 56 ```shell 57 nix-env -iA nixpkgs.myLuaEnv 58 ``` 59 The environment is installed by referring to the attribute, and considering 60 the `nixpkgs` channel was used. 61 62 + #### Lua environment defined in `/etc/nixos/configuration.nix` {#lua-environment-defined-in-etcnixosconfiguration.nix} 63 64 For the sake of completeness, here's another example how to install the environment system-wide. 65 ··· 72 } 73 ``` 74 75 + ### How to override a Lua package using overlays? {#how-to-override-a-lua-package-using-overlays} 76 77 Use the following overlay template: 78 ··· 93 } 94 ``` 95 96 + ### Temporary Lua environment with `nix-shell` {#temporary-lua-environment-with-nix-shell} 97 98 99 There are two methods for loading a shell with Lua packages. The first and recommended method 100 is to create an environment with `lua.buildEnv` or `lua.withPackages` and load that. E.g. 101 + 102 ```sh 103 $ nix-shell -p 'lua.withPackages(ps: with ps; [ busted luafilesystem ])' 104 ``` 105 + 106 opens a shell from which you can launch the interpreter 107 + 108 ```sh 109 [nix-shell:~] lua 110 ``` 111 + 112 The other method, which is not recommended, does not create an environment and requires you to list the packages directly, 113 114 ```sh ··· 118 The Lua interpreter has the attribute `pkgs` which contains all Lua libraries for that specific interpreter. 119 120 121 + ## Developing with Lua {#developing-with-lua} 122 123 Now that you know how to get a working Lua environment with Nix, it is time 124 to go forward and start actually developing with Lua. There are two ways to ··· 126 of by the luarocks2nix converter or the packaging has to be done manually. 127 Let's present the luarocks way first and the manual one in a second time. 128 129 + ### Packaging a library on luarocks {#packaging-a-library-on-luarocks} 130 131 [Luarocks.org](www.luarocks.org) is the main repository of lua packages. 132 The site proposes two types of packages, the rockspec and the src.rock ··· 145 Nix rely on luarocks to install lua packages, basically it runs: 146 `luarocks make --deps-mode=none --tree $out` 147 148 + #### Packaging a library manually {#packaging-a-library-manually} 149 150 You can develop your package as you usually would, just don't forget to wrap it 151 within a `toLuaModule` call, for instance 152 + 153 ```nix 154 mynewlib = toLuaModule ( stdenv.mkDerivation { ... }); 155 ``` ··· 157 There is also the `buildLuaPackage` function that can be used when lua modules 158 are not packaged for luarocks. You can see a few examples at `pkgs/top-level/lua-packages.nix`. 159 160 + ## Lua Reference {#lua-reference} 161 162 + ### Lua interpreters {#lua-interpreters} 163 164 Versions 5.1, 5.2 and 5.3 of the lua interpreter are available as 165 respectively `lua5_1`, `lua5_2` and `lua5_3`. Luajit is available too. 166 The Nix expressions for the interpreters can be found in `pkgs/development/interpreters/lua-5`. 167 168 + #### Attributes on lua interpreters packages {#attributes-on-lua-interpreters-packages} 169 170 Each interpreter has the following attributes: 171 ··· 174 - `withPackages`. Simpler interface to `buildEnv`. 175 - `pkgs`. Set of Lua packages for that specific interpreter. The package set can be modified by overriding the interpreter and passing `packageOverrides`. 176 177 + #### `buildLuarocksPackage` function {#buildluarockspackage-function} 178 179 The `buildLuarocksPackage` function is implemented in `pkgs/development/interpreters/lua-5/build-lua-package.nix` 180 The following is an example: ··· 214 215 By default `meta.platforms` is set to the same value as the interpreter unless overridden otherwise. 216 217 + #### `buildLuaApplication` function {#buildluaapplication-function} 218 219 The `buildLuaApplication` function is practically the same as `buildLuaPackage`. 220 The difference is that `buildLuaPackage` by default prefixes the names of the packages with the version of the interpreter. 221 Because with an application we're not interested in multiple version the prefix is dropped. 222 223 + #### lua.withPackages function {#lua.withpackages-function} 224 225 The `lua.withPackages` takes a function as an argument that is passed the set of lua packages and returns the list of packages to be included in the environment. 226 Using the `withPackages` function, the previous example for the luafilesystem environment can be written like this: 227 + 228 ```nix 229 with import <nixpkgs> {}; 230 ··· 233 234 `withPackages` passes the correct package set for the specific interpreter version as an argument to the function. In the above example, `ps` equals `luaPackages`. 235 But you can also easily switch to using `lua5_2`: 236 + 237 ```nix 238 with import <nixpkgs> {}; 239 ··· 242 243 Now, `ps` is set to `lua52Packages`, matching the version of the interpreter. 244 245 + ### Possible Todos {#possible-todos} 246 247 * export/use version specific variables such as `LUA_PATH_5_2`/`LUAROCKS_CONFIG_5_2` 248 * let luarocks check for dependencies via exporting the different rocktrees in temporary config 249 250 + ### Lua Contributing guidelines {#lua-contributing-guidelines} 251 252 Following rules should be respected: 253
+10 -7
doc/languages-frameworks/maven.section.md
··· 43 44 You find this demo project at https://github.com/fzakaria/nixos-maven-example 45 46 - ## Solving for dependencies 47 48 - ### buildMaven with NixOS/mvn2nix-maven-plugin 49 50 > ⚠️ Although `buildMaven` is the "blessed" way within nixpkgs, as of 2020, it hasn't seen much activity in quite a while. 51 ··· 82 A simple derivation that runs through `mvn compile` & `mvn package` to build the JAR. You may use this as inspiration for more complicated derivations. 83 84 Here is an [example](https://github.com/fzakaria/nixos-maven-example/blob/main/build-maven-repository.nix) of building the Maven repository 85 ```nix 86 { pkgs ? import <nixpkgs> { } }: 87 with pkgs; ··· 103 │   └── 4.1.3 104 │   ├── avalon-framework-4.1.3.jar -> /nix/store/iv5fp3955w3nq28ff9xfz86wvxbiw6n9-avalon-framework-4.1.3.jar 105 ``` 106 - ### Double Invocation 107 108 > ⚠️ This pattern is the simplest but may cause unnecessary rebuilds due to the output hash changing. 109 ··· 163 164 If your package uses _SNAPSHOT_ dependencies or _version ranges_; there is a strong likelihood that over-time your output hash will change since the resolved dependencies may change. Hence this method is less recommended then using `buildMaven`. 165 166 - ## Building a JAR 167 168 Regardless of which strategy is chosen above, the step to build the derivation is the same. 169 ··· 201 2 directories, 1 file 202 ``` 203 204 - ## Runnable JAR 205 206 The previous example builds a `jar` file but that's not a file one can run. 207 ··· 213 214 The following two methods are more suited to Nix then building an [UberJar](https://imagej.net/Uber-JAR) which may be the more traditional approach. 215 216 - ### CLASSPATH 217 218 > This is ideal if you are providing a derivation for _nixpkgs_ and don't want to patch the project's `pom.xml`. 219 ··· 252 } 253 ``` 254 255 - ### MANIFEST file via Maven Plugin 256 257 > This is ideal if you are the project owner and want to change your `pom.xml` to set the CLASSPATH within it. 258 259 Augment the `pom.xml` to create a JAR with the following manifest: 260 ```xml 261 <build> 262 <plugins>
··· 43 44 You find this demo project at https://github.com/fzakaria/nixos-maven-example 45 46 + ## Solving for dependencies {#solving-for-dependencies} 47 48 + ### buildMaven with NixOS/mvn2nix-maven-plugin {#buildmaven-with-nixosmvn2nix-maven-plugin} 49 50 > ⚠️ Although `buildMaven` is the "blessed" way within nixpkgs, as of 2020, it hasn't seen much activity in quite a while. 51 ··· 82 A simple derivation that runs through `mvn compile` & `mvn package` to build the JAR. You may use this as inspiration for more complicated derivations. 83 84 Here is an [example](https://github.com/fzakaria/nixos-maven-example/blob/main/build-maven-repository.nix) of building the Maven repository 85 + 86 ```nix 87 { pkgs ? import <nixpkgs> { } }: 88 with pkgs; ··· 104 │   └── 4.1.3 105 │   ├── avalon-framework-4.1.3.jar -> /nix/store/iv5fp3955w3nq28ff9xfz86wvxbiw6n9-avalon-framework-4.1.3.jar 106 ``` 107 + 108 + ### Double Invocation {#double-invocation} 109 110 > ⚠️ This pattern is the simplest but may cause unnecessary rebuilds due to the output hash changing. 111 ··· 165 166 If your package uses _SNAPSHOT_ dependencies or _version ranges_; there is a strong likelihood that over-time your output hash will change since the resolved dependencies may change. Hence this method is less recommended then using `buildMaven`. 167 168 + ## Building a JAR {#building-a-jar} 169 170 Regardless of which strategy is chosen above, the step to build the derivation is the same. 171 ··· 203 2 directories, 1 file 204 ``` 205 206 + ## Runnable JAR {#runnable-jar} 207 208 The previous example builds a `jar` file but that's not a file one can run. 209 ··· 215 216 The following two methods are more suited to Nix then building an [UberJar](https://imagej.net/Uber-JAR) which may be the more traditional approach. 217 218 + ### CLASSPATH {#classpath} 219 220 > This is ideal if you are providing a derivation for _nixpkgs_ and don't want to patch the project's `pom.xml`. 221 ··· 254 } 255 ``` 256 257 + ### MANIFEST file via Maven Plugin {#manifest-file-via-maven-plugin} 258 259 > This is ideal if you are the project owner and want to change your `pom.xml` to set the CLASSPATH within it. 260 261 Augment the `pom.xml` to create a JAR with the following manifest: 262 + 263 ```xml 264 <build> 265 <plugins>
+64 -57
doc/languages-frameworks/python.section.md
··· 1 # Python {#python} 2 3 - ## User Guide 4 5 - ### Using Python 6 7 - #### Overview 8 9 Several versions of the Python interpreter are available on Nix, as well as a 10 high amount of packages. The attribute `python3` refers to the default ··· 31 `pythonPackages` refers to `python.pkgs` and `python38Packages` to 32 `python38.pkgs`. 33 34 - #### Installing Python and packages 35 36 The Nix and NixOS manuals explain how packages are generally installed. In the 37 case of Python and Nix, it is important to make a distinction between whether the ··· 62 of development: individual projects create their own Python environments without 63 impacting the global environment or each other. 64 65 - #### Ad-hoc temporary Python environment with `nix-shell` 66 67 The simplest way to start playing with the way nix wraps and sets up Python 68 environments is with `nix-shell` at the cmdline. These environments create a ··· 131 interpreter and dependencies work in Nix and NixOS, but to do some actual 132 development, we'll want to make it a bit more persistent. 133 134 - ##### Running Python scripts and using `nix-shell` as shebang 135 136 Sometimes, we have a script whose header looks like this: 137 ··· 146 Executing this script requires a `python3` that has `numpy`. Using what we learned 147 in the previous section, we could startup a shell and just run it like so: 148 149 - ```ShellSesssion 150 $ nix-shell -p 'python38.withPackages(ps: with ps; [ numpy ])' --run 'python3 foo.py' 151 The dot product of [1 2] and [3 4] is: 11 152 ``` ··· 203 This is also a great way to ensure the script executes identically on different 204 servers. 205 206 - ##### Load environment from `.nix` expression 207 208 We've now seen how to create an ad-hoc temporary shell session, and how to 209 create a single script with Python dependencies, but in the course of normal ··· 262 like `libffi` the `openssl` in scope. This is generic and can span any number of 263 tools or languages across the Nixpkgs ecosystem. 264 265 - ##### Installing environments globally on the system 266 267 Up to now, we've been creating environments scoped to an ad-hoc shell session, 268 or a single script, or a single project. This is generally advisable, as it ··· 315 atomically *uninstall* all other imperatively installed packages and replace 316 your profile with just `myEnv` by using the `--replace` flag. 317 318 - ##### Environment defined in `/etc/nixos/configuration.nix` 319 320 For the sake of completeness, here's how to install the environment system-wide 321 on NixOS. ··· 329 } 330 ``` 331 332 - ### Developing with Python 333 334 Above, we were mostly just focused on use cases and what to do to get started 335 creating working Python environments in nix. ··· 338 back and take a deeper look at how Python packages are packaged on Nix. Then, 339 we will look at how you can use development mode with your code. 340 341 - #### Python library packages in Nixpkgs 342 343 With Nix all packages are built by functions. The main function in Nix for 344 building Python libraries is `buildPythonPackage`. Let's see how we can build the ··· 425 `toolz` from the Nixpkgs package set this time, but instead took our own version 426 that we introduced with the `let` expression. 427 428 - #### Handling dependencies 429 430 Our example, `toolz`, does not have any dependencies on other Python packages or 431 system libraries. According to the manual, `buildPythonPackage` uses the ··· 537 }; 538 } 539 ``` 540 Note also the line `doCheck = false;`, we explicitly disabled running the test-suite. 541 542 - #### Testing Python Packages 543 544 It is highly encouraged to have testing as part of the package build. This 545 helps to avoid situations where the package was able to build and install, ··· 559 as many tests should be enabled as possible. Failing tests can still be 560 a good indication that the package is not in a valid state. 561 562 - #### Using pytest 563 564 Pytest is the most common test runner for python repositories. A trivial 565 test run would be: 566 ``` 567 checkInputs = [ pytest ]; 568 checkPhase = "pytest"; ··· 572 sandbox, and will generally need many tests to be disabled. 573 574 To filter tests using pytest, one can do the following: 575 ``` 576 checkInputs = [ pytest ]; 577 # avoid tests which need additional data or touch network ··· 587 588 `-k` is used to define a predicate for test names. In this example, we are 589 filtering out tests which contain `download` or `update` in their test case name. 590 - Only one `-k` argument is allows, and thus a long predicate should be concatenated 591 - with "\" and wrapped to the next line. 592 593 - *NOTE:* In pytest==6.0.1, the use of "\" to continue a line (e.g. `-k 'not download \'`) has 594 been removed, in this case, it's recommended to use `pytestCheckHook`. 595 596 - #### Using pytestCheckHook 597 598 `pytestCheckHook` is a convenient hook which will substitute the setuptools 599 `test` command for a checkPhase which runs `pytest`. This is also beneficial 600 when a package may need many items disabled to run the test suite. 601 602 Using the example above, the analagous pytestCheckHook usage would be: 603 ``` 604 checkInputs = [ pytestCheckHook ]; 605 ··· 637 would be much harder to read. This also enables us to comment on why specific tests 638 are disabled. 639 640 - #### Using pythonImportsCheck 641 642 Although unit tests are highly prefered to validate correctness of a package, not 643 all packages have test suites that can be ran easily, and some have none at all. ··· 659 This can also be useful in verifying that the package doesn't assume commonly 660 present packages (e.g. `setuptools`) 661 662 - ### Develop local package 663 664 As a Python developer you're likely aware of [development mode](http://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode) 665 (`python setup.py develop`); instead of installing the package this command ··· 694 It is important to note that due to how development mode is implemented on Nix 695 it is not possible to have multiple packages simultaneously in development mode. 696 697 - ### Organising your packages 698 699 So far we discussed how you can use Python on Nix, and how you can develop with 700 it. We've looked at how you write expressions to package Python packages, and we ··· 706 duplication we now look at how you can maintain a repository with your 707 own packages. The important functions here are `import` and `callPackage`. 708 709 - ### Including a derivation using `callPackage` 710 711 Earlier we created a Python environment using `withPackages`, and included the 712 `toolz` package via a `let` expression. ··· 756 example we use `buildPythonPackage` that is part of the set `python38Packages`, 757 and in this case the `python38` interpreter is automatically used. 758 759 - ## Reference 760 761 - ### Interpreters 762 763 Versions 2.7, 3.6, 3.7, 3.8 and 3.9 of the CPython interpreter are available as 764 respectively `python27`, `python36`, `python37`, `python38` and `python39`. The ··· 773 `out/{python.sitePackages}` to `$PYTHONPATH` if such directory 774 exists. 775 776 - #### Missing `tkinter` module standard library 777 778 To reduce closure size the `Tkinter`/`tkinter` is available as a separate package, `pythonPackages.tkinter`. 779 780 - #### Attributes on interpreters packages 781 782 Each interpreter has the following attributes: 783 ··· 789 - `executable`. Name of the interpreter executable, e.g. `python3.8`. 790 - `pkgs`. Set of Python packages for that specific interpreter. The package set can be modified by overriding the interpreter and passing `packageOverrides`. 791 792 - ### Optimizations 793 794 The Python interpreters are by default not build with optimizations enabled, because 795 the builds are in that case not reproducible. To enable optimizations, override the ··· 806 in mypython 807 ``` 808 809 - ### Building packages and applications 810 811 Python libraries and applications that use `setuptools` or 812 `distutils` are typically built with respectively the `buildPythonPackage` and ··· 838 * `pkgs.python3Packages` pointing to `pkgs.python38Packages` 839 * `pkgs.pythonPackages` pointing to `pkgs.python2Packages` 840 841 - #### `buildPythonPackage` function 842 843 The `buildPythonPackage` function is implemented in 844 `pkgs/development/interpreters/python/mk-python-derivation` ··· 890 By default `meta.platforms` is set to the same value 891 as the interpreter unless overridden otherwise. 892 893 - ##### `buildPythonPackage` parameters 894 895 All parameters from `stdenv.mkDerivation` function are still supported. The 896 following are specific to `buildPythonPackage`: ··· 946 `buildPythonPackage` also injects code into and wraps executables with the 947 paths included in this list. Items listed in `install_requires` go here. 948 949 - ##### Overriding Python packages 950 951 The `buildPythonPackage` function has a `overridePythonAttrs` method that can be 952 used to override the package. In the following example we create an environment ··· 974 in python.withPackages(ps: [ps.blaze])).env 975 ``` 976 977 - #### `buildPythonApplication` function 978 979 The `buildPythonApplication` function is practically the same as 980 `buildPythonPackage`. The main purpose of this function is to build a Python ··· 1019 Since the package is an application, a consumer doesn't need to care about 1020 Python versions or modules, which is why they don't go in `pythonPackages`. 1021 1022 - #### `toPythonApplication` function 1023 1024 A distinction is made between applications and libraries, however, sometimes a 1025 package is used as both. In this case the package is added as a library to ··· 1031 `python-packages.nix`. A reference shall be created from `all-packages.nix` to 1032 the attribute in `python-packages.nix`, and the `toPythonApplication` shall be 1033 applied to the reference: 1034 ```nix 1035 youtube-dl = with pythonPackages; toPythonApplication youtube-dl; 1036 ``` 1037 1038 - #### `toPythonModule` function 1039 1040 In some cases, such as bindings, a package is created using 1041 `stdenv.mkDerivation` and added as attribute in `all-packages.nix`. The Python ··· 1052 1053 Do pay attention to passing in the right Python version! 1054 1055 - #### `python.buildEnv` function 1056 1057 Python environments can be created using the low-level `pkgs.buildEnv` function. 1058 This example shows how to create an environment that has the Pyramid Web Framework. ··· 1090 will drop you into a shell where Python will have the 1091 specified packages in its path. 1092 1093 1094 - ##### `python.buildEnv` arguments 1095 1096 * `extraLibs`: List of packages installed inside the environment. 1097 * `postBuild`: Shell command executed after the build of environment. ··· 1099 * `permitUserSite`: Skip setting the `PYTHONNOUSERSITE` environment variable in 1100 wrapped binaries in the environment. 1101 1102 - #### `python.withPackages` function 1103 1104 The `python.withPackages` function provides a simpler interface to the `python.buildEnv` functionality. 1105 It takes a function as an argument that is passed the set of python packages and returns the list ··· 1141 Python 2 namespace packages may provide `__init__.py` that collide. In that case 1142 `python.buildEnv` should be used with `ignoreCollisions = true`. 1143 1144 - #### Setup hooks 1145 1146 The following are setup hooks specifically for Python packages. Most of these 1147 are used in `buildPythonPackage`. ··· 1166 - `wheelUnpackHook` to move a wheel to the correct folder so it can be installed 1167 with the `pipInstallHook`. 1168 1169 - ### Development mode 1170 1171 Development or editable mode is supported. To develop Python packages 1172 `buildPythonPackage` has additional logic inside `shellPhase` to run `pip ··· 1175 Warning: `shellPhase` is executed only if `setup.py` exists. 1176 1177 Given a `default.nix`: 1178 ```nix 1179 with import <nixpkgs> {}; 1180 ··· 1197 1198 Note: There is a boolean value `lib.inNixShell` set to `true` if nix-shell is invoked. 1199 1200 - ### Tools 1201 1202 Packages inside nixpkgs are written by hand. However many tools exist in 1203 community to help save time. No tool is preferred at the moment. ··· 1209 - [nixpkgs-pytools](https://github.com/nix-community/nixpkgs-pytools) 1210 - [poetry2nix](https://github.com/nix-community/poetry2nix) 1211 1212 - ### Deterministic builds 1213 1214 The Python interpreters are now built deterministically. Minor modifications had 1215 to be made to the interpreters in order to generate deterministic bytecode. This ··· 1221 and [PYTHONHASHSEED=0](https://docs.python.org/3.8/using/cmdline.html#envvar-PYTHONHASHSEED). 1222 Both are also exported in `nix-shell`. 1223 1224 - ### Automatic tests 1225 1226 It is recommended to test packages as part of the build process. 1227 Source distributions (`sdist`) often include test files, but not always. ··· 1230 `checkPhase`, but often it is necessary to pass a custom `checkPhase`. An 1231 example of such a situation is when `py.test` is used. 1232 1233 - #### Common issues 1234 1235 * Non-working tests can often be deselected. By default `buildPythonPackage` 1236 runs `python setup.py test`. Most Python modules follows the standard test ··· 1247 ''; 1248 } 1249 ``` 1250 * Tests that attempt to access `$HOME` can be fixed by using the following 1251 work-around before running tests (e.g. `preCheck`): `export HOME=$(mktemp -d)` 1252 1253 - ## FAQ 1254 1255 - ### How to solve circular dependencies? 1256 1257 Consider the packages `A` and `B` that depend on each other. When packaging `B`, 1258 a solution is to override package `A` not to depend on `B` as an input. The same 1259 should also be done when packaging `A`. 1260 1261 - ### How to override a Python package? 1262 1263 We can override the interpreter and pass `packageOverrides`. In the following 1264 example we rename the `pandas` package and build it. ··· 1316 in newpkgs.inkscape 1317 ``` 1318 1319 - ### `python setup.py bdist_wheel` cannot create .whl 1320 1321 Executing `python setup.py bdist_wheel` in a `nix-shell `fails with 1322 ``` ··· 1349 nix-shell --run "unset SOURCE_DATE_EPOCH; python3 setup.py bdist_wheel" 1350 ``` 1351 1352 - ### `install_data` / `data_files` problems 1353 1354 If you get the following error: 1355 ··· 1369 sed -i '/ = data\_files/d' setup.py 1370 ``` 1371 1372 - ### Rationale of non-existent global site-packages 1373 1374 On most operating systems a global `site-packages` is maintained. This however 1375 becomes problematic if you want to run multiple Python versions or have multiple ··· 1384 method is to use `nix-shell`, either with or without the `python.buildEnv` 1385 function. 1386 1387 - ### How to consume Python modules using pip in a virtual environment like I am used to on other Operating Systems? 1388 1389 While this approach is not very idiomatic from Nix perspective, it can still be 1390 useful when dealing with pre-existing projects or in situations where it's not ··· 1497 requirements.txt. However these will be cached locally within the `virtualenv` 1498 folder and not downloaded again. 1499 1500 - ### How to override a Python package from `configuration.nix`? 1501 1502 If you need to change a package's attribute(s) from `configuration.nix` you could do: 1503 ··· 1535 } 1536 ``` 1537 1538 - ### How to override a Python package using overlays? 1539 1540 Use the following overlay template: 1541 ··· 1556 } 1557 ``` 1558 1559 - ### How to use Intel's MKL with numpy and scipy? 1560 1561 MKL can be configured using an overlay. See the section "[Using overlays to 1562 configure alternatives](#sec-overlays-alternatives-blas-lapack)". 1563 1564 - ### What inputs do `setup_requires`, `install_requires` and `tests_require` map to? 1565 1566 In a `setup.py` or `setup.cfg` it is common to declare dependencies: 1567 ··· 1569 * `install_requires` corresponds to `propagatedBuildInputs` 1570 * `tests_require` corresponds to `checkInputs` 1571 1572 - ## Contributing 1573 1574 - ### Contributing guidelines 1575 1576 The following rules are desired to be respected: 1577
··· 1 # Python {#python} 2 3 + ## User Guide {#user-guide} 4 5 + ### Using Python {#using-python} 6 7 + #### Overview {#overview} 8 9 Several versions of the Python interpreter are available on Nix, as well as a 10 high amount of packages. The attribute `python3` refers to the default ··· 31 `pythonPackages` refers to `python.pkgs` and `python38Packages` to 32 `python38.pkgs`. 33 34 + #### Installing Python and packages {#installing-python-and-packages} 35 36 The Nix and NixOS manuals explain how packages are generally installed. In the 37 case of Python and Nix, it is important to make a distinction between whether the ··· 62 of development: individual projects create their own Python environments without 63 impacting the global environment or each other. 64 65 + #### Ad-hoc temporary Python environment with `nix-shell` {#ad-hoc-temporary-python-environment-with-nix-shell} 66 67 The simplest way to start playing with the way nix wraps and sets up Python 68 environments is with `nix-shell` at the cmdline. These environments create a ··· 131 interpreter and dependencies work in Nix and NixOS, but to do some actual 132 development, we'll want to make it a bit more persistent. 133 134 + ##### Running Python scripts and using `nix-shell` as shebang {#running-python-scripts-and-using-nix-shell-as-shebang} 135 136 Sometimes, we have a script whose header looks like this: 137 ··· 146 Executing this script requires a `python3` that has `numpy`. Using what we learned 147 in the previous section, we could startup a shell and just run it like so: 148 149 + ```ShellSession 150 $ nix-shell -p 'python38.withPackages(ps: with ps; [ numpy ])' --run 'python3 foo.py' 151 The dot product of [1 2] and [3 4] is: 11 152 ``` ··· 203 This is also a great way to ensure the script executes identically on different 204 servers. 205 206 + ##### Load environment from `.nix` expression {#load-environment-from-.nix-expression} 207 208 We've now seen how to create an ad-hoc temporary shell session, and how to 209 create a single script with Python dependencies, but in the course of normal ··· 262 like `libffi` the `openssl` in scope. This is generic and can span any number of 263 tools or languages across the Nixpkgs ecosystem. 264 265 + ##### Installing environments globally on the system {#installing-environments-globally-on-the-system} 266 267 Up to now, we've been creating environments scoped to an ad-hoc shell session, 268 or a single script, or a single project. This is generally advisable, as it ··· 315 atomically *uninstall* all other imperatively installed packages and replace 316 your profile with just `myEnv` by using the `--replace` flag. 317 318 + ##### Environment defined in `/etc/nixos/configuration.nix` {#environment-defined-in-etcnixosconfiguration.nix} 319 320 For the sake of completeness, here's how to install the environment system-wide 321 on NixOS. ··· 329 } 330 ``` 331 332 + ### Developing with Python {#developing-with-python} 333 334 Above, we were mostly just focused on use cases and what to do to get started 335 creating working Python environments in nix. ··· 338 back and take a deeper look at how Python packages are packaged on Nix. Then, 339 we will look at how you can use development mode with your code. 340 341 + #### Python library packages in Nixpkgs {#python-library-packages-in-nixpkgs} 342 343 With Nix all packages are built by functions. The main function in Nix for 344 building Python libraries is `buildPythonPackage`. Let's see how we can build the ··· 425 `toolz` from the Nixpkgs package set this time, but instead took our own version 426 that we introduced with the `let` expression. 427 428 + #### Handling dependencies {#handling-dependencies} 429 430 Our example, `toolz`, does not have any dependencies on other Python packages or 431 system libraries. According to the manual, `buildPythonPackage` uses the ··· 537 }; 538 } 539 ``` 540 + 541 Note also the line `doCheck = false;`, we explicitly disabled running the test-suite. 542 543 + #### Testing Python Packages {#testing-python-packages} 544 545 It is highly encouraged to have testing as part of the package build. This 546 helps to avoid situations where the package was able to build and install, ··· 560 as many tests should be enabled as possible. Failing tests can still be 561 a good indication that the package is not in a valid state. 562 563 + #### Using pytest {#using-pytest} 564 565 Pytest is the most common test runner for python repositories. A trivial 566 test run would be: 567 + 568 ``` 569 checkInputs = [ pytest ]; 570 checkPhase = "pytest"; ··· 574 sandbox, and will generally need many tests to be disabled. 575 576 To filter tests using pytest, one can do the following: 577 + 578 ``` 579 checkInputs = [ pytest ]; 580 # avoid tests which need additional data or touch network ··· 590 591 `-k` is used to define a predicate for test names. In this example, we are 592 filtering out tests which contain `download` or `update` in their test case name. 593 + Only one `-k` argument is allowed, and thus a long predicate should be concatenated 594 + with “\\” and wrapped to the next line. 595 596 + *NOTE:* In pytest==6.0.1, the use of “\\” to continue a line (e.g. `-k 'not download \'`) has 597 been removed, in this case, it's recommended to use `pytestCheckHook`. 598 599 + #### Using pytestCheckHook {#using-pytestcheckhook} 600 601 `pytestCheckHook` is a convenient hook which will substitute the setuptools 602 `test` command for a checkPhase which runs `pytest`. This is also beneficial 603 when a package may need many items disabled to run the test suite. 604 605 Using the example above, the analagous pytestCheckHook usage would be: 606 + 607 ``` 608 checkInputs = [ pytestCheckHook ]; 609 ··· 641 would be much harder to read. This also enables us to comment on why specific tests 642 are disabled. 643 644 + #### Using pythonImportsCheck {#using-pythonimportscheck} 645 646 Although unit tests are highly prefered to validate correctness of a package, not 647 all packages have test suites that can be ran easily, and some have none at all. ··· 663 This can also be useful in verifying that the package doesn't assume commonly 664 present packages (e.g. `setuptools`) 665 666 + ### Develop local package {#develop-local-package} 667 668 As a Python developer you're likely aware of [development mode](http://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode) 669 (`python setup.py develop`); instead of installing the package this command ··· 698 It is important to note that due to how development mode is implemented on Nix 699 it is not possible to have multiple packages simultaneously in development mode. 700 701 + ### Organising your packages {#organising-your-packages} 702 703 So far we discussed how you can use Python on Nix, and how you can develop with 704 it. We've looked at how you write expressions to package Python packages, and we ··· 710 duplication we now look at how you can maintain a repository with your 711 own packages. The important functions here are `import` and `callPackage`. 712 713 + ### Including a derivation using `callPackage` {#including-a-derivation-using-callpackage} 714 715 Earlier we created a Python environment using `withPackages`, and included the 716 `toolz` package via a `let` expression. ··· 760 example we use `buildPythonPackage` that is part of the set `python38Packages`, 761 and in this case the `python38` interpreter is automatically used. 762 763 + ## Reference {#reference} 764 765 + ### Interpreters {#interpreters} 766 767 Versions 2.7, 3.6, 3.7, 3.8 and 3.9 of the CPython interpreter are available as 768 respectively `python27`, `python36`, `python37`, `python38` and `python39`. The ··· 777 `out/{python.sitePackages}` to `$PYTHONPATH` if such directory 778 exists. 779 780 + #### Missing `tkinter` module standard library {#missing-tkinter-module-standard-library} 781 782 To reduce closure size the `Tkinter`/`tkinter` is available as a separate package, `pythonPackages.tkinter`. 783 784 + #### Attributes on interpreters packages {#attributes-on-interpreters-packages} 785 786 Each interpreter has the following attributes: 787 ··· 793 - `executable`. Name of the interpreter executable, e.g. `python3.8`. 794 - `pkgs`. Set of Python packages for that specific interpreter. The package set can be modified by overriding the interpreter and passing `packageOverrides`. 795 796 + ### Optimizations {#optimizations} 797 798 The Python interpreters are by default not build with optimizations enabled, because 799 the builds are in that case not reproducible. To enable optimizations, override the ··· 810 in mypython 811 ``` 812 813 + ### Building packages and applications {#building-packages-and-applications} 814 815 Python libraries and applications that use `setuptools` or 816 `distutils` are typically built with respectively the `buildPythonPackage` and ··· 842 * `pkgs.python3Packages` pointing to `pkgs.python38Packages` 843 * `pkgs.pythonPackages` pointing to `pkgs.python2Packages` 844 845 + #### `buildPythonPackage` function {#buildpythonpackage-function} 846 847 The `buildPythonPackage` function is implemented in 848 `pkgs/development/interpreters/python/mk-python-derivation` ··· 894 By default `meta.platforms` is set to the same value 895 as the interpreter unless overridden otherwise. 896 897 + ##### `buildPythonPackage` parameters {#buildpythonpackage-parameters} 898 899 All parameters from `stdenv.mkDerivation` function are still supported. The 900 following are specific to `buildPythonPackage`: ··· 950 `buildPythonPackage` also injects code into and wraps executables with the 951 paths included in this list. Items listed in `install_requires` go here. 952 953 + ##### Overriding Python packages {#overriding-python-packages} 954 955 The `buildPythonPackage` function has a `overridePythonAttrs` method that can be 956 used to override the package. In the following example we create an environment ··· 978 in python.withPackages(ps: [ps.blaze])).env 979 ``` 980 981 + #### `buildPythonApplication` function {#buildpythonapplication-function} 982 983 The `buildPythonApplication` function is practically the same as 984 `buildPythonPackage`. The main purpose of this function is to build a Python ··· 1023 Since the package is an application, a consumer doesn't need to care about 1024 Python versions or modules, which is why they don't go in `pythonPackages`. 1025 1026 + #### `toPythonApplication` function {#topythonapplication-function} 1027 1028 A distinction is made between applications and libraries, however, sometimes a 1029 package is used as both. In this case the package is added as a library to ··· 1035 `python-packages.nix`. A reference shall be created from `all-packages.nix` to 1036 the attribute in `python-packages.nix`, and the `toPythonApplication` shall be 1037 applied to the reference: 1038 + 1039 ```nix 1040 youtube-dl = with pythonPackages; toPythonApplication youtube-dl; 1041 ``` 1042 1043 + #### `toPythonModule` function {#topythonmodule-function} 1044 1045 In some cases, such as bindings, a package is created using 1046 `stdenv.mkDerivation` and added as attribute in `all-packages.nix`. The Python ··· 1057 1058 Do pay attention to passing in the right Python version! 1059 1060 + #### `python.buildEnv` function {#python.buildenv-function} 1061 1062 Python environments can be created using the low-level `pkgs.buildEnv` function. 1063 This example shows how to create an environment that has the Pyramid Web Framework. ··· 1095 will drop you into a shell where Python will have the 1096 specified packages in its path. 1097 1098 + ##### `python.buildEnv` arguments {#python.buildenv-arguments} 1099 1100 1101 * `extraLibs`: List of packages installed inside the environment. 1102 * `postBuild`: Shell command executed after the build of environment. ··· 1104 * `permitUserSite`: Skip setting the `PYTHONNOUSERSITE` environment variable in 1105 wrapped binaries in the environment. 1106 1107 + #### `python.withPackages` function {#python.withpackages-function} 1108 1109 The `python.withPackages` function provides a simpler interface to the `python.buildEnv` functionality. 1110 It takes a function as an argument that is passed the set of python packages and returns the list ··· 1146 Python 2 namespace packages may provide `__init__.py` that collide. In that case 1147 `python.buildEnv` should be used with `ignoreCollisions = true`. 1148 1149 + #### Setup hooks {#setup-hooks} 1150 1151 The following are setup hooks specifically for Python packages. Most of these 1152 are used in `buildPythonPackage`. ··· 1171 - `wheelUnpackHook` to move a wheel to the correct folder so it can be installed 1172 with the `pipInstallHook`. 1173 1174 + ### Development mode {#development-mode} 1175 1176 Development or editable mode is supported. To develop Python packages 1177 `buildPythonPackage` has additional logic inside `shellPhase` to run `pip ··· 1180 Warning: `shellPhase` is executed only if `setup.py` exists. 1181 1182 Given a `default.nix`: 1183 + 1184 ```nix 1185 with import <nixpkgs> {}; 1186 ··· 1203 1204 Note: There is a boolean value `lib.inNixShell` set to `true` if nix-shell is invoked. 1205 1206 + ### Tools {#tools} 1207 1208 Packages inside nixpkgs are written by hand. However many tools exist in 1209 community to help save time. No tool is preferred at the moment. ··· 1215 - [nixpkgs-pytools](https://github.com/nix-community/nixpkgs-pytools) 1216 - [poetry2nix](https://github.com/nix-community/poetry2nix) 1217 1218 + ### Deterministic builds {#deterministic-builds} 1219 1220 The Python interpreters are now built deterministically. Minor modifications had 1221 to be made to the interpreters in order to generate deterministic bytecode. This ··· 1227 and [PYTHONHASHSEED=0](https://docs.python.org/3.8/using/cmdline.html#envvar-PYTHONHASHSEED). 1228 Both are also exported in `nix-shell`. 1229 1230 + ### Automatic tests {#automatic-tests} 1231 1232 It is recommended to test packages as part of the build process. 1233 Source distributions (`sdist`) often include test files, but not always. ··· 1236 `checkPhase`, but often it is necessary to pass a custom `checkPhase`. An 1237 example of such a situation is when `py.test` is used. 1238 1239 + #### Common issues {#common-issues} 1240 1241 * Non-working tests can often be deselected. By default `buildPythonPackage` 1242 runs `python setup.py test`. Most Python modules follows the standard test ··· 1253 ''; 1254 } 1255 ``` 1256 + 1257 * Tests that attempt to access `$HOME` can be fixed by using the following 1258 work-around before running tests (e.g. `preCheck`): `export HOME=$(mktemp -d)` 1259 1260 + ## FAQ {#faq} 1261 1262 + ### How to solve circular dependencies? {#how-to-solve-circular-dependencies} 1263 1264 Consider the packages `A` and `B` that depend on each other. When packaging `B`, 1265 a solution is to override package `A` not to depend on `B` as an input. The same 1266 should also be done when packaging `A`. 1267 1268 + ### How to override a Python package? {#how-to-override-a-python-package} 1269 1270 We can override the interpreter and pass `packageOverrides`. In the following 1271 example we rename the `pandas` package and build it. ··· 1323 in newpkgs.inkscape 1324 ``` 1325 1326 + ### `python setup.py bdist_wheel` cannot create .whl {#python-setup.py-bdist_wheel-cannot-create-.whl} 1327 1328 Executing `python setup.py bdist_wheel` in a `nix-shell `fails with 1329 ``` ··· 1356 nix-shell --run "unset SOURCE_DATE_EPOCH; python3 setup.py bdist_wheel" 1357 ``` 1358 1359 + ### `install_data` / `data_files` problems {#install_data-data_files-problems} 1360 1361 If you get the following error: 1362 ··· 1376 sed -i '/ = data\_files/d' setup.py 1377 ``` 1378 1379 + ### Rationale of non-existent global site-packages {#rationale-of-non-existent-global-site-packages} 1380 1381 On most operating systems a global `site-packages` is maintained. This however 1382 becomes problematic if you want to run multiple Python versions or have multiple ··· 1391 method is to use `nix-shell`, either with or without the `python.buildEnv` 1392 function. 1393 1394 + ### How to consume Python modules using pip in a virtual environment like I am used to on other Operating Systems? {#how-to-consume-python-modules-using-pip-in-a-virtual-environment-like-i-am-used-to-on-other-operating-systems} 1395 1396 While this approach is not very idiomatic from Nix perspective, it can still be 1397 useful when dealing with pre-existing projects or in situations where it's not ··· 1504 requirements.txt. However these will be cached locally within the `virtualenv` 1505 folder and not downloaded again. 1506 1507 + ### How to override a Python package from `configuration.nix`? {#how-to-override-a-python-package-from-configuration.nix} 1508 1509 If you need to change a package's attribute(s) from `configuration.nix` you could do: 1510 ··· 1542 } 1543 ``` 1544 1545 + ### How to override a Python package using overlays? {#how-to-override-a-python-package-using-overlays} 1546 1547 Use the following overlay template: 1548 ··· 1563 } 1564 ``` 1565 1566 + ### How to use Intel’s MKL with numpy and scipy? {#how-to-use-intels-mkl-with-numpy-and-scipy} 1567 1568 MKL can be configured using an overlay. See the section "[Using overlays to 1569 configure alternatives](#sec-overlays-alternatives-blas-lapack)". 1570 1571 + ### What inputs do `setup_requires`, `install_requires` and `tests_require` map to? {#what-inputs-do-setup_requires-install_requires-and-tests_require-map-to} 1572 1573 In a `setup.py` or `setup.cfg` it is common to declare dependencies: 1574 ··· 1576 * `install_requires` corresponds to `propagatedBuildInputs` 1577 * `tests_require` corresponds to `checkInputs` 1578 1579 + ## Contributing {#contributing} 1580 1581 + ### Contributing guidelines {#contributing-guidelines} 1582 1583 The following rules are desired to be respected: 1584
+8 -3
doc/languages-frameworks/qt.section.md
··· 90 } 91 ``` 92 93 - ::: note 94 `wrapQtAppsHook` ignores files that are non-ELF executables. 95 This means that scripts won't be automatically wrapped so you'll need to manually wrap them as previously mentioned. 96 An example of when you'd always need to do this is with Python applications that use PyQt. 97 ::: 98 99 - ## Adding a library to Nixpkgs 100 Add Qt libraries to `qt5-packages.nix` to make them available for every 101 supported Qt version. 102 103 ### Example adding a Qt library {#qt-library-all-packages-nix} 104 105 The following represents the contents of `qt5-packages.nix`. 106 ```nix 107 { 108 # ... ··· 126 } 127 ``` 128 129 - ## Adding an application to Nixpkgs 130 Add Qt applications to `qt5-packages.nix`. Add an alias to `all-packages.nix` 131 to select the Qt 5 version used for the application. 132 133 ### Example adding a Qt application {#qt-application-all-packages-nix} 134 135 The following represents the contents of `qt5-packages.nix`. 136 ```nix 137 { 138 # ... ··· 144 ``` 145 146 The following represents the contents of `all-packages.nix`. 147 ```nix 148 { 149 # ...
··· 90 } 91 ``` 92 93 + ::: {.note} 94 `wrapQtAppsHook` ignores files that are non-ELF executables. 95 This means that scripts won't be automatically wrapped so you'll need to manually wrap them as previously mentioned. 96 An example of when you'd always need to do this is with Python applications that use PyQt. 97 ::: 98 99 + ## Adding a library to Nixpkgs {#adding-a-library-to-nixpkgs} 100 + 101 Add Qt libraries to `qt5-packages.nix` to make them available for every 102 supported Qt version. 103 104 ### Example adding a Qt library {#qt-library-all-packages-nix} 105 106 The following represents the contents of `qt5-packages.nix`. 107 + 108 ```nix 109 { 110 # ... ··· 128 } 129 ``` 130 131 + ## Adding an application to Nixpkgs {#adding-an-application-to-nixpkgs} 132 + 133 Add Qt applications to `qt5-packages.nix`. Add an alias to `all-packages.nix` 134 to select the Qt 5 version used for the application. 135 136 ### Example adding a Qt application {#qt-application-all-packages-nix} 137 138 The following represents the contents of `qt5-packages.nix`. 139 + 140 ```nix 141 { 142 # ... ··· 148 ``` 149 150 The following represents the contents of `all-packages.nix`. 151 + 152 ```nix 153 { 154 # ...
+5 -5
doc/languages-frameworks/r.section.md
··· 1 # R {#r} 2 3 - ## Installation 4 5 Define an environment for R that contains all the libraries that you'd like to 6 use by adding the following snippet to your $HOME/.config/nixpkgs/config.nix file: ··· 31 However, if you'd like to add a file to your project source to make the 32 environment available for other contributors, you can create a `default.nix` 33 file like so: 34 ```nix 35 with import <nixpkgs> {}; 36 { ··· 50 and then run `nix-shell .` to be dropped into a shell with those packages 51 available. 52 53 - ## RStudio 54 55 RStudio uses a standard set of packages and ignores any custom R 56 environments or installed packages you may have. To create a custom ··· 93 one above. If you need additional packages just add them to the list and 94 re-enter the shell. 95 96 - ## Updating the package set 97 98 ```bash 99 nix-shell generate-shell.nix ··· 113 114 `generate-r-packages.R <repo>` reads `<repo>-packages.nix`, therefor the renaming. 115 116 - 117 - ## Testing if the Nix-expression could be evaluated 118 119 ```bash 120 nix-build test-evaluation.nix --dry-run
··· 1 # R {#r} 2 3 + ## Installation {#installation} 4 5 Define an environment for R that contains all the libraries that you'd like to 6 use by adding the following snippet to your $HOME/.config/nixpkgs/config.nix file: ··· 31 However, if you'd like to add a file to your project source to make the 32 environment available for other contributors, you can create a `default.nix` 33 file like so: 34 + 35 ```nix 36 with import <nixpkgs> {}; 37 { ··· 51 and then run `nix-shell .` to be dropped into a shell with those packages 52 available. 53 54 + ## RStudio {#rstudio} 55 56 RStudio uses a standard set of packages and ignores any custom R 57 environments or installed packages you may have. To create a custom ··· 94 one above. If you need additional packages just add them to the list and 95 re-enter the shell. 96 97 + ## Updating the package set {#updating-the-package-set} 98 99 ```bash 100 nix-shell generate-shell.nix ··· 114 115 `generate-r-packages.R <repo>` reads `<repo>-packages.nix`, therefor the renaming. 116 117 + ## Testing if the Nix-expression could be evaluated {#testing-if-the-nix-expression-could-be-evaluated} 118 119 ```bash 120 nix-build test-evaluation.nix --dry-run
+11 -11
doc/languages-frameworks/ruby.section.md
··· 1 # Ruby {#sec-language-ruby} 2 3 - ## Using Ruby 4 5 Several versions of Ruby interpreters are available on Nix, as well as over 250 gems and many applications written in Ruby. The attribute `ruby` refers to the default Ruby interpreter, which is currently MRI 2.6. It's also possible to refer to specific versions, e.g. `ruby_2_y`, `jruby`, or `mruby`. 6 ··· 12 13 Since not all gems have executables like `nokogiri`, it's usually more convenient to use the `withPackages` function like this: `ruby.withPackages (p: with p; [ nokogiri ])`. This will also make sure that the Ruby in your environment will be able to find the gem and it can be used in your Ruby code (for example via `ruby` or `irb` executables) via `require "nokogiri"` as usual. 14 15 - ### Temporary Ruby environment with `nix-shell` 16 17 Rather than having a single Ruby environment shared by all Ruby development projects on a system, Nix allows you to create separate environments per project. `nix-shell` gives you the possibility to temporarily load another environment akin to a combined `chruby` or `rvm` and `bundle exec`. 18 ··· 30 31 Again, it's possible to launch the interpreter from the shell. The Ruby interpreter has the attribute `gems` which contains all Ruby gems for that specific interpreter. 32 33 - #### Load Ruby environment from `.nix` expression 34 35 As explained in the Nix manual, `nix-shell` can also load an expression from a `.nix` file. Say we want to have Ruby 2.6, `nokogori`, and `pry`. Consider a `shell.nix` file with: 36 ··· 45 2. Then we create a Ruby environment with the `withPackages` function. 46 3. The `withPackages` function expects us to provide a function as an argument that takes the set of all ruby gems and returns a list of packages to include in the environment. Here, we select the packages `nokogiri` and `pry` from the package set. 47 48 - #### Execute command with `--run` 49 50 A convenient flag for `nix-shell` is `--run`. It executes a command in the `nix-shell`. We can e.g. directly open a `pry` REPL: 51 ··· 65 $ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --run "ruby example.rb" 66 ``` 67 68 - #### Using `nix-shell` as shebang 69 70 In fact, for the last case, there is a more convenient method. You can add a [shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>) to your script specifying which dependencies `nix-shell` needs. With the following shebang, you can just execute `./example.rb`, and it will run with all dependencies. 71 ··· 80 puts Nokogiri::HTML(body).at('h1').text 81 ``` 82 83 - ## Developing with Ruby 84 85 - ### Using an existing Gemfile 86 87 In most cases, you'll already have a `Gemfile.lock` listing all your dependencies. This can be used to generate a `gemset.nix` which is used to fetch the gems and combine them into a single environment. The reason why you need to have a separate file for this, is that Nix requires you to have a checksum for each input to your build. Since the `Gemfile.lock` that `bundler` generates doesn't provide us with checksums, we have to first download each gem, calculate its SHA256, and store it in this separate file. 88 ··· 120 mkShell { buildInputs = [ gems (lowPrio gems.wrappedRuby) ]; } 121 ``` 122 123 - ### Gem-specific configurations and workarounds 124 125 In some cases, especially if the gem has native extensions, you might need to modify the way the gem is built. 126 ··· 201 202 Of course for this use-case one could also use overlays since the configuration for `pg` depends on the `postgresql` alias, but for demonstration purposes this has to suffice. 203 204 - ### Adding a gem to the default gemset 205 206 Now that you know how to get a working Ruby environment with Nix, it's time to go forward and start actually developing with Ruby. We will first have a look at how Ruby gems are packaged on Nix. Then, we will look at how you can use development mode with your code. 207 ··· 215 NIX_PATH=nixpkgs=$PWD nix-shell -p "ruby.withPackages (ps: with ps; [ name-of-your-gem ])" 216 ``` 217 218 - ### Packaging applications 219 220 A common task is to add a ruby executable to nixpkgs, popular examples would be `chef`, `jekyll`, or `sass`. A good way to do that is to use the `bundlerApp` function, that allows you to make a package that only exposes the listed executables, otherwise the package may cause conflicts through common paths like `bin/rake` or `bin/bundler` that aren't meant to be used. 221 ··· 243 244 All that's left to do is to generate the corresponding `Gemfile.lock` and `gemset.nix` as described above in the `Using an existing Gemfile` section. 245 246 - #### Packaging executables that require wrapping 247 248 Sometimes your app will depend on other executables at runtime, and tries to find it through the `PATH` environment variable. 249
··· 1 # Ruby {#sec-language-ruby} 2 3 + ## Using Ruby {#using-ruby} 4 5 Several versions of Ruby interpreters are available on Nix, as well as over 250 gems and many applications written in Ruby. The attribute `ruby` refers to the default Ruby interpreter, which is currently MRI 2.6. It's also possible to refer to specific versions, e.g. `ruby_2_y`, `jruby`, or `mruby`. 6 ··· 12 13 Since not all gems have executables like `nokogiri`, it's usually more convenient to use the `withPackages` function like this: `ruby.withPackages (p: with p; [ nokogiri ])`. This will also make sure that the Ruby in your environment will be able to find the gem and it can be used in your Ruby code (for example via `ruby` or `irb` executables) via `require "nokogiri"` as usual. 14 15 + ### Temporary Ruby environment with `nix-shell` {#temporary-ruby-environment-with-nix-shell} 16 17 Rather than having a single Ruby environment shared by all Ruby development projects on a system, Nix allows you to create separate environments per project. `nix-shell` gives you the possibility to temporarily load another environment akin to a combined `chruby` or `rvm` and `bundle exec`. 18 ··· 30 31 Again, it's possible to launch the interpreter from the shell. The Ruby interpreter has the attribute `gems` which contains all Ruby gems for that specific interpreter. 32 33 + #### Load Ruby environment from `.nix` expression {#load-ruby-environment-from-.nix-expression} 34 35 As explained in the Nix manual, `nix-shell` can also load an expression from a `.nix` file. Say we want to have Ruby 2.6, `nokogori`, and `pry`. Consider a `shell.nix` file with: 36 ··· 45 2. Then we create a Ruby environment with the `withPackages` function. 46 3. The `withPackages` function expects us to provide a function as an argument that takes the set of all ruby gems and returns a list of packages to include in the environment. Here, we select the packages `nokogiri` and `pry` from the package set. 47 48 + #### Execute command with `--run` {#execute-command-with---run} 49 50 A convenient flag for `nix-shell` is `--run`. It executes a command in the `nix-shell`. We can e.g. directly open a `pry` REPL: 51 ··· 65 $ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --run "ruby example.rb" 66 ``` 67 68 + #### Using `nix-shell` as shebang {#using-nix-shell-as-shebang} 69 70 In fact, for the last case, there is a more convenient method. You can add a [shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>) to your script specifying which dependencies `nix-shell` needs. With the following shebang, you can just execute `./example.rb`, and it will run with all dependencies. 71 ··· 80 puts Nokogiri::HTML(body).at('h1').text 81 ``` 82 83 + ## Developing with Ruby {#developing-with-ruby} 84 85 + ### Using an existing Gemfile {#using-an-existing-gemfile} 86 87 In most cases, you'll already have a `Gemfile.lock` listing all your dependencies. This can be used to generate a `gemset.nix` which is used to fetch the gems and combine them into a single environment. The reason why you need to have a separate file for this, is that Nix requires you to have a checksum for each input to your build. Since the `Gemfile.lock` that `bundler` generates doesn't provide us with checksums, we have to first download each gem, calculate its SHA256, and store it in this separate file. 88 ··· 120 mkShell { buildInputs = [ gems (lowPrio gems.wrappedRuby) ]; } 121 ``` 122 123 + ### Gem-specific configurations and workarounds {#gem-specific-configurations-and-workarounds} 124 125 In some cases, especially if the gem has native extensions, you might need to modify the way the gem is built. 126 ··· 201 202 Of course for this use-case one could also use overlays since the configuration for `pg` depends on the `postgresql` alias, but for demonstration purposes this has to suffice. 203 204 + ### Adding a gem to the default gemset {#adding-a-gem-to-the-default-gemset} 205 206 Now that you know how to get a working Ruby environment with Nix, it's time to go forward and start actually developing with Ruby. We will first have a look at how Ruby gems are packaged on Nix. Then, we will look at how you can use development mode with your code. 207 ··· 215 NIX_PATH=nixpkgs=$PWD nix-shell -p "ruby.withPackages (ps: with ps; [ name-of-your-gem ])" 216 ``` 217 218 + ### Packaging applications {#packaging-applications} 219 220 A common task is to add a ruby executable to nixpkgs, popular examples would be `chef`, `jekyll`, or `sass`. A good way to do that is to use the `bundlerApp` function, that allows you to make a package that only exposes the listed executables, otherwise the package may cause conflicts through common paths like `bin/rake` or `bin/bundler` that aren't meant to be used. 221 ··· 243 244 All that's left to do is to generate the corresponding `Gemfile.lock` and `gemset.nix` as described above in the `Using an existing Gemfile` section. 245 246 + #### Packaging executables that require wrapping {#packaging-executables-that-require-wrapping} 247 248 Sometimes your app will depend on other executables at runtime, and tries to find it through the `PATH` environment variable. 249
+59 -43
doc/languages-frameworks/rust.section.md
··· 15 use either `rustup` from nixpkgs (which will manage the rust installation in your home directory), 16 or use Mozilla's [Rust nightlies overlay](#using-the-rust-nightlies-overlay). 17 18 - ## Compiling Rust applications with Cargo 19 20 Rust applications are packaged by using the `buildRustPackage` helper from `rustPlatform`: 21 ··· 107 } 108 ``` 109 110 - ### Importing a `Cargo.lock` file 111 112 Using `cargoSha256` or `cargoHash` is tedious when using 113 `buildRustPackage` within a project, since it requires that the hash ··· 156 `lib.fakeHash` as a stub hash. Building the package (and thus the 157 vendored dependencies) will then inform you of the correct hash. 158 159 - ### Cross compilation 160 161 By default, Rust packages are compiled for the host platform, just like any 162 other package is. The `--target` passed to rust tools is computed from this. ··· 168 name will be used instead. 169 170 For example: 171 ```nix 172 import <nixpkgs> { 173 crossSystem = (import <nixpkgs/lib>).systems.examples.armhf-embedded // { ··· 175 }; 176 } 177 ``` 178 will result in: 179 ```shell 180 --target thumbv7em-none-eabi 181 ``` ··· 188 will be used instead. 189 190 For example: 191 ```nix 192 import <nixpkgs> { 193 crossSystem = (import <nixpkgs/lib>).systems.examples.armhf-embedded // { ··· 196 }; 197 } 198 ``` 199 will result in: 200 ```shell 201 --target /nix/store/asdfasdfsadf-thumb-crazy.json # contains {"foo":"","bar":""} 202 ``` ··· 220 Note that currently custom targets aren't compiled with `std`, so `cargo test` 221 will fail. This can be ignored by adding `doCheck = false;` to your derivation. 222 223 - ### Running package tests 224 225 When using `buildRustPackage`, the `checkPhase` is enabled by default and runs 226 `cargo test` on the package to build. To make sure that we don't compile the ··· 248 binary itself, as stated 249 (here)[https://doc.rust-lang.org/cargo/commands/cargo-test.html]. 250 251 - #### Tests relying on the structure of the `target/` directory 252 253 Some tests may rely on the structure of the `target/` directory. Those tests 254 are likely to fail because we use `cargo --target` during the build. This means that ··· 258 259 This can only be worked around by patching the affected tests accordingly. 260 261 - #### Disabling package-tests 262 263 In some instances, it may be necessary to disable testing altogether (with `doCheck = false;`): 264 ··· 272 However, please check if it's possible to disable a problematic subset of the 273 test suite and leave a comment explaining your reasoning. 274 275 - #### Setting `test-threads` 276 277 `buildRustPackage` will use parallel test threads by default, 278 sometimes it may be necessary to disable this so the tests run consecutively. ··· 284 } 285 ``` 286 287 - ### Building a package in `debug` mode 288 289 By default, `buildRustPackage` will use `release` mode for builds. If a package 290 should be built in `debug` mode, it can be configured like so: ··· 298 299 In this scenario, the `checkPhase` will be ran in `debug` mode as well. 300 301 - ### Custom `build`/`install`-procedures 302 303 Some packages may use custom scripts for building/installing, e.g. with a `Makefile`. 304 In these cases, it's recommended to override the `buildPhase`/`installPhase`/`checkPhase`. 305 306 Otherwise, some steps may fail because of the modified directory structure of `target/`. 307 308 - ### Building a crate with an absent or out-of-date Cargo.lock file 309 310 `buildRustPackage` needs a `Cargo.lock` file to get all dependencies in the 311 source code in a reproducible way. If it is missing or out-of-date one can use ··· 321 } 322 ``` 323 324 - ## Compiling non-Rust packages that include Rust code 325 326 Several non-Rust packages incorporate Rust code for performance- or 327 security-sensitive parts. `rustPlatform` exposes several functions and 328 hooks that can be used to integrate Cargo in non-Rust packages. 329 330 - ### Vendoring of dependencies 331 332 Since network access is not allowed in sandboxed builds, Rust crate 333 dependencies need to be retrieved using a fetcher. `rustPlatform` ··· 387 `lib.fakeHash` as a stub hash. Building `cargoDeps` will then inform 388 you of the correct hash. 389 390 - ### Hooks 391 392 `rustPlatform` provides the following hooks to automate Cargo builds: 393 ··· 416 * `cargoInstallHook`: install binaries and static/shared libraries 417 that were built using `cargoBuildHook`. 418 419 - ### Examples 420 421 - #### Python package using `setuptools-rust` 422 423 For Python packages using `setuptools-rust`, you can use 424 `fetchCargoTarball` and `cargoSetupHook` to retrieve and set up Cargo ··· 504 } 505 ``` 506 507 - #### Python package using `maturin` 508 509 Python packages that use [Maturin](https://github.com/PyO3/maturin) 510 can be built with `fetchCargoTarball`, `cargoSetupHook`, and ··· 545 } 546 ``` 547 548 - ## Compiling Rust crates using Nix instead of Cargo 549 550 - ### Simple operation 551 552 When run, `cargo build` produces a file called `Cargo.lock`, 553 containing pinned versions of all dependencies. Nixpkgs contains a ··· 558 and can be used to compile a crate and all its dependencies. Here is 559 an example for a minimal `hello` crate: 560 561 - 562 - $ cargo new hello 563 - $ cd hello 564 - $ cargo build 565 Compiling hello v0.1.0 (file:///tmp/hello) 566 - Finished dev [unoptimized + debuginfo] target(s) in 0.20 secs 567 - $ carnix -o hello.nix --src ./. Cargo.lock --standalone 568 - $ nix-build hello.nix -A hello_0_1_0 569 570 Now, the file produced by the call to `carnix`, called `hello.nix`, looks like: 571 ··· 644 will fetch it from [crates.io](https://crates.io). A `sha256` 645 attribute is still needed for Nix purity. 646 647 - ### Handling external dependencies 648 649 Some crates require external libraries. For crates from 650 [crates.io](https://crates.io), such libraries can be specified in ··· 703 } 704 ``` 705 706 - ### Options and phases configuration 707 708 Actually, the overrides introduced in the previous section are more 709 general. A number of other parameters can be overridden: ··· 750 }; 751 ``` 752 753 - ### Features 754 755 One can also supply features switches. For example, if we want to 756 compile `diesel_cli` only with the `postgres` feature, and no default ··· 765 766 Where `diesel.nix` is the file generated by Carnix, as explained above. 767 768 769 - ## Setting Up `nix-shell` 770 Oftentimes you want to develop code from within `nix-shell`. Unfortunately 771 `buildRustCrate` does not support common `nix-shell` operations directly 772 (see [this issue](https://github.com/NixOS/nixpkgs/issues/37945)) 773 so we will use `stdenv.mkDerivation` instead. 774 775 Using the example `hello` project above, we want to do the following: 776 - Have access to `cargo` and `rustc` 777 - Have the `openssl` library available to a crate through it's _normal_ 778 compilation mechanism (`pkg-config`). ··· 801 ``` 802 803 You should now be able to run the following: 804 - ```ShellSesssion 805 $ nix-shell --pure 806 $ cargo build 807 $ cargo test 808 ``` 809 810 - ### Controlling Rust Version Inside `nix-shell` 811 To control your rust version (i.e. use nightly) from within `shell.nix` (or 812 other nix expressions) you can use the following `shell.nix` 813 ··· 839 ``` 840 841 Now run: 842 ```ShellSession 843 $ rustc --version 844 rustc 1.26.0-nightly (188e693b3 2018-03-26) ··· 846 847 To see that you are using nightly. 848 849 - 850 - ## Using the Rust nightlies overlay 851 852 Mozilla provides an overlay for nixpkgs to bring a nightly version of Rust into scope. 853 This overlay can _also_ be used to install recent unstable or stable versions 854 of Rust, if desired. 855 856 - ### Rust overlay installation 857 858 You can use this overlay by either changing your local nixpkgs configuration, 859 or by adding the overlay declaratively in a nix expression, e.g. in `configuration.nix`. 860 - For more information see [#sec-overlays-install](the manual on installing overlays). 861 862 - #### Imperative rust overlay installation 863 864 Clone [nixpkgs-mozilla](https://github.com/mozilla/nixpkgs-mozilla), 865 and create a symbolic link to the file 866 [rust-overlay.nix](https://github.com/mozilla/nixpkgs-mozilla/blob/master/rust-overlay.nix) 867 in the `~/.config/nixpkgs/overlays` directory. 868 869 - $ git clone https://github.com/mozilla/nixpkgs-mozilla.git 870 - $ mkdir -p ~/.config/nixpkgs/overlays 871 - $ ln -s $(pwd)/nixpkgs-mozilla/rust-overlay.nix ~/.config/nixpkgs/overlays/rust-overlay.nix 872 873 - ### Declarative rust overlay installation 874 875 Add the following to your `configuration.nix`, `home-configuration.nix`, `shell.nix`, or similar: 876 ··· 886 887 Note that this will fetch the latest overlay version when rebuilding your system. 888 889 - ### Rust overlay usage 890 891 The overlay contains attribute sets corresponding to different versions of the rust toolchain, such as: 892 ··· 900 901 Imperatively, the latest stable version can be installed with the following command: 902 903 - $ nix-env -Ai nixpkgs.latest.rustChannels.stable.rust 904 905 Or using the attribute with nix-shell: 906 907 - $ nix-shell -p nixpkgs.latest.rustChannels.stable.rust 908 909 Substitute the `nixpkgs` prefix with `nixos` on NixOS. 910 To install the beta or nightly channel, "stable" should be substituted by
··· 15 use either `rustup` from nixpkgs (which will manage the rust installation in your home directory), 16 or use Mozilla's [Rust nightlies overlay](#using-the-rust-nightlies-overlay). 17 18 + ## Compiling Rust applications with Cargo {#compiling-rust-applications-with-cargo} 19 20 Rust applications are packaged by using the `buildRustPackage` helper from `rustPlatform`: 21 ··· 107 } 108 ``` 109 110 + ### Importing a `Cargo.lock` file {#importing-a-cargo.lock-file} 111 112 Using `cargoSha256` or `cargoHash` is tedious when using 113 `buildRustPackage` within a project, since it requires that the hash ··· 156 `lib.fakeHash` as a stub hash. Building the package (and thus the 157 vendored dependencies) will then inform you of the correct hash. 158 159 + ### Cross compilation {#cross-compilation} 160 161 By default, Rust packages are compiled for the host platform, just like any 162 other package is. The `--target` passed to rust tools is computed from this. ··· 168 name will be used instead. 169 170 For example: 171 + 172 ```nix 173 import <nixpkgs> { 174 crossSystem = (import <nixpkgs/lib>).systems.examples.armhf-embedded // { ··· 176 }; 177 } 178 ``` 179 + 180 will result in: 181 + 182 ```shell 183 --target thumbv7em-none-eabi 184 ``` ··· 191 will be used instead. 192 193 For example: 194 + 195 ```nix 196 import <nixpkgs> { 197 crossSystem = (import <nixpkgs/lib>).systems.examples.armhf-embedded // { ··· 200 }; 201 } 202 ``` 203 + 204 will result in: 205 + 206 ```shell 207 --target /nix/store/asdfasdfsadf-thumb-crazy.json # contains {"foo":"","bar":""} 208 ``` ··· 226 Note that currently custom targets aren't compiled with `std`, so `cargo test` 227 will fail. This can be ignored by adding `doCheck = false;` to your derivation. 228 229 + ### Running package tests {#running-package-tests} 230 231 When using `buildRustPackage`, the `checkPhase` is enabled by default and runs 232 `cargo test` on the package to build. To make sure that we don't compile the ··· 254 binary itself, as stated 255 (here)[https://doc.rust-lang.org/cargo/commands/cargo-test.html]. 256 257 + #### Tests relying on the structure of the `target/` directory {#tests-relying-on-the-structure-of-the-target-directory} 258 259 Some tests may rely on the structure of the `target/` directory. Those tests 260 are likely to fail because we use `cargo --target` during the build. This means that ··· 264 265 This can only be worked around by patching the affected tests accordingly. 266 267 + #### Disabling package-tests {#disabling-package-tests} 268 269 In some instances, it may be necessary to disable testing altogether (with `doCheck = false;`): 270 ··· 278 However, please check if it's possible to disable a problematic subset of the 279 test suite and leave a comment explaining your reasoning. 280 281 + #### Setting `test-threads` {#setting-test-threads} 282 283 `buildRustPackage` will use parallel test threads by default, 284 sometimes it may be necessary to disable this so the tests run consecutively. ··· 290 } 291 ``` 292 293 + ### Building a package in `debug` mode {#building-a-package-in-debug-mode} 294 295 By default, `buildRustPackage` will use `release` mode for builds. If a package 296 should be built in `debug` mode, it can be configured like so: ··· 304 305 In this scenario, the `checkPhase` will be ran in `debug` mode as well. 306 307 + ### Custom `build`/`install`-procedures {#custom-buildinstall-procedures} 308 309 Some packages may use custom scripts for building/installing, e.g. with a `Makefile`. 310 In these cases, it's recommended to override the `buildPhase`/`installPhase`/`checkPhase`. 311 312 Otherwise, some steps may fail because of the modified directory structure of `target/`. 313 314 + ### Building a crate with an absent or out-of-date Cargo.lock file {#building-a-crate-with-an-absent-or-out-of-date-cargo.lock-file} 315 316 `buildRustPackage` needs a `Cargo.lock` file to get all dependencies in the 317 source code in a reproducible way. If it is missing or out-of-date one can use ··· 327 } 328 ``` 329 330 + ## Compiling non-Rust packages that include Rust code {#compiling-non-rust-packages-that-include-rust-code} 331 332 Several non-Rust packages incorporate Rust code for performance- or 333 security-sensitive parts. `rustPlatform` exposes several functions and 334 hooks that can be used to integrate Cargo in non-Rust packages. 335 336 + ### Vendoring of dependencies {#vendoring-of-dependencies} 337 338 Since network access is not allowed in sandboxed builds, Rust crate 339 dependencies need to be retrieved using a fetcher. `rustPlatform` ··· 393 `lib.fakeHash` as a stub hash. Building `cargoDeps` will then inform 394 you of the correct hash. 395 396 + ### Hooks {#hooks} 397 398 `rustPlatform` provides the following hooks to automate Cargo builds: 399 ··· 422 * `cargoInstallHook`: install binaries and static/shared libraries 423 that were built using `cargoBuildHook`. 424 425 + ### Examples {#examples} 426 427 + #### Python package using `setuptools-rust` {#python-package-using-setuptools-rust} 428 429 For Python packages using `setuptools-rust`, you can use 430 `fetchCargoTarball` and `cargoSetupHook` to retrieve and set up Cargo ··· 510 } 511 ``` 512 513 + #### Python package using `maturin` {#python-package-using-maturin} 514 515 Python packages that use [Maturin](https://github.com/PyO3/maturin) 516 can be built with `fetchCargoTarball`, `cargoSetupHook`, and ··· 551 } 552 ``` 553 554 + ## Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo} 555 556 + ### Simple operation {#simple-operation} 557 558 When run, `cargo build` produces a file called `Cargo.lock`, 559 containing pinned versions of all dependencies. Nixpkgs contains a ··· 564 and can be used to compile a crate and all its dependencies. Here is 565 an example for a minimal `hello` crate: 566 567 + ```ShellSession 568 + $ cargo new hello 569 + $ cd hello 570 + $ cargo build 571 Compiling hello v0.1.0 (file:///tmp/hello) 572 + Finished dev [unoptimized + debuginfo] target(s) in 0.20 secs 573 + $ carnix -o hello.nix --src ./. Cargo.lock --standalone 574 + $ nix-build hello.nix -A hello_0_1_0 575 + ``` 576 577 Now, the file produced by the call to `carnix`, called `hello.nix`, looks like: 578 ··· 651 will fetch it from [crates.io](https://crates.io). A `sha256` 652 attribute is still needed for Nix purity. 653 654 + ### Handling external dependencies {#handling-external-dependencies} 655 656 Some crates require external libraries. For crates from 657 [crates.io](https://crates.io), such libraries can be specified in ··· 710 } 711 ``` 712 713 + ### Options and phases configuration {#options-and-phases-configuration} 714 715 Actually, the overrides introduced in the previous section are more 716 general. A number of other parameters can be overridden: ··· 757 }; 758 ``` 759 760 + ### Features {#features} 761 762 One can also supply features switches. For example, if we want to 763 compile `diesel_cli` only with the `postgres` feature, and no default ··· 772 773 Where `diesel.nix` is the file generated by Carnix, as explained above. 774 775 + ## Setting Up `nix-shell` {#setting-up-nix-shell} 776 777 Oftentimes you want to develop code from within `nix-shell`. Unfortunately 778 `buildRustCrate` does not support common `nix-shell` operations directly 779 (see [this issue](https://github.com/NixOS/nixpkgs/issues/37945)) 780 so we will use `stdenv.mkDerivation` instead. 781 782 Using the example `hello` project above, we want to do the following: 783 + 784 - Have access to `cargo` and `rustc` 785 - Have the `openssl` library available to a crate through it's _normal_ 786 compilation mechanism (`pkg-config`). ··· 809 ``` 810 811 You should now be able to run the following: 812 + 813 + ```ShellSession 814 $ nix-shell --pure 815 $ cargo build 816 $ cargo test 817 ``` 818 819 + ### Controlling Rust Version Inside `nix-shell` {#controlling-rust-version-inside-nix-shell} 820 + 821 To control your rust version (i.e. use nightly) from within `shell.nix` (or 822 other nix expressions) you can use the following `shell.nix` 823 ··· 849 ``` 850 851 Now run: 852 + 853 ```ShellSession 854 $ rustc --version 855 rustc 1.26.0-nightly (188e693b3 2018-03-26) ··· 857 858 To see that you are using nightly. 859 860 + ## Using the Rust nightlies overlay {#using-the-rust-nightlies-overlay} 861 862 Mozilla provides an overlay for nixpkgs to bring a nightly version of Rust into scope. 863 This overlay can _also_ be used to install recent unstable or stable versions 864 of Rust, if desired. 865 866 + ### Rust overlay installation {#rust-overlay-installation} 867 868 You can use this overlay by either changing your local nixpkgs configuration, 869 or by adding the overlay declaratively in a nix expression, e.g. in `configuration.nix`. 870 + For more information see [the manual on installing overlays](#sec-overlays-install). 871 872 + #### Imperative rust overlay installation {#imperative-rust-overlay-installation} 873 874 Clone [nixpkgs-mozilla](https://github.com/mozilla/nixpkgs-mozilla), 875 and create a symbolic link to the file 876 [rust-overlay.nix](https://github.com/mozilla/nixpkgs-mozilla/blob/master/rust-overlay.nix) 877 in the `~/.config/nixpkgs/overlays` directory. 878 879 + ```ShellSession 880 + $ git clone https://github.com/mozilla/nixpkgs-mozilla.git 881 + $ mkdir -p ~/.config/nixpkgs/overlays 882 + $ ln -s $(pwd)/nixpkgs-mozilla/rust-overlay.nix ~/.config/nixpkgs/overlays/rust-overlay.nix 883 + ``` 884 885 + ### Declarative rust overlay installation {#declarative-rust-overlay-installation} 886 887 Add the following to your `configuration.nix`, `home-configuration.nix`, `shell.nix`, or similar: 888 ··· 898 899 Note that this will fetch the latest overlay version when rebuilding your system. 900 901 + ### Rust overlay usage {#rust-overlay-usage} 902 903 The overlay contains attribute sets corresponding to different versions of the rust toolchain, such as: 904 ··· 912 913 Imperatively, the latest stable version can be installed with the following command: 914 915 + ```ShellSession 916 + $ nix-env -Ai nixpkgs.latest.rustChannels.stable.rust 917 + ``` 918 919 Or using the attribute with nix-shell: 920 921 + ```ShellSession 922 + $ nix-shell -p nixpkgs.latest.rustChannels.stable.rust 923 + ``` 924 925 Substitute the `nixpkgs` prefix with `nixos` on NixOS. 926 To install the beta or nightly channel, "stable" should be substituted by
+2
doc/languages-frameworks/texlive.section.md
··· 5 ## User's guide {#sec-language-texlive-user-guide} 6 7 - For basic usage just pull `texlive.combined.scheme-basic` for an environment with basic LaTeX support. 8 - It typically won't work to use separately installed packages together. Instead, you can build a custom set of packages like this: 9 10 ```nix ··· 14 ``` 15 16 - There are all the schemes, collections and a few thousand packages, as defined upstream (perhaps with tiny differences). 17 - By default you only get executables and files needed during runtime, and a little documentation for the core packages. To change that, you need to add `pkgFilter` function to `combine`. 18 19 ```nix
··· 5 ## User's guide {#sec-language-texlive-user-guide} 6 7 - For basic usage just pull `texlive.combined.scheme-basic` for an environment with basic LaTeX support. 8 + 9 - It typically won't work to use separately installed packages together. Instead, you can build a custom set of packages like this: 10 11 ```nix ··· 15 ``` 16 17 - There are all the schemes, collections and a few thousand packages, as defined upstream (perhaps with tiny differences). 18 + 19 - By default you only get executables and files needed during runtime, and a little documentation for the core packages. To change that, you need to add `pkgFilter` function to `combine`. 20 21 ```nix
+4 -4
doc/languages-frameworks/titanium.section.md
··· 9 Not all Titanium features supported -- currently, it can only be used to build 10 Android and iOS apps. 11 12 - Building a Titanium app 13 - ----------------------- 14 We can build a Titanium app from source for Android or iOS and for debugging or 15 release purposes by invoking the `titaniumenv.buildApp {}` function: 16 ··· 103 path of the PHP script (`installURL`) (that is included with the iOS build 104 environment) to enable wireless ad-hoc installations. 105 106 - Emulating or simulating the app 107 - ------------------------------- 108 It is also possible to simulate the correspond iOS simulator build by using 109 `xcodeenv.simulateApp {}` and emulate an Android APK by using 110 `androidenv.emulateApp {}`.
··· 9 Not all Titanium features supported -- currently, it can only be used to build 10 Android and iOS apps. 11 12 + ## Building a Titanium app {#building-a-titanium-app} 13 + 14 We can build a Titanium app from source for Android or iOS and for debugging or 15 release purposes by invoking the `titaniumenv.buildApp {}` function: 16 ··· 103 path of the PHP script (`installURL`) (that is included with the iOS build 104 environment) to enable wireless ad-hoc installations. 105 106 + ## Emulating or simulating the app {#emulating-or-simulating-the-app} 107 + 108 It is also possible to simulate the correspond iOS simulator build by using 109 `xcodeenv.simulateApp {}` and emulate an Android APK by using 110 `androidenv.emulateApp {}`.
+10 -10
doc/languages-frameworks/vim.section.md
··· 12 - Pathogen 13 - vim-plug 14 15 - ## Custom configuration 16 17 Adding custom .vimrc lines can be done using the following code: 18 ··· 56 } 57 ``` 58 59 - ## Managing plugins with Vim packages 60 61 To store you plugins in Vim packages (the native Vim plugin manager, see `:help packages`) the following example can be used: 62 ··· 116 117 After that you can install your special grafted `myVim` or `myNeovim` packages. 118 119 - ### What if your favourite Vim plugin isn't already packaged? 120 121 If one of your favourite plugins isn't packaged, you can package it yourself: 122 ··· 154 } 155 ``` 156 157 - ## Managing plugins with vim-plug 158 159 To use [vim-plug](https://github.com/junegunn/vim-plug) to manage your Vim 160 plugins the following example can be used: ··· 183 } 184 ``` 185 186 - ## Managing plugins with VAM 187 188 - ### Handling dependencies of Vim plugins 189 190 VAM introduced .json files supporting dependencies without versioning 191 assuming that "using latest version" is ok most of the time. 192 193 - ### Example 194 195 First create a vim-scripts file having one plugin name per line. Example: 196 ··· 280 ] 281 ``` 282 283 - ## Adding new plugins to nixpkgs 284 285 Nix expressions for Vim plugins are stored in [pkgs/misc/vim-plugins](/pkgs/misc/vim-plugins). For the vast majority of plugins, Nix expressions are automatically generated by running [`./update.py`](/pkgs/misc/vim-plugins/update.py). This creates a [generated.nix](/pkgs/misc/vim-plugins/generated.nix) file based on the plugins listed in [vim-plugin-names](/pkgs/misc/vim-plugins/vim-plugin-names). Plugins are listed in alphabetical order in `vim-plugin-names` using the format `[github username]/[repository]`. For example https://github.com/scrooloose/nerdtree becomes `scrooloose/nerdtree`. 286 ··· 298 299 Finally, there are some plugins that are also packaged in nodePackages because they have Javascript-related build steps, such as running webpack. Those plugins are not listed in `vim-plugin-names` or managed by `update.py` at all, and are included separately in `overrides.nix`. Currently, all these plugins are related to the `coc.nvim` ecosystem of Language Server Protocol integration with vim/neovim. 300 301 - ## Updating plugins in nixpkgs 302 303 Run the update script with a GitHub API token that has at least `public_repo` access. Running the script without the token is likely to result in rate-limiting (429 errors). For steps on creating an API token, please refer to [GitHub's token documentation](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token). 304 ··· 312 ./pkgs/misc/vim-plugins/update.py --proc 1 313 ``` 314 315 - ## Important repositories 316 317 - [vim-pi](https://bitbucket.org/vimcommunity/vim-pi) is a plugin repository 318 from VAM plugin manager meant to be used by others as well used by
··· 12 - Pathogen 13 - vim-plug 14 15 + ## Custom configuration {#custom-configuration} 16 17 Adding custom .vimrc lines can be done using the following code: 18 ··· 56 } 57 ``` 58 59 + ## Managing plugins with Vim packages {#managing-plugins-with-vim-packages} 60 61 To store you plugins in Vim packages (the native Vim plugin manager, see `:help packages`) the following example can be used: 62 ··· 116 117 After that you can install your special grafted `myVim` or `myNeovim` packages. 118 119 + ### What if your favourite Vim plugin isn’t already packaged? {#what-if-your-favourite-vim-plugin-isnt-already-packaged} 120 121 If one of your favourite plugins isn't packaged, you can package it yourself: 122 ··· 154 } 155 ``` 156 157 + ## Managing plugins with vim-plug {#managing-plugins-with-vim-plug} 158 159 To use [vim-plug](https://github.com/junegunn/vim-plug) to manage your Vim 160 plugins the following example can be used: ··· 183 } 184 ``` 185 186 + ## Managing plugins with VAM {#managing-plugins-with-vam} 187 188 + ### Handling dependencies of Vim plugins {#handling-dependencies-of-vim-plugins} 189 190 VAM introduced .json files supporting dependencies without versioning 191 assuming that "using latest version" is ok most of the time. 192 193 + ### Example {#example} 194 195 First create a vim-scripts file having one plugin name per line. Example: 196 ··· 280 ] 281 ``` 282 283 + ## Adding new plugins to nixpkgs {#adding-new-plugins-to-nixpkgs} 284 285 Nix expressions for Vim plugins are stored in [pkgs/misc/vim-plugins](/pkgs/misc/vim-plugins). For the vast majority of plugins, Nix expressions are automatically generated by running [`./update.py`](/pkgs/misc/vim-plugins/update.py). This creates a [generated.nix](/pkgs/misc/vim-plugins/generated.nix) file based on the plugins listed in [vim-plugin-names](/pkgs/misc/vim-plugins/vim-plugin-names). Plugins are listed in alphabetical order in `vim-plugin-names` using the format `[github username]/[repository]`. For example https://github.com/scrooloose/nerdtree becomes `scrooloose/nerdtree`. 286 ··· 298 299 Finally, there are some plugins that are also packaged in nodePackages because they have Javascript-related build steps, such as running webpack. Those plugins are not listed in `vim-plugin-names` or managed by `update.py` at all, and are included separately in `overrides.nix`. Currently, all these plugins are related to the `coc.nvim` ecosystem of Language Server Protocol integration with vim/neovim. 300 301 + ## Updating plugins in nixpkgs {#updating-plugins-in-nixpkgs} 302 303 Run the update script with a GitHub API token that has at least `public_repo` access. Running the script without the token is likely to result in rate-limiting (429 errors). For steps on creating an API token, please refer to [GitHub's token documentation](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token). 304 ··· 312 ./pkgs/misc/vim-plugins/update.py --proc 1 313 ``` 314 315 + ## Important repositories {#important-repositories} 316 317 - [vim-pi](https://bitbucket.org/vimcommunity/vim-pi) is a plugin repository 318 from VAM plugin manager meant to be used by others as well used by
+1 -1
doc/preface.chapter.md
··· 12 expression language, then you are kindly referred to the [Nix manual](https://nixos.org/nix/manual/). 13 The NixOS distribution is documented in the [NixOS manual](https://nixos.org/nixos/manual/). 14 15 - ## Overview of Nixpkgs 16 17 Nix expressions describe how to build packages from source and are collected in 18 the [nixpkgs repository](https://github.com/NixOS/nixpkgs). Also included in the
··· 12 expression language, then you are kindly referred to the [Nix manual](https://nixos.org/nix/manual/). 13 The NixOS distribution is documented in the [NixOS manual](https://nixos.org/nixos/manual/). 14 15 + ## Overview of Nixpkgs {#overview-of-nixpkgs} 16 17 Nix expressions describe how to build packages from source and are collected in 18 the [nixpkgs repository](https://github.com/NixOS/nixpkgs). Also included in the
+19 -16
doc/stdenv/cross-compilation.chapter.md
··· 6 7 This chapter will be organized in three parts. First, it will describe the basics of how to package software in a way that supports cross-compilation. Second, it will describe how to use Nixpkgs when cross-compiling. Third, it will describe the internal infrastructure supporting cross-compilation. 8 9 - 10 ## Packaging in a cross-friendly manner {#sec-cross-packaging} 11 12 ### Platform parameters {#ssec-cross-platform-parameters} ··· 65 66 ### Theory of dependency categorization {#ssec-cross-dependency-categorization} 67 68 - ::: note 69 - This is a rather philosophical description that isn't very Nixpkgs-specific. For an overview of all the relevant attributes given to `mkDerivation`, see <xref linkend="ssec-stdenv-dependencies"/>. For a description of how everything is implemented, see <xref linkend="ssec-cross-dependency-implementation"/>. 70 ::: 71 72 In this section we explore the relationship between both runtime and build-time dependencies and the 3 Autoconf platforms. ··· 81 82 Putting this all together, that means we have dependencies in the form "host → target", in at most the following six combinations: 83 84 85 - #### Possible dependency types 86 - | Dependency's host platform | Dependency's target platform | 87 - | -- | -- | 88 | build | build | 89 | build | host | 90 | build | target | ··· 113 $ nix-build '<nixpkgs>' -A pkgsCross.raspberryPi.hello 114 ``` 115 116 - #### What if my package's build system needs to build a C program to be run under the build environment? {#cross-qa-build-c-program-in-build-environment} 117 Add the following to your `mkDerivation` invocation. 118 ```nix 119 depsBuildBuild = [ buildPackages.stdenv.cc ]; 120 ``` 121 122 - #### My package's testsuite needs to run host platform code. {#cross-testsuite-runs-host-code} 123 124 Add the following to your `mkDerivation` invocation. 125 ```nix 126 doCheck = stdenv.hostPlatform == stdenv.buildPlatform; 127 ``` ··· 134 $ nix-build '<nixpkgs>' --arg crossSystem '(import <nixpkgs/lib>).systems.examples.fooBarBaz' -A whatever 135 ``` 136 137 - ::: note 138 Eventually we would like to make these platform examples an unnecessary convenience so that 139 140 ```ShellSession ··· 146 147 While one is free to pass both parameters in full, there's a lot of logic to fill in missing fields. As discussed in the previous section, only one of `system`, `config`, and `parsed` is needed to infer the other two. Additionally, `libc` will be inferred from `parse`. Finally, `localSystem.system` is also _impurely_ inferred based on the platform evaluation occurs. This means it is often not necessary to pass `localSystem` at all, as in the command-line example in the previous paragraph. 148 149 - ::: note 150 Many sources (manual, wiki, etc) probably mention passing `system`, `platform`, along with the optional `crossSystem` to Nixpkgs: `import <nixpkgs> { system = ..; platform = ..; crossSystem = ..; }`. Passing those two instead of `localSystem` is still supported for compatibility, but is discouraged. Indeed, much of the inference we do for these parameters is motivated by compatibility as much as convenience. 151 ::: 152 ··· 156 157 ### Implementation of dependencies {#ssec-cross-dependency-implementation} 158 159 - The categories of dependencies developed in <xref linkend="ssec-cross-dependency-categorization"/> are specified as lists of derivations given to `mkDerivation`, as documented in <xref linkend="ssec-stdenv-dependencies"/>. In short, each list of dependencies for "host → target" of "foo → bar" is called `depsFooBar`, with exceptions for backwards compatibility that `depsBuildHost` is instead called `nativeBuildInputs` and `depsHostTarget` is instead called `buildInputs`. Nixpkgs is now structured so that each `depsFooBar` is automatically taken from `pkgsFooBar`. (These `pkgsFooBar`s are quite new, so there is no special case for `nativeBuildInputs` and `buildInputs`.) For example, `pkgsBuildHost.gcc` should be used at build-time, while `pkgsHostTarget.gcc` should be used at run-time. 160 161 Now, for most of Nixpkgs's history, there were no `pkgsFooBar` attributes, and most packages have not been refactored to use it explicitly. Prior to those, there were just `buildPackages`, `pkgs`, and `targetPackages`. Those are now redefined as aliases to `pkgsBuildHost`, `pkgsHostTarget`, and `pkgsTargetTarget`. It is acceptable, even recommended, to use them for libraries to show that the host platform is irrelevant. 162 ··· 178 179 In each stage, `pkgsBuildHost` refers to the previous stage, `pkgsBuildBuild` refers to the one before that, and `pkgsHostTarget` refers to the current one, and `pkgsTargetTarget` refers to the next one. When there is no previous or next stage, they instead refer to the current stage. Note how all the invariants regarding the mapping between dependency and depending packages' build host and target platforms are preserved. `pkgsBuildTarget` and `pkgsHostHost` are more complex in that the stage fitting the requirements isn't always a fixed chain of "prevs" and "nexts" away (modulo the "saturating" self-references at the ends). We just special case each instead. All the primary edges are implemented is in `pkgs/stdenv/booter.nix`, and secondarily aliases in `pkgs/top-level/stage.nix`. 180 181 - ::: note 182 The native stages are bootstrapped in legacy ways that predate the current cross implementation. This is why the bootstrapping stages leading up to the final stages are ignored in the previous paragraph. 183 ::: 184 ··· 186 ``` 187 (native, native, native, foreign, foreign) 188 ``` 189 If one imagines the saturating self references at the end being replaced with infinite stages, and then overlays those platform triples, one ends up with the infinite tuple: 190 ``` 191 (native..., native, native, native, foreign, foreign, foreign...) ··· 193 One can then imagine any sequence of platforms such that there are bootstrap stages with their 3 platforms determined by "sliding a window" that is the 3 tuple through the sequence. This was the original model for bootstrapping. Without a target platform (assume a better world where all compilers are multi-target and all standard libraries are built in their own derivation), this is sufficient. Conversely if one wishes to cross compile "faster", with a "Canadian Cross" bootstrapping stage where `build != host != target`, more bootstrapping stages are needed since no sliding window provides the pesky `pkgsBuildTarget` package set since it skips the Canadian cross stage's "host". 194 195 196 - ::: note 197 - It is much better to refer to `buildPackages` than `targetPackages`, or more broadly package sets that do not mention "target". There are three reasons for this. 198 199 First, it is because bootstrapping stages do not have a unique `targetPackages`. For example a `(x86-linux, x86-linux, arm-linux)` and `(x86-linux, x86-linux, x86-windows)` package set both have a `(x86-linux, x86-linux, x86-linux)` package set. Because there is no canonical `targetPackages` for such a native (`build == host == target`) package set, we set their `targetPackages` 200 ··· 203 Thirdly, it is because everything target-mentioning only exists to accommodate compilers with lousy build systems that insist on the compiler itself and standard library being built together. Of course that is bad because bigger derivations means longer rebuilds. It is also problematic because it tends to make the standard libraries less like other libraries than they could be, complicating code and build systems alike. Because of the other problems, and because of these innate disadvantages, compilers ought to be packaged another way where possible. 204 ::: 205 206 - ::: note 207 - If one explores Nixpkgs, they will see derivations with names like `gccCross`. Such `*Cross` derivations is a holdover from before we properly distinguished between the host and target platforms—the derivation with "Cross" in the name covered the `build = host != target` case, while the other covered the `host = target`, with build platform the same or not based on whether one was using its `.nativeDrv` or `.crossDrv`. This ugliness will disappear soon. 208 :::
··· 6 7 This chapter will be organized in three parts. First, it will describe the basics of how to package software in a way that supports cross-compilation. Second, it will describe how to use Nixpkgs when cross-compiling. Third, it will describe the internal infrastructure supporting cross-compilation. 8 9 ## Packaging in a cross-friendly manner {#sec-cross-packaging} 10 11 ### Platform parameters {#ssec-cross-platform-parameters} ··· 64 65 ### Theory of dependency categorization {#ssec-cross-dependency-categorization} 66 67 + ::: {.note} 68 + This is a rather philosophical description that isn't very Nixpkgs-specific. For an overview of all the relevant attributes given to `mkDerivation`, see [](#ssec-stdenv-dependencies). For a description of how everything is implemented, see [](#ssec-cross-dependency-implementation). 69 ::: 70 71 In this section we explore the relationship between both runtime and build-time dependencies and the 3 Autoconf platforms. ··· 80 81 Putting this all together, that means we have dependencies in the form "host → target", in at most the following six combinations: 82 83 + #### Possible dependency types {#possible-dependency-types} 84 85 + | Dependency’s host platform | Dependency’s target platform | 86 + |----------------------------|------------------------------| 87 | build | build | 88 | build | host | 89 | build | target | ··· 112 $ nix-build '<nixpkgs>' -A pkgsCross.raspberryPi.hello 113 ``` 114 115 + #### What if my package’s build system needs to build a C program to be run under the build environment? {#cross-qa-build-c-program-in-build-environment} 116 + 117 Add the following to your `mkDerivation` invocation. 118 + 119 ```nix 120 depsBuildBuild = [ buildPackages.stdenv.cc ]; 121 ``` 122 123 + #### My package’s testsuite needs to run host platform code. {#cross-testsuite-runs-host-code} 124 125 Add the following to your `mkDerivation` invocation. 126 + 127 ```nix 128 doCheck = stdenv.hostPlatform == stdenv.buildPlatform; 129 ``` ··· 136 $ nix-build '<nixpkgs>' --arg crossSystem '(import <nixpkgs/lib>).systems.examples.fooBarBaz' -A whatever 137 ``` 138 139 + ::: {.note} 140 Eventually we would like to make these platform examples an unnecessary convenience so that 141 142 ```ShellSession ··· 148 149 While one is free to pass both parameters in full, there's a lot of logic to fill in missing fields. As discussed in the previous section, only one of `system`, `config`, and `parsed` is needed to infer the other two. Additionally, `libc` will be inferred from `parse`. Finally, `localSystem.system` is also _impurely_ inferred based on the platform evaluation occurs. This means it is often not necessary to pass `localSystem` at all, as in the command-line example in the previous paragraph. 150 151 + ::: {.note} 152 Many sources (manual, wiki, etc) probably mention passing `system`, `platform`, along with the optional `crossSystem` to Nixpkgs: `import <nixpkgs> { system = ..; platform = ..; crossSystem = ..; }`. Passing those two instead of `localSystem` is still supported for compatibility, but is discouraged. Indeed, much of the inference we do for these parameters is motivated by compatibility as much as convenience. 153 ::: 154 ··· 158 159 ### Implementation of dependencies {#ssec-cross-dependency-implementation} 160 161 + The categories of dependencies developed in [](#ssec-cross-dependency-categorization) are specified as lists of derivations given to `mkDerivation`, as documented in [](#ssec-stdenv-dependencies). In short, each list of dependencies for "host → target" of "foo → bar" is called `depsFooBar`, with exceptions for backwards compatibility that `depsBuildHost` is instead called `nativeBuildInputs` and `depsHostTarget` is instead called `buildInputs`. Nixpkgs is now structured so that each `depsFooBar` is automatically taken from `pkgsFooBar`. (These `pkgsFooBar`s are quite new, so there is no special case for `nativeBuildInputs` and `buildInputs`.) For example, `pkgsBuildHost.gcc` should be used at build-time, while `pkgsHostTarget.gcc` should be used at run-time. 162 163 Now, for most of Nixpkgs's history, there were no `pkgsFooBar` attributes, and most packages have not been refactored to use it explicitly. Prior to those, there were just `buildPackages`, `pkgs`, and `targetPackages`. Those are now redefined as aliases to `pkgsBuildHost`, `pkgsHostTarget`, and `pkgsTargetTarget`. It is acceptable, even recommended, to use them for libraries to show that the host platform is irrelevant. 164 ··· 180 181 In each stage, `pkgsBuildHost` refers to the previous stage, `pkgsBuildBuild` refers to the one before that, and `pkgsHostTarget` refers to the current one, and `pkgsTargetTarget` refers to the next one. When there is no previous or next stage, they instead refer to the current stage. Note how all the invariants regarding the mapping between dependency and depending packages' build host and target platforms are preserved. `pkgsBuildTarget` and `pkgsHostHost` are more complex in that the stage fitting the requirements isn't always a fixed chain of "prevs" and "nexts" away (modulo the "saturating" self-references at the ends). We just special case each instead. All the primary edges are implemented is in `pkgs/stdenv/booter.nix`, and secondarily aliases in `pkgs/top-level/stage.nix`. 182 183 + ::: {.note} 184 The native stages are bootstrapped in legacy ways that predate the current cross implementation. This is why the bootstrapping stages leading up to the final stages are ignored in the previous paragraph. 185 ::: 186 ··· 188 ``` 189 (native, native, native, foreign, foreign) 190 ``` 191 + 192 If one imagines the saturating self references at the end being replaced with infinite stages, and then overlays those platform triples, one ends up with the infinite tuple: 193 ``` 194 (native..., native, native, native, foreign, foreign, foreign...) ··· 196 One can then imagine any sequence of platforms such that there are bootstrap stages with their 3 platforms determined by "sliding a window" that is the 3 tuple through the sequence. This was the original model for bootstrapping. Without a target platform (assume a better world where all compilers are multi-target and all standard libraries are built in their own derivation), this is sufficient. Conversely if one wishes to cross compile "faster", with a "Canadian Cross" bootstrapping stage where `build != host != target`, more bootstrapping stages are needed since no sliding window provides the pesky `pkgsBuildTarget` package set since it skips the Canadian cross stage's "host". 197 198 199 + ::: {.note} 200 + It is much better to refer to `buildPackages` than `targetPackages`, or more broadly package sets that do not mention “target”. There are three reasons for this. 201 202 First, it is because bootstrapping stages do not have a unique `targetPackages`. For example a `(x86-linux, x86-linux, arm-linux)` and `(x86-linux, x86-linux, x86-windows)` package set both have a `(x86-linux, x86-linux, x86-linux)` package set. Because there is no canonical `targetPackages` for such a native (`build == host == target`) package set, we set their `targetPackages` 203 ··· 206 Thirdly, it is because everything target-mentioning only exists to accommodate compilers with lousy build systems that insist on the compiler itself and standard library being built together. Of course that is bad because bigger derivations means longer rebuilds. It is also problematic because it tends to make the standard libraries less like other libraries than they could be, complicating code and build systems alike. Because of the other problems, and because of these innate disadvantages, compilers ought to be packaged another way where possible. 207 ::: 208 209 + ::: {.note} 210 + If one explores Nixpkgs, they will see derivations with names like `gccCross`. Such `*Cross` derivations is a holdover from before we properly distinguished between the host and target platforms—the derivation with “Cross” in the name covered the `build = host != target` case, while the other covered the `host = target`, with build platform the same or not based on whether one was using its `.nativeDrv` or `.crossDrv`. This ugliness will disappear soon. 211 :::
+5 -5
doc/stdenv/meta.chapter.md
··· 130 131 ### `tests` {#var-meta-tests} 132 133 - ::: warning 134 This attribute is special in that it is not actually under the `meta` attribute set but rather under the `passthru` attribute set. This is due to how `meta` attributes work, and the fact that they are supposed to contain only metadata, not derivations. 135 ::: 136 ··· 175 176 Although it’s typically better to indicate the specific license, a few generic options are available: 177 178 - ### `lib.licenses.free`, `"free"` 179 180 Catch-all for free software licenses not listed above. 181 182 - ### `lib.licenses.unfreeRedistributable`, `"unfree-redistributable"` 183 184 Unfree package that can be redistributed in binary form. That is, it’s legal to redistribute the *output* of the derivation. This means that the package can be included in the Nixpkgs channel. 185 186 Sometimes proprietary software can only be redistributed unmodified. Make sure the builder doesn’t actually modify the original binaries; otherwise we’re breaking the license. For instance, the NVIDIA X11 drivers can be redistributed unmodified, but our builder applies `patchelf` to make them work. Thus, its license is `"unfree"` and it cannot be included in the Nixpkgs channel. 187 188 - ### `lib.licenses.unfree`, `"unfree"` 189 190 Unfree package that cannot be redistributed. You can build it yourself, but you cannot redistribute the output of the derivation. Thus it cannot be included in the Nixpkgs channel. 191 192 - ### `lib.licenses.unfreeRedistributableFirmware`, `"unfree-redistributable-firmware"` 193 194 This package supplies unfree, redistributable firmware. This is a separate value from `unfree-redistributable` because not everybody cares whether firmware is free.
··· 130 131 ### `tests` {#var-meta-tests} 132 133 + ::: {.warning} 134 This attribute is special in that it is not actually under the `meta` attribute set but rather under the `passthru` attribute set. This is due to how `meta` attributes work, and the fact that they are supposed to contain only metadata, not derivations. 135 ::: 136 ··· 175 176 Although it’s typically better to indicate the specific license, a few generic options are available: 177 178 + ### `lib.licenses.free`, `"free"` {#lib.licenses.free-free} 179 180 Catch-all for free software licenses not listed above. 181 182 + ### `lib.licenses.unfreeRedistributable`, `"unfree-redistributable"` {#lib.licenses.unfreeredistributable-unfree-redistributable} 183 184 Unfree package that can be redistributed in binary form. That is, it’s legal to redistribute the *output* of the derivation. This means that the package can be included in the Nixpkgs channel. 185 186 Sometimes proprietary software can only be redistributed unmodified. Make sure the builder doesn’t actually modify the original binaries; otherwise we’re breaking the license. For instance, the NVIDIA X11 drivers can be redistributed unmodified, but our builder applies `patchelf` to make them work. Thus, its license is `"unfree"` and it cannot be included in the Nixpkgs channel. 187 188 + ### `lib.licenses.unfree`, `"unfree"` {#lib.licenses.unfree-unfree} 189 190 Unfree package that cannot be redistributed. You can build it yourself, but you cannot redistribute the output of the derivation. Thus it cannot be included in the Nixpkgs channel. 191 192 + ### `lib.licenses.unfreeRedistributableFirmware`, `"unfree-redistributable-firmware"` {#lib.licenses.unfreeredistributablefirmware-unfree-redistributable-firmware} 193 194 This package supplies unfree, redistributable firmware. This is a separate value from `unfree-redistributable` because not everybody cares whether firmware is free.
+14 -14
doc/stdenv/multiple-output.chapter.md
··· 6 7 The main motivation is to save disk space by reducing runtime closure sizes; consequently also sizes of substituted binaries get reduced. Splitting can be used to have more granular runtime dependencies, for example the typical reduction is to split away development-only files, as those are typically not needed during runtime. As a result, closure sizes of many packages can get reduced to a half or even much less. 8 9 - ::: note 10 The reduction effects could be instead achieved by building the parts in completely separate derivations. That would often additionally reduce build-time closures, but it tends to be much harder to write such derivations, as build systems typically assume all parts are being built at once. This compromise approach of single source package producing multiple binary packages is also utilized often by rpm and deb. 11 ::: 12 ··· 28 29 `nix-env` lacks an easy way to select the outputs to install. When installing a package, `nix-env` always installs the outputs listed in `meta.outputsToInstall`, even when the user explicitly selects an output. 30 31 - ::: warning 32 `nix-env` silenty disregards the outputs selected by the user, and instead installs the outputs from `meta.outputsToInstall`. For example, 33 34 ```ShellSession ··· 38 installs the `"out"` output (`coreutils.meta.outputsToInstall` is `[ "out" ]`) instead of the requested `"info"`. 39 ::: 40 41 - The only recourse to select an output with `nix-env` is to override the package’s `meta.outputsToInstall`, using the functions described in <xref linkend="chap-overrides" />. For example, the following overlay adds the `"info"` output for the `coreutils` package: 42 43 ```nix 44 self: super: ··· 53 54 In the Nix language the individual outputs can be reached explicitly as attributes, e.g. `coreutils.info`, but the typical case is just using packages as build inputs. 55 56 - When a multiple-output derivation gets into a build input of another derivation, the `dev` output is added if it exists, otherwise the first output is added. In addition to that, `propagatedBuildOutputs` of that package which by default contain `$outputBin` and `$outputLib` are also added. (See <xref linkend="multiple-output-file-type-groups" />.) 57 58 In some cases it may be desirable to combine different outputs under a single store path. A function `symlinkJoin` can be used to do this. (Note that it may negate some closure size benefits of using a multiple-output package.) 59 ··· 69 70 Often such a single line is enough. For each output an equally named environment variable is passed to the builder and contains the path in nix store for that output. Typically you also want to have the main `out` output, as it catches any files that didn’t get elsewhere. 71 72 - ::: note 73 - There is a special handling of the `debug` output, described at <xref linkend="stdenv-separateDebugInfo" />. 74 ::: 75 76 ### “Binaries first” {#multiple-output-file-binaries-first-convention} ··· 85 86 The support code currently recognizes some particular kinds of outputs and either instructs the build system of the package to put files into their desired outputs or it moves the files during the fixup phase. Each group of file types has an `outputFoo` variable specifying the output name where they should go. If that variable isn’t defined by the derivation writer, it is guessed – a default output name is defined, falling back to other possibilities if the output isn’t defined. 87 88 - #### ` $outputDev` 89 90 is for development-only files. These include C(++) headers (`include/`), pkg-config (`lib/pkgconfig/`), cmake (`lib/cmake/`) and aclocal files (`share/aclocal/`). They go to `dev` or `out` by default. 91 92 - #### ` $outputBin` 93 94 is meant for user-facing binaries, typically residing in `bin/`. They go to `bin` or `out` by default. 95 96 - #### ` $outputLib` 97 98 is meant for libraries, typically residing in `lib/` and `libexec/`. They go to `lib` or `out` by default. 99 100 - #### ` $outputDoc` 101 102 is for user documentation, typically residing in `share/doc/`. It goes to `doc` or `out` by default. 103 104 - #### ` $outputDevdoc` 105 106 is for _developer_ documentation. Currently we count gtk-doc and devhelp books, typically residing in `share/gtk-doc/` and `share/devhelp/`, in there. It goes to `devdoc` or is removed (!) by default. This is because e.g. gtk-doc tends to be rather large and completely unused by nixpkgs users. 107 108 - #### ` $outputMan` 109 110 is for man pages (except for section 3), typically residing in `share/man/man[0-9]/`. They go to `man` or `$outputBin` by default. 111 112 - #### ` $outputDevman` 113 114 is for section 3 man pages, typically residing in `share/man/man[0-9]/`. They go to `devman` or `$outputMan` by default. 115 116 - #### ` $outputInfo` 117 118 is for info pages, typically residing in `share/info/`. They go to `info` or `$outputBin` by default. 119
··· 6 7 The main motivation is to save disk space by reducing runtime closure sizes; consequently also sizes of substituted binaries get reduced. Splitting can be used to have more granular runtime dependencies, for example the typical reduction is to split away development-only files, as those are typically not needed during runtime. As a result, closure sizes of many packages can get reduced to a half or even much less. 8 9 + ::: {.note} 10 The reduction effects could be instead achieved by building the parts in completely separate derivations. That would often additionally reduce build-time closures, but it tends to be much harder to write such derivations, as build systems typically assume all parts are being built at once. This compromise approach of single source package producing multiple binary packages is also utilized often by rpm and deb. 11 ::: 12 ··· 28 29 `nix-env` lacks an easy way to select the outputs to install. When installing a package, `nix-env` always installs the outputs listed in `meta.outputsToInstall`, even when the user explicitly selects an output. 30 31 + ::: {.warning} 32 `nix-env` silenty disregards the outputs selected by the user, and instead installs the outputs from `meta.outputsToInstall`. For example, 33 34 ```ShellSession ··· 38 installs the `"out"` output (`coreutils.meta.outputsToInstall` is `[ "out" ]`) instead of the requested `"info"`. 39 ::: 40 41 + The only recourse to select an output with `nix-env` is to override the package’s `meta.outputsToInstall`, using the functions described in [](#chap-overrides). For example, the following overlay adds the `"info"` output for the `coreutils` package: 42 43 ```nix 44 self: super: ··· 53 54 In the Nix language the individual outputs can be reached explicitly as attributes, e.g. `coreutils.info`, but the typical case is just using packages as build inputs. 55 56 + When a multiple-output derivation gets into a build input of another derivation, the `dev` output is added if it exists, otherwise the first output is added. In addition to that, `propagatedBuildOutputs` of that package which by default contain `$outputBin` and `$outputLib` are also added. (See [](#multiple-output-file-type-groups).) 57 58 In some cases it may be desirable to combine different outputs under a single store path. A function `symlinkJoin` can be used to do this. (Note that it may negate some closure size benefits of using a multiple-output package.) 59 ··· 69 70 Often such a single line is enough. For each output an equally named environment variable is passed to the builder and contains the path in nix store for that output. Typically you also want to have the main `out` output, as it catches any files that didn’t get elsewhere. 71 72 + ::: {.note} 73 + There is a special handling of the `debug` output, described at [](#stdenv-separateDebugInfo). 74 ::: 75 76 ### “Binaries first” {#multiple-output-file-binaries-first-convention} ··· 85 86 The support code currently recognizes some particular kinds of outputs and either instructs the build system of the package to put files into their desired outputs or it moves the files during the fixup phase. Each group of file types has an `outputFoo` variable specifying the output name where they should go. If that variable isn’t defined by the derivation writer, it is guessed – a default output name is defined, falling back to other possibilities if the output isn’t defined. 87 88 + #### `$outputDev` {#outputdev} 89 90 is for development-only files. These include C(++) headers (`include/`), pkg-config (`lib/pkgconfig/`), cmake (`lib/cmake/`) and aclocal files (`share/aclocal/`). They go to `dev` or `out` by default. 91 92 + #### `$outputBin` {#outputbin} 93 94 is meant for user-facing binaries, typically residing in `bin/`. They go to `bin` or `out` by default. 95 96 + #### `$outputLib` {#outputlib} 97 98 is meant for libraries, typically residing in `lib/` and `libexec/`. They go to `lib` or `out` by default. 99 100 + #### `$outputDoc` {#outputdoc} 101 102 is for user documentation, typically residing in `share/doc/`. It goes to `doc` or `out` by default. 103 104 + #### `$outputDevdoc` {#outputdevdoc} 105 106 is for _developer_ documentation. Currently we count gtk-doc and devhelp books, typically residing in `share/gtk-doc/` and `share/devhelp/`, in there. It goes to `devdoc` or is removed (!) by default. This is because e.g. gtk-doc tends to be rather large and completely unused by nixpkgs users. 107 108 + #### `$outputMan` {#outputman} 109 110 is for man pages (except for section 3), typically residing in `share/man/man[0-9]/`. They go to `man` or `$outputBin` by default. 111 112 + #### `$outputDevman` {#outputdevman} 113 114 is for section 3 man pages, typically residing in `share/man/man[0-9]/`. They go to `devman` or `$outputMan` by default. 115 116 + #### `$outputInfo` {#outputinfo} 117 118 is for info pages, typically residing in `share/info/`. They go to `info` or `$outputBin` by default. 119
+74 -72
doc/stdenv/stdenv.chapter.md
··· 39 } 40 ``` 41 42 - This attribute ensures that the `bin` subdirectories of these packages appear in the `PATH` environment variable during the build, that their `include` subdirectories are searched by the C compiler, and so on. (See <xref linkend="ssec-setup-hooks" /> for details.) 43 44 - Often it is necessary to override or modify some aspect of the build. To make this easier, the standard environment breaks the package build into a number of *phases*, all of which can be overridden or modified individually: unpacking the sources, applying patches, configuring, building, and installing. (There are some others; see <xref linkend="sec-stdenv-phases" />.) For instance, a package that doesn’t supply a makefile but instead has to be compiled "manually" could be handled like this: 45 46 ```nix 47 stdenv.mkDerivation { ··· 59 60 (Note the use of `''`-style string literals, which are very convenient for large multi-line script fragments because they don’t need escaping of `"` and `\`, and because indentation is intelligently removed.) 61 62 - There are many other attributes to customise the build. These are listed in <xref linkend="ssec-stdenv-attributes" />. 63 64 While the standard environment provides a generic builder, you can still supply your own build script: 65 ··· 116 117 ## Specifying dependencies {#ssec-stdenv-dependencies} 118 119 - As described in the Nix manual, almost any `*.drv` store path in a derivation’s attribute set will induce a dependency on that derivation. `mkDerivation`, however, takes a few attributes intended to, between them, include all the dependencies of a package. This is done both for structure and consistency, but also so that certain other setup can take place. For example, certain dependencies need their bin directories added to the `PATH`. That is built-in, but other setup is done via a pluggable mechanism that works in conjunction with these dependency attributes. See <xref linkend="ssec-setup-hooks" /> for details. 120 121 - Dependencies can be broken down along three axes: their host and target platforms relative to the new derivation’s, and whether they are propagated. The platform distinctions are motivated by cross compilation; see <xref linkend="chap-cross" /> for exactly what each platform means. [^footnote-stdenv-ignored-build-platform] But even if one is not cross compiling, the platforms imply whether or not the dependency is needed at run-time or build-time, a concept that makes perfect sense outside of cross compilation. By default, the run-time/build-time distinction is just a hint for mental clarity, but with `strictDeps` set it is mostly enforced even in the native case. 122 123 The extension of `PATH` with dependencies, alluded to above, proceeds according to the relative platforms alone. The process is carried out only for dependencies whose host platform matches the new derivation’s build platform i.e. dependencies which run on the platform where the new derivation will be built. [^footnote-stdenv-native-dependencies-in-path] For each dependency \<dep\> of those dependencies, `dep/bin`, if present, is added to the `PATH` environment variable. 124 ··· 175 176 Overall, the unifying theme here is that propagation shouldn’t be introducing transitive dependencies involving platforms the depending package is unaware of. \[One can imagine the dependending package asking for dependencies with the platforms it knows about; other platforms it doesn’t know how to ask for. The platform description in that scenario is a kind of unforagable capability.\] The offset bounds checking and definition of `mapOffset` together ensure that this is the case. Discovering a new offset is discovering a new platform, and since those platforms weren’t in the derivation “spec” of the needing package, they cannot be relevant. From a capability perspective, we can imagine that the host and target platforms of a package are the capabilities a package requires, and the depending package must provide the capability to the dependency. 177 178 - ### Variables specifying dependencies 179 #### `depsBuildBuild` {#var-stdenv-depsBuildBuild} 180 181 A list of dependencies whose host and target platforms are the new derivation’s build platform. This means a `-1` host and `-1` target offset from the new derivation’s platforms. These are programs and libraries used at build time that produce programs and libraries also used at build time. If the dependency doesn’t care about the target platform (i.e. isn’t a compiler or similar tool), put it in `nativeBuildInputs` instead. The most common use of this `buildPackages.stdenv.cc`, the default C compiler for this role. That example crops up more than one might think in old commonly used C libraries. ··· 236 237 ## Attributes {#ssec-stdenv-attributes} 238 239 - ### Variables affecting `stdenv` initialisation 240 241 #### `NIX_DEBUG` {#var-stdenv-NIX_DEBUG} 242 243 A natural number indicating how much information to log. If set to 1 or higher, `stdenv` will print moderate debugging information during the build. In particular, the `gcc` and `ld` wrapper scripts will print out the complete command line passed to the wrapped tools. If set to 6 or higher, the `stdenv` setup script will be run with `set -x` tracing. If set to 7 or higher, the `gcc` and `ld` wrapper scripts will also be run with `set -x` tracing. 244 245 - ### Attributes affecting build properties 246 247 #### `enableParallelBuilding` {#var-stdenv-enableParallelBuilding} 248 ··· 250 251 Unless set to `false`, some build systems with good support for parallel building including `cmake`, `meson`, and `qmake` will set it to `true`. 252 253 - ### Special variables 254 255 #### `passthru` {#var-stdenv-passthru} 256 ··· 298 299 The script will be run with `UPDATE_NIX_ATTR_PATH` environment variable set to the attribute path it is supposed to update. 300 301 - ::: note 302 The script will be usually run from the root of the Nixpkgs repository but you should not rely on that. Also note that the update scripts will be run in parallel by default; you should avoid running `git commit` or any other commands that cannot handle that. 303 ::: 304 ··· 314 315 There are a number of variables that control what phases are executed and in what order: 316 317 - #### Variables affecting phase control 318 319 ##### `phases` {#var-stdenv-phases} 320 ··· 354 355 The unpack phase is responsible for unpacking the source code of the package. The default implementation of `unpackPhase` unpacks the source files listed in the `src` environment variable to the current directory. It supports the following files by default: 356 357 - #### Tar files 358 359 These can optionally be compressed using `gzip` (`.tar.gz`, `.tgz` or `.tar.Z`), `bzip2` (`.tar.bz2`, `.tbz2` or `.tbz`) or `xz` (`.tar.xz`, `.tar.lzma` or `.txz`). 360 361 - #### Zip files 362 363 Zip files are unpacked using `unzip`. However, `unzip` is not in the standard environment, so you should add it to `nativeBuildInputs` yourself. 364 365 - #### Directories in the Nix store 366 367 These are simply copied to the current directory. The hash part of the file name is stripped, e.g. `/nix/store/1wydxgby13cz...-my-sources` would be copied to `my-sources`. 368 369 Additional file types can be supported by setting the `unpackCmd` variable (see below). 370 371 - #### Variables controlling the unpack phase 372 ##### `srcs` / `src` {#var-stdenv-src} 373 374 The list of source files or directories to be unpacked or copied. One of these must be set. ··· 405 406 The patch phase applies the list of patches defined in the `patches` variable. 407 408 - #### Variables controlling the patch phase 409 410 ##### `dontPatch` {#var-stdenv-dontPatch} 411 ··· 431 432 The configure phase prepares the source tree for building. The default `configurePhase` runs `./configure` (typically an Autoconf-generated script) if it exists. 433 434 - #### Variables controlling the configure phase 435 436 ##### `configureScript` {#var-stdenv-configureScript} 437 ··· 491 492 The build phase is responsible for actually building the package (e.g. compiling it). The default `buildPhase` simply calls `make` if a file named `Makefile`, `makefile` or `GNUmakefile` exists in the current directory (or the `makefile` is explicitly set); otherwise it does nothing. 493 494 - #### Variables controlling the build phase 495 496 ##### `dontBuild` {#var-stdenv-dontBuild} 497 ··· 509 makeFlags = [ "PREFIX=$(out)" ]; 510 ``` 511 512 - ::: note 513 The flags are quoted in bash, but environment variables can be specified by using the make syntax. 514 ::: 515 ··· 545 546 The check phase checks whether the package was built correctly by running its test suite. The default `checkPhase` calls `make check`, but only if the `doCheck` variable is enabled. 547 548 - #### Variables controlling the check phase 549 550 ##### `doCheck` {#var-stdenv-doCheck} 551 ··· 557 558 in the derivation to enable checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how `doCheck` is set, as the newly-built program won’t run on the platform used to build it. 559 560 - ##### `makeFlags` / `makeFlagsArray` / `makefile` 561 562 See the [build phase](#var-stdenv-makeFlags) for details. 563 ··· 585 586 The install phase is responsible for installing the package in the Nix store under `out`. The default `installPhase` creates the directory `$out` and calls `make install`. 587 588 - #### Variables controlling the install phase 589 590 ##### `dontInstall` {#var-stdenv-dontInstall} 591 592 Set to true to skip the install phase. 593 594 - ##### `makeFlags` / `makeFlagsArray` / `makefile` 595 596 See the [build phase](#var-stdenv-makeFlags) for details. 597 ··· 624 - On Linux, it applies the `patchelf` command to ELF executables and libraries to remove unused directories from the `RPATH` in order to prevent unnecessary runtime dependencies. 625 - It rewrites the interpreter paths of shell scripts to paths found in `PATH`. E.g., `/usr/bin/perl` will be rewritten to `/nix/store/some-perl/bin/perl` found in `PATH`. 626 627 - #### Variables controlling the fixup phase 628 629 ##### `dontFixup` {#var-stdenv-dontFixup} 630 ··· 706 707 The installCheck phase checks whether the package was installed correctly by running its test suite against the installed directories. The default `installCheck` calls `make installcheck`. 708 709 - #### Variables controlling the installCheck phase 710 711 ##### `doInstallCheck` {#var-stdenv-doInstallCheck} 712 ··· 742 743 The distribution phase is intended to produce a source distribution of the package. The default `distPhase` first calls `make dist`, then it copies the resulting source tarballs to `$out/tarballs/`. This phase is only executed if the attribute `doDist` is set. 744 745 - #### Variables controlling the distribution phase 746 747 ##### `distTarget` {#var-stdenv-distTarget} 748 ··· 879 880 Packages adding a hook should not hard code a specific hook, but rather choose a variable *relative* to how they are included. Returning to the C compiler wrapper example, if the wrapper itself is an `n` dependency, then it only wants to accumulate flags from `n + 1` dependencies, as only those ones match the compiler’s target platform. The `hostOffset` variable is defined with the current dependency’s host offset `targetOffset` with its target offset, before its setup hook is sourced. Additionally, since most environment hooks don’t care about the target platform, that means the setup hook can append to the right bash array by doing something like 881 882 - ```{.bash} 883 addEnvHooks "$hostOffset" myBashFunction 884 ``` 885 ··· 887 888 First, let’s cover some setup hooks that are part of Nixpkgs default stdenv. This means that they are run for every package built using `stdenv.mkDerivation`. Some of these are platform specific, so they may run on Linux but not Darwin or vice-versa. 889 890 - ### `move-docs.sh` 891 892 This setup hook moves any installed documentation to the `/share` subdirectory directory. This includes the man, doc and info directories. This is needed for legacy programs that do not know how to use the `share` subdirectory. 893 894 - ### `compress-man-pages.sh` 895 896 This setup hook compresses any man pages that have been installed. The compression is done using the gzip program. This helps to reduce the installed size of packages. 897 898 - ### `strip.sh` 899 900 This runs the strip command on installed binaries and libraries. This removes unnecessary information like debug symbols when they are not needed. This also helps to reduce the installed size of packages. 901 902 - ### `patch-shebangs.sh` 903 904 This setup hook patches installed scripts to use the full path to the shebang interpreter. A shebang interpreter is the first commented line of a script telling the operating system which program will run the script (e.g `#!/bin/bash`). In Nix, we want an exact path to that interpreter to be used. This often replaces `/bin/sh` with a path in the Nix store. 905 906 - ### `audit-tmpdir.sh` 907 908 This verifies that no references are left from the install binaries to the directory used to build those binaries. This ensures that the binaries do not need things outside the Nix store. This is currently supported in Linux only. 909 910 - ### `multiple-outputs.sh` 911 912 - This setup hook adds configure flags that tell packages to install files into any one of the proper outputs listed in `outputs`. This behavior can be turned off by setting `setOutputFlags` to false in the derivation environment. See <xref linkend="chap-multiple-output" /> for more information. 913 914 - ### `move-sbin.sh` 915 916 This setup hook moves any binaries installed in the `sbin/` subdirectory into `bin/`. In addition, a link is provided from `sbin/` to `bin/` for compatibility. 917 918 - ### `move-lib64.sh` 919 920 This setup hook moves any libraries installed in the `lib64/` subdirectory into `lib/`. In addition, a link is provided from `lib64/` to `lib/` for compatibility. 921 922 - ### `move-systemd-user-units.sh` 923 924 This setup hook moves any systemd user units installed in the `lib/` subdirectory into `share/`. In addition, a link is provided from `share/` to `lib/` for compatibility. This is needed for systemd to find user services when installed into the user profile. 925 926 - ### `set-source-date-epoch-to-latest.sh` 927 928 This sets `SOURCE_DATE_EPOCH` to the modification time of the most recent file. 929 930 - ### Bintools Wrapper 931 932 The Bintools Wrapper wraps the binary utilities for a bunch of miscellaneous purposes. These are GNU Binutils when targetting Linux, and a mix of cctools and GNU binutils for Darwin. \[The “Bintools” name is supposed to be a compromise between “Binutils” and “cctools” not denoting any specific implementation.\] Specifically, the underlying bintools package, and a C standard library (glibc or Darwin’s libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by the Bintools Wrapper. Packages typically depend on CC Wrapper, which in turn (at run time) depends on the Bintools Wrapper. 933 ··· 937 938 A problem with this final task is that the Bintools Wrapper is honest and defines `LD` as `ld`. Most packages, however, firstly use the C compiler for linking, secondly use `LD` anyways, defining it as the C compiler, and thirdly, only so define `LD` when it is undefined as a fallback. This triple-threat means Bintools Wrapper will break those packages, as LD is already defined as the actual linker which the package won’t override yet doesn’t want to use. The workaround is to define, just for the problematic package, `LD` as the C compiler. A good way to do this would be `preConfigure = "LD=$CC"`. 939 940 - ### CC Wrapper 941 942 The CC Wrapper wraps a C toolchain for a bunch of miscellaneous purposes. Specifically, a C compiler (GCC or Clang), wrapped binary tools, and a C standard library (glibc or Darwin’s libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by the CC Wrapper. Packages typically depend on the CC Wrapper, which in turn (at run-time) depends on the Bintools Wrapper. 943 ··· 971 972 Adds every file named `catalog.xml` found under the `xml/dtd` and `xml/xsl` subdirectories of each build input to the `XML_CATALOG_FILES` environment variable. 973 974 - ### teTeX / TeX Live 975 976 Adds the `share/texmf-nix` subdirectory of each build input to the `TEXINPUTS` environment variable. 977 978 - ### Qt 4 979 980 Sets the `QTDIR` environment variable to Qt’s path. 981 ··· 983 984 Exports `GDK_PIXBUF_MODULE_FILE` environment variable to the builder. Add librsvg package to `buildInputs` to get svg support. See also the [setup hook description in GNOME platform docs](#ssec-gnome-hooks-gdk-pixbuf). 985 986 - ### GHC 987 988 Creates a temporary package database and registers every Haskell build input in it (TODO: how?). 989 990 - ### GNOME platform 991 992 - Hooks related to GNOME platform and related libraries like GLib, GTK and GStreamer are described in <xref linkend="sec-language-gnome" />. 993 994 ### autoPatchelfHook {#setup-hook-autopatchelfhook} 995 ··· 1003 1004 The `autoPatchelf` command also recognizes a `--no-recurse` command line flag, which prevents it from recursing into subdirectories. 1005 1006 - ### breakpointHook 1007 1008 This hook will make a build pause instead of stopping when a failure happens. It prevents nix from cleaning up the build environment immediately and allows the user to attach to a build environment using the `cntr` command. Upon build error it will print instructions on how to use `cntr`, which can be used to enter the environment for debugging. Installing cntr and running the command will provide shell access to the build sandbox of failed build. At `/var/lib/cntr` the sandboxed filesystem is mounted. All commands and files of the system are still accessible within the shell. To execute commands from the sandbox use the cntr exec subcommand. `cntr` is only supported on Linux-based platforms. To use it first add `cntr` to your `environment.systemPackages` on NixOS or alternatively to the root user on non-NixOS systems. Then in the package that is supposed to be inspected, add `breakpointHook` to `nativeBuildInputs`. 1009 ··· 1013 1014 When a build failure happens there will be an instruction printed that shows how to attach with `cntr` to the build sandbox. 1015 1016 - ::: note 1017 - ::: title 1018 Caution with remote builds 1019 ::: 1020 1021 This won’t work with remote builds as the build environment is on a different machine and can’t be accessed by `cntr`. Remote builds can be turned off by setting `--option builders ''` for `nix-build` or `--builders ''` for `nix build`. 1022 ::: 1023 1024 - ### installShellFiles 1025 1026 This hook helps with installing manpages and shell completion files. It exposes 2 shell functions `installManPage` and `installShellCompletion` that can be used from your `postInstall` hook. 1027 ··· 1047 ''; 1048 ``` 1049 1050 - ### libiconv, libintl 1051 1052 A few libraries automatically add to `NIX_LDFLAGS` their library, making their symbols automatically available to the linker. This includes libiconv and libintl (gettext). This is done to provide compatibility between GNU Linux, where libiconv and libintl are bundled in, and other systems where that might not be the case. Sometimes, this behavior is not desired. To disable this behavior, set `dontAddExtraLibs`. 1053 1054 - ### validatePkgConfig 1055 1056 The `validatePkgConfig` hook validates all pkg-config (`.pc`) files in a package. This helps catching some common errors in pkg-config files, such as undefined variables. 1057 1058 - ### cmake 1059 1060 Overrides the default configure phase to run the CMake command. By default, we use the Make generator of CMake. In addition, dependencies are added automatically to CMAKE_PREFIX_PATH so that packages are correctly detected by CMake. Some additional flags are passed in to give similar behavior to configure-based packages. You can disable this hook’s behavior by setting configurePhase to a custom value, or by setting dontUseCmakeConfigure. cmakeFlags controls flags passed only to CMake. By default, parallel building is enabled as CMake supports parallel building almost everywhere. When Ninja is also in use, CMake will detect that and use the ninja generator. 1061 1062 - ### xcbuildHook 1063 1064 Overrides the build and install phases to run the "xcbuild" command. This hook is needed when a project only comes with build files for the XCode build system. You can disable this behavior by setting buildPhase and configurePhase to a custom value. xcbuildFlags controls flags passed only to xcbuild. 1065 1066 - ### Meson 1067 1068 Overrides the configure phase to run meson to generate Ninja files. To run these files, you should accompany Meson with ninja. By default, `enableParallelBuilding` is enabled as Meson supports parallel building almost everywhere. 1069 1070 - #### Variables controlling Meson 1071 1072 - ##### `mesonFlags` 1073 1074 Controls the flags passed to meson. 1075 1076 - ##### `mesonBuildType` 1077 1078 Which [`--buildtype`](https://mesonbuild.com/Builtin-options.html#core-options) to pass to Meson. We default to `plain`. 1079 1080 - ##### `mesonAutoFeatures` 1081 1082 What value to set [`-Dauto_features=`](https://mesonbuild.com/Builtin-options.html#core-options) to. We default to `enabled`. 1083 1084 - ##### `mesonWrapMode` 1085 1086 What value to set [`-Dwrap_mode=`](https://mesonbuild.com/Builtin-options.html#core-options) to. We default to `nodownload` as we disallow network access. 1087 1088 - ##### `dontUseMesonConfigure` 1089 1090 Disables using Meson’s `configurePhase`. 1091 1092 - ### ninja 1093 1094 Overrides the build, install, and check phase to run ninja instead of make. You can disable this behavior with the `dontUseNinjaBuild`, `dontUseNinjaInstall`, and `dontUseNinjaCheck`, respectively. Parallel building is enabled by default in Ninja. 1095 1096 - ### unzip 1097 1098 This setup hook will allow you to unzip .zip files specified in `$src`. There are many similar packages like `unrar`, `undmg`, etc. 1099 1100 - ### wafHook 1101 1102 Overrides the configure, build, and install phases. This will run the “waf” script used by many projects. If `wafPath` (default `./waf`) doesn’t exist, it will copy the version of waf available in Nixpkgs. `wafFlags` can be used to pass flags to the waf script. 1103 1104 - ### scons 1105 1106 Overrides the build, install, and check phases. This uses the scons build system as a replacement for make. scons does not provide a configure phase, so everything is managed at build and install time. 1107 ··· 1119 1120 The following flags are enabled by default and might require disabling with `hardeningDisable` if the program to package is incompatible. 1121 1122 - ### `format` 1123 1124 Adds the `-Wformat -Wformat-security -Werror=format-security` compiler options. At present, this warns about calls to `printf` and `scanf` functions where the format string is not a string literal and there are no format arguments, as in `printf(foo);`. This may be a security hole if the format string came from untrusted input and contains `%n`. 1125 ··· 1132 cc1plus: some warnings being treated as errors 1133 ``` 1134 1135 - ### `stackprotector` 1136 1137 Adds the `-fstack-protector-strong --param ssp-buffer-size=4` compiler options. This adds safety checks against stack overwrites rendering many potential code injection attacks into aborting situations. In the best case this turns code injection vulnerabilities into denial of service or into non-issues (depending on the application). 1138 ··· 1143 /tmp/nix-build-ipxe-20141124-5cbdc41.drv-0/ipxe-5cbdc41/src/arch/i386/firmware/pcbios/bios_console.c:86: undefined reference to `__stack_chk_fail' 1144 ``` 1145 1146 - ### `fortify` 1147 1148 Adds the `-O2 -D_FORTIFY_SOURCE=2` compiler options. During code generation the compiler knows a great deal of information about buffer sizes (where possible), and attempts to replace insecure unlimited length buffer function calls with length-limited ones. This is especially useful for old, crufty code. Additionally, format strings in writable memory that contain `%n` are blocked. If an application depends on such a format string, it will need to be worked around. 1149 ··· 1164 fcntl2.h:50:4: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments 1165 ``` 1166 1167 - ### `pic` 1168 1169 Adds the `-fPIC` compiler options. This options adds support for position independent code in shared libraries and thus making ASLR possible. 1170 ··· 1177 ccbLfRgg.s:33: Error: missing or invalid displacement expression `private_key_len@GOTOFF' 1178 ``` 1179 1180 - ### `strictoverflow` 1181 1182 Signed integer overflow is undefined behaviour according to the C standard. If it happens, it is an error in the program as it should check for overflow before it can happen, not afterwards. GCC provides built-in functions to perform arithmetic with overflow checking, which are correct and faster than any custom implementation. As a workaround, the option `-fno-strict-overflow` makes gcc behave as if signed integer overflows were defined. 1183 1184 This flag should not trigger any build or runtime errors. 1185 1186 - ### `relro` 1187 1188 Adds the `-z relro` linker option. During program load, several ELF memory sections need to be written to by the linker, but can be turned read-only before turning over control to the program. This prevents some GOT (and .dtors) overwrite attacks, but at least the part of the GOT used by the dynamic linker (.got.plt) is still vulnerable. 1189 1190 This flag can break dynamic shared object loading. For instance, the module systems of Xorg and OpenCV are incompatible with this flag. In almost all cases the `bindnow` flag must also be disabled and incompatible programs typically fail with similar errors at runtime. 1191 1192 - ### `bindnow` 1193 1194 Adds the `-z bindnow` linker option. During program load, all dynamic symbols are resolved, allowing for the complete GOT to be marked read-only (due to `relro`). This prevents GOT overwrite attacks. For very large applications, this can incur some performance loss during initial load while symbols are resolved, but this shouldn’t be an issue for daemons. 1195 ··· 1201 1202 The following flags are disabled by default and should be enabled with `hardeningEnable` for packages that take untrusted input like network services. 1203 1204 - ### `pie` 1205 1206 Adds the `-fPIE` compiler and `-pie` linker options. Position Independent Executables are needed to take advantage of Address Space Layout Randomization, supported by modern kernel versions. While ASLR can already be enforced for data areas in the stack and heap (brk and mmap), the code areas must be compiled as position-independent. Shared libraries already do this with the `pic` flag, so they gain ASLR automatically, but binary .text regions need to be build with `pie` to gain ASLR. When this happens, ROP attacks are much harder since there are no static locations to bounce off of during a memory corruption attack. 1207
··· 39 } 40 ``` 41 42 + This attribute ensures that the `bin` subdirectories of these packages appear in the `PATH` environment variable during the build, that their `include` subdirectories are searched by the C compiler, and so on. (See [](#ssec-setup-hooks) for details.) 43 44 + Often it is necessary to override or modify some aspect of the build. To make this easier, the standard environment breaks the package build into a number of *phases*, all of which can be overridden or modified individually: unpacking the sources, applying patches, configuring, building, and installing. (There are some others; see [](#sec-stdenv-phases).) For instance, a package that doesn’t supply a makefile but instead has to be compiled "manually" could be handled like this: 45 46 ```nix 47 stdenv.mkDerivation { ··· 59 60 (Note the use of `''`-style string literals, which are very convenient for large multi-line script fragments because they don’t need escaping of `"` and `\`, and because indentation is intelligently removed.) 61 62 + There are many other attributes to customise the build. These are listed in [](#ssec-stdenv-attributes). 63 64 While the standard environment provides a generic builder, you can still supply your own build script: 65 ··· 116 117 ## Specifying dependencies {#ssec-stdenv-dependencies} 118 119 + As described in the Nix manual, almost any `*.drv` store path in a derivation’s attribute set will induce a dependency on that derivation. `mkDerivation`, however, takes a few attributes intended to, between them, include all the dependencies of a package. This is done both for structure and consistency, but also so that certain other setup can take place. For example, certain dependencies need their bin directories added to the `PATH`. That is built-in, but other setup is done via a pluggable mechanism that works in conjunction with these dependency attributes. See [](#ssec-setup-hooks) for details. 120 121 + Dependencies can be broken down along three axes: their host and target platforms relative to the new derivation’s, and whether they are propagated. The platform distinctions are motivated by cross compilation; see [](#chap-cross) for exactly what each platform means. [^footnote-stdenv-ignored-build-platform] But even if one is not cross compiling, the platforms imply whether or not the dependency is needed at run-time or build-time, a concept that makes perfect sense outside of cross compilation. By default, the run-time/build-time distinction is just a hint for mental clarity, but with `strictDeps` set it is mostly enforced even in the native case. 122 123 The extension of `PATH` with dependencies, alluded to above, proceeds according to the relative platforms alone. The process is carried out only for dependencies whose host platform matches the new derivation’s build platform i.e. dependencies which run on the platform where the new derivation will be built. [^footnote-stdenv-native-dependencies-in-path] For each dependency \<dep\> of those dependencies, `dep/bin`, if present, is added to the `PATH` environment variable. 124 ··· 175 176 Overall, the unifying theme here is that propagation shouldn’t be introducing transitive dependencies involving platforms the depending package is unaware of. \[One can imagine the dependending package asking for dependencies with the platforms it knows about; other platforms it doesn’t know how to ask for. The platform description in that scenario is a kind of unforagable capability.\] The offset bounds checking and definition of `mapOffset` together ensure that this is the case. Discovering a new offset is discovering a new platform, and since those platforms weren’t in the derivation “spec” of the needing package, they cannot be relevant. From a capability perspective, we can imagine that the host and target platforms of a package are the capabilities a package requires, and the depending package must provide the capability to the dependency. 177 178 + ### Variables specifying dependencies {#variables-specifying-dependencies} 179 + 180 #### `depsBuildBuild` {#var-stdenv-depsBuildBuild} 181 182 A list of dependencies whose host and target platforms are the new derivation’s build platform. This means a `-1` host and `-1` target offset from the new derivation’s platforms. These are programs and libraries used at build time that produce programs and libraries also used at build time. If the dependency doesn’t care about the target platform (i.e. isn’t a compiler or similar tool), put it in `nativeBuildInputs` instead. The most common use of this `buildPackages.stdenv.cc`, the default C compiler for this role. That example crops up more than one might think in old commonly used C libraries. ··· 237 238 ## Attributes {#ssec-stdenv-attributes} 239 240 + ### Variables affecting `stdenv` initialisation {#variables-affecting-stdenv-initialisation} 241 242 #### `NIX_DEBUG` {#var-stdenv-NIX_DEBUG} 243 244 A natural number indicating how much information to log. If set to 1 or higher, `stdenv` will print moderate debugging information during the build. In particular, the `gcc` and `ld` wrapper scripts will print out the complete command line passed to the wrapped tools. If set to 6 or higher, the `stdenv` setup script will be run with `set -x` tracing. If set to 7 or higher, the `gcc` and `ld` wrapper scripts will also be run with `set -x` tracing. 245 246 + ### Attributes affecting build properties {#attributes-affecting-build-properties} 247 248 #### `enableParallelBuilding` {#var-stdenv-enableParallelBuilding} 249 ··· 251 252 Unless set to `false`, some build systems with good support for parallel building including `cmake`, `meson`, and `qmake` will set it to `true`. 253 254 + ### Special variables {#special-variables} 255 256 #### `passthru` {#var-stdenv-passthru} 257 ··· 299 300 The script will be run with `UPDATE_NIX_ATTR_PATH` environment variable set to the attribute path it is supposed to update. 301 302 + ::: {.note} 303 The script will be usually run from the root of the Nixpkgs repository but you should not rely on that. Also note that the update scripts will be run in parallel by default; you should avoid running `git commit` or any other commands that cannot handle that. 304 ::: 305 ··· 315 316 There are a number of variables that control what phases are executed and in what order: 317 318 + #### Variables affecting phase control {#variables-affecting-phase-control} 319 320 ##### `phases` {#var-stdenv-phases} 321 ··· 355 356 The unpack phase is responsible for unpacking the source code of the package. The default implementation of `unpackPhase` unpacks the source files listed in the `src` environment variable to the current directory. It supports the following files by default: 357 358 + #### Tar files {#tar-files} 359 360 These can optionally be compressed using `gzip` (`.tar.gz`, `.tgz` or `.tar.Z`), `bzip2` (`.tar.bz2`, `.tbz2` or `.tbz`) or `xz` (`.tar.xz`, `.tar.lzma` or `.txz`). 361 362 + #### Zip files {#zip-files} 363 364 Zip files are unpacked using `unzip`. However, `unzip` is not in the standard environment, so you should add it to `nativeBuildInputs` yourself. 365 366 + #### Directories in the Nix store {#directories-in-the-nix-store} 367 368 These are simply copied to the current directory. The hash part of the file name is stripped, e.g. `/nix/store/1wydxgby13cz...-my-sources` would be copied to `my-sources`. 369 370 Additional file types can be supported by setting the `unpackCmd` variable (see below). 371 372 + #### Variables controlling the unpack phase {#variables-controlling-the-unpack-phase} 373 + 374 ##### `srcs` / `src` {#var-stdenv-src} 375 376 The list of source files or directories to be unpacked or copied. One of these must be set. ··· 407 408 The patch phase applies the list of patches defined in the `patches` variable. 409 410 + #### Variables controlling the patch phase {#variables-controlling-the-patch-phase} 411 412 ##### `dontPatch` {#var-stdenv-dontPatch} 413 ··· 433 434 The configure phase prepares the source tree for building. The default `configurePhase` runs `./configure` (typically an Autoconf-generated script) if it exists. 435 436 + #### Variables controlling the configure phase {#variables-controlling-the-configure-phase} 437 438 ##### `configureScript` {#var-stdenv-configureScript} 439 ··· 493 494 The build phase is responsible for actually building the package (e.g. compiling it). The default `buildPhase` simply calls `make` if a file named `Makefile`, `makefile` or `GNUmakefile` exists in the current directory (or the `makefile` is explicitly set); otherwise it does nothing. 495 496 + #### Variables controlling the build phase {#variables-controlling-the-build-phase} 497 498 ##### `dontBuild` {#var-stdenv-dontBuild} 499 ··· 511 makeFlags = [ "PREFIX=$(out)" ]; 512 ``` 513 514 + ::: {.note} 515 The flags are quoted in bash, but environment variables can be specified by using the make syntax. 516 ::: 517 ··· 547 548 The check phase checks whether the package was built correctly by running its test suite. The default `checkPhase` calls `make check`, but only if the `doCheck` variable is enabled. 549 550 + #### Variables controlling the check phase {#variables-controlling-the-check-phase} 551 552 ##### `doCheck` {#var-stdenv-doCheck} 553 ··· 559 560 in the derivation to enable checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how `doCheck` is set, as the newly-built program won’t run on the platform used to build it. 561 562 + ##### `makeFlags` / `makeFlagsArray` / `makefile` {#makeflags-makeflagsarray-makefile} 563 564 See the [build phase](#var-stdenv-makeFlags) for details. 565 ··· 587 588 The install phase is responsible for installing the package in the Nix store under `out`. The default `installPhase` creates the directory `$out` and calls `make install`. 589 590 + #### Variables controlling the install phase {#variables-controlling-the-install-phase} 591 592 ##### `dontInstall` {#var-stdenv-dontInstall} 593 594 Set to true to skip the install phase. 595 596 + ##### `makeFlags` / `makeFlagsArray` / `makefile` {#makeflags-makeflagsarray-makefile-1} 597 598 See the [build phase](#var-stdenv-makeFlags) for details. 599 ··· 626 - On Linux, it applies the `patchelf` command to ELF executables and libraries to remove unused directories from the `RPATH` in order to prevent unnecessary runtime dependencies. 627 - It rewrites the interpreter paths of shell scripts to paths found in `PATH`. E.g., `/usr/bin/perl` will be rewritten to `/nix/store/some-perl/bin/perl` found in `PATH`. 628 629 + #### Variables controlling the fixup phase {#variables-controlling-the-fixup-phase} 630 631 ##### `dontFixup` {#var-stdenv-dontFixup} 632 ··· 708 709 The installCheck phase checks whether the package was installed correctly by running its test suite against the installed directories. The default `installCheck` calls `make installcheck`. 710 711 + #### Variables controlling the installCheck phase {#variables-controlling-the-installcheck-phase} 712 713 ##### `doInstallCheck` {#var-stdenv-doInstallCheck} 714 ··· 744 745 The distribution phase is intended to produce a source distribution of the package. The default `distPhase` first calls `make dist`, then it copies the resulting source tarballs to `$out/tarballs/`. This phase is only executed if the attribute `doDist` is set. 746 747 + #### Variables controlling the distribution phase {#variables-controlling-the-distribution-phase} 748 749 ##### `distTarget` {#var-stdenv-distTarget} 750 ··· 881 882 Packages adding a hook should not hard code a specific hook, but rather choose a variable *relative* to how they are included. Returning to the C compiler wrapper example, if the wrapper itself is an `n` dependency, then it only wants to accumulate flags from `n + 1` dependencies, as only those ones match the compiler’s target platform. The `hostOffset` variable is defined with the current dependency’s host offset `targetOffset` with its target offset, before its setup hook is sourced. Additionally, since most environment hooks don’t care about the target platform, that means the setup hook can append to the right bash array by doing something like 883 884 + ```bash 885 addEnvHooks "$hostOffset" myBashFunction 886 ``` 887 ··· 889 890 First, let’s cover some setup hooks that are part of Nixpkgs default stdenv. This means that they are run for every package built using `stdenv.mkDerivation`. Some of these are platform specific, so they may run on Linux but not Darwin or vice-versa. 891 892 + ### `move-docs.sh` {#move-docs.sh} 893 894 This setup hook moves any installed documentation to the `/share` subdirectory directory. This includes the man, doc and info directories. This is needed for legacy programs that do not know how to use the `share` subdirectory. 895 896 + ### `compress-man-pages.sh` {#compress-man-pages.sh} 897 898 This setup hook compresses any man pages that have been installed. The compression is done using the gzip program. This helps to reduce the installed size of packages. 899 900 + ### `strip.sh` {#strip.sh} 901 902 This runs the strip command on installed binaries and libraries. This removes unnecessary information like debug symbols when they are not needed. This also helps to reduce the installed size of packages. 903 904 + ### `patch-shebangs.sh` {#patch-shebangs.sh} 905 906 This setup hook patches installed scripts to use the full path to the shebang interpreter. A shebang interpreter is the first commented line of a script telling the operating system which program will run the script (e.g `#!/bin/bash`). In Nix, we want an exact path to that interpreter to be used. This often replaces `/bin/sh` with a path in the Nix store. 907 908 + ### `audit-tmpdir.sh` {#audit-tmpdir.sh} 909 910 This verifies that no references are left from the install binaries to the directory used to build those binaries. This ensures that the binaries do not need things outside the Nix store. This is currently supported in Linux only. 911 912 + ### `multiple-outputs.sh` {#multiple-outputs.sh} 913 914 + This setup hook adds configure flags that tell packages to install files into any one of the proper outputs listed in `outputs`. This behavior can be turned off by setting `setOutputFlags` to false in the derivation environment. See [](#chap-multiple-output) for more information. 915 916 + ### `move-sbin.sh` {#move-sbin.sh} 917 918 This setup hook moves any binaries installed in the `sbin/` subdirectory into `bin/`. In addition, a link is provided from `sbin/` to `bin/` for compatibility. 919 920 + ### `move-lib64.sh` {#move-lib64.sh} 921 922 This setup hook moves any libraries installed in the `lib64/` subdirectory into `lib/`. In addition, a link is provided from `lib64/` to `lib/` for compatibility. 923 924 + ### `move-systemd-user-units.sh` {#move-systemd-user-units.sh} 925 926 This setup hook moves any systemd user units installed in the `lib/` subdirectory into `share/`. In addition, a link is provided from `share/` to `lib/` for compatibility. This is needed for systemd to find user services when installed into the user profile. 927 928 + ### `set-source-date-epoch-to-latest.sh` {#set-source-date-epoch-to-latest.sh} 929 930 This sets `SOURCE_DATE_EPOCH` to the modification time of the most recent file. 931 932 + ### Bintools Wrapper {#bintools-wrapper} 933 934 The Bintools Wrapper wraps the binary utilities for a bunch of miscellaneous purposes. These are GNU Binutils when targetting Linux, and a mix of cctools and GNU binutils for Darwin. \[The “Bintools” name is supposed to be a compromise between “Binutils” and “cctools” not denoting any specific implementation.\] Specifically, the underlying bintools package, and a C standard library (glibc or Darwin’s libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by the Bintools Wrapper. Packages typically depend on CC Wrapper, which in turn (at run time) depends on the Bintools Wrapper. 935 ··· 939 940 A problem with this final task is that the Bintools Wrapper is honest and defines `LD` as `ld`. Most packages, however, firstly use the C compiler for linking, secondly use `LD` anyways, defining it as the C compiler, and thirdly, only so define `LD` when it is undefined as a fallback. This triple-threat means Bintools Wrapper will break those packages, as LD is already defined as the actual linker which the package won’t override yet doesn’t want to use. The workaround is to define, just for the problematic package, `LD` as the C compiler. A good way to do this would be `preConfigure = "LD=$CC"`. 941 942 + ### CC Wrapper {#cc-wrapper} 943 944 The CC Wrapper wraps a C toolchain for a bunch of miscellaneous purposes. Specifically, a C compiler (GCC or Clang), wrapped binary tools, and a C standard library (glibc or Darwin’s libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by the CC Wrapper. Packages typically depend on the CC Wrapper, which in turn (at run-time) depends on the Bintools Wrapper. 945 ··· 973 974 Adds every file named `catalog.xml` found under the `xml/dtd` and `xml/xsl` subdirectories of each build input to the `XML_CATALOG_FILES` environment variable. 975 976 + ### teTeX / TeX Live {#tetex-tex-live} 977 978 Adds the `share/texmf-nix` subdirectory of each build input to the `TEXINPUTS` environment variable. 979 980 + ### Qt 4 {#qt-4} 981 982 Sets the `QTDIR` environment variable to Qt’s path. 983 ··· 985 986 Exports `GDK_PIXBUF_MODULE_FILE` environment variable to the builder. Add librsvg package to `buildInputs` to get svg support. See also the [setup hook description in GNOME platform docs](#ssec-gnome-hooks-gdk-pixbuf). 987 988 + ### GHC {#ghc} 989 990 Creates a temporary package database and registers every Haskell build input in it (TODO: how?). 991 992 + ### GNOME platform {#gnome-platform} 993 994 + Hooks related to GNOME platform and related libraries like GLib, GTK and GStreamer are described in [](#sec-language-gnome). 995 996 ### autoPatchelfHook {#setup-hook-autopatchelfhook} 997 ··· 1005 1006 The `autoPatchelf` command also recognizes a `--no-recurse` command line flag, which prevents it from recursing into subdirectories. 1007 1008 + ### breakpointHook {#breakpointhook} 1009 1010 This hook will make a build pause instead of stopping when a failure happens. It prevents nix from cleaning up the build environment immediately and allows the user to attach to a build environment using the `cntr` command. Upon build error it will print instructions on how to use `cntr`, which can be used to enter the environment for debugging. Installing cntr and running the command will provide shell access to the build sandbox of failed build. At `/var/lib/cntr` the sandboxed filesystem is mounted. All commands and files of the system are still accessible within the shell. To execute commands from the sandbox use the cntr exec subcommand. `cntr` is only supported on Linux-based platforms. To use it first add `cntr` to your `environment.systemPackages` on NixOS or alternatively to the root user on non-NixOS systems. Then in the package that is supposed to be inspected, add `breakpointHook` to `nativeBuildInputs`. 1011 ··· 1015 1016 When a build failure happens there will be an instruction printed that shows how to attach with `cntr` to the build sandbox. 1017 1018 + ::: {.note} 1019 + ::: {.title} 1020 Caution with remote builds 1021 ::: 1022 1023 This won’t work with remote builds as the build environment is on a different machine and can’t be accessed by `cntr`. Remote builds can be turned off by setting `--option builders ''` for `nix-build` or `--builders ''` for `nix build`. 1024 ::: 1025 1026 + ### installShellFiles {#installshellfiles} 1027 1028 This hook helps with installing manpages and shell completion files. It exposes 2 shell functions `installManPage` and `installShellCompletion` that can be used from your `postInstall` hook. 1029 ··· 1049 ''; 1050 ``` 1051 1052 + ### libiconv, libintl {#libiconv-libintl} 1053 1054 A few libraries automatically add to `NIX_LDFLAGS` their library, making their symbols automatically available to the linker. This includes libiconv and libintl (gettext). This is done to provide compatibility between GNU Linux, where libiconv and libintl are bundled in, and other systems where that might not be the case. Sometimes, this behavior is not desired. To disable this behavior, set `dontAddExtraLibs`. 1055 1056 + ### validatePkgConfig {#validatepkgconfig} 1057 1058 The `validatePkgConfig` hook validates all pkg-config (`.pc`) files in a package. This helps catching some common errors in pkg-config files, such as undefined variables. 1059 1060 + ### cmake {#cmake} 1061 1062 Overrides the default configure phase to run the CMake command. By default, we use the Make generator of CMake. In addition, dependencies are added automatically to CMAKE_PREFIX_PATH so that packages are correctly detected by CMake. Some additional flags are passed in to give similar behavior to configure-based packages. You can disable this hook’s behavior by setting configurePhase to a custom value, or by setting dontUseCmakeConfigure. cmakeFlags controls flags passed only to CMake. By default, parallel building is enabled as CMake supports parallel building almost everywhere. When Ninja is also in use, CMake will detect that and use the ninja generator. 1063 1064 + ### xcbuildHook {#xcbuildhook} 1065 1066 Overrides the build and install phases to run the "xcbuild" command. This hook is needed when a project only comes with build files for the XCode build system. You can disable this behavior by setting buildPhase and configurePhase to a custom value. xcbuildFlags controls flags passed only to xcbuild. 1067 1068 + ### Meson {#meson} 1069 1070 Overrides the configure phase to run meson to generate Ninja files. To run these files, you should accompany Meson with ninja. By default, `enableParallelBuilding` is enabled as Meson supports parallel building almost everywhere. 1071 1072 + #### Variables controlling Meson {#variables-controlling-meson} 1073 1074 + ##### `mesonFlags` {#mesonflags} 1075 1076 Controls the flags passed to meson. 1077 1078 + ##### `mesonBuildType` {#mesonbuildtype} 1079 1080 Which [`--buildtype`](https://mesonbuild.com/Builtin-options.html#core-options) to pass to Meson. We default to `plain`. 1081 1082 + ##### `mesonAutoFeatures` {#mesonautofeatures} 1083 1084 What value to set [`-Dauto_features=`](https://mesonbuild.com/Builtin-options.html#core-options) to. We default to `enabled`. 1085 1086 + ##### `mesonWrapMode` {#mesonwrapmode} 1087 1088 What value to set [`-Dwrap_mode=`](https://mesonbuild.com/Builtin-options.html#core-options) to. We default to `nodownload` as we disallow network access. 1089 1090 + ##### `dontUseMesonConfigure` {#dontusemesonconfigure} 1091 1092 Disables using Meson’s `configurePhase`. 1093 1094 + ### ninja {#ninja} 1095 1096 Overrides the build, install, and check phase to run ninja instead of make. You can disable this behavior with the `dontUseNinjaBuild`, `dontUseNinjaInstall`, and `dontUseNinjaCheck`, respectively. Parallel building is enabled by default in Ninja. 1097 1098 + ### unzip {#unzip} 1099 1100 This setup hook will allow you to unzip .zip files specified in `$src`. There are many similar packages like `unrar`, `undmg`, etc. 1101 1102 + ### wafHook {#wafhook} 1103 1104 Overrides the configure, build, and install phases. This will run the “waf” script used by many projects. If `wafPath` (default `./waf`) doesn’t exist, it will copy the version of waf available in Nixpkgs. `wafFlags` can be used to pass flags to the waf script. 1105 1106 + ### scons {#scons} 1107 1108 Overrides the build, install, and check phases. This uses the scons build system as a replacement for make. scons does not provide a configure phase, so everything is managed at build and install time. 1109 ··· 1121 1122 The following flags are enabled by default and might require disabling with `hardeningDisable` if the program to package is incompatible. 1123 1124 + ### `format` {#format} 1125 1126 Adds the `-Wformat -Wformat-security -Werror=format-security` compiler options. At present, this warns about calls to `printf` and `scanf` functions where the format string is not a string literal and there are no format arguments, as in `printf(foo);`. This may be a security hole if the format string came from untrusted input and contains `%n`. 1127 ··· 1134 cc1plus: some warnings being treated as errors 1135 ``` 1136 1137 + ### `stackprotector` {#stackprotector} 1138 1139 Adds the `-fstack-protector-strong --param ssp-buffer-size=4` compiler options. This adds safety checks against stack overwrites rendering many potential code injection attacks into aborting situations. In the best case this turns code injection vulnerabilities into denial of service or into non-issues (depending on the application). 1140 ··· 1145 /tmp/nix-build-ipxe-20141124-5cbdc41.drv-0/ipxe-5cbdc41/src/arch/i386/firmware/pcbios/bios_console.c:86: undefined reference to `__stack_chk_fail' 1146 ``` 1147 1148 + ### `fortify` {#fortify} 1149 1150 Adds the `-O2 -D_FORTIFY_SOURCE=2` compiler options. During code generation the compiler knows a great deal of information about buffer sizes (where possible), and attempts to replace insecure unlimited length buffer function calls with length-limited ones. This is especially useful for old, crufty code. Additionally, format strings in writable memory that contain `%n` are blocked. If an application depends on such a format string, it will need to be worked around. 1151 ··· 1166 fcntl2.h:50:4: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments 1167 ``` 1168 1169 + ### `pic` {#pic} 1170 1171 Adds the `-fPIC` compiler options. This options adds support for position independent code in shared libraries and thus making ASLR possible. 1172 ··· 1179 ccbLfRgg.s:33: Error: missing or invalid displacement expression `private_key_len@GOTOFF' 1180 ``` 1181 1182 + ### `strictoverflow` {#strictoverflow} 1183 1184 Signed integer overflow is undefined behaviour according to the C standard. If it happens, it is an error in the program as it should check for overflow before it can happen, not afterwards. GCC provides built-in functions to perform arithmetic with overflow checking, which are correct and faster than any custom implementation. As a workaround, the option `-fno-strict-overflow` makes gcc behave as if signed integer overflows were defined. 1185 1186 This flag should not trigger any build or runtime errors. 1187 1188 + ### `relro` {#relro} 1189 1190 Adds the `-z relro` linker option. During program load, several ELF memory sections need to be written to by the linker, but can be turned read-only before turning over control to the program. This prevents some GOT (and .dtors) overwrite attacks, but at least the part of the GOT used by the dynamic linker (.got.plt) is still vulnerable. 1191 1192 This flag can break dynamic shared object loading. For instance, the module systems of Xorg and OpenCV are incompatible with this flag. In almost all cases the `bindnow` flag must also be disabled and incompatible programs typically fail with similar errors at runtime. 1193 1194 + ### `bindnow` {#bindnow} 1195 1196 Adds the `-z bindnow` linker option. During program load, all dynamic symbols are resolved, allowing for the complete GOT to be marked read-only (due to `relro`). This prevents GOT overwrite attacks. For very large applications, this can incur some performance loss during initial load while symbols are resolved, but this shouldn’t be an issue for daemons. 1197 ··· 1203 1204 The following flags are disabled by default and should be enabled with `hardeningEnable` for packages that take untrusted input like network services. 1205 1206 + ### `pie` {#pie} 1207 1208 Adds the `-fPIE` compiler and `-pie` linker options. Position Independent Executables are needed to take advantage of Address Space Layout Randomization, supported by modern kernel versions. While ASLR can already be enforced for data areas in the stack and heap (brk and mmap), the code areas must be compiled as position-independent. Shared libraries already do this with the `pic` flag, so they gain ASLR automatically, but binary .text regions need to be build with `pie` to gain ASLR. When this happens, ROP attacks are much harder since there are no static locations to bounce off of during a memory corruption attack. 1209
+1 -1
doc/using/overlays.chapter.md
··· 63 64 The value returned by this function should be a set similar to `pkgs/top-level/all-packages.nix`, containing overridden and/or new packages. 65 66 - Overlays are similar to other methods for customizing Nixpkgs, in particular the `packageOverrides` attribute described in <xref linkend="sec-modify-via-packageOverrides"/>. Indeed, `packageOverrides` acts as an overlay with only the `super` argument. It is therefore appropriate for basic use, but overlays are more powerful and easier to distribute. 67 68 ## Using overlays to configure alternatives {#sec-overlays-alternatives} 69
··· 63 64 The value returned by this function should be a set similar to `pkgs/top-level/all-packages.nix`, containing overridden and/or new packages. 65 66 + Overlays are similar to other methods for customizing Nixpkgs, in particular the `packageOverrides` attribute described in [](#sec-modify-via-packageOverrides). Indeed, `packageOverrides` acts as an overlay with only the `super` argument. It is therefore appropriate for basic use, but overlays are more powerful and easier to distribute. 67 68 ## Using overlays to configure alternatives {#sec-overlays-alternatives} 69
+6 -6
doc/using/overrides.chapter.md
··· 48 49 The argument `oldAttrs` is conventionally used to refer to the attr set originally passed to `stdenv.mkDerivation`. 50 51 - ::: note 52 - Note that `separateDebugInfo` is processed only by the `stdenv.mkDerivation` function, not the generated, raw Nix derivation. Thus, using `overrideDerivation` will not work in this case, as it overrides only the attributes of the final derivation. It is for this reason that `overrideAttrs` should be preferred in (almost) all cases to `overrideDerivation`, i.e. to allow using `stdenv.mkDerivation` to process input arguments, as well as the fact that it is easier to use (you can use the same attribute names you see in your Nix code, instead of the ones generated (e.g. `buildInputs` vs `nativeBuildInputs`), and it involves less typing). 53 ::: 54 55 ## &lt;pkg&gt;.overrideDerivation {#sec-pkg-overrideDerivation} 56 57 - ::: warning 58 You should prefer `overrideAttrs` in almost all cases, see its documentation for the reasons why. `overrideDerivation` is not deprecated and will continue to work, but is less nice to use and does not have as many abilities as `overrideAttrs`. 59 ::: 60 61 - ::: warning 62 Do not use this function in Nixpkgs as it evaluates a Derivation before modifying it, which breaks package abstraction and removes error-checking of function arguments. In addition, this evaluation-per-function application incurs a performance penalty, which can become a problem if many overrides are used. It is only intended for ad-hoc customisation, such as in `~/.config/nixpkgs/config.nix`. 63 ::: 64 ··· 81 82 The argument `oldAttrs` is used to refer to the attribute set of the original derivation. 83 84 - ::: note 85 - A package's attributes are evaluated *before* being modified by the `overrideDerivation` function. For example, the `name` attribute reference in `url = "mirror://gnu/hello/${name}.tar.gz";` is filled-in *before* the `overrideDerivation` function modifies the attribute set. This means that overriding the `name` attribute, in this example, *will not* change the value of the `url` attribute. Instead, we need to override both the `name` *and* `url` attributes. 86 ::: 87 88 ## lib.makeOverridable {#sec-lib-makeOverridable}
··· 48 49 The argument `oldAttrs` is conventionally used to refer to the attr set originally passed to `stdenv.mkDerivation`. 50 51 + ::: {.note} 52 + Note that `separateDebugInfo` is processed only by the `stdenv.mkDerivation` function, not the generated, raw Nix derivation. Thus, using `overrideDerivation` will not work in this case, as it overrides only the attributes of the final derivation. It is for this reason that `overrideAttrs` should be preferred in (almost) all cases to `overrideDerivation`, i.e. to allow using `stdenv.mkDerivation` to process input arguments, as well as the fact that it is easier to use (you can use the same attribute names you see in your Nix code, instead of the ones generated (e.g. `buildInputs` vs `nativeBuildInputs`), and it involves less typing). 53 ::: 54 55 ## &lt;pkg&gt;.overrideDerivation {#sec-pkg-overrideDerivation} 56 57 + ::: {.warning} 58 You should prefer `overrideAttrs` in almost all cases, see its documentation for the reasons why. `overrideDerivation` is not deprecated and will continue to work, but is less nice to use and does not have as many abilities as `overrideAttrs`. 59 ::: 60 61 + ::: {.warning} 62 Do not use this function in Nixpkgs as it evaluates a Derivation before modifying it, which breaks package abstraction and removes error-checking of function arguments. In addition, this evaluation-per-function application incurs a performance penalty, which can become a problem if many overrides are used. It is only intended for ad-hoc customisation, such as in `~/.config/nixpkgs/config.nix`. 63 ::: 64 ··· 81 82 The argument `oldAttrs` is used to refer to the attribute set of the original derivation. 83 84 + ::: {.note} 85 + A package's attributes are evaluated *before* being modified by the `overrideDerivation` function. For example, the `name` attribute reference in `url = "mirror://gnu/hello/${name}.tar.gz";` is filled-in *before* the `overrideDerivation` function modifies the attribute set. This means that overriding the `name` attribute, in this example, *will not* change the value of the `url` attribute. Instead, we need to override both the `name` *and* `url` attributes. 86 ::: 87 88 ## lib.makeOverridable {#sec-lib-makeOverridable}
+9 -1
nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
··· 24 </section> 25 <section xml:id="new-services"> 26 <title>New Services</title> 27 - <itemizedlist spacing="compact"> 28 <listitem> 29 <para> 30 <link xlink:href="https://github.com/maxmind/geoipupdate">geoipupdate</link>, 31 a GeoIP database updater from MaxMind. Available as 32 <link xlink:href="options.html#opt-services.geoipupdate.enable">services.geoipupdate</link>. 33 </para> 34 </listitem> 35 </itemizedlist>
··· 24 </section> 25 <section xml:id="new-services"> 26 <title>New Services</title> 27 + <itemizedlist> 28 <listitem> 29 <para> 30 <link xlink:href="https://github.com/maxmind/geoipupdate">geoipupdate</link>, 31 a GeoIP database updater from MaxMind. Available as 32 <link xlink:href="options.html#opt-services.geoipupdate.enable">services.geoipupdate</link>. 33 + </para> 34 + </listitem> 35 + <listitem> 36 + <para> 37 + <link xlink:href="https://sr.ht">sourcehut</link>, a 38 + collection of tools useful for software development. Available 39 + as 40 + <link xlink:href="options.html#opt-services.sourcehut.enable">services.sourcehut</link>. 41 </para> 42 </listitem> 43 </itemizedlist>
+4
nixos/doc/manual/release-notes/rl-2111.section.md
··· 14 database updater from MaxMind. Available as 15 [services.geoipupdate](options.html#opt-services.geoipupdate.enable). 16 17 ## Backward Incompatibilities 18 19 * The `staticjinja` package has been upgraded from 1.0.4 to 2.0.0
··· 14 database updater from MaxMind. Available as 15 [services.geoipupdate](options.html#opt-services.geoipupdate.enable). 16 17 + * [sourcehut](https://sr.ht), a collection of tools useful for software 18 + development. Available as 19 + [services.sourcehut](options.html#opt-services.sourcehut.enable). 20 + 21 ## Backward Incompatibilities 22 23 * The `staticjinja` package has been upgraded from 1.0.4 to 2.0.0
+7
nixos/modules/virtualisation/libvirtd.nix
··· 155 156 config = mkIf cfg.enable { 157 158 environment = { 159 # this file is expected in /etc/qemu and not sysconfdir (/var/lib) 160 etc."qemu/bridge.conf".text = lib.concatMapStringsSep "\n" (e:
··· 155 156 config = mkIf cfg.enable { 157 158 + assertions = [ 159 + { 160 + assertion = config.security.polkit.enable; 161 + message = "The libvirtd module currently requires Polkit to be enabled ('security.polkit.enable = true')."; 162 + } 163 + ]; 164 + 165 environment = { 166 # this file is expected in /etc/qemu and not sysconfdir (/var/lib) 167 etc."qemu/bridge.conf".text = lib.concatMapStringsSep "\n" (e:
+2
pkgs/applications/editors/neovim/utils.nix
··· 148 , vimAlias ? false 149 , viAlias ? false 150 , configure ? {} 151 }: 152 let 153 /* for compatibility with passing extraPythonPackages as a list; added 2018-07-11 */ ··· 160 extraPython3Packages = compatFun extraPython3Packages; 161 inherit withNodeJs withRuby viAlias vimAlias; 162 inherit configure; 163 }; 164 in 165 assert withPython -> throw "Python2 support has been removed from neovim, please remove withPython and extraPythonPackages.";
··· 148 , vimAlias ? false 149 , viAlias ? false 150 , configure ? {} 151 + , extraName ? "" 152 }: 153 let 154 /* for compatibility with passing extraPythonPackages as a list; added 2018-07-11 */ ··· 161 extraPython3Packages = compatFun extraPython3Packages; 162 inherit withNodeJs withRuby viAlias vimAlias; 163 inherit configure; 164 + inherit extraName; 165 }; 166 in 167 assert withPython -> throw "Python2 support has been removed from neovim, please remove withPython and extraPythonPackages.";
+16 -12
pkgs/applications/editors/neovim/wrapper.nix
··· 27 # set to false if you want to control where to save the generated config 28 # (e.g., in ~/.config/init.vim or project/.nvimrc) 29 , wrapRc ? true 30 , ... 31 }@args: 32 let 33 34 wrapperArgsStr = if isString wrapperArgs then wrapperArgs else lib.escapeShellArgs wrapperArgs; 35 36 - # If configure != {}, we can't generate the rplugin.vim file with e.g 37 - # NVIM_SYSTEM_RPLUGIN_MANIFEST *and* NVIM_RPLUGIN_MANIFEST env vars set in 38 - # the wrapper. That's why only when configure != {} (tested both here and 39 - # when postBuild is evaluated), we call makeWrapper once to generate a 40 - # wrapper with most arguments we need, excluding those that cause problems to 41 - # generate rplugin.vim, but still required for the final wrapper. 42 - finalMakeWrapperArgs = 43 - [ "${neovim}/bin/nvim" "${placeholder "out"}/bin/nvim" ] 44 - ++ [ "--set" "NVIM_SYSTEM_RPLUGIN_MANIFEST" "${placeholder "out"}/rplugin.vim" ] 45 - ++ optionals wrapRc [ "--add-flags" "-u ${writeText "init.vim" args.neovimRcContent}" ] 46 - ; 47 in 48 assert withPython2 -> throw "Python2 support has been removed from the neovim wrapper, please remove withPython2 and python2Env."; 49 ··· 116 preferLocalBuild = true; 117 118 nativeBuildInputs = [ makeWrapper ]; 119 - passthru = { unwrapped = neovim; }; 120 121 meta = neovim.meta // { 122 # To prevent builds on hydra
··· 27 # set to false if you want to control where to save the generated config 28 # (e.g., in ~/.config/init.vim or project/.nvimrc) 29 , wrapRc ? true 30 + , neovimRcContent ? "" 31 , ... 32 }@args: 33 let 34 35 wrapperArgsStr = if isString wrapperArgs then wrapperArgs else lib.escapeShellArgs wrapperArgs; 36 37 + # If configure != {}, we can't generate the rplugin.vim file with e.g 38 + # NVIM_SYSTEM_RPLUGIN_MANIFEST *and* NVIM_RPLUGIN_MANIFEST env vars set in 39 + # the wrapper. That's why only when configure != {} (tested both here and 40 + # when postBuild is evaluated), we call makeWrapper once to generate a 41 + # wrapper with most arguments we need, excluding those that cause problems to 42 + # generate rplugin.vim, but still required for the final wrapper. 43 + finalMakeWrapperArgs = 44 + [ "${neovim}/bin/nvim" "${placeholder "out"}/bin/nvim" ] 45 + ++ [ "--set" "NVIM_SYSTEM_RPLUGIN_MANIFEST" "${placeholder "out"}/rplugin.vim" ] 46 + ++ optionals wrapRc [ "--add-flags" "-u ${writeText "init.vim" neovimRcContent}" ] 47 + ; 48 in 49 assert withPython2 -> throw "Python2 support has been removed from the neovim wrapper, please remove withPython2 and python2Env."; 50 ··· 117 preferLocalBuild = true; 118 119 nativeBuildInputs = [ makeWrapper ]; 120 + passthru = { 121 + unwrapped = neovim; 122 + initRc = neovimRcContent; 123 + }; 124 125 meta = neovim.meta // { 126 # To prevent builds on hydra
-4
pkgs/applications/networking/browsers/firefox/wrapper.nix
··· 303 ln -sLt $out/lib/mozilla/pkcs11-modules $ext/lib/mozilla/pkcs11-modules/* 304 done 305 306 - # For manpages, in case the program supplies them 307 - mkdir -p $out/nix-support 308 - echo ${browser} > $out/nix-support/propagated-user-env-packages 309 - 310 311 ######################### 312 # #
··· 303 ln -sLt $out/lib/mozilla/pkcs11-modules $ext/lib/mozilla/pkcs11-modules/* 304 done 305 306 307 ######################### 308 # #
+18 -10
pkgs/applications/networking/twtxt/default.nix
··· 1 - { lib, fetchFromGitHub, buildGoModule }: 2 3 - buildGoModule rec { 4 pname = "twtxt"; 5 - version = "0.1.0"; 6 7 src = fetchFromGitHub { 8 - owner = "jointwt"; 9 repo = pname; 10 - rev = version; 11 - sha256 = "15jhfnhpk34nmad04f7xz1w041dba8cn17hq46p9n5sarjgkjiiw"; 12 }; 13 14 - vendorSha256 = "1lnf8wd2rv9d292rp8jndfdg0rjs6gfw0yg49l9spw4yzifnd7f7"; 15 16 - subPackages = [ "cmd/twt" "cmd/twtd" ]; 17 18 meta = with lib; { 19 - description = "Self-hosted, Twitter-like decentralised microblogging platform"; 20 - homepage = "https://github.com/jointwt/twtxt"; 21 license = licenses.mit; 22 maintainers = with maintainers; [ siraben ]; 23 };
··· 1 + { lib, fetchFromGitHub, buildPythonApplication, aiohttp, python-dateutil, humanize, click, pytestCheckHook, tox }: 2 3 + buildPythonApplication rec { 4 pname = "twtxt"; 5 + version = "1.2.3"; 6 7 src = fetchFromGitHub { 8 + owner = "buckket"; 9 repo = pname; 10 + rev = "v${version}"; 11 + sha256 = "sha256-AdM95G2Vz3UbVPI7fs8/D78BMxscbTGrCpIyyHzSmho="; 12 }; 13 14 + # Relax some dependencies 15 + postPatch = '' 16 + substituteInPlace setup.py \ 17 + --replace 'aiohttp>=2.2.5,<3' 'aiohttp' \ 18 + --replace 'click>=6.7,<7' 'click' \ 19 + --replace 'humanize>=0.5.1,<1' 'humanize' 20 + ''; 21 22 + propagatedBuildInputs = [ aiohttp python-dateutil humanize click ]; 23 + 24 + checkInputs = [ pytestCheckHook tox ]; 25 26 meta = with lib; { 27 + description = "Decentralised, minimalist microblogging service for hackers"; 28 + homepage = "https://github.com/buckket/twtxt"; 29 license = licenses.mit; 30 maintainers = with maintainers; [ siraben ]; 31 };
+3 -1
pkgs/build-support/bintools-wrapper/default.nix
··· 14 if libc == null then 15 null 16 else if stdenvNoCC.targetPlatform.isNetBSD then 17 - if libc != targetPackages.netbsdCross.headers then 18 targetPackages.netbsdCross.ld_elf_so 19 else 20 null
··· 14 if libc == null then 15 null 16 else if stdenvNoCC.targetPlatform.isNetBSD then 17 + if !(targetPackages ? netbsdCross) then 18 + netbsd.ld_elf_so 19 + else if libc != targetPackages.netbsdCross.headers then 20 targetPackages.netbsdCross.ld_elf_so 21 else 22 null
+2
pkgs/development/python-modules/jupyter_core/default.nix
··· 1 { lib 2 , buildPythonPackage 3 , fetchPypi 4 , ipython 5 , traitlets 6 , glibcLocales ··· 12 buildPythonPackage rec { 13 pname = "jupyter_core"; 14 version = "4.7.1"; 15 16 src = fetchPypi { 17 inherit pname version;
··· 1 { lib 2 , buildPythonPackage 3 , fetchPypi 4 + , isPy3k 5 , ipython 6 , traitlets 7 , glibcLocales ··· 13 buildPythonPackage rec { 14 pname = "jupyter_core"; 15 version = "4.7.1"; 16 + disabled = !isPy3k; 17 18 src = fetchPypi { 19 inherit pname version;
+60 -6
pkgs/test/vim/default.nix
··· 1 { vimUtils, vim_configurable, writeText, neovim, vimPlugins 2 , lib, fetchFromGitHub, neovimUtils, wrapNeovimUnstable 3 , neovim-unwrapped 4 }: 5 let 6 inherit (vimUtils) buildVimPluginFrom2Nix; 7 8 packages.myVimPackage.start = with vimPlugins; [ vim-nix ]; 9 ··· 16 } 17 ]; 18 19 - nvimConfNix = neovimUtils.makeNeovimConfig { 20 inherit plugins; 21 customRC = '' 22 " just a comment 23 ''; 24 }; 25 26 - wrapNeovim = suffix: config: 27 wrapNeovimUnstable neovim-unwrapped (config // { 28 extraName = suffix; 29 - wrapRc = true; 30 }); 31 in 32 - { 33 vim_empty_config = vimUtils.vimrcFile { beforePlugins = ""; customRC = ""; }; 34 35 ### neovim tests 36 ################## 37 - nvim_with_plugins = wrapNeovim "-with-plugins" nvimConfNix; 38 39 nvim_via_override = neovim.override { 40 configure = { 41 packages.foo.start = [ vimPlugins.ale ]; 42 customRC = '' ··· 44 ''; 45 }; 46 }; 47 48 ### vim tests 49 ################## ··· 107 test_nvim_with_remote_plugin = neovim.override { 108 configure.pathogen.pluginNames = with vimPlugins; [ deoplete-nvim ]; 109 }; 110 - }
··· 1 { vimUtils, vim_configurable, writeText, neovim, vimPlugins 2 , lib, fetchFromGitHub, neovimUtils, wrapNeovimUnstable 3 , neovim-unwrapped 4 + , fetchFromGitLab 5 + , pkgs 6 }: 7 let 8 inherit (vimUtils) buildVimPluginFrom2Nix; 9 + inherit (neovimUtils) makeNeovimConfig; 10 11 packages.myVimPackage.start = with vimPlugins; [ vim-nix ]; 12 ··· 19 } 20 ]; 21 22 + nvimConfNix = makeNeovimConfig { 23 + inherit plugins; 24 + customRC = '' 25 + " just a comment 26 + ''; 27 + }; 28 + 29 + nvimConfDontWrap = makeNeovimConfig { 30 inherit plugins; 31 customRC = '' 32 " just a comment 33 ''; 34 }; 35 36 + wrapNeovim2 = suffix: config: 37 wrapNeovimUnstable neovim-unwrapped (config // { 38 extraName = suffix; 39 }); 40 + 41 + nmt = fetchFromGitLab { 42 + owner = "rycee"; 43 + repo = "nmt"; 44 + rev = "d2cc8c1042b1c2511f68f40e2790a8c0e29eeb42"; 45 + sha256 = "1ykcvyx82nhdq167kbnpgwkgjib8ii7c92y3427v986n2s5lsskc"; 46 + }; 47 + 48 + runTest = neovim-drv: buildCommand: 49 + pkgs.runCommandLocal "test-${neovim-drv.name}" ({ 50 + nativeBuildInputs = [ ]; 51 + meta.platforms = neovim-drv.meta.platforms; 52 + }) ('' 53 + source ${nmt}/bash-lib/assertions.sh 54 + vimrc="${writeText "init.vim" neovim-drv.initRc}" 55 + vimrcGeneric="$out/patched.vim" 56 + mkdir $out 57 + ${pkgs.perl}/bin/perl -pe "s|\Q$NIX_STORE\E/[a-z0-9]{32}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" < "$vimrc" > "$vimrcGeneric" 58 + '' + buildCommand); 59 + 60 in 61 + pkgs.recurseIntoAttrs ( 62 + rec { 63 vim_empty_config = vimUtils.vimrcFile { beforePlugins = ""; customRC = ""; }; 64 65 ### neovim tests 66 ################## 67 + nvim_with_plugins = wrapNeovim2 "-with-plugins" nvimConfNix; 68 69 nvim_via_override = neovim.override { 70 + extraName = "-via-override"; 71 configure = { 72 packages.foo.start = [ vimPlugins.ale ]; 73 customRC = '' ··· 75 ''; 76 }; 77 }; 78 + 79 + 80 + # nixpkgs should detect that no wrapping is necessary 81 + nvimShouldntWrap = wrapNeovim2 "-should-not-wrap" nvimConfNix; 82 + 83 + 84 + # this will generate a neovimRc content but we disable wrapping 85 + nvimDontWrap = wrapNeovim2 "-dont-wrap" (makeNeovimConfig { 86 + wrapRc = false; 87 + customRC = '' 88 + " this shouldn't trigger the creation of an init.vim 89 + ''; 90 + }); 91 + 92 + nvim_dontwrap-test = runTest nvimDontWrap '' 93 + ! grep "-u" ${nvimDontWrap}/bin/nvim 94 + ''; 95 + 96 + nvim_via_override-test = runTest nvim_via_override '' 97 + assertFileContent \ 98 + "$vimrcGeneric" \ 99 + "${./neovim-override.vim}" 100 + ''; 101 102 ### vim tests 103 ################## ··· 161 test_nvim_with_remote_plugin = neovim.override { 162 configure.pathogen.pluginNames = with vimPlugins; [ deoplete-nvim ]; 163 }; 164 + })
+7
pkgs/test/vim/neovim-override.vim
···
··· 1 + " configuration generated by NIX 2 + set nocompatible 3 + 4 + set packpath^=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vim-pack-dir 5 + set runtimepath^=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vim-pack-dir 6 + 7 + :help ale
+1 -1
pkgs/top-level/all-packages.nix
··· 9346 9347 twitterBootstrap = callPackage ../development/web/twitter-bootstrap {}; 9348 9349 - twtxt = callPackage ../applications/networking/twtxt { }; 9350 9351 txr = callPackage ../tools/misc/txr { stdenv = clangStdenv; }; 9352
··· 9346 9347 twitterBootstrap = callPackage ../development/web/twitter-bootstrap {}; 9348 9349 + twtxt = python3Packages.callPackage ../applications/networking/twtxt { }; 9350 9351 txr = callPackage ../tools/misc/txr { stdenv = clangStdenv; }; 9352