Merge remote-tracking branch 'origin/master' into weechat-unwrapped
This commit is contained in:
commit
9504292b1e
@ -1,8 +0,0 @@
|
|||||||
;;; Directory Local Variables
|
|
||||||
;;; For more information see (info "(emacs) Directory Variables")
|
|
||||||
|
|
||||||
((nil
|
|
||||||
(bug-reference-bug-regexp . "\\(\\(?:[Ii]ssue \\|[Ff]ixe[ds] \\|[Rr]esolve[ds]? \\|[Cc]lose[ds]? \\|[Pp]\\(?:ull [Rr]equest\\|[Rr]\\) \\|(\\)#\\([0-9]+\\))?\\)")
|
|
||||||
(bug-reference-url-format . "https://github.com/NixOS/nixpkgs/issues/%s"))
|
|
||||||
(nix-mode
|
|
||||||
(tab-width . 2)))
|
|
36
.github/CODEOWNERS
vendored
36
.github/CODEOWNERS
vendored
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
# Libraries
|
# Libraries
|
||||||
/lib @edolstra @nbp
|
/lib @edolstra @nbp
|
||||||
/lib/systems @nbp @ericson2314
|
/lib/systems @nbp @ericson2314 @matthewbauer
|
||||||
/lib/generators.nix @edolstra @nbp @Profpatsch
|
/lib/generators.nix @edolstra @nbp @Profpatsch
|
||||||
/lib/debug.nix @edolstra @nbp @Profpatsch
|
/lib/debug.nix @edolstra @nbp @Profpatsch
|
||||||
|
|
||||||
@ -20,8 +20,11 @@
|
|||||||
/default.nix @nbp
|
/default.nix @nbp
|
||||||
/pkgs/top-level/default.nix @nbp @Ericson2314
|
/pkgs/top-level/default.nix @nbp @Ericson2314
|
||||||
/pkgs/top-level/impure.nix @nbp @Ericson2314
|
/pkgs/top-level/impure.nix @nbp @Ericson2314
|
||||||
/pkgs/top-level/stage.nix @nbp @Ericson2314
|
/pkgs/top-level/stage.nix @nbp @Ericson2314 @matthewbauer
|
||||||
/pkgs/stdenv
|
/pkgs/top-level/splice.nix @Ericson2314 @matthewbauer
|
||||||
|
/pkgs/top-level/release-cross.nix @Ericson2314 @matthewbauer
|
||||||
|
/pkgs/stdenv/generic @Ericson2314 @matthewbauer
|
||||||
|
/pkgs/stdenv/cross @Ericson2314 @matthewbauer
|
||||||
/pkgs/build-support/cc-wrapper @Ericson2314 @orivej
|
/pkgs/build-support/cc-wrapper @Ericson2314 @orivej
|
||||||
/pkgs/build-support/bintools-wrapper @Ericson2314 @orivej
|
/pkgs/build-support/bintools-wrapper @Ericson2314 @orivej
|
||||||
/pkgs/build-support/setup-hooks @Ericson2314
|
/pkgs/build-support/setup-hooks @Ericson2314
|
||||||
@ -44,6 +47,9 @@
|
|||||||
/nixos/doc/manual/man-nixos-option.xml @nbp
|
/nixos/doc/manual/man-nixos-option.xml @nbp
|
||||||
/nixos/modules/installer/tools/nixos-option.sh @nbp
|
/nixos/modules/installer/tools/nixos-option.sh @nbp
|
||||||
|
|
||||||
|
# NixOS modules
|
||||||
|
/nixos/modules @Infinisil
|
||||||
|
|
||||||
# Python-related code and docs
|
# Python-related code and docs
|
||||||
/maintainers/scripts/update-python-libraries @FRidh
|
/maintainers/scripts/update-python-libraries @FRidh
|
||||||
/pkgs/top-level/python-packages.nix @FRidh
|
/pkgs/top-level/python-packages.nix @FRidh
|
||||||
@ -73,6 +79,14 @@
|
|||||||
/pkgs/stdenv/darwin @NixOS/darwin-maintainers
|
/pkgs/stdenv/darwin @NixOS/darwin-maintainers
|
||||||
/pkgs/os-specific/darwin @NixOS/darwin-maintainers
|
/pkgs/os-specific/darwin @NixOS/darwin-maintainers
|
||||||
|
|
||||||
|
# C compilers
|
||||||
|
/pkgs/development/compilers/gcc @matthewbauer
|
||||||
|
/pkgs/development/compilers/llvm @matthewbauer
|
||||||
|
|
||||||
|
# Compatibility stuff
|
||||||
|
/pkgs/top-level/unix-tools.nix @matthewbauer
|
||||||
|
/pkgs/development/tools/xcbuild @matthewbauer
|
||||||
|
|
||||||
# Beam-related (Erlang, Elixir, LFE, etc)
|
# Beam-related (Erlang, Elixir, LFE, etc)
|
||||||
/pkgs/development/beam-modules @gleber
|
/pkgs/development/beam-modules @gleber
|
||||||
/pkgs/development/interpreters/erlang @gleber
|
/pkgs/development/interpreters/erlang @gleber
|
||||||
@ -96,3 +110,19 @@
|
|||||||
/pkgs/desktops/plasma-5 @ttuegel
|
/pkgs/desktops/plasma-5 @ttuegel
|
||||||
/pkgs/development/libraries/kde-frameworks @ttuegel
|
/pkgs/development/libraries/kde-frameworks @ttuegel
|
||||||
/pkgs/development/libraries/qt-5 @ttuegel
|
/pkgs/development/libraries/qt-5 @ttuegel
|
||||||
|
|
||||||
|
# PostgreSQL and related stuff
|
||||||
|
/pkgs/servers/sql/postgresql @thoughtpolice
|
||||||
|
/nixos/modules/services/databases/postgresql.xml @thoughtpolice
|
||||||
|
/nixos/modules/services/databases/postgresql.nix @thoughtpolice
|
||||||
|
/nixos/tests/postgresql.nix @thoughtpolice
|
||||||
|
|
||||||
|
# Dhall
|
||||||
|
/pkgs/development/dhall-modules @Gabriel439 @Profpatsch
|
||||||
|
/pkgs/development/interpreters/dhall @Gabriel439 @Profpatsch
|
||||||
|
|
||||||
|
# Idris
|
||||||
|
/pkgs/development/idris-modules @Infinisil
|
||||||
|
|
||||||
|
# Bazel
|
||||||
|
/pkgs/development/tools/build-managers/bazel @mboes @Profpatsch
|
||||||
|
4
.github/CONTRIBUTING.md
vendored
4
.github/CONTRIBUTING.md
vendored
@ -20,6 +20,8 @@ under the terms of [COPYING](../COPYING), which is an MIT-like license.
|
|||||||
(Motivation for change. Additional information.)
|
(Motivation for change. Additional information.)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For consistency, there should not be a period at the end of the commit message's summary line (the first line of the commit message).
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
* nginx: init at 2.0.1
|
* nginx: init at 2.0.1
|
||||||
@ -43,7 +45,7 @@ See the nixpkgs manual for more details on [standard meta-attributes](https://ni
|
|||||||
|
|
||||||
## Writing good commit messages
|
## Writing good commit messages
|
||||||
|
|
||||||
In addition to writing properly formatted commit messages, it's important to include relevant information so other developers can later understand *why* a change was made. While this information usually can be found by digging code, mailing list archives, pull request discussions or upstream changes, it may require a lot of work.
|
In addition to writing properly formatted commit messages, it's important to include relevant information so other developers can later understand *why* a change was made. While this information usually can be found by digging code, mailing list/Discourse archives, pull request discussions or upstream changes, it may require a lot of work.
|
||||||
|
|
||||||
For package version upgrades and such a one-line commit message is usually sufficient.
|
For package version upgrades and such a one-line commit message is usually sufficient.
|
||||||
|
|
||||||
|
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -14,6 +14,7 @@
|
|||||||
- [ ] Tested compilation of all pkgs that depend on this change using `nix-shell -p nox --run "nox-review wip"`
|
- [ ] Tested compilation of all pkgs that depend on this change using `nix-shell -p nox --run "nox-review wip"`
|
||||||
- [ ] Tested execution of all binary files (usually in `./result/bin/`)
|
- [ ] Tested execution of all binary files (usually in `./result/bin/`)
|
||||||
- [ ] Determined the impact on package closure size (by running `nix path-info -S` before and after)
|
- [ ] Determined the impact on package closure size (by running `nix path-info -S` before and after)
|
||||||
|
- [ ] Assured whether relevant documentation is up to date
|
||||||
- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md).
|
- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
9
COPYING
9
COPYING
@ -18,12 +18,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
======================================================================
|
|
||||||
|
|
||||||
Note: the license above does not apply to the packages built by the
|
|
||||||
Nix Packages collection, merely to the package descriptions (i.e., Nix
|
|
||||||
expressions, build scripts, etc.). It also might not apply to patches
|
|
||||||
included in Nixpkgs, which may be derivative works of the packages to
|
|
||||||
which they apply. The aforementioned artifacts are all covered by the
|
|
||||||
licenses of the respective packages.
|
|
||||||
|
20
README.md
20
README.md
@ -8,19 +8,19 @@ build daemon as so-called channels. To get channel information via git, add
|
|||||||
[nixpkgs-channels](https://github.com/NixOS/nixpkgs-channels.git) as a remote:
|
[nixpkgs-channels](https://github.com/NixOS/nixpkgs-channels.git) as a remote:
|
||||||
|
|
||||||
```
|
```
|
||||||
% git remote add channels git://github.com/NixOS/nixpkgs-channels.git
|
% git remote add channels https://github.com/NixOS/nixpkgs-channels.git
|
||||||
```
|
```
|
||||||
|
|
||||||
For stability and maximum binary package support, it is recommended to maintain
|
For stability and maximum binary package support, it is recommended to maintain
|
||||||
custom changes on top of one of the channels, e.g. `nixos-18.03` for the latest
|
custom changes on top of one of the channels, e.g. `nixos-18.09` for the latest
|
||||||
release and `nixos-unstable` for the latest successful build of master:
|
release and `nixos-unstable` for the latest successful build of master:
|
||||||
|
|
||||||
```
|
```
|
||||||
% git remote update channels
|
% git remote update channels
|
||||||
% git rebase channels/nixos-18.03
|
% git rebase channels/nixos-18.09
|
||||||
```
|
```
|
||||||
|
|
||||||
For pull-requests, please rebase onto nixpkgs `master`.
|
For pull requests, please rebase onto nixpkgs `master`.
|
||||||
|
|
||||||
[NixOS](https://nixos.org/nixos/) Linux distribution source code is located inside
|
[NixOS](https://nixos.org/nixos/) Linux distribution source code is located inside
|
||||||
`nixos/` folder.
|
`nixos/` folder.
|
||||||
@ -31,11 +31,17 @@ For pull-requests, please rebase onto nixpkgs `master`.
|
|||||||
* [Manual (NixOS)](https://nixos.org/nixos/manual/)
|
* [Manual (NixOS)](https://nixos.org/nixos/manual/)
|
||||||
* [Community maintained wiki](https://nixos.wiki/)
|
* [Community maintained wiki](https://nixos.wiki/)
|
||||||
* [Continuous package builds for unstable/master](https://hydra.nixos.org/jobset/nixos/trunk-combined)
|
* [Continuous package builds for unstable/master](https://hydra.nixos.org/jobset/nixos/trunk-combined)
|
||||||
* [Continuous package builds for 18.03 release](https://hydra.nixos.org/jobset/nixos/release-18.03)
|
* [Continuous package builds for 18.09 release](https://hydra.nixos.org/jobset/nixos/release-18.09)
|
||||||
* [Tests for unstable/master](https://hydra.nixos.org/job/nixos/trunk-combined/tested#tabs-constituents)
|
* [Tests for unstable/master](https://hydra.nixos.org/job/nixos/trunk-combined/tested#tabs-constituents)
|
||||||
* [Tests for 18.03 release](https://hydra.nixos.org/job/nixos/release-18.03/tested#tabs-constituents)
|
* [Tests for 18.09 release](https://hydra.nixos.org/job/nixos/release-18.09/tested#tabs-constituents)
|
||||||
|
|
||||||
Communication:
|
Communication:
|
||||||
|
|
||||||
* [Mailing list](https://groups.google.com/forum/#!forum/nix-devel)
|
* [Discourse Forum](https://discourse.nixos.org/)
|
||||||
* [IRC - #nixos on freenode.net](irc://irc.freenode.net/#nixos)
|
* [IRC - #nixos on freenode.net](irc://irc.freenode.net/#nixos)
|
||||||
|
|
||||||
|
Note: MIT license does not apply to the packages built by Nixpkgs, merely to
|
||||||
|
the package descriptions (Nix expressions, build scripts, and so on). It also
|
||||||
|
might not apply to patches included in Nixpkgs, which may be derivative works
|
||||||
|
of the packages to which they apply. The aforementioned artifacts are all
|
||||||
|
covered by the licenses of the respective packages.
|
||||||
|
@ -15,6 +15,12 @@ if ! builtins ? nixVersion || builtins.compareVersions requiredVersion builtins.
|
|||||||
it is safe to upgrade by running it again:
|
it is safe to upgrade by running it again:
|
||||||
|
|
||||||
curl https://nixos.org/nix/install | sh
|
curl https://nixos.org/nix/install | sh
|
||||||
|
|
||||||
|
For more information, please see the NixOS release notes at
|
||||||
|
https://nixos.org/nixos/manual or locally at
|
||||||
|
${toString ./nixos/doc/manual/release-notes}.
|
||||||
|
|
||||||
|
If you need further help, see https://nixos.org/nixos/support.html
|
||||||
''
|
''
|
||||||
|
|
||||||
else
|
else
|
||||||
|
1
doc/.gitignore
vendored
1
doc/.gitignore
vendored
@ -4,3 +4,4 @@
|
|||||||
out
|
out
|
||||||
manual-full.xml
|
manual-full.xml
|
||||||
highlightjs
|
highlightjs
|
||||||
|
functions/library/locations.xml
|
||||||
|
@ -19,7 +19,7 @@ fix-misc-xml:
|
|||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -f ${MD_TARGETS} .version manual-full.xml
|
rm -f ${MD_TARGETS} .version manual-full.xml functions/library/locations.xml
|
||||||
rm -rf ./out/ ./highlightjs
|
rm -rf ./out/ ./highlightjs
|
||||||
|
|
||||||
.PHONY: validate
|
.PHONY: validate
|
||||||
@ -69,13 +69,17 @@ highlightjs:
|
|||||||
cp -r "$$HIGHLIGHTJS/loader.js" highlightjs/
|
cp -r "$$HIGHLIGHTJS/loader.js" highlightjs/
|
||||||
|
|
||||||
|
|
||||||
manual-full.xml: ${MD_TARGETS} .version *.xml
|
manual-full.xml: ${MD_TARGETS} .version functions/library/locations.xml *.xml **/*.xml **/**/*.xml
|
||||||
xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml
|
xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml
|
||||||
|
|
||||||
.version:
|
.version:
|
||||||
nix-instantiate --eval \
|
nix-instantiate --eval \
|
||||||
-E '(import ../lib).version' > .version
|
-E '(import ../lib).version' > .version
|
||||||
|
|
||||||
|
functions/library/locations.xml:
|
||||||
|
nix-build ./lib-function-locations.nix \
|
||||||
|
--out-link ./functions/library/locations.xml
|
||||||
|
|
||||||
%.section.xml: %.section.md
|
%.section.xml: %.section.md
|
||||||
pandoc $^ -w docbook+smart \
|
pandoc $^ -w docbook+smart \
|
||||||
-f markdown+smart \
|
-f markdown+smart \
|
||||||
|
@ -56,25 +56,30 @@ foo { arg = ...; }
|
|||||||
or list elements should be aligned:
|
or list elements should be aligned:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
# A long list.
|
# A long list.
|
||||||
list =
|
list = [
|
||||||
[ elem1
|
elem1
|
||||||
elem2
|
elem2
|
||||||
elem3
|
elem3
|
||||||
];
|
];
|
||||||
|
|
||||||
# A long attribute set.
|
# A long attribute set.
|
||||||
attrs =
|
|
||||||
{ attr1 = short_expr;
|
|
||||||
attr2 =
|
|
||||||
if true then big_expr else big_expr;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Alternatively:
|
|
||||||
attrs = {
|
attrs = {
|
||||||
attr1 = short_expr;
|
attr1 = short_expr;
|
||||||
attr2 =
|
attr2 =
|
||||||
if true then big_expr else big_expr;
|
if true then big_expr else big_expr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Combined
|
||||||
|
listOfAttrs = [
|
||||||
|
{
|
||||||
|
attr1 = 3;
|
||||||
|
attr2 = "fff";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
attr1 = 5;
|
||||||
|
attr2 = "ggg";
|
||||||
|
}
|
||||||
|
];
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -191,6 +196,23 @@ args.stdenv.mkDerivation (args // {
|
|||||||
<section xml:id="sec-package-naming">
|
<section xml:id="sec-package-naming">
|
||||||
<title>Package naming</title>
|
<title>Package naming</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The key words
|
||||||
|
<emphasis>must</emphasis>,
|
||||||
|
<emphasis>must not</emphasis>,
|
||||||
|
<emphasis>required</emphasis>,
|
||||||
|
<emphasis>shall</emphasis>,
|
||||||
|
<emphasis>shall not</emphasis>,
|
||||||
|
<emphasis>should</emphasis>,
|
||||||
|
<emphasis>should not</emphasis>,
|
||||||
|
<emphasis>recommended</emphasis>,
|
||||||
|
<emphasis>may</emphasis>,
|
||||||
|
and <emphasis>optional</emphasis> in this section
|
||||||
|
are to be interpreted as described in
|
||||||
|
<link xlink:href="https://tools.ietf.org/html/rfc2119">RFC 2119</link>.
|
||||||
|
Only <emphasis>emphasized</emphasis> words are to be interpreted in this way.
|
||||||
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
In Nixpkgs, there are generally three different names associated with a
|
In Nixpkgs, there are generally three different names associated with a
|
||||||
package:
|
package:
|
||||||
@ -231,14 +253,15 @@ args.stdenv.mkDerivation (args // {
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Generally, try to stick to the upstream package name.
|
The <literal>name</literal> attribute <emphasis>should</emphasis>
|
||||||
|
be identical to the upstream package name.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Don’t use uppercase letters in the <literal>name</literal> attribute
|
The <literal>name</literal> attribute <emphasis>must not</emphasis>
|
||||||
— e.g., <literal>"mplayer-1.0rc2"</literal> instead of
|
contain uppercase letters — e.g., <literal>"mplayer-1.0rc2"</literal>
|
||||||
<literal>"MPlayer-1.0rc2"</literal>.
|
instead of <literal>"MPlayer-1.0rc2"</literal>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -252,14 +275,14 @@ args.stdenv.mkDerivation (args // {
|
|||||||
<para>
|
<para>
|
||||||
If a package is not a release but a commit from a repository, then the
|
If a package is not a release but a commit from a repository, then the
|
||||||
version part of the name <emphasis>must</emphasis> be the date of that
|
version part of the name <emphasis>must</emphasis> be the date of that
|
||||||
(fetched) commit. The date must be in <literal>"YYYY-MM-DD"</literal>
|
(fetched) commit. The date <emphasis>must</emphasis> be in <literal>"YYYY-MM-DD"</literal>
|
||||||
format. Also append <literal>"unstable"</literal> to the name - e.g.,
|
format. Also append <literal>"unstable"</literal> to the name - e.g.,
|
||||||
<literal>"pkgname-unstable-2014-09-23"</literal>.
|
<literal>"pkgname-unstable-2014-09-23"</literal>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Dashes in the package name should be preserved in new variable names,
|
Dashes in the package name <emphasis>should</emphasis> be preserved in new variable names,
|
||||||
rather than converted to underscores or camel cased — e.g.,
|
rather than converted to underscores or camel cased — e.g.,
|
||||||
<varname>http-parser</varname> instead of <varname>http_parser</varname>
|
<varname>http-parser</varname> instead of <varname>http_parser</varname>
|
||||||
or <varname>httpParser</varname>. The hyphenated style is preferred in
|
or <varname>httpParser</varname>. The hyphenated style is preferred in
|
||||||
@ -268,7 +291,7 @@ args.stdenv.mkDerivation (args // {
|
|||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
If there are multiple versions of a package, this should be reflected in
|
If there are multiple versions of a package, this <emphasis>should</emphasis> be reflected in
|
||||||
the variable names in <filename>all-packages.nix</filename>, e.g.
|
the variable names in <filename>all-packages.nix</filename>, e.g.
|
||||||
<varname>json-c-0-9</varname> and <varname>json-c-0-11</varname>. If
|
<varname>json-c-0-9</varname> and <varname>json-c-0-11</varname>. If
|
||||||
there is an obvious “default” version, make an attribute like
|
there is an obvious “default” version, make an attribute like
|
||||||
@ -842,9 +865,12 @@ src = fetchFromGitHub {
|
|||||||
owner = "NixOS";
|
owner = "NixOS";
|
||||||
repo = "nix";
|
repo = "nix";
|
||||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
|
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
|
||||||
sha256 = "04yri911rj9j19qqqn6m82266fl05pz98inasni0vxr1cf1gdgv9";
|
sha256 = "1i2yxndxb6yc9l6c99pypbd92lfq5aac4klq7y2v93c9qvx2cgpc";
|
||||||
}
|
}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
Find the value to put as <literal>sha256</literal> by running
|
||||||
|
<literal>nix run -f '<nixpkgs>' nix-prefetch-github -c nix-prefetch-github --rev 1f795f9f44607cc5bec70d1300150bfefcef2aae NixOS nix</literal>
|
||||||
|
or <literal>nix-prefetch-url --unpack https://github.com/NixOS/nix/archive/1f795f9f44607cc5bec70d1300150bfefcef2aae.tar.gz</literal>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The difference between an a package being unsupported on some system and
|
The difference between a package being unsupported on some system and
|
||||||
being broken is admittedly a bit fuzzy. If a program
|
being broken is admittedly a bit fuzzy. If a program
|
||||||
<emphasis>ought</emphasis> to work on a certain platform, but doesn't, the
|
<emphasis>ought</emphasis> to work on a certain platform, but doesn't, the
|
||||||
platform should be included in <literal>meta.platforms</literal>, but marked
|
platform should be included in <literal>meta.platforms</literal>, but marked
|
||||||
@ -175,11 +175,12 @@
|
|||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
A more useful example, the following configuration allows only allows
|
For a more useful example, try the following. This configuration
|
||||||
flash player and visual studio code:
|
only allows unfree packages named flash player and visual studio
|
||||||
|
code:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{
|
{
|
||||||
allowUnfreePredicate = (pkg: elem (builtins.parseDrvName pkg.name).name [ "flashplayer" "vscode" ]);
|
allowUnfreePredicate = (pkg: builtins.elem (builtins.parseDrvName pkg.name).name [ "flashplayer" "vscode" ]);
|
||||||
}
|
}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
@ -286,8 +287,8 @@
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
You can define a function called <varname>packageOverrides</varname> in your
|
You can define a function called <varname>packageOverrides</varname> in your
|
||||||
local <filename>~/.config/nixpkgs/config.nix</filename> to override nix
|
local <filename>~/.config/nixpkgs/config.nix</filename> to override Nix
|
||||||
packages. It must be a function that takes pkgs as an argument and return
|
packages. It must be a function that takes pkgs as an argument and returns a
|
||||||
modified set of packages.
|
modified set of packages.
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{
|
{
|
||||||
@ -325,7 +326,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
</screen>
|
</screen>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
To install it into our environment, you can just run <literal>nix-env -iA
|
To install it into our environment, you can just run <literal>nix-env -iA
|
||||||
@ -347,7 +348,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
</screen>
|
</screen>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<literal>pathsToLink</literal> tells Nixpkgs to only link the paths listed
|
<literal>pathsToLink</literal> tells Nixpkgs to only link the paths listed
|
||||||
@ -383,7 +384,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
</screen>
|
</screen>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
This provides us with some useful documentation for using our packages.
|
This provides us with some useful documentation for using our packages.
|
||||||
@ -395,15 +396,15 @@
|
|||||||
{
|
{
|
||||||
packageOverrides = pkgs: with pkgs; rec {
|
packageOverrides = pkgs: with pkgs; rec {
|
||||||
myProfile = writeText "my-profile" ''
|
myProfile = writeText "my-profile" ''
|
||||||
export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
|
export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
|
||||||
'';
|
'';
|
||||||
myPackages = pkgs.buildEnv {
|
myPackages = pkgs.buildEnv {
|
||||||
name = "my-packages";
|
name = "my-packages";
|
||||||
paths = [
|
paths = [
|
||||||
(runCommand "profile" {} ''
|
(runCommand "profile" {} ''
|
||||||
mkdir -p $out/etc/profile.d
|
mkdir -p $out/etc/profile.d
|
||||||
cp ${myProfile} $out/etc/profile.d/my-profile.sh
|
cp ${myProfile} $out/etc/profile.d/my-profile.sh
|
||||||
'')
|
'')
|
||||||
aspell
|
aspell
|
||||||
bc
|
bc
|
||||||
@ -421,7 +422,7 @@ cp ${myProfile} $out/etc/profile.d/my-profile.sh
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
</screen>
|
</screen>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
For this to work fully, you must also have this script sourced when you are
|
For this to work fully, you must also have this script sourced when you are
|
||||||
@ -438,7 +439,7 @@ if [ -d $HOME/.nix-profile/etc/profile.d ]; then
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
</screen>
|
</screen>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Now just run <literal>source $HOME/.profile</literal> and you can starting
|
Now just run <literal>source $HOME/.profile</literal> and you can starting
|
||||||
@ -459,16 +460,16 @@ fi
|
|||||||
{
|
{
|
||||||
packageOverrides = pkgs: with pkgs; rec {
|
packageOverrides = pkgs: with pkgs; rec {
|
||||||
myProfile = writeText "my-profile" ''
|
myProfile = writeText "my-profile" ''
|
||||||
export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
|
export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
|
||||||
export INFOPATH=$HOME/.nix-profile/share/info:/nix/var/nix/profiles/default/share/info:/usr/share/info
|
export INFOPATH=$HOME/.nix-profile/share/info:/nix/var/nix/profiles/default/share/info:/usr/share/info
|
||||||
'';
|
'';
|
||||||
myPackages = pkgs.buildEnv {
|
myPackages = pkgs.buildEnv {
|
||||||
name = "my-packages";
|
name = "my-packages";
|
||||||
paths = [
|
paths = [
|
||||||
(runCommand "profile" {} ''
|
(runCommand "profile" {} ''
|
||||||
mkdir -p $out/etc/profile.d
|
mkdir -p $out/etc/profile.d
|
||||||
cp ${myProfile} $out/etc/profile.d/my-profile.sh
|
cp ${myProfile} $out/etc/profile.d/my-profile.sh
|
||||||
'')
|
'')
|
||||||
aspell
|
aspell
|
||||||
bc
|
bc
|
||||||
@ -485,17 +486,17 @@ cp ${myProfile} $out/etc/profile.d/my-profile.sh
|
|||||||
pathsToLink = [ "/share/man" "/share/doc" "/share/info" "/bin" "/etc" ];
|
pathsToLink = [ "/share/man" "/share/doc" "/share/info" "/bin" "/etc" ];
|
||||||
extraOutputsToInstall = [ "man" "doc" "info" ];
|
extraOutputsToInstall = [ "man" "doc" "info" ];
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
if [ -x $out/bin/install-info -a -w $out/share/info ]; then
|
if [ -x $out/bin/install-info -a -w $out/share/info ]; then
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
for i in $out/share/info/*.info $out/share/info/*.info.gz; do
|
for i in $out/share/info/*.info $out/share/info/*.info.gz; do
|
||||||
$out/bin/install-info $i $out/share/info/dir
|
$out/bin/install-info $i $out/share/info/dir
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
</screen>
|
</screen>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<literal>postBuild</literal> tells Nixpkgs to run a command after building
|
<literal>postBuild</literal> tells Nixpkgs to run a command after building
|
||||||
|
@ -6,17 +6,17 @@
|
|||||||
<title>Introduction</title>
|
<title>Introduction</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
"Cross-compilation" means compiling a program on one machine for another
|
"Cross-compilation" means compiling a program on one machine for another type
|
||||||
type of machine. For example, a typical use of cross compilation is to
|
of machine. For example, a typical use of cross-compilation is to compile
|
||||||
compile programs for embedded devices. These devices often don't have the
|
programs for embedded devices. These devices often don't have the computing
|
||||||
computing power and memory to compile their own programs. One might think
|
power and memory to compile their own programs. One might think that
|
||||||
that cross-compilation is a fairly niche concern, but there are advantages
|
cross-compilation is a fairly niche concern. However, there are significant
|
||||||
to being rigorous about distinguishing build-time vs run-time environments
|
advantages to rigorously distinguishing between build-time and run-time
|
||||||
even when one is developing and deploying on the same machine. Nixpkgs is
|
environments! This applies even when one is developing and deploying on the
|
||||||
increasingly adopting the opinion that packages should be written with
|
same machine. Nixpkgs is increasingly adopting the opinion that packages
|
||||||
cross-compilation in mind, and nixpkgs should evaluate in a similar way (by
|
should be written with cross-compilation in mind, and nixpkgs should evaluate
|
||||||
minimizing cross-compilation-specific special cases) whether or not one is
|
in a similar way (by minimizing cross-compilation-specific special cases)
|
||||||
cross-compiling.
|
whether or not one is cross-compiling.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -30,30 +30,27 @@
|
|||||||
<section xml:id="sec-cross-packaging">
|
<section xml:id="sec-cross-packaging">
|
||||||
<title>Packaging in a cross-friendly manner</title>
|
<title>Packaging in a cross-friendly manner</title>
|
||||||
|
|
||||||
<section>
|
<section xml:id="sec-cross-platform-parameters">
|
||||||
<title>Platform parameters</title>
|
<title>Platform parameters</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Nixpkgs follows the
|
Nixpkgs follows the <link
|
||||||
<link xlink:href="https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html">common
|
xlink:href="https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html">conventions
|
||||||
historical convention of GNU autoconf</link> of distinguishing between 3
|
of GNU autoconf</link>. We distinguish between 3 types of platforms when
|
||||||
types of platform: <wordasword>build</wordasword>,
|
building a derivation: <wordasword>build</wordasword>,
|
||||||
<wordasword>host</wordasword>, and <wordasword>target</wordasword>. In
|
<wordasword>host</wordasword>, and <wordasword>target</wordasword>. In
|
||||||
summary, <wordasword>build</wordasword> is the platform on which a package
|
summary, <wordasword>build</wordasword> is the platform on which a package
|
||||||
is being built, <wordasword>host</wordasword> is the platform on which it
|
is being built, <wordasword>host</wordasword> is the platform on which it
|
||||||
is to run. The third attribute, <wordasword>target</wordasword>, is
|
will run. The third attribute, <wordasword>target</wordasword>, is relevant
|
||||||
relevant only for certain specific compilers and build tools.
|
only for certain specific compilers and build tools.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
In Nixpkgs, these three platforms are defined as attribute sets under the
|
In Nixpkgs, these three platforms are defined as attribute sets under the
|
||||||
names <literal>buildPlatform</literal>, <literal>hostPlatform</literal>,
|
names <literal>buildPlatform</literal>, <literal>hostPlatform</literal>,
|
||||||
and <literal>targetPlatform</literal>. All three are always defined as
|
and <literal>targetPlatform</literal>. They are always defined as
|
||||||
attributes in the standard environment, and at the top level. That means
|
attributes in the standard environment. That means one can access them
|
||||||
one can get at them just like a dependency in a function that is imported
|
like:
|
||||||
with <literal>callPackage</literal>:
|
|
||||||
<programlisting>{ stdenv, buildPlatform, hostPlatform, fooDep, barDep, .. }: ...buildPlatform...</programlisting>
|
|
||||||
, or just off <varname>stdenv</varname>:
|
|
||||||
<programlisting>{ stdenv, fooDep, barDep, .. }: ...stdenv.buildPlatform...</programlisting>
|
<programlisting>{ stdenv, fooDep, barDep, .. }: ...stdenv.buildPlatform...</programlisting>
|
||||||
.
|
.
|
||||||
</para>
|
</para>
|
||||||
@ -67,7 +64,7 @@
|
|||||||
<para>
|
<para>
|
||||||
The "build platform" is the platform on which a package is built. Once
|
The "build platform" is the platform on which a package is built. Once
|
||||||
someone has a built package, or pre-built binary package, the build
|
someone has a built package, or pre-built binary package, the build
|
||||||
platform should not matter and be safe to ignore.
|
platform should not matter and can be ignored.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -97,11 +94,11 @@
|
|||||||
<para>
|
<para>
|
||||||
The build process of certain compilers is written in such a way that the
|
The build process of certain compilers is written in such a way that the
|
||||||
compiler resulting from a single build can itself only produce binaries
|
compiler resulting from a single build can itself only produce binaries
|
||||||
for a single platform. The task specifying this single "target platform"
|
for a single platform. The task of specifying this single "target
|
||||||
is thus pushed to build time of the compiler. The root cause of this
|
platform" is thus pushed to build time of the compiler. The root cause of
|
||||||
mistake is often that the compiler (which will be run on the host) and
|
this that the compiler (which will be run on the host) and the standard
|
||||||
the the standard library/runtime (which will be run on the target) are
|
library/runtime (which will be run on the target) are built by a single
|
||||||
built by a single build process.
|
build process.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
There is no fundamental need to think about a single target ahead of
|
There is no fundamental need to think about a single target ahead of
|
||||||
@ -138,8 +135,10 @@
|
|||||||
<para>
|
<para>
|
||||||
This is a two-component shorthand for the platform. Examples of this
|
This is a two-component shorthand for the platform. Examples of this
|
||||||
would be "x86_64-darwin" and "i686-linux"; see
|
would be "x86_64-darwin" and "i686-linux"; see
|
||||||
<literal>lib.systems.doubles</literal> for more. This format isn't very
|
<literal>lib.systems.doubles</literal> for more. The first component
|
||||||
standard, but has built-in support in Nix, such as the
|
corresponds to the CPU architecture of the platform and the second to the
|
||||||
|
operating system of the platform (<literal>[cpu]-[os]</literal>). This
|
||||||
|
format has built-in support in Nix, such as the
|
||||||
<varname>builtins.currentSystem</varname> impure string.
|
<varname>builtins.currentSystem</varname> impure string.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -150,12 +149,13 @@
|
|||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
This is a 3- or 4- component shorthand for the platform. Examples of
|
This is a 3- or 4- component shorthand for the platform. Examples of this
|
||||||
this would be "x86_64-unknown-linux-gnu" and "aarch64-apple-darwin14".
|
would be <literal>x86_64-unknown-linux-gnu</literal> and
|
||||||
This is a standard format called the "LLVM target triple", as they are
|
<literal>aarch64-apple-darwin14</literal>. This is a standard format
|
||||||
pioneered by LLVM and traditionally just used for the
|
called the "LLVM target triple", as they are pioneered by LLVM. In the
|
||||||
<varname>targetPlatform</varname>. This format is strictly more
|
4-part form, this corresponds to
|
||||||
informative than the "Nix host double", as the previous format could
|
<literal>[cpu]-[vendor]-[os]-[abi]</literal>. This format is strictly
|
||||||
|
more informative than the "Nix host double", as the previous format could
|
||||||
analogously be termed. This needs a better name than
|
analogously be termed. This needs a better name than
|
||||||
<varname>config</varname>!
|
<varname>config</varname>!
|
||||||
</para>
|
</para>
|
||||||
@ -167,12 +167,11 @@
|
|||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
This is a nix representation of a parsed LLVM target triple with
|
This is a Nix representation of a parsed LLVM target triple
|
||||||
white-listed components. This can be specified directly, or actually
|
with white-listed components. This can be specified directly,
|
||||||
parsed from the <varname>config</varname>. [Technically, only one need
|
or actually parsed from the <varname>config</varname>. See
|
||||||
be specified and the others can be inferred, though the precision of
|
<literal>lib.systems.parse</literal> for the exact
|
||||||
inference may not be very good.] See
|
representation.
|
||||||
<literal>lib.systems.parse</literal> for the exact representation.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -196,7 +195,7 @@
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
These predicates are defined in <literal>lib.systems.inspect</literal>,
|
These predicates are defined in <literal>lib.systems.inspect</literal>,
|
||||||
and slapped on every platform. They are superior to the ones in
|
and slapped onto every platform. They are superior to the ones in
|
||||||
<varname>stdenv</varname> as they force the user to be explicit about
|
<varname>stdenv</varname> as they force the user to be explicit about
|
||||||
which platform they are inspecting. Please use these instead of those.
|
which platform they are inspecting. Please use these instead of those.
|
||||||
</para>
|
</para>
|
||||||
@ -219,12 +218,12 @@
|
|||||||
</variablelist>
|
</variablelist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="sec-cross-specifying-dependencies">
|
||||||
<title>Specifying Dependencies</title>
|
<title>Specifying Dependencies</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
In this section we explore the relationship between both runtime and
|
In this section we explore the relationship between both runtime and
|
||||||
buildtime dependencies and the 3 Autoconf platforms.
|
build-time dependencies and the 3 Autoconf platforms.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -252,17 +251,17 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Some examples will probably make this clearer. If a package is being built
|
Some examples will make this clearer. If a package is being built with a
|
||||||
with a <literal>(build, host, target)</literal> platform triple of
|
<literal>(build, host, target)</literal> platform triple of <literal>(foo,
|
||||||
<literal>(foo, bar, bar)</literal>, then its build-time dependencies would
|
bar, bar)</literal>, then its build-time dependencies would have a triple of
|
||||||
have a triple of <literal>(foo, foo, bar)</literal>, and <emphasis>those
|
<literal>(foo, foo, bar)</literal>, and <emphasis>those packages'</emphasis>
|
||||||
packages'</emphasis> build-time dependencies would have triple of
|
build-time dependencies would have a triple of <literal>(foo, foo,
|
||||||
<literal>(foo, foo, foo)</literal>. In other words, it should take two
|
foo)</literal>. In other words, it should take two "rounds" of following
|
||||||
"rounds" of following build-time dependency edges before one reaches a
|
build-time dependency edges before one reaches a fixed point where, by the
|
||||||
fixed point where, by the sliding window principle, the platform triple no
|
sliding window principle, the platform triple no longer changes. Indeed,
|
||||||
longer changes. Indeed, this happens with cross compilation, where only
|
this happens with cross-compilation, where only rounds of native
|
||||||
rounds of native dependencies starting with the second necessarily coincide
|
dependencies starting with the second necessarily coincide with native
|
||||||
with native packages.
|
packages.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
@ -274,23 +273,23 @@
|
|||||||
</note>
|
</note>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
How does this work in practice? Nixpkgs is now structured so that
|
How does this work in practice? Nixpkgs is now structured so that build-time
|
||||||
build-time dependencies are taken from <varname>buildPackages</varname>,
|
dependencies are taken from <varname>buildPackages</varname>, whereas
|
||||||
whereas run-time dependencies are taken from the top level attribute set.
|
run-time dependencies are taken from the top level attribute set. For
|
||||||
For example, <varname>buildPackages.gcc</varname> should be used at build
|
example, <varname>buildPackages.gcc</varname> should be used at build-time,
|
||||||
time, while <varname>gcc</varname> should be used at run time. Now, for
|
while <varname>gcc</varname> should be used at run-time. Now, for most of
|
||||||
most of Nixpkgs's history, there was no <varname>buildPackages</varname>,
|
Nixpkgs's history, there was no <varname>buildPackages</varname>, and most
|
||||||
and most packages have not been refactored to use it explicitly. Instead,
|
packages have not been refactored to use it explicitly. Instead, one can use
|
||||||
one can use the six (<emphasis>gasp</emphasis>) attributes used for
|
the six (<emphasis>gasp</emphasis>) attributes used for specifying
|
||||||
specifying dependencies as documented in
|
dependencies as documented in <xref linkend="ssec-stdenv-dependencies"/>. We
|
||||||
<xref linkend="ssec-stdenv-dependencies"/>. We "splice" together the
|
"splice" together the run-time and build-time package sets with
|
||||||
run-time and build-time package sets with <varname>callPackage</varname>,
|
<varname>callPackage</varname>, and then <varname>mkDerivation</varname> for
|
||||||
and then <varname>mkDerivation</varname> for each of four attributes pulls
|
each of four attributes pulls the right derivation out. This splicing can be
|
||||||
the right derivation out. This splicing can be skipped when not cross
|
skipped when not cross-compiling as the package sets are the same, but is a
|
||||||
compiling as the package sets are the same, but is a bit slow for cross
|
bit slow for cross-compiling. Because of this, a best-of-both-worlds
|
||||||
compiling. Because of this, a best-of-both-worlds solution is in the works
|
solution is in the works with no splicing or explicit access of
|
||||||
with no splicing or explicit access of <varname>buildPackages</varname>
|
<varname>buildPackages</varname> needed. For now, feel free to use either
|
||||||
needed. For now, feel free to use either method.
|
method.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
@ -304,20 +303,20 @@
|
|||||||
</note>
|
</note>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="sec-cross-cookbook">
|
||||||
<title>Cross packaging cookbook</title>
|
<title>Cross packaging cookbook</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Some frequently problems when packaging for cross compilation are good to
|
Some frequently encountered problems when packaging for cross-compilation
|
||||||
just spell and answer. Ideally the information above is exhaustive, so this
|
should be answered here. Ideally, the information above is exhaustive, so
|
||||||
section cannot provide any new information, but its ludicrous and cruel to
|
this section cannot provide any new information, but it is ludicrous and
|
||||||
expect everyone to spend effort working through the interaction of many
|
cruel to expect everyone to spend effort working through the interaction of
|
||||||
features just to figure out the same answer to the same common problem.
|
many features just to figure out the same answer to the same common problem.
|
||||||
Feel free to add to this list!
|
Feel free to add to this list!
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<qandaset>
|
<qandaset>
|
||||||
<qandaentry>
|
<qandaentry xml:id="cross-qa-build-c-program-in-build-environment">
|
||||||
<question>
|
<question>
|
||||||
<para>
|
<para>
|
||||||
What if my package's build system needs to build a C program to be run
|
What if my package's build system needs to build a C program to be run
|
||||||
@ -331,7 +330,7 @@
|
|||||||
</para>
|
</para>
|
||||||
</answer>
|
</answer>
|
||||||
</qandaentry>
|
</qandaentry>
|
||||||
<qandaentry>
|
<qandaentry xml:id="cross-qa-fails-to-find-ar">
|
||||||
<question>
|
<question>
|
||||||
<para>
|
<para>
|
||||||
My package fails to find <command>ar</command>.
|
My package fails to find <command>ar</command>.
|
||||||
@ -347,7 +346,7 @@
|
|||||||
</para>
|
</para>
|
||||||
</answer>
|
</answer>
|
||||||
</qandaentry>
|
</qandaentry>
|
||||||
<qandaentry>
|
<qandaentry xml:id="cross-testsuite-runs-host-code">
|
||||||
<question>
|
<question>
|
||||||
<para>
|
<para>
|
||||||
My package's testsuite needs to run host platform code.
|
My package's testsuite needs to run host platform code.
|
||||||
@ -367,17 +366,9 @@
|
|||||||
<section xml:id="sec-cross-usage">
|
<section xml:id="sec-cross-usage">
|
||||||
<title>Cross-building packages</title>
|
<title>Cross-building packages</title>
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
More information needs to moved from the old wiki, especially
|
|
||||||
<link xlink:href="https://nixos.org/wiki/CrossCompiling" />, for this
|
|
||||||
section.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Nixpkgs can be instantiated with <varname>localSystem</varname> alone, in
|
Nixpkgs can be instantiated with <varname>localSystem</varname> alone, in
|
||||||
which case there is no cross compiling and everything is built by and for
|
which case there is no cross-compiling and everything is built by and for
|
||||||
that system, or also with <varname>crossSystem</varname>, in which case
|
that system, or also with <varname>crossSystem</varname>, in which case
|
||||||
packages run on the latter, but all building happens on the former. Both
|
packages run on the latter, but all building happens on the former. Both
|
||||||
parameters take the same schema as the 3 (build, host, and target) platforms
|
parameters take the same schema as the 3 (build, host, and target) platforms
|
||||||
@ -394,7 +385,7 @@ nix-build <nixpkgs> --arg crossSystem '(import <nixpkgs/lib>).system
|
|||||||
Eventually we would like to make these platform examples an unnecessary
|
Eventually we would like to make these platform examples an unnecessary
|
||||||
convenience so that
|
convenience so that
|
||||||
<programlisting>
|
<programlisting>
|
||||||
nix-build <nixpkgs> --arg crossSystem.config '<arch>-<os>-<vendor>-<abi>' -A whatever</programlisting>
|
nix-build <nixpkgs> --arg crossSystem '{ config = "<arch>-<os>-<vendor>-<abi>"; }' -A whatever</programlisting>
|
||||||
works in the vast majority of cases. The problem today is dependencies on
|
works in the vast majority of cases. The problem today is dependencies on
|
||||||
other sorts of configuration which aren't given proper defaults. We rely on
|
other sorts of configuration which aren't given proper defaults. We rely on
|
||||||
the examples to crudely to set those configuration parameters in some
|
the examples to crudely to set those configuration parameters in some
|
||||||
@ -443,15 +434,14 @@ nix-build <nixpkgs> --arg crossSystem.config '<arch>-<os>-<
|
|||||||
build plan or package set. A simple "build vs deploy" dichotomy is adequate:
|
build plan or package set. A simple "build vs deploy" dichotomy is adequate:
|
||||||
the sliding window principle described in the previous section shows how to
|
the sliding window principle described in the previous section shows how to
|
||||||
interpolate between the these two "end points" to get the 3 platform triple
|
interpolate between the these two "end points" to get the 3 platform triple
|
||||||
for each bootstrapping stage. That means for any package a given package
|
for each bootstrapping stage. That means for any package a given package set,
|
||||||
set, even those not bound on the top level but only reachable via
|
even those not bound on the top level but only reachable via dependencies or
|
||||||
dependencies or <varname>buildPackages</varname>, the three platforms will
|
<varname>buildPackages</varname>, the three platforms will be defined as one
|
||||||
be defined as one of <varname>localSystem</varname> or
|
of <varname>localSystem</varname> or <varname>crossSystem</varname>, with the
|
||||||
<varname>crossSystem</varname>, with the former replacing the latter as one
|
former replacing the latter as one traverses build-time dependencies. A last
|
||||||
traverses build-time dependencies. A last simple difference then is
|
simple difference is that <varname>crossSystem</varname> should be null when
|
||||||
<varname>crossSystem</varname> should be null when one doesn't want to
|
one doesn't want to cross-compile, while the <varname>*Platform</varname>s
|
||||||
cross-compile, while the <varname>*Platform</varname>s are always non-null.
|
are always non-null. <varname>localSystem</varname> is always non-null.
|
||||||
<varname>localSystem</varname> is always non-null.
|
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<!--============================================================-->
|
<!--============================================================-->
|
||||||
@ -464,14 +454,14 @@ nix-build <nixpkgs> --arg crossSystem.config '<arch>-<os>-<
|
|||||||
|
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
If one explores nixpkgs, they will see derivations with names like
|
If one explores Nixpkgs, they will see derivations with names like
|
||||||
<literal>gccCross</literal>. Such <literal>*Cross</literal> derivations is
|
<literal>gccCross</literal>. Such <literal>*Cross</literal> derivations is a
|
||||||
a holdover from before we properly distinguished between the host and
|
holdover from before we properly distinguished between the host and target
|
||||||
target platforms —the derivation with "Cross" in the name covered the
|
platforms—the derivation with "Cross" in the name covered the <literal>build
|
||||||
<literal>build = host != target</literal> case, while the other covered the
|
= host != target</literal> case, while the other covered the <literal>host =
|
||||||
<literal>host = target</literal>, with build platform the same or not based
|
target</literal>, with build platform the same or not based on whether one
|
||||||
on whether one was using its <literal>.nativeDrv</literal> or
|
was using its <literal>.nativeDrv</literal> or <literal>.crossDrv</literal>.
|
||||||
<literal>.crossDrv</literal>. This ugliness will disappear soon.
|
This ugliness will disappear soon.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
</section>
|
</section>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
{ pkgs ? (import ./.. { }), nixpkgs ? { }}:
|
||||||
let
|
let
|
||||||
pkgs = import ./.. { };
|
|
||||||
lib = pkgs.lib;
|
lib = pkgs.lib;
|
||||||
|
locationsXml = import ./lib-function-locations.nix { inherit pkgs nixpkgs; };
|
||||||
in
|
in
|
||||||
pkgs.stdenv.mkDerivation {
|
pkgs.stdenv.mkDerivation {
|
||||||
name = "nixpkgs-manual";
|
name = "nixpkgs-manual";
|
||||||
@ -29,6 +30,8 @@ pkgs.stdenv.mkDerivation {
|
|||||||
];
|
];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
|
rm -rf ./functions/library/locations.xml
|
||||||
|
ln -s ${locationsXml} ./functions/library/locations.xml
|
||||||
echo ${lib.version} > .version
|
echo ${lib.version} > .version
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -1,776 +1,17 @@
|
|||||||
<chapter xmlns="http://docbook.org/ns/docbook"
|
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
xml:id="chap-functions">
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xml:id="chap-functions">
|
||||||
<title>Functions reference</title>
|
<title>Functions reference</title>
|
||||||
<para>
|
<para>
|
||||||
The nixpkgs repository has several utility functions to manipulate Nix
|
The nixpkgs repository has several utility functions to manipulate Nix
|
||||||
expressions.
|
expressions.
|
||||||
</para>
|
</para>
|
||||||
<section xml:id="sec-overrides">
|
<xi:include href="functions/library.xml" />
|
||||||
<title>Overriding</title>
|
<xi:include href="functions/overrides.xml" />
|
||||||
|
<xi:include href="functions/generators.xml" />
|
||||||
<para>
|
<xi:include href="functions/debug.xml" />
|
||||||
Sometimes one wants to override parts of <literal>nixpkgs</literal>, e.g.
|
<xi:include href="functions/fhs-environments.xml" />
|
||||||
derivation attributes, the results of derivations or even the whole package
|
<xi:include href="functions/shell.xml" />
|
||||||
set.
|
<xi:include href="functions/dockertools.xml" />
|
||||||
</para>
|
|
||||||
|
|
||||||
<section xml:id="sec-pkg-override">
|
|
||||||
<title><pkg>.override</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The function <varname>override</varname> is usually available for all the
|
|
||||||
derivations in the nixpkgs expression (<varname>pkgs</varname>).
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
It is used to override the arguments passed to a function.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Example usages:
|
|
||||||
<programlisting>pkgs.foo.override { arg1 = val1; arg2 = val2; ... }</programlisting>
|
|
||||||
<programlisting>import pkgs.path { overlays = [ (self: super: {
|
|
||||||
foo = super.foo.override { barSupport = true ; };
|
|
||||||
})]};</programlisting>
|
|
||||||
<programlisting>mypkg = pkgs.callPackage ./mypkg.nix {
|
|
||||||
mydep = pkgs.mydep.override { ... };
|
|
||||||
}</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
In the first example, <varname>pkgs.foo</varname> is the result of a
|
|
||||||
function call with some default arguments, usually a derivation. Using
|
|
||||||
<varname>pkgs.foo.override</varname> will call the same function with the
|
|
||||||
given new arguments.
|
|
||||||
</para>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section xml:id="sec-pkg-overrideAttrs">
|
|
||||||
<title><pkg>.overrideAttrs</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The function <varname>overrideAttrs</varname> allows overriding the
|
|
||||||
attribute set passed to a <varname>stdenv.mkDerivation</varname> call,
|
|
||||||
producing a new derivation based on the original one. This function is
|
|
||||||
available on all derivations produced by the
|
|
||||||
<varname>stdenv.mkDerivation</varname> function, which is most packages in
|
|
||||||
the nixpkgs expression <varname>pkgs</varname>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Example usage:
|
|
||||||
<programlisting>helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec {
|
|
||||||
separateDebugInfo = true;
|
|
||||||
});</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
In the above example, the <varname>separateDebugInfo</varname> attribute is
|
|
||||||
overridden to be true, thus building debug info for
|
|
||||||
<varname>helloWithDebug</varname>, while all other attributes will be
|
|
||||||
retained from the original <varname>hello</varname> package.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The argument <varname>oldAttrs</varname> is conventionally used to refer to
|
|
||||||
the attr set originally passed to <varname>stdenv.mkDerivation</varname>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
Note that <varname>separateDebugInfo</varname> is processed only by the
|
|
||||||
<varname>stdenv.mkDerivation</varname> function, not the generated, raw
|
|
||||||
Nix derivation. Thus, using <varname>overrideDerivation</varname> will not
|
|
||||||
work in this case, as it overrides only the attributes of the final
|
|
||||||
derivation. It is for this reason that <varname>overrideAttrs</varname>
|
|
||||||
should be preferred in (almost) all cases to
|
|
||||||
<varname>overrideDerivation</varname>, i.e. to allow using
|
|
||||||
<varname>sdenv.mkDerivation</varname> 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.
|
|
||||||
<varname>buildInputs</varname> vs <varname>nativeBuildInputs</varname>,
|
|
||||||
and involves less typing.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section xml:id="sec-pkg-overrideDerivation">
|
|
||||||
<title><pkg>.overrideDerivation</title>
|
|
||||||
|
|
||||||
<warning>
|
|
||||||
<para>
|
|
||||||
You should prefer <varname>overrideAttrs</varname> in almost all cases,
|
|
||||||
see its documentation for the reasons why.
|
|
||||||
<varname>overrideDerivation</varname> is not deprecated and will continue
|
|
||||||
to work, but is less nice to use and does not have as many abilities as
|
|
||||||
<varname>overrideAttrs</varname>.
|
|
||||||
</para>
|
|
||||||
</warning>
|
|
||||||
|
|
||||||
<warning>
|
|
||||||
<para>
|
|
||||||
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 <filename>~/.config/nixpkgs/config.nix</filename>.
|
|
||||||
</para>
|
|
||||||
</warning>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The function <varname>overrideDerivation</varname> creates a new derivation
|
|
||||||
based on an existing one by overriding the original's attributes with the
|
|
||||||
attribute set produced by the specified function. This function is
|
|
||||||
available on all derivations defined using the
|
|
||||||
<varname>makeOverridable</varname> function. Most standard
|
|
||||||
derivation-producing functions, such as
|
|
||||||
<varname>stdenv.mkDerivation</varname>, are defined using this function,
|
|
||||||
which means most packages in the nixpkgs expression,
|
|
||||||
<varname>pkgs</varname>, have this function.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Example usage:
|
|
||||||
<programlisting>mySed = pkgs.gnused.overrideDerivation (oldAttrs: {
|
|
||||||
name = "sed-4.2.2-pre";
|
|
||||||
src = fetchurl {
|
|
||||||
url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2;
|
|
||||||
sha256 = "11nq06d131y4wmf3drm0yk502d2xc6n5qy82cg88rb9nqd2lj41k";
|
|
||||||
};
|
|
||||||
patches = [];
|
|
||||||
});</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
In the above example, the <varname>name</varname>, <varname>src</varname>,
|
|
||||||
and <varname>patches</varname> of the derivation will be overridden, while
|
|
||||||
all other attributes will be retained from the original derivation.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The argument <varname>oldAttrs</varname> is used to refer to the attribute
|
|
||||||
set of the original derivation.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
A package's attributes are evaluated *before* being modified by the
|
|
||||||
<varname>overrideDerivation</varname> function. For example, the
|
|
||||||
<varname>name</varname> attribute reference in <varname>url =
|
|
||||||
"mirror://gnu/hello/${name}.tar.gz";</varname> is filled-in *before* the
|
|
||||||
<varname>overrideDerivation</varname> function modifies the attribute set.
|
|
||||||
This means that overriding the <varname>name</varname> attribute, in this
|
|
||||||
example, *will not* change the value of the <varname>url</varname>
|
|
||||||
attribute. Instead, we need to override both the <varname>name</varname>
|
|
||||||
*and* <varname>url</varname> attributes.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section xml:id="sec-lib-makeOverridable">
|
|
||||||
<title>lib.makeOverridable</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The function <varname>lib.makeOverridable</varname> is used to make the
|
|
||||||
result of a function easily customizable. This utility only makes sense for
|
|
||||||
functions that accept an argument set and return an attribute set.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Example usage:
|
|
||||||
<programlisting>f = { a, b }: { result = a+b; }
|
|
||||||
c = lib.makeOverridable f { a = 1; b = 2; }</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The variable <varname>c</varname> is the value of the <varname>f</varname>
|
|
||||||
function applied with some default arguments. Hence the value of
|
|
||||||
<varname>c.result</varname> is <literal>3</literal>, in this example.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The variable <varname>c</varname> however also has some additional
|
|
||||||
functions, like <link linkend="sec-pkg-override">c.override</link> which
|
|
||||||
can be used to override the default arguments. In this example the value of
|
|
||||||
<varname>(c.override { a = 4; }).result</varname> is 6.
|
|
||||||
</para>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
<section xml:id="sec-generators">
|
|
||||||
<title>Generators</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Generators are functions that create file formats from nix data structures,
|
|
||||||
e. g. for configuration files. There are generators available for:
|
|
||||||
<literal>INI</literal>, <literal>JSON</literal> and <literal>YAML</literal>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
All generators follow a similar call interface: <code>generatorName
|
|
||||||
configFunctions data</code>, where <literal>configFunctions</literal> is an
|
|
||||||
attrset of user-defined functions that format nested parts of the content.
|
|
||||||
They each have common defaults, so often they do not need to be set
|
|
||||||
manually. An example is <code>mkSectionName ? (name: libStr.escape [ "[" "]"
|
|
||||||
] name)</code> from the <literal>INI</literal> generator. It receives the
|
|
||||||
name of a section and sanitizes it. The default
|
|
||||||
<literal>mkSectionName</literal> escapes <literal>[</literal> and
|
|
||||||
<literal>]</literal> with a backslash.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Generators can be fine-tuned to produce exactly the file format required by
|
|
||||||
your application/service. One example is an INI-file format which uses
|
|
||||||
<literal>: </literal> as separator, the strings
|
|
||||||
<literal>"yes"</literal>/<literal>"no"</literal> as boolean values and
|
|
||||||
requires all string values to be quoted:
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
with lib;
|
|
||||||
let
|
|
||||||
customToINI = generators.toINI {
|
|
||||||
# specifies how to format a key/value pair
|
|
||||||
mkKeyValue = generators.mkKeyValueDefault {
|
|
||||||
# specifies the generated string for a subset of nix values
|
|
||||||
mkValueString = v:
|
|
||||||
if v == true then ''"yes"''
|
|
||||||
else if v == false then ''"no"''
|
|
||||||
else if isString v then ''"${v}"''
|
|
||||||
# and delegats all other values to the default generator
|
|
||||||
else generators.mkValueStringDefault {} v;
|
|
||||||
} ":";
|
|
||||||
};
|
|
||||||
|
|
||||||
# the INI file can now be given as plain old nix values
|
|
||||||
in customToINI {
|
|
||||||
main = {
|
|
||||||
pushinfo = true;
|
|
||||||
autopush = false;
|
|
||||||
host = "localhost";
|
|
||||||
port = 42;
|
|
||||||
};
|
|
||||||
mergetool = {
|
|
||||||
merge = "diff3";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</programlisting>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
This will produce the following INI file as nix string:
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<programlisting>
|
|
||||||
[main]
|
|
||||||
autopush:"no"
|
|
||||||
host:"localhost"
|
|
||||||
port:42
|
|
||||||
pushinfo:"yes"
|
|
||||||
str\:ange:"very::strange"
|
|
||||||
|
|
||||||
[mergetool]
|
|
||||||
merge:"diff3"
|
|
||||||
</programlisting>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
Nix store paths can be converted to strings by enclosing a derivation
|
|
||||||
attribute like so: <code>"${drv}"</code>.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Detailed documentation for each generator can be found in
|
|
||||||
<literal>lib/generators.nix</literal>.
|
|
||||||
</para>
|
|
||||||
</section>
|
|
||||||
<section xml:id="sec-debug">
|
|
||||||
<title>Debugging Nix Expressions</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Nix is a unityped, dynamic language, this means every value can potentially
|
|
||||||
appear anywhere. Since it is also non-strict, evaluation order and what
|
|
||||||
ultimately is evaluated might surprise you. Therefore it is important to be
|
|
||||||
able to debug nix expressions.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
In the <literal>lib/debug.nix</literal> file you will find a number of
|
|
||||||
functions that help (pretty-)printing values while evaluation is runnnig.
|
|
||||||
You can even specify how deep these values should be printed recursively,
|
|
||||||
and transform them on the fly. Please consult the docstrings in
|
|
||||||
<literal>lib/debug.nix</literal> for usage information.
|
|
||||||
</para>
|
|
||||||
</section>
|
|
||||||
<section xml:id="sec-fhs-environments">
|
|
||||||
<title>buildFHSUserEnv</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
<function>buildFHSUserEnv</function> provides a way to build and run
|
|
||||||
FHS-compatible lightweight sandboxes. It creates an isolated root with bound
|
|
||||||
<filename>/nix/store</filename>, so its footprint in terms of disk space
|
|
||||||
needed is quite small. This allows one to run software which is hard or
|
|
||||||
unfeasible to patch for NixOS -- 3rd-party source trees with FHS
|
|
||||||
assumptions, games distributed as tarballs, software with integrity checking
|
|
||||||
and/or external self-updated binaries. It uses Linux namespaces feature to
|
|
||||||
create temporary lightweight environments which are destroyed after all
|
|
||||||
child processes exit, without root user rights requirement. Accepted
|
|
||||||
arguments are:
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<literal>name</literal>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Environment name.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<literal>targetPkgs</literal>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Packages to be installed for the main host's architecture (i.e. x86_64 on
|
|
||||||
x86_64 installations). Along with libraries binaries are also installed.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<literal>multiPkgs</literal>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Packages to be installed for all architectures supported by a host (i.e.
|
|
||||||
i686 and x86_64 on x86_64 installations). Only libraries are installed by
|
|
||||||
default.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<literal>extraBuildCommands</literal>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Additional commands to be executed for finalizing the directory
|
|
||||||
structure.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<literal>extraBuildCommandsMulti</literal>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Like <literal>extraBuildCommands</literal>, but executed only on multilib
|
|
||||||
architectures.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<literal>extraOutputsToInstall</literal>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Additional derivation outputs to be linked for both target and
|
|
||||||
multi-architecture packages.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<literal>extraInstallCommands</literal>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Additional commands to be executed for finalizing the derivation with
|
|
||||||
runner script.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<literal>runScript</literal>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
A command that would be executed inside the sandbox and passed all the
|
|
||||||
command line arguments. It defaults to <literal>bash</literal>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
One can create a simple environment using a <literal>shell.nix</literal>
|
|
||||||
like that:
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<programlisting><![CDATA[
|
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
|
||||||
|
|
||||||
(pkgs.buildFHSUserEnv {
|
|
||||||
name = "simple-x11-env";
|
|
||||||
targetPkgs = pkgs: (with pkgs;
|
|
||||||
[ udev
|
|
||||||
alsaLib
|
|
||||||
]) ++ (with pkgs.xorg;
|
|
||||||
[ libX11
|
|
||||||
libXcursor
|
|
||||||
libXrandr
|
|
||||||
]);
|
|
||||||
multiPkgs = pkgs: (with pkgs;
|
|
||||||
[ udev
|
|
||||||
alsaLib
|
|
||||||
]);
|
|
||||||
runScript = "bash";
|
|
||||||
}).env
|
|
||||||
]]></programlisting>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Running <literal>nix-shell</literal> would then drop you into a shell with
|
|
||||||
these libraries and binaries available. You can use this to run
|
|
||||||
closed-source applications which expect FHS structure without hassles:
|
|
||||||
simply change <literal>runScript</literal> to the application path, e.g.
|
|
||||||
<filename>./bin/start.sh</filename> -- relative paths are supported.
|
|
||||||
</para>
|
|
||||||
</section>
|
|
||||||
<section xml:id="sec-pkgs-dockerTools">
|
|
||||||
<title>pkgs.dockerTools</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
<varname>pkgs.dockerTools</varname> is a set of functions for creating and
|
|
||||||
manipulating Docker images according to the
|
|
||||||
<link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120">
|
|
||||||
Docker Image Specification v1.2.0 </link>. Docker itself is not used to
|
|
||||||
perform any of the operations done by these functions.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<warning>
|
|
||||||
<para>
|
|
||||||
The <varname>dockerTools</varname> API is unstable and may be subject to
|
|
||||||
backwards-incompatible changes in the future.
|
|
||||||
</para>
|
|
||||||
</warning>
|
|
||||||
|
|
||||||
<section xml:id="ssec-pkgs-dockerTools-buildImage">
|
|
||||||
<title>buildImage</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
This function is analogous to the <command>docker build</command> command,
|
|
||||||
in that can used to build a Docker-compatible repository tarball containing
|
|
||||||
a single image with one or multiple layers. As such, the result is suitable
|
|
||||||
for being loaded in Docker with <command>docker load</command>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The parameters of <varname>buildImage</varname> with relative example
|
|
||||||
values are described below:
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<example xml:id='ex-dockerTools-buildImage'>
|
|
||||||
<title>Docker build</title>
|
|
||||||
<programlisting>
|
|
||||||
buildImage {
|
|
||||||
name = "redis"; <co xml:id='ex-dockerTools-buildImage-1' />
|
|
||||||
tag = "latest"; <co xml:id='ex-dockerTools-buildImage-2' />
|
|
||||||
|
|
||||||
fromImage = someBaseImage; <co xml:id='ex-dockerTools-buildImage-3' />
|
|
||||||
fromImageName = null; <co xml:id='ex-dockerTools-buildImage-4' />
|
|
||||||
fromImageTag = "latest"; <co xml:id='ex-dockerTools-buildImage-5' />
|
|
||||||
|
|
||||||
contents = pkgs.redis; <co xml:id='ex-dockerTools-buildImage-6' />
|
|
||||||
runAsRoot = '' <co xml:id='ex-dockerTools-buildImage-runAsRoot' />
|
|
||||||
#!${stdenv.shell}
|
|
||||||
mkdir -p /data
|
|
||||||
'';
|
|
||||||
|
|
||||||
config = { <co xml:id='ex-dockerTools-buildImage-8' />
|
|
||||||
Cmd = [ "/bin/redis-server" ];
|
|
||||||
WorkingDir = "/data";
|
|
||||||
Volumes = {
|
|
||||||
"/data" = {};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</programlisting>
|
|
||||||
</example>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The above example will build a Docker image <literal>redis/latest</literal>
|
|
||||||
from the given base image. Loading and running this image in Docker results
|
|
||||||
in <literal>redis-server</literal> being started automatically.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<calloutlist>
|
|
||||||
<callout arearefs='ex-dockerTools-buildImage-1'>
|
|
||||||
<para>
|
|
||||||
<varname>name</varname> specifies the name of the resulting image. This
|
|
||||||
is the only required argument for <varname>buildImage</varname>.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
<callout arearefs='ex-dockerTools-buildImage-2'>
|
|
||||||
<para>
|
|
||||||
<varname>tag</varname> specifies the tag of the resulting image. By
|
|
||||||
default it's <literal>null</literal>, which indicates that the nix output hash will be used as tag.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
<callout arearefs='ex-dockerTools-buildImage-3'>
|
|
||||||
<para>
|
|
||||||
<varname>fromImage</varname> is the repository tarball containing the
|
|
||||||
base image. It must be a valid Docker image, such as exported by
|
|
||||||
<command>docker save</command>. By default it's <literal>null</literal>,
|
|
||||||
which can be seen as equivalent to <literal>FROM scratch</literal> of a
|
|
||||||
<filename>Dockerfile</filename>.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
<callout arearefs='ex-dockerTools-buildImage-4'>
|
|
||||||
<para>
|
|
||||||
<varname>fromImageName</varname> can be used to further specify the base
|
|
||||||
image within the repository, in case it contains multiple images. By
|
|
||||||
default it's <literal>null</literal>, in which case
|
|
||||||
<varname>buildImage</varname> will peek the first image available in the
|
|
||||||
repository.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
<callout arearefs='ex-dockerTools-buildImage-5'>
|
|
||||||
<para>
|
|
||||||
<varname>fromImageTag</varname> can be used to further specify the tag of
|
|
||||||
the base image within the repository, in case an image contains multiple
|
|
||||||
tags. By default it's <literal>null</literal>, in which case
|
|
||||||
<varname>buildImage</varname> will peek the first tag available for the
|
|
||||||
base image.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
<callout arearefs='ex-dockerTools-buildImage-6'>
|
|
||||||
<para>
|
|
||||||
<varname>contents</varname> is a derivation that will be copied in the
|
|
||||||
new layer of the resulting image. This can be similarly seen as
|
|
||||||
<command>ADD contents/ /</command> in a <filename>Dockerfile</filename>.
|
|
||||||
By default it's <literal>null</literal>.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
<callout arearefs='ex-dockerTools-buildImage-runAsRoot'>
|
|
||||||
<para>
|
|
||||||
<varname>runAsRoot</varname> is a bash script that will run as root in an
|
|
||||||
environment that overlays the existing layers of the base image with the
|
|
||||||
new resulting layer, including the previously copied
|
|
||||||
<varname>contents</varname> derivation. This can be similarly seen as
|
|
||||||
<command>RUN ...</command> in a <filename>Dockerfile</filename>.
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
Using this parameter requires the <literal>kvm</literal> device to be
|
|
||||||
available.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
<callout arearefs='ex-dockerTools-buildImage-8'>
|
|
||||||
<para>
|
|
||||||
<varname>config</varname> 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
|
|
||||||
<link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions">
|
|
||||||
Docker Image Specification v1.2.0 </link>.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
</calloutlist>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
After the new layer has been created, its closure (to which
|
|
||||||
<varname>contents</varname>, <varname>config</varname> and
|
|
||||||
<varname>runAsRoot</varname> contribute) will be copied in the layer
|
|
||||||
itself. Only new dependencies that are not already in the existing layers
|
|
||||||
will be copied.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
At the end of the process, only one new single layer will be produced and
|
|
||||||
added to the resulting image.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The resulting repository will only list the single image
|
|
||||||
<varname>image/tag</varname>. In the case of
|
|
||||||
<xref linkend='ex-dockerTools-buildImage'/> it would be
|
|
||||||
<varname>redis/latest</varname>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
It is possible to inspect the arguments with which an image was built using
|
|
||||||
its <varname>buildArgs</varname> attribute.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
If you see errors similar to <literal>getProtocolByName: does not exist
|
|
||||||
(no such protocol name: tcp)</literal> you may need to add
|
|
||||||
<literal>pkgs.iana-etc</literal> to <varname>contents</varname>.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
If you see errors similar to <literal>Error_Protocol ("certificate has
|
|
||||||
unknown CA",True,UnknownCa)</literal> you may need to add
|
|
||||||
<literal>pkgs.cacert</literal> to <varname>contents</varname>.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section xml:id="ssec-pkgs-dockerTools-fetchFromRegistry">
|
|
||||||
<title>pullImage</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
This function is analogous to the <command>docker pull</command> command,
|
|
||||||
in that can be used to pull a Docker image from a Docker registry. By
|
|
||||||
default <link xlink:href="https://hub.docker.com/">Docker Hub</link> is
|
|
||||||
used to pull images.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Its parameters are described in the example below:
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<example xml:id='ex-dockerTools-pullImage'>
|
|
||||||
<title>Docker pull</title>
|
|
||||||
<programlisting>
|
|
||||||
pullImage {
|
|
||||||
imageName = "nixos/nix"; <co xml:id='ex-dockerTools-pullImage-1' />
|
|
||||||
imageDigest = "sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b"; <co xml:id='ex-dockerTools-pullImage-2' />
|
|
||||||
finalImageTag = "1.11"; <co xml:id='ex-dockerTools-pullImage-3' />
|
|
||||||
sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8"; <co xml:id='ex-dockerTools-pullImage-4' />
|
|
||||||
}
|
|
||||||
</programlisting>
|
|
||||||
</example>
|
|
||||||
|
|
||||||
<calloutlist>
|
|
||||||
<callout arearefs='ex-dockerTools-pullImage-1'>
|
|
||||||
<para>
|
|
||||||
<varname>imageName</varname> specifies the name of the image to be
|
|
||||||
downloaded, which can also include the registry namespace (e.g.
|
|
||||||
<literal>nixos</literal>). This argument is required.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
<callout arearefs='ex-dockerTools-pullImage-2'>
|
|
||||||
<para>
|
|
||||||
<varname>imageDigest</varname> specifies the digest of the image to be
|
|
||||||
downloaded. Skopeo can be used to get the digest of an image
|
|
||||||
<programlisting>
|
|
||||||
$ skopeo inspect docker://docker.io/nixos/nix:1.11 | jq -r '.Digest'
|
|
||||||
sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b
|
|
||||||
</programlisting>
|
|
||||||
This argument is required.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
<callout arearefs='ex-dockerTools-pullImage-3'>
|
|
||||||
<para>
|
|
||||||
<varname>finalImageTag</varname>, if specified, this is the tag of the
|
|
||||||
image to be created. Note it is never used to fetch the image since we
|
|
||||||
prefer to rely on the immutable digest ID. By default it's
|
|
||||||
<literal>latest</literal>.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
<callout arearefs='ex-dockerTools-pullImage-4'>
|
|
||||||
<para>
|
|
||||||
<varname>sha256</varname> is the checksum of the whole fetched image.
|
|
||||||
This argument is required.
|
|
||||||
</para>
|
|
||||||
</callout>
|
|
||||||
</calloutlist>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section xml:id="ssec-pkgs-dockerTools-exportImage">
|
|
||||||
<title>exportImage</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
This function is analogous to the <command>docker export</command> command,
|
|
||||||
in that can used to flatten a Docker image that contains multiple layers.
|
|
||||||
It is in fact the result of the merge of all the layers of the image. As
|
|
||||||
such, the result is suitable for being imported in Docker with
|
|
||||||
<command>docker import</command>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
Using this function requires the <literal>kvm</literal> device to be
|
|
||||||
available.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The parameters of <varname>exportImage</varname> are the following:
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<example xml:id='ex-dockerTools-exportImage'>
|
|
||||||
<title>Docker export</title>
|
|
||||||
<programlisting>
|
|
||||||
exportImage {
|
|
||||||
fromImage = someLayeredImage;
|
|
||||||
fromImageName = null;
|
|
||||||
fromImageTag = null;
|
|
||||||
|
|
||||||
name = someLayeredImage.name;
|
|
||||||
}
|
|
||||||
</programlisting>
|
|
||||||
</example>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The parameters relative to the base image have the same synopsis as
|
|
||||||
described in <xref linkend='ssec-pkgs-dockerTools-buildImage'/>, except
|
|
||||||
that <varname>fromImage</varname> is the only required argument in this
|
|
||||||
case.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The <varname>name</varname> argument is the name of the derivation output,
|
|
||||||
which defaults to <varname>fromImage.name</varname>.
|
|
||||||
</para>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section xml:id="ssec-pkgs-dockerTools-shadowSetup">
|
|
||||||
<title>shadowSetup</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
This constant string is a helper for setting up the base files for managing
|
|
||||||
users and groups, only if such files don't exist already. It is suitable
|
|
||||||
for being used in a <varname>runAsRoot</varname>
|
|
||||||
<xref linkend='ex-dockerTools-buildImage-runAsRoot'/> script for cases like
|
|
||||||
in the example below:
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<example xml:id='ex-dockerTools-shadowSetup'>
|
|
||||||
<title>Shadow base files</title>
|
|
||||||
<programlisting>
|
|
||||||
buildImage {
|
|
||||||
name = "shadow-basic";
|
|
||||||
|
|
||||||
runAsRoot = ''
|
|
||||||
#!${stdenv.shell}
|
|
||||||
${shadowSetup}
|
|
||||||
groupadd -r redis
|
|
||||||
useradd -r -g redis redis
|
|
||||||
mkdir /data
|
|
||||||
chown redis:redis /data
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
</programlisting>
|
|
||||||
</example>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Creating base files like <literal>/etc/passwd</literal> or
|
|
||||||
<literal>/etc/login.defs</literal> are necessary for shadow-utils to
|
|
||||||
manipulate users and groups.
|
|
||||||
</para>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
</chapter>
|
</chapter>
|
||||||
|
21
doc/functions/debug.xml
Normal file
21
doc/functions/debug.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xml:id="sec-debug">
|
||||||
|
<title>Debugging Nix Expressions</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Nix is a unityped, dynamic language, this means every value can potentially
|
||||||
|
appear anywhere. Since it is also non-strict, evaluation order and what
|
||||||
|
ultimately is evaluated might surprise you. Therefore it is important to be
|
||||||
|
able to debug nix expressions.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
In the <literal>lib/debug.nix</literal> file you will find a number of
|
||||||
|
functions that help (pretty-)printing values while evaluation is runnnig. You
|
||||||
|
can even specify how deep these values should be printed recursively, and
|
||||||
|
transform them on the fly. Please consult the docstrings in
|
||||||
|
<literal>lib/debug.nix</literal> for usage information.
|
||||||
|
</para>
|
||||||
|
</section>
|
564
doc/functions/dockertools.xml
Normal file
564
doc/functions/dockertools.xml
Normal file
@ -0,0 +1,564 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xml:id="sec-pkgs-dockerTools">
|
||||||
|
<title>pkgs.dockerTools</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<varname>pkgs.dockerTools</varname> is a set of functions for creating and
|
||||||
|
manipulating Docker images according to the
|
||||||
|
<link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120">
|
||||||
|
Docker Image Specification v1.2.0 </link>. Docker itself is not used to
|
||||||
|
perform any of the operations done by these functions.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<warning>
|
||||||
|
<para>
|
||||||
|
The <varname>dockerTools</varname> API is unstable and may be subject to
|
||||||
|
backwards-incompatible changes in the future.
|
||||||
|
</para>
|
||||||
|
</warning>
|
||||||
|
|
||||||
|
<section xml:id="ssec-pkgs-dockerTools-buildImage">
|
||||||
|
<title>buildImage</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This function is analogous to the <command>docker build</command> command,
|
||||||
|
in that can used to build a Docker-compatible repository tarball containing
|
||||||
|
a single image with one or multiple layers. As such, the result is suitable
|
||||||
|
for being loaded in Docker with <command>docker load</command>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The parameters of <varname>buildImage</varname> with relative example values
|
||||||
|
are described below:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<example xml:id='ex-dockerTools-buildImage'>
|
||||||
|
<title>Docker build</title>
|
||||||
|
<programlisting>
|
||||||
|
buildImage {
|
||||||
|
name = "redis"; <co xml:id='ex-dockerTools-buildImage-1' />
|
||||||
|
tag = "latest"; <co xml:id='ex-dockerTools-buildImage-2' />
|
||||||
|
|
||||||
|
fromImage = someBaseImage; <co xml:id='ex-dockerTools-buildImage-3' />
|
||||||
|
fromImageName = null; <co xml:id='ex-dockerTools-buildImage-4' />
|
||||||
|
fromImageTag = "latest"; <co xml:id='ex-dockerTools-buildImage-5' />
|
||||||
|
|
||||||
|
contents = pkgs.redis; <co xml:id='ex-dockerTools-buildImage-6' />
|
||||||
|
runAsRoot = '' <co xml:id='ex-dockerTools-buildImage-runAsRoot' />
|
||||||
|
#!${stdenv.shell}
|
||||||
|
mkdir -p /data
|
||||||
|
'';
|
||||||
|
|
||||||
|
config = { <co xml:id='ex-dockerTools-buildImage-8' />
|
||||||
|
Cmd = [ "/bin/redis-server" ];
|
||||||
|
WorkingDir = "/data";
|
||||||
|
Volumes = {
|
||||||
|
"/data" = {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The above example will build a Docker image <literal>redis/latest</literal>
|
||||||
|
from the given base image. Loading and running this image in Docker results
|
||||||
|
in <literal>redis-server</literal> being started automatically.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<calloutlist>
|
||||||
|
<callout arearefs='ex-dockerTools-buildImage-1'>
|
||||||
|
<para>
|
||||||
|
<varname>name</varname> specifies the name of the resulting image. This is
|
||||||
|
the only required argument for <varname>buildImage</varname>.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-buildImage-2'>
|
||||||
|
<para>
|
||||||
|
<varname>tag</varname> specifies the tag of the resulting image. By
|
||||||
|
default it's <literal>null</literal>, which indicates that the nix output
|
||||||
|
hash will be used as tag.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-buildImage-3'>
|
||||||
|
<para>
|
||||||
|
<varname>fromImage</varname> is the repository tarball containing the base
|
||||||
|
image. It must be a valid Docker image, such as exported by
|
||||||
|
<command>docker save</command>. By default it's <literal>null</literal>,
|
||||||
|
which can be seen as equivalent to <literal>FROM scratch</literal> of a
|
||||||
|
<filename>Dockerfile</filename>.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-buildImage-4'>
|
||||||
|
<para>
|
||||||
|
<varname>fromImageName</varname> can be used to further specify the base
|
||||||
|
image within the repository, in case it contains multiple images. By
|
||||||
|
default it's <literal>null</literal>, in which case
|
||||||
|
<varname>buildImage</varname> will peek the first image available in the
|
||||||
|
repository.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-buildImage-5'>
|
||||||
|
<para>
|
||||||
|
<varname>fromImageTag</varname> can be used to further specify the tag of
|
||||||
|
the base image within the repository, in case an image contains multiple
|
||||||
|
tags. By default it's <literal>null</literal>, in which case
|
||||||
|
<varname>buildImage</varname> will peek the first tag available for the
|
||||||
|
base image.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-buildImage-6'>
|
||||||
|
<para>
|
||||||
|
<varname>contents</varname> is a derivation that will be copied in the new
|
||||||
|
layer of the resulting image. This can be similarly seen as <command>ADD
|
||||||
|
contents/ /</command> in a <filename>Dockerfile</filename>. By default
|
||||||
|
it's <literal>null</literal>.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-buildImage-runAsRoot'>
|
||||||
|
<para>
|
||||||
|
<varname>runAsRoot</varname> is a bash script that will run as root in an
|
||||||
|
environment that overlays the existing layers of the base image with the
|
||||||
|
new resulting layer, including the previously copied
|
||||||
|
<varname>contents</varname> derivation. This can be similarly seen as
|
||||||
|
<command>RUN ...</command> in a <filename>Dockerfile</filename>.
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
Using this parameter requires the <literal>kvm</literal> device to be
|
||||||
|
available.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-buildImage-8'>
|
||||||
|
<para>
|
||||||
|
<varname>config</varname> 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
|
||||||
|
<link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions">
|
||||||
|
Docker Image Specification v1.2.0 </link>.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
</calloutlist>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
After the new layer has been created, its closure (to which
|
||||||
|
<varname>contents</varname>, <varname>config</varname> and
|
||||||
|
<varname>runAsRoot</varname> contribute) will be copied in the layer itself.
|
||||||
|
Only new dependencies that are not already in the existing layers will be
|
||||||
|
copied.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
At the end of the process, only one new single layer will be produced and
|
||||||
|
added to the resulting image.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The resulting repository will only list the single image
|
||||||
|
<varname>image/tag</varname>. In the case of
|
||||||
|
<xref linkend='ex-dockerTools-buildImage'/> it would be
|
||||||
|
<varname>redis/latest</varname>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
It is possible to inspect the arguments with which an image was built using
|
||||||
|
its <varname>buildArgs</varname> attribute.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
If you see errors similar to <literal>getProtocolByName: does not exist (no
|
||||||
|
such protocol name: tcp)</literal> you may need to add
|
||||||
|
<literal>pkgs.iana-etc</literal> to <varname>contents</varname>.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
If you see errors similar to <literal>Error_Protocol ("certificate has
|
||||||
|
unknown CA",True,UnknownCa)</literal> you may need to add
|
||||||
|
<literal>pkgs.cacert</literal> to <varname>contents</varname>.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
|
||||||
|
<example xml:id="example-pkgs-dockerTools-buildImage-creation-date">
|
||||||
|
<title>Impurely Defining a Docker Layer's Creation Date</title>
|
||||||
|
<para>
|
||||||
|
By default <function>buildImage</function> will use a static date of one
|
||||||
|
second past the UNIX Epoch. This allows <function>buildImage</function> to
|
||||||
|
produce binary reproducible images. When listing images with
|
||||||
|
<command>docker list images</command>, the newly created images will be
|
||||||
|
listed like this:
|
||||||
|
</para>
|
||||||
|
<screen><![CDATA[
|
||||||
|
$ docker image list
|
||||||
|
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||||
|
hello latest 08c791c7846e 48 years ago 25.2MB
|
||||||
|
]]></screen>
|
||||||
|
<para>
|
||||||
|
You can break binary reproducibility but have a sorted, meaningful
|
||||||
|
<literal>CREATED</literal> column by setting <literal>created</literal> to
|
||||||
|
<literal>now</literal>.
|
||||||
|
</para>
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
pkgs.dockerTools.buildImage {
|
||||||
|
name = "hello";
|
||||||
|
tag = "latest";
|
||||||
|
created = "now";
|
||||||
|
contents = pkgs.hello;
|
||||||
|
|
||||||
|
config.Cmd = [ "/bin/hello" ];
|
||||||
|
}
|
||||||
|
]]></programlisting>
|
||||||
|
<para>
|
||||||
|
and now the Docker CLI will display a reasonable date and sort the images
|
||||||
|
as expected:
|
||||||
|
<screen><![CDATA[
|
||||||
|
$ docker image list
|
||||||
|
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||||
|
hello latest de2bf4786de6 About a minute ago 25.2MB
|
||||||
|
]]></screen>
|
||||||
|
however, the produced images will not be binary reproducible.
|
||||||
|
</para>
|
||||||
|
</example>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="ssec-pkgs-dockerTools-buildLayeredImage">
|
||||||
|
<title>buildLayeredImage</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Create a Docker image with many of the store paths being on their own layer
|
||||||
|
to improve sharing between images.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>name</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The name of the resulting image.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>tag</varname> <emphasis>optional</emphasis>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Tag of the generated image.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
<emphasis>Default:</emphasis> the output path's hash
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>contents</varname> <emphasis>optional</emphasis>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Top level paths in the container. Either a single derivation, or a list
|
||||||
|
of derivations.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
<emphasis>Default:</emphasis> <literal>[]</literal>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>config</varname> <emphasis>optional</emphasis>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Run-time configuration of the container. A full list of the options are
|
||||||
|
available at in the
|
||||||
|
<link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions">
|
||||||
|
Docker Image Specification v1.2.0 </link>.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
<emphasis>Default:</emphasis> <literal>{}</literal>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>created</varname> <emphasis>optional</emphasis>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Date and time the layers were created. Follows the same
|
||||||
|
<literal>now</literal> exception supported by
|
||||||
|
<literal>buildImage</literal>.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
<emphasis>Default:</emphasis> <literal>1970-01-01T00:00:01Z</literal>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>maxLayers</varname> <emphasis>optional</emphasis>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Maximum number of layers to create.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
<emphasis>Default:</emphasis> <literal>24</literal>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<section xml:id="dockerTools-buildLayeredImage-arg-contents">
|
||||||
|
<title>Behavior of <varname>contents</varname> in the final image</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Each path directly listed in <varname>contents</varname> will have a
|
||||||
|
symlink in the root of the image.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
For example:
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
pkgs.dockerTools.buildLayeredImage {
|
||||||
|
name = "hello";
|
||||||
|
contents = [ pkgs.hello ];
|
||||||
|
}
|
||||||
|
]]></programlisting>
|
||||||
|
will create symlinks for all the paths in the <literal>hello</literal>
|
||||||
|
package:
|
||||||
|
<screen><![CDATA[
|
||||||
|
/bin/hello -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/bin/hello
|
||||||
|
/share/info/hello.info -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/share/info/hello.info
|
||||||
|
/share/locale/bg/LC_MESSAGES/hello.mo -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/share/locale/bg/LC_MESSAGES/hello.mo
|
||||||
|
]]></screen>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="dockerTools-buildLayeredImage-arg-config">
|
||||||
|
<title>Automatic inclusion of <varname>config</varname> references</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The closure of <varname>config</varname> is automatically included in the
|
||||||
|
closure of the final image.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This allows you to make very simple Docker images with very little code.
|
||||||
|
This container will start up and run <command>hello</command>:
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
pkgs.dockerTools.buildLayeredImage {
|
||||||
|
name = "hello";
|
||||||
|
config.Cmd = [ "${pkgs.hello}/bin/hello" ];
|
||||||
|
}
|
||||||
|
]]></programlisting>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="dockerTools-buildLayeredImage-arg-maxLayers">
|
||||||
|
<title>Adjusting <varname>maxLayers</varname></title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Increasing the <varname>maxLayers</varname> increases the number of layers
|
||||||
|
which have a chance to be shared between different images.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Modern Docker installations support up to 128 layers, however older
|
||||||
|
versions support as few as 42.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
If the produced image will not be extended by other Docker builds, it is
|
||||||
|
safe to set <varname>maxLayers</varname> to <literal>128</literal>. However
|
||||||
|
it will be impossible to extend the image further.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The first (<literal>maxLayers-2</literal>) most "popular" paths will have
|
||||||
|
their own individual layers, then layer #<literal>maxLayers-1</literal>
|
||||||
|
will contain all the remaining "unpopular" paths, and finally layer
|
||||||
|
#<literal>maxLayers</literal> will contain the Image configuration.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Docker's Layers are not inherently ordered, they are content-addressable
|
||||||
|
and are not explicitly layered until they are composed in to an Image.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="ssec-pkgs-dockerTools-fetchFromRegistry">
|
||||||
|
<title>pullImage</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This function is analogous to the <command>docker pull</command> command, in
|
||||||
|
that can be used to pull a Docker image from a Docker registry. By default
|
||||||
|
<link xlink:href="https://hub.docker.com/">Docker Hub</link> is used to pull
|
||||||
|
images.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Its parameters are described in the example below:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<example xml:id='ex-dockerTools-pullImage'>
|
||||||
|
<title>Docker pull</title>
|
||||||
|
<programlisting>
|
||||||
|
pullImage {
|
||||||
|
imageName = "nixos/nix"; <co xml:id='ex-dockerTools-pullImage-1' />
|
||||||
|
imageDigest = "sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b"; <co xml:id='ex-dockerTools-pullImage-2' />
|
||||||
|
finalImageTag = "1.11"; <co xml:id='ex-dockerTools-pullImage-3' />
|
||||||
|
sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8"; <co xml:id='ex-dockerTools-pullImage-4' />
|
||||||
|
os = "linux"; <co xml:id='ex-dockerTools-pullImage-5' />
|
||||||
|
arch = "x86_64"; <co xml:id='ex-dockerTools-pullImage-6' />
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
|
<calloutlist>
|
||||||
|
<callout arearefs='ex-dockerTools-pullImage-1'>
|
||||||
|
<para>
|
||||||
|
<varname>imageName</varname> specifies the name of the image to be
|
||||||
|
downloaded, which can also include the registry namespace (e.g.
|
||||||
|
<literal>nixos</literal>). This argument is required.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-pullImage-2'>
|
||||||
|
<para>
|
||||||
|
<varname>imageDigest</varname> specifies the digest of the image to be
|
||||||
|
downloaded. Skopeo can be used to get the digest of an image, with its
|
||||||
|
<varname>inspect</varname> subcommand. Since a given
|
||||||
|
<varname>imageName</varname> may transparently refer to a manifest list of
|
||||||
|
images which support multiple architectures and/or operating systems,
|
||||||
|
supply the `--override-os` and `--override-arch` arguments to specify
|
||||||
|
exactly which image you want. By default it will match the OS and
|
||||||
|
architecture of the host the command is run on.
|
||||||
|
<programlisting>
|
||||||
|
$ nix-shell --packages skopeo jq --command "skopeo --override-os linux --override-arch x86_64 inspect docker://docker.io/nixos/nix:1.11 | jq -r '.Digest'"
|
||||||
|
sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b
|
||||||
|
</programlisting>
|
||||||
|
This argument is required.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-pullImage-3'>
|
||||||
|
<para>
|
||||||
|
<varname>finalImageTag</varname>, if specified, this is the tag of the
|
||||||
|
image to be created. Note it is never used to fetch the image since we
|
||||||
|
prefer to rely on the immutable digest ID. By default it's
|
||||||
|
<literal>latest</literal>.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-pullImage-4'>
|
||||||
|
<para>
|
||||||
|
<varname>sha256</varname> is the checksum of the whole fetched image. This
|
||||||
|
argument is required.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-pullImage-5'>
|
||||||
|
<para>
|
||||||
|
<varname>os</varname>, if specified, is the operating system of the
|
||||||
|
fetched image. By default it's <literal>linux</literal>.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
<callout arearefs='ex-dockerTools-pullImage-6'>
|
||||||
|
<para>
|
||||||
|
<varname>arch</varname>, if specified, is the cpu architecture of the
|
||||||
|
fetched image. By default it's <literal>x86_64</literal>.
|
||||||
|
</para>
|
||||||
|
</callout>
|
||||||
|
</calloutlist>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="ssec-pkgs-dockerTools-exportImage">
|
||||||
|
<title>exportImage</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This function is analogous to the <command>docker export</command> command,
|
||||||
|
in that can used to flatten a Docker image that contains multiple layers. It
|
||||||
|
is in fact the result of the merge of all the layers of the image. As such,
|
||||||
|
the result is suitable for being imported in Docker with <command>docker
|
||||||
|
import</command>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
Using this function requires the <literal>kvm</literal> device to be
|
||||||
|
available.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The parameters of <varname>exportImage</varname> are the following:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<example xml:id='ex-dockerTools-exportImage'>
|
||||||
|
<title>Docker export</title>
|
||||||
|
<programlisting>
|
||||||
|
exportImage {
|
||||||
|
fromImage = someLayeredImage;
|
||||||
|
fromImageName = null;
|
||||||
|
fromImageTag = null;
|
||||||
|
|
||||||
|
name = someLayeredImage.name;
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The parameters relative to the base image have the same synopsis as
|
||||||
|
described in <xref linkend='ssec-pkgs-dockerTools-buildImage'/>, except that
|
||||||
|
<varname>fromImage</varname> is the only required argument in this case.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The <varname>name</varname> argument is the name of the derivation output,
|
||||||
|
which defaults to <varname>fromImage.name</varname>.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="ssec-pkgs-dockerTools-shadowSetup">
|
||||||
|
<title>shadowSetup</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This constant string is a helper for setting up the base files for managing
|
||||||
|
users and groups, only if such files don't exist already. It is suitable for
|
||||||
|
being used in a <varname>runAsRoot</varname>
|
||||||
|
<xref linkend='ex-dockerTools-buildImage-runAsRoot'/> script for cases like
|
||||||
|
in the example below:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<example xml:id='ex-dockerTools-shadowSetup'>
|
||||||
|
<title>Shadow base files</title>
|
||||||
|
<programlisting>
|
||||||
|
buildImage {
|
||||||
|
name = "shadow-basic";
|
||||||
|
|
||||||
|
runAsRoot = ''
|
||||||
|
#!${stdenv.shell}
|
||||||
|
${shadowSetup}
|
||||||
|
groupadd -r redis
|
||||||
|
useradd -r -g redis redis
|
||||||
|
mkdir /data
|
||||||
|
chown redis:redis /data
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Creating base files like <literal>/etc/passwd</literal> or
|
||||||
|
<literal>/etc/login.defs</literal> are necessary for shadow-utils to
|
||||||
|
manipulate users and groups.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
</section>
|
142
doc/functions/fhs-environments.xml
Normal file
142
doc/functions/fhs-environments.xml
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xml:id="sec-fhs-environments">
|
||||||
|
<title>buildFHSUserEnv</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<function>buildFHSUserEnv</function> provides a way to build and run
|
||||||
|
FHS-compatible lightweight sandboxes. It creates an isolated root with bound
|
||||||
|
<filename>/nix/store</filename>, so its footprint in terms of disk space
|
||||||
|
needed is quite small. This allows one to run software which is hard or
|
||||||
|
unfeasible to patch for NixOS -- 3rd-party source trees with FHS assumptions,
|
||||||
|
games distributed as tarballs, software with integrity checking and/or
|
||||||
|
external self-updated binaries. It uses Linux namespaces feature to create
|
||||||
|
temporary lightweight environments which are destroyed after all child
|
||||||
|
processes exit, without root user rights requirement. Accepted arguments are:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<literal>name</literal>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Environment name.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<literal>targetPkgs</literal>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Packages to be installed for the main host's architecture (i.e. x86_64 on
|
||||||
|
x86_64 installations). Along with libraries binaries are also installed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<literal>multiPkgs</literal>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Packages to be installed for all architectures supported by a host (i.e.
|
||||||
|
i686 and x86_64 on x86_64 installations). Only libraries are installed by
|
||||||
|
default.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<literal>extraBuildCommands</literal>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Additional commands to be executed for finalizing the directory structure.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<literal>extraBuildCommandsMulti</literal>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Like <literal>extraBuildCommands</literal>, but executed only on multilib
|
||||||
|
architectures.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<literal>extraOutputsToInstall</literal>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Additional derivation outputs to be linked for both target and
|
||||||
|
multi-architecture packages.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<literal>extraInstallCommands</literal>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Additional commands to be executed for finalizing the derivation with
|
||||||
|
runner script.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<literal>runScript</literal>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
A command that would be executed inside the sandbox and passed all the
|
||||||
|
command line arguments. It defaults to <literal>bash</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
One can create a simple environment using a <literal>shell.nix</literal> like
|
||||||
|
that:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
|
||||||
|
(pkgs.buildFHSUserEnv {
|
||||||
|
name = "simple-x11-env";
|
||||||
|
targetPkgs = pkgs: (with pkgs;
|
||||||
|
[ udev
|
||||||
|
alsaLib
|
||||||
|
]) ++ (with pkgs.xorg;
|
||||||
|
[ libX11
|
||||||
|
libXcursor
|
||||||
|
libXrandr
|
||||||
|
]);
|
||||||
|
multiPkgs = pkgs: (with pkgs;
|
||||||
|
[ udev
|
||||||
|
alsaLib
|
||||||
|
]);
|
||||||
|
runScript = "bash";
|
||||||
|
}).env
|
||||||
|
]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Running <literal>nix-shell</literal> would then drop you into a shell with
|
||||||
|
these libraries and binaries available. You can use this to run closed-source
|
||||||
|
applications which expect FHS structure without hassles: simply change
|
||||||
|
<literal>runScript</literal> to the application path, e.g.
|
||||||
|
<filename>./bin/start.sh</filename> -- relative paths are supported.
|
||||||
|
</para>
|
||||||
|
</section>
|
89
doc/functions/generators.xml
Normal file
89
doc/functions/generators.xml
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xml:id="sec-generators">
|
||||||
|
<title>Generators</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Generators are functions that create file formats from nix data structures,
|
||||||
|
e. g. for configuration files. There are generators available for:
|
||||||
|
<literal>INI</literal>, <literal>JSON</literal> and <literal>YAML</literal>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
All generators follow a similar call interface: <code>generatorName
|
||||||
|
configFunctions data</code>, where <literal>configFunctions</literal> is an
|
||||||
|
attrset of user-defined functions that format nested parts of the content.
|
||||||
|
They each have common defaults, so often they do not need to be set manually.
|
||||||
|
An example is <code>mkSectionName ? (name: libStr.escape [ "[" "]" ]
|
||||||
|
name)</code> from the <literal>INI</literal> generator. It receives the name
|
||||||
|
of a section and sanitizes it. The default <literal>mkSectionName</literal>
|
||||||
|
escapes <literal>[</literal> and <literal>]</literal> with a backslash.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Generators can be fine-tuned to produce exactly the file format required by
|
||||||
|
your application/service. One example is an INI-file format which uses
|
||||||
|
<literal>: </literal> as separator, the strings
|
||||||
|
<literal>"yes"</literal>/<literal>"no"</literal> as boolean values and
|
||||||
|
requires all string values to be quoted:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
customToINI = generators.toINI {
|
||||||
|
# specifies how to format a key/value pair
|
||||||
|
mkKeyValue = generators.mkKeyValueDefault {
|
||||||
|
# specifies the generated string for a subset of nix values
|
||||||
|
mkValueString = v:
|
||||||
|
if v == true then ''"yes"''
|
||||||
|
else if v == false then ''"no"''
|
||||||
|
else if isString v then ''"${v}"''
|
||||||
|
# and delegats all other values to the default generator
|
||||||
|
else generators.mkValueStringDefault {} v;
|
||||||
|
} ":";
|
||||||
|
};
|
||||||
|
|
||||||
|
# the INI file can now be given as plain old nix values
|
||||||
|
in customToINI {
|
||||||
|
main = {
|
||||||
|
pushinfo = true;
|
||||||
|
autopush = false;
|
||||||
|
host = "localhost";
|
||||||
|
port = 42;
|
||||||
|
};
|
||||||
|
mergetool = {
|
||||||
|
merge = "diff3";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This will produce the following INI file as nix string:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
[main]
|
||||||
|
autopush:"no"
|
||||||
|
host:"localhost"
|
||||||
|
port:42
|
||||||
|
pushinfo:"yes"
|
||||||
|
str\:ange:"very::strange"
|
||||||
|
|
||||||
|
[mergetool]
|
||||||
|
merge:"diff3"
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
Nix store paths can be converted to strings by enclosing a derivation
|
||||||
|
attribute like so: <code>"${drv}"</code>.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Detailed documentation for each generator can be found in
|
||||||
|
<literal>lib/generators.nix</literal>.
|
||||||
|
</para>
|
||||||
|
</section>
|
15
doc/functions/library.xml
Normal file
15
doc/functions/library.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xml:id="sec-functions-library">
|
||||||
|
<title>Nixpkgs Library Functions</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Nixpkgs provides a standard library at <varname>pkgs.lib</varname>, or
|
||||||
|
through <code>import <nixpkgs/lib></code>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<xi:include href="./library/asserts.xml" />
|
||||||
|
|
||||||
|
<xi:include href="./library/attrsets.xml" />
|
||||||
|
</section>
|
117
doc/functions/library/asserts.xml
Normal file
117
doc/functions/library/asserts.xml
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xml:id="sec-functions-library-asserts">
|
||||||
|
<title>Assert functions</title>
|
||||||
|
|
||||||
|
<section xml:id="function-library-lib.asserts.assertMsg">
|
||||||
|
<title><function>lib.asserts.assertMsg</function></title>
|
||||||
|
|
||||||
|
<subtitle><literal>assertMsg :: Bool -> String -> Bool</literal>
|
||||||
|
</subtitle>
|
||||||
|
|
||||||
|
<xi:include href="./locations.xml" xpointer="lib.asserts.assertMsg" />
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Print a trace message if <literal>pred</literal> is false.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Intended to be used to augment asserts with helpful error messages.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>pred</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Condition under which the <varname>msg</varname> should
|
||||||
|
<emphasis>not</emphasis> be printed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>msg</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Message to print.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<example xml:id="function-library-lib.asserts.assertMsg-example-false">
|
||||||
|
<title>Printing when the predicate is false</title>
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
assert lib.asserts.assertMsg ("foo" == "bar") "foo is not bar, silly"
|
||||||
|
stderr> trace: foo is not bar, silly
|
||||||
|
stderr> assert failed
|
||||||
|
]]></programlisting>
|
||||||
|
</example>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="function-library-lib.asserts.assertOneOf">
|
||||||
|
<title><function>lib.asserts.assertOneOf</function></title>
|
||||||
|
|
||||||
|
<subtitle><literal>assertOneOf :: String -> String ->
|
||||||
|
StringList -> Bool</literal>
|
||||||
|
</subtitle>
|
||||||
|
|
||||||
|
<xi:include href="./locations.xml" xpointer="lib.asserts.assertOneOf" />
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Specialized <function>asserts.assertMsg</function> for checking if
|
||||||
|
<varname>val</varname> is one of the elements of <varname>xs</varname>.
|
||||||
|
Useful for checking enums.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>name</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The name of the variable the user entered <varname>val</varname> into,
|
||||||
|
for inclusion in the error message.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>val</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The value of what the user provided, to be compared against the values in
|
||||||
|
<varname>xs</varname>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>xs</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The list of valid values.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<example xml:id="function-library-lib.asserts.assertOneOf-example">
|
||||||
|
<title>Ensuring a user provided a possible value</title>
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
let sslLibrary = "bearssl";
|
||||||
|
in lib.asserts.assertOneOf "sslLibrary" sslLibrary [ "openssl" "bearssl" ];
|
||||||
|
=> false
|
||||||
|
stderr> trace: sslLibrary must be one of "openssl", "libressl", but is: "bearssl"
|
||||||
|
]]></programlisting>
|
||||||
|
</example>
|
||||||
|
</section>
|
||||||
|
</section>
|
1731
doc/functions/library/attrsets.xml
Normal file
1731
doc/functions/library/attrsets.xml
Normal file
File diff suppressed because it is too large
Load Diff
212
doc/functions/overrides.xml
Normal file
212
doc/functions/overrides.xml
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xml:id="sec-overrides">
|
||||||
|
<title>Overriding</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Sometimes one wants to override parts of <literal>nixpkgs</literal>, e.g.
|
||||||
|
derivation attributes, the results of derivations.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
These functions are used to make changes to packages, returning only single
|
||||||
|
packages. <link xlink:href="#chap-overlays">Overlays</link>, on the other
|
||||||
|
hand, can be used to combine the overridden packages across the entire
|
||||||
|
package set of Nixpkgs.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<section xml:id="sec-pkg-override">
|
||||||
|
<title><pkg>.override</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The function <varname>override</varname> is usually available for all the
|
||||||
|
derivations in the nixpkgs expression (<varname>pkgs</varname>).
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
It is used to override the arguments passed to a function.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Example usages:
|
||||||
|
<programlisting>pkgs.foo.override { arg1 = val1; arg2 = val2; ... }</programlisting>
|
||||||
|
<!-- TODO: move below programlisting to a new section about extending and overlays
|
||||||
|
and reference it
|
||||||
|
-->
|
||||||
|
<programlisting>
|
||||||
|
import pkgs.path { overlays = [ (self: super: {
|
||||||
|
foo = super.foo.override { barSupport = true ; };
|
||||||
|
})]};
|
||||||
|
</programlisting>
|
||||||
|
<programlisting>
|
||||||
|
mypkg = pkgs.callPackage ./mypkg.nix {
|
||||||
|
mydep = pkgs.mydep.override { ... };
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
In the first example, <varname>pkgs.foo</varname> is the result of a
|
||||||
|
function call with some default arguments, usually a derivation. Using
|
||||||
|
<varname>pkgs.foo.override</varname> will call the same function with the
|
||||||
|
given new arguments.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-pkg-overrideAttrs">
|
||||||
|
<title><pkg>.overrideAttrs</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The function <varname>overrideAttrs</varname> allows overriding the
|
||||||
|
attribute set passed to a <varname>stdenv.mkDerivation</varname> call,
|
||||||
|
producing a new derivation based on the original one. This function is
|
||||||
|
available on all derivations produced by the
|
||||||
|
<varname>stdenv.mkDerivation</varname> function, which is most packages in
|
||||||
|
the nixpkgs expression <varname>pkgs</varname>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Example usage:
|
||||||
|
<programlisting>
|
||||||
|
helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec {
|
||||||
|
separateDebugInfo = true;
|
||||||
|
});
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
In the above example, the <varname>separateDebugInfo</varname> attribute is
|
||||||
|
overridden to be true, thus building debug info for
|
||||||
|
<varname>helloWithDebug</varname>, while all other attributes will be
|
||||||
|
retained from the original <varname>hello</varname> package.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The argument <varname>oldAttrs</varname> is conventionally used to refer to
|
||||||
|
the attr set originally passed to <varname>stdenv.mkDerivation</varname>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
Note that <varname>separateDebugInfo</varname> is processed only by the
|
||||||
|
<varname>stdenv.mkDerivation</varname> function, not the generated, raw Nix
|
||||||
|
derivation. Thus, using <varname>overrideDerivation</varname> will not work
|
||||||
|
in this case, as it overrides only the attributes of the final derivation.
|
||||||
|
It is for this reason that <varname>overrideAttrs</varname> should be
|
||||||
|
preferred in (almost) all cases to <varname>overrideDerivation</varname>,
|
||||||
|
i.e. to allow using <varname>stdenv.mkDerivation</varname> 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. <varname>buildInputs</varname> vs
|
||||||
|
<varname>nativeBuildInputs</varname>), and it involves less typing).
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-pkg-overrideDerivation">
|
||||||
|
<title><pkg>.overrideDerivation</title>
|
||||||
|
|
||||||
|
<warning>
|
||||||
|
<para>
|
||||||
|
You should prefer <varname>overrideAttrs</varname> in almost all cases, see
|
||||||
|
its documentation for the reasons why.
|
||||||
|
<varname>overrideDerivation</varname> is not deprecated and will continue
|
||||||
|
to work, but is less nice to use and does not have as many abilities as
|
||||||
|
<varname>overrideAttrs</varname>.
|
||||||
|
</para>
|
||||||
|
</warning>
|
||||||
|
|
||||||
|
<warning>
|
||||||
|
<para>
|
||||||
|
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 <filename>~/.config/nixpkgs/config.nix</filename>.
|
||||||
|
</para>
|
||||||
|
</warning>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The function <varname>overrideDerivation</varname> creates a new derivation
|
||||||
|
based on an existing one by overriding the original's attributes with the
|
||||||
|
attribute set produced by the specified function. This function is available
|
||||||
|
on all derivations defined using the <varname>makeOverridable</varname>
|
||||||
|
function. Most standard derivation-producing functions, such as
|
||||||
|
<varname>stdenv.mkDerivation</varname>, are defined using this function,
|
||||||
|
which means most packages in the nixpkgs expression,
|
||||||
|
<varname>pkgs</varname>, have this function.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Example usage:
|
||||||
|
<programlisting>
|
||||||
|
mySed = pkgs.gnused.overrideDerivation (oldAttrs: {
|
||||||
|
name = "sed-4.2.2-pre";
|
||||||
|
src = fetchurl {
|
||||||
|
url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2;
|
||||||
|
sha256 = "11nq06d131y4wmf3drm0yk502d2xc6n5qy82cg88rb9nqd2lj41k";
|
||||||
|
};
|
||||||
|
patches = [];
|
||||||
|
});
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
In the above example, the <varname>name</varname>, <varname>src</varname>,
|
||||||
|
and <varname>patches</varname> of the derivation will be overridden, while
|
||||||
|
all other attributes will be retained from the original derivation.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The argument <varname>oldAttrs</varname> is used to refer to the attribute
|
||||||
|
set of the original derivation.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
A package's attributes are evaluated *before* being modified by the
|
||||||
|
<varname>overrideDerivation</varname> function. For example, the
|
||||||
|
<varname>name</varname> attribute reference in <varname>url =
|
||||||
|
"mirror://gnu/hello/${name}.tar.gz";</varname> is filled-in *before* the
|
||||||
|
<varname>overrideDerivation</varname> function modifies the attribute set.
|
||||||
|
This means that overriding the <varname>name</varname> attribute, in this
|
||||||
|
example, *will not* change the value of the <varname>url</varname>
|
||||||
|
attribute. Instead, we need to override both the <varname>name</varname>
|
||||||
|
*and* <varname>url</varname> attributes.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-lib-makeOverridable">
|
||||||
|
<title>lib.makeOverridable</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The function <varname>lib.makeOverridable</varname> is used to make the
|
||||||
|
result of a function easily customizable. This utility only makes sense for
|
||||||
|
functions that accept an argument set and return an attribute set.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Example usage:
|
||||||
|
<programlisting>
|
||||||
|
f = { a, b }: { result = a+b; };
|
||||||
|
c = lib.makeOverridable f { a = 1; b = 2; };
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The variable <varname>c</varname> is the value of the <varname>f</varname>
|
||||||
|
function applied with some default arguments. Hence the value of
|
||||||
|
<varname>c.result</varname> is <literal>3</literal>, in this example.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The variable <varname>c</varname> however also has some additional
|
||||||
|
functions, like <link linkend="sec-pkg-override">c.override</link> which can
|
||||||
|
be used to override the default arguments. In this example the value of
|
||||||
|
<varname>(c.override { a = 4; }).result</varname> is 6.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
</section>
|
26
doc/functions/shell.xml
Normal file
26
doc/functions/shell.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xml:id="sec-pkgs-mkShell">
|
||||||
|
<title>pkgs.mkShell</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<function>pkgs.mkShell</function> is a special kind of derivation that is
|
||||||
|
only useful when using it combined with <command>nix-shell</command>. It will
|
||||||
|
in fact fail to instantiate when invoked with <command>nix-build</command>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<section xml:id="sec-pkgs-mkShell-usage">
|
||||||
|
<title>Usage</title>
|
||||||
|
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
pkgs.mkShell {
|
||||||
|
# this will make all the build inputs from hello and gnutar
|
||||||
|
# available to the shell environment
|
||||||
|
inputsFrom = with pkgs; [ hello gnutar ];
|
||||||
|
buildInputs = [ pkgs.gnumake ];
|
||||||
|
}
|
||||||
|
]]></programlisting>
|
||||||
|
</section>
|
||||||
|
</section>
|
@ -11,10 +11,9 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Some libraries require OCaml and sometimes also Camlp5 or findlib. The exact
|
Some extensions (plugins) might require OCaml and sometimes other OCaml
|
||||||
versions that were used to build Coq are saved in the
|
packages. The <literal>coq.ocamlPackages</literal> attribute can be used to
|
||||||
<literal>coq.ocaml</literal> and <literal>coq.camlp5</literal> and
|
depend on the same package set Coq was built against.
|
||||||
<literal>coq.findlib</literal> attributes.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
@ -1047,6 +1047,19 @@ As you can see, `packunused` finds out that although the testsuite component has
|
|||||||
no redundant dependencies the library component of `scientific-0.3.5.1` depends
|
no redundant dependencies the library component of `scientific-0.3.5.1` depends
|
||||||
on `ghc-prim` which is unused in the library.
|
on `ghc-prim` which is unused in the library.
|
||||||
|
|
||||||
|
### Using hackage2nix with nixpkgs
|
||||||
|
|
||||||
|
Hackage package derivations are found in the
|
||||||
|
[`hackage-packages.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/hackage-packages.nix)
|
||||||
|
file within `nixpkgs` and are used as the initial package set for
|
||||||
|
`haskellPackages`. The `hackage-packages.nix` file is not meant to be edited
|
||||||
|
by hand, but rather autogenerated by [`hackage2nix`](https://github.com/NixOS/cabal2nix/tree/master/hackage2nix),
|
||||||
|
which by default uses the [`configuration-hackage2nix.yaml`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/configuration-hackage2nix.yaml)
|
||||||
|
file to generate all the derivations.
|
||||||
|
|
||||||
|
To modify the contents `configuration-hackage2nix.yaml`, follow the
|
||||||
|
instructions on [`hackage2nix`](https://github.com/NixOS/cabal2nix/tree/master/hackage2nix).
|
||||||
|
|
||||||
## Other resources
|
## Other resources
|
||||||
|
|
||||||
- The Youtube video [Nix Loves Haskell](https://www.youtube.com/watch?v=BsBhi_r-OeE)
|
- The Youtube video [Nix Loves Haskell](https://www.youtube.com/watch?v=BsBhi_r-OeE)
|
||||||
|
@ -1,39 +1,115 @@
|
|||||||
Idris packages
|
# Idris packages
|
||||||
==============
|
|
||||||
|
|
||||||
This directory contains build rules for idris packages. In addition,
|
## Installing Idris
|
||||||
it contains several functions to build and compose those packages.
|
|
||||||
Everything is exposed to the user via the `idrisPackages` attribute.
|
|
||||||
|
|
||||||
callPackage
|
The easiest way to get a working idris version is to install the `idris` attribute:
|
||||||
------------
|
|
||||||
|
|
||||||
This is like the normal nixpkgs callPackage function, specialized to
|
```
|
||||||
idris packages.
|
$ # On NixOS
|
||||||
|
$ nix-env -i nixos.idris
|
||||||
|
$ # On non-NixOS
|
||||||
|
$ nix-env -i nixpkgs.idris
|
||||||
|
```
|
||||||
|
|
||||||
builtins
|
This however only provides the `prelude` and `base` libraries. To install additional libraries:
|
||||||
---------
|
|
||||||
|
|
||||||
This is a list of all of the libraries that come packaged with Idris
|
```
|
||||||
itself.
|
$ nix-env -iE 'pkgs: pkgs.idrisPackages.with-packages (with pkgs.idrisPackages; [ contrib pruviloj ])'
|
||||||
|
```
|
||||||
|
|
||||||
build-idris-package
|
To see all available Idris packages:
|
||||||
--------------------
|
```
|
||||||
|
$ # On NixOS
|
||||||
|
$ nix-env -qaPA nixos.idrisPackages
|
||||||
|
$ # On non-NixOS
|
||||||
|
$ nix-env -qaPA nixpkgs.idrisPackages
|
||||||
|
```
|
||||||
|
|
||||||
A function to build an idris package. Its sole argument is a set like
|
Similarly, entering a `nix-shell`:
|
||||||
you might pass to `stdenv.mkDerivation`, except `build-idris-package`
|
```
|
||||||
sets several attributes for you. See `build-idris-package.nix` for
|
$ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])'
|
||||||
details.
|
```
|
||||||
|
|
||||||
build-builtin-package
|
## Starting Idris with library support
|
||||||
----------------------
|
|
||||||
|
|
||||||
A version of `build-idris-package` specialized to builtin libraries.
|
To have access to these libraries in idris, call it with an argument `-p <library name>` for each library:
|
||||||
Mostly for internal use.
|
|
||||||
|
|
||||||
with-packages
|
```
|
||||||
-------------
|
$ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])'
|
||||||
|
[nix-shell:~]$ idris -p contrib -p pruviloj
|
||||||
|
```
|
||||||
|
|
||||||
Bundle idris together with a list of packages. Because idris currently
|
A listing of all available packages the Idris binary has access to is available via `--listlibs`:
|
||||||
only supports a single directory in its library path, you must include
|
|
||||||
all desired libraries here, including `prelude` and `base`.
|
```
|
||||||
|
$ idris --listlibs
|
||||||
|
00prelude-idx.ibc
|
||||||
|
pruviloj
|
||||||
|
base
|
||||||
|
contrib
|
||||||
|
prelude
|
||||||
|
00pruviloj-idx.ibc
|
||||||
|
00base-idx.ibc
|
||||||
|
00contrib-idx.ibc
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building an Idris project with Nix
|
||||||
|
|
||||||
|
As an example of how a Nix expression for an Idris package can be created, here is the one for `idrisPackages.yaml`:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ build-idris-package
|
||||||
|
, fetchFromGitHub
|
||||||
|
, contrib
|
||||||
|
, lightyear
|
||||||
|
, lib
|
||||||
|
}:
|
||||||
|
build-idris-package {
|
||||||
|
name = "yaml";
|
||||||
|
version = "2018-01-25";
|
||||||
|
|
||||||
|
# This is the .ipkg file that should be built, defaults to the package name
|
||||||
|
# In this case it should build `Yaml.ipkg` instead of `yaml.ipkg`
|
||||||
|
# This is only necessary because the yaml packages ipkg file is
|
||||||
|
# different from its package name here.
|
||||||
|
ipkgName = "Yaml";
|
||||||
|
# Idris dependencies to provide for the build
|
||||||
|
idrisDeps = [ contrib lightyear ];
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "Heather";
|
||||||
|
repo = "Idris.Yaml";
|
||||||
|
rev = "5afa51ffc839844862b8316faba3bafa15656db4";
|
||||||
|
sha256 = "1g4pi0swmg214kndj85hj50ccmckni7piprsxfdzdfhg87s0avw7";
|
||||||
|
};
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Idris YAML lib";
|
||||||
|
homepage = https://github.com/Heather/Idris.Yaml;
|
||||||
|
license = lib.licenses.mit;
|
||||||
|
maintainers = [ lib.maintainers.brainrape ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Assuming this file is saved as `yaml.nix`, it's buildable using
|
||||||
|
|
||||||
|
```
|
||||||
|
$ nix-build -E '(import <nixpkgs> {}).idrisPackages.callPackage ./yaml.nix {}'
|
||||||
|
```
|
||||||
|
|
||||||
|
Or it's possible to use
|
||||||
|
|
||||||
|
```nix
|
||||||
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
|
{
|
||||||
|
yaml = idrisPackages.callPackage ./yaml.nix {};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
in another file (say `default.nix`) to be able to build it with
|
||||||
|
|
||||||
|
```
|
||||||
|
$ nix-build -A yaml
|
||||||
|
```
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
<xi:include href="java.xml" />
|
<xi:include href="java.xml" />
|
||||||
<xi:include href="lua.xml" />
|
<xi:include href="lua.xml" />
|
||||||
<xi:include href="node.section.xml" />
|
<xi:include href="node.section.xml" />
|
||||||
|
<xi:include href="ocaml.xml" />
|
||||||
<xi:include href="perl.xml" />
|
<xi:include href="perl.xml" />
|
||||||
<xi:include href="python.section.xml" />
|
<xi:include href="python.section.xml" />
|
||||||
<xi:include href="qt.xml" />
|
<xi:include href="qt.xml" />
|
||||||
|
@ -15,15 +15,18 @@ stdenv.mkDerivation {
|
|||||||
buildPhase = "ant";
|
buildPhase = "ant";
|
||||||
}
|
}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
Note that <varname>jdk</varname> is an alias for the OpenJDK.
|
Note that <varname>jdk</varname> is an alias for the OpenJDK (self-built
|
||||||
|
where available, or pre-built via Zulu). Platforms with OpenJDK not (yet) in
|
||||||
|
Nixpkgs (<literal>Aarch32</literal>, <literal>Aarch64</literal>) point to the
|
||||||
|
(unfree) <literal>oraclejdk</literal>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
JAR files that are intended to be used by other packages should be installed
|
JAR files that are intended to be used by other packages should be installed
|
||||||
in <filename>$out/share/java</filename>. The OpenJDK has a stdenv setup hook
|
in <filename>$out/share/java</filename>. JDKs have a stdenv setup hook that
|
||||||
that adds any JARs in the <filename>share/java</filename> directories of the
|
add any JARs in the <filename>share/java</filename> directories of the build
|
||||||
build inputs to the <envar>CLASSPATH</envar> environment variable. For
|
inputs to the <envar>CLASSPATH</envar> environment variable. For instance, if
|
||||||
instance, if the package <literal>libfoo</literal> installs a JAR named
|
the package <literal>libfoo</literal> installs a JAR named
|
||||||
<filename>foo.jar</filename> in its <filename>share/java</filename>
|
<filename>foo.jar</filename> in its <filename>share/java</filename>
|
||||||
directory, and another package declares the attribute
|
directory, and another package declares the attribute
|
||||||
<programlisting>
|
<programlisting>
|
||||||
@ -59,6 +62,16 @@ installPhase =
|
|||||||
on the JDK at runtime.
|
on the JDK at runtime.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Note all JDKs passthru <literal>home</literal>, so if your application
|
||||||
|
requires environment variables like <envar>JAVA_HOME</envar> being set, that
|
||||||
|
can be done in a generic fashion with the <literal>--set</literal> argument
|
||||||
|
of <literal>makeWrapper</literal>:
|
||||||
|
<programlisting>
|
||||||
|
--set JAVA_HOME ${jdk.home}
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
It is possible to use a different Java compiler than <command>javac</command>
|
It is possible to use a different Java compiler than <command>javac</command>
|
||||||
from the OpenJDK. For instance, to use the GNU Java Compiler:
|
from the OpenJDK. For instance, to use the GNU Java Compiler:
|
||||||
|
@ -14,7 +14,7 @@ project.
|
|||||||
|
|
||||||
The package set also provides support for multiple Node.js versions. The policy
|
The package set also provides support for multiple Node.js versions. The policy
|
||||||
is that a new package should be added to the collection for the latest stable LTS
|
is that a new package should be added to the collection for the latest stable LTS
|
||||||
release (which is currently 6.x), unless there is an explicit reason to support
|
release (which is currently 10.x), unless there is an explicit reason to support
|
||||||
a different release.
|
a different release.
|
||||||
|
|
||||||
If your package uses native addons, you need to examine what kind of native
|
If your package uses native addons, you need to examine what kind of native
|
||||||
@ -26,7 +26,7 @@ build system it uses. Here are some examples:
|
|||||||
|
|
||||||
After you have identified the correct system, you need to override your package
|
After you have identified the correct system, you need to override your package
|
||||||
expression while adding in build system as a build input. For example, `dat`
|
expression while adding in build system as a build input. For example, `dat`
|
||||||
requires `node-gyp-build`, so we override its expression in `default-v6.nix`:
|
requires `node-gyp-build`, so we override its expression in `default-v10.nix`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
dat = nodePackages.dat.override (oldAttrs: {
|
dat = nodePackages.dat.override (oldAttrs: {
|
||||||
@ -36,14 +36,14 @@ dat = nodePackages.dat.override (oldAttrs: {
|
|||||||
|
|
||||||
To add a package from NPM to nixpkgs:
|
To add a package from NPM to nixpkgs:
|
||||||
|
|
||||||
1. Modify `pkgs/development/node-packages/node-packages-v6.json` to add, update
|
1. Modify `pkgs/development/node-packages/node-packages-v10.json` to add, update
|
||||||
or remove package entries. (Or `pkgs/development/node-packages/node-packages-v4.json`
|
or remove package entries. (Or `pkgs/development/node-packages/node-packages-v8.json`
|
||||||
for packages depending on Node.js 4.x)
|
for packages depending on Node.js 8.x)
|
||||||
2. Run the script: `(cd pkgs/development/node-packages && ./generate.sh)`.
|
2. Run the script: `(cd pkgs/development/node-packages && ./generate.sh)`.
|
||||||
3. Build your new package to test your changes:
|
3. Build your new package to test your changes:
|
||||||
`cd /path/to/nixpkgs && nix-build -A nodePackages.<new-or-updated-package>`.
|
`cd /path/to/nixpkgs && nix-build -A nodePackages.<new-or-updated-package>`.
|
||||||
To build against a specific Node.js version (e.g. 4.x):
|
To build against a specific Node.js version (e.g. 10.x):
|
||||||
`nix-build -A nodePackages_4_x.<new-or-updated-package>`
|
`nix-build -A nodePackages_10_x.<new-or-updated-package>`
|
||||||
4. Add and commit all modified and generated files.
|
4. Add and commit all modified and generated files.
|
||||||
|
|
||||||
For more information about the generation process, consult the
|
For more information about the generation process, consult the
|
||||||
|
99
doc/languages-frameworks/ocaml.xml
Normal file
99
doc/languages-frameworks/ocaml.xml
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xml:id="sec-language-ocaml">
|
||||||
|
<title>OCaml</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
OCaml libraries should be installed in
|
||||||
|
<literal>$(out)/lib/ocaml/${ocaml.version}/site-lib/</literal>. Such
|
||||||
|
directories are automatically added to the <literal>$OCAMLPATH</literal>
|
||||||
|
environment variable when building another package that depends on them
|
||||||
|
or when opening a <literal>nix-shell</literal>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Given that most of the OCaml ecosystem is now built with dune,
|
||||||
|
nixpkgs includes a convenience build support function called
|
||||||
|
<literal>buildDunePackage</literal> that will build an OCaml package
|
||||||
|
using dune, OCaml and findlib and any additional dependencies provided
|
||||||
|
as <literal>buildInputs</literal> or <literal>propagatedBuildInputs</literal>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Here is a simple package example. It defines an (optional) attribute
|
||||||
|
<literal>minimumOCamlVersion</literal> that will be used to throw a
|
||||||
|
descriptive evaluation error if building with an older OCaml is attempted.
|
||||||
|
It uses the <literal>fetchFromGitHub</literal> fetcher to get its source.
|
||||||
|
It sets the <literal>doCheck</literal> (optional) attribute to
|
||||||
|
<literal>true</literal> which means that tests will be run with
|
||||||
|
<literal>dune runtest -p angstrom</literal> after the build
|
||||||
|
(<literal>dune build -p angstrom</literal>) is complete.
|
||||||
|
It uses <literal>alcotest</literal> as a build input (because it is needed
|
||||||
|
to run the tests) and <literal>bigstringaf</literal> and
|
||||||
|
<literal>result</literal> as propagated build inputs (thus they will also
|
||||||
|
be available to libraries depending on this library).
|
||||||
|
The library will be installed using the <literal>angstrom.install</literal>
|
||||||
|
file that dune generates.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
{ stdenv, fetchFromGitHub, buildDunePackage, alcotest, result, bigstringaf }:
|
||||||
|
|
||||||
|
buildDunePackage rec {
|
||||||
|
pname = "angstrom";
|
||||||
|
version = "0.10.0";
|
||||||
|
|
||||||
|
minimumOCamlVersion = "4.03";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "inhabitedtype";
|
||||||
|
repo = pname;
|
||||||
|
rev = version;
|
||||||
|
sha256 = "0lh6024yf9ds0nh9i93r9m6p5psi8nvrqxl5x7jwl13zb0r9xfpw";
|
||||||
|
};
|
||||||
|
|
||||||
|
buildInputs = [ alcotest ];
|
||||||
|
propagatedBuildInputs = [ bigstringaf result ];
|
||||||
|
doCheck = true;
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
homepage = https://github.com/inhabitedtype/angstrom;
|
||||||
|
description = "OCaml parser combinators built for speed and memory efficiency";
|
||||||
|
license = stdenv.lib.licenses.bsd3;
|
||||||
|
maintainers = with stdenv.lib.maintainers; [ sternenseemann ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Here is a second example, this time using a source archive generated with
|
||||||
|
<literal>dune-release</literal>. It is a good idea to use this archive when
|
||||||
|
it is available as it will usually contain substituted variables such as a
|
||||||
|
<literal>%%VERSION%%</literal> field. This library does not depend
|
||||||
|
on any other OCaml library and no tests are run after building it.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
{ stdenv, fetchurl, buildDunePackage }:
|
||||||
|
|
||||||
|
buildDunePackage rec {
|
||||||
|
pname = "wtf8";
|
||||||
|
version = "1.0.1";
|
||||||
|
|
||||||
|
minimumOCamlVersion = "4.01";
|
||||||
|
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://github.com/flowtype/ocaml-${pname}/releases/download/v${version}/${pname}-${version}.tbz";
|
||||||
|
sha256 = "1msg3vycd3k8qqj61sc23qks541cxpb97vrnrvrhjnqxsqnh6ygq";
|
||||||
|
};
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
homepage = https://github.com/flowtype/ocaml-wtf8;
|
||||||
|
description = "WTF-8 is a superset of UTF-8 that allows unpaired surrogates.";
|
||||||
|
license = licenses.mit;
|
||||||
|
maintainers = [ maintainers.eqyiel ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
</section>
|
@ -186,7 +186,7 @@ building Python libraries is `buildPythonPackage`. Let's see how we can build th
|
|||||||
`toolz` package.
|
`toolz` package.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ # ...
|
{ lib, buildPythonPackage, fetchPypi }:
|
||||||
|
|
||||||
toolz = buildPythonPackage rec {
|
toolz = buildPythonPackage rec {
|
||||||
pname = "toolz";
|
pname = "toolz";
|
||||||
@ -199,8 +199,8 @@ building Python libraries is `buildPythonPackage`. Let's see how we can build th
|
|||||||
|
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
meta = {
|
meta = with lib; {
|
||||||
homepage = "https://github.com/pytoolz/toolz/";
|
homepage = https://github.com/pytoolz/toolz;
|
||||||
description = "List processing tools and functional utilities";
|
description = "List processing tools and functional utilities";
|
||||||
license = licenses.bsd3;
|
license = licenses.bsd3;
|
||||||
maintainers = with maintainers; [ fridh ];
|
maintainers = with maintainers; [ fridh ];
|
||||||
@ -267,12 +267,13 @@ that we introduced with the `let` expression.
|
|||||||
|
|
||||||
#### Handling dependencies
|
#### Handling dependencies
|
||||||
|
|
||||||
Our example, `toolz`, does not have any dependencies on other Python
|
Our example, `toolz`, does not have any dependencies on other Python packages or
|
||||||
packages or system libraries. According to the manual, `buildPythonPackage`
|
system libraries. According to the manual, `buildPythonPackage` uses the
|
||||||
uses the arguments `buildInputs` and `propagatedBuildInputs` to specify dependencies. If something is
|
arguments `buildInputs` and `propagatedBuildInputs` to specify dependencies. If
|
||||||
exclusively a build-time dependency, then the dependency should be included as a
|
something is exclusively a build-time dependency, then the dependency should be
|
||||||
`buildInput`, but if it is (also) a runtime dependency, then it should be added
|
included as a `buildInput`, but if it is (also) a runtime dependency, then it
|
||||||
to `propagatedBuildInputs`. Test dependencies are considered build-time dependencies.
|
should be added to `propagatedBuildInputs`. Test dependencies are considered
|
||||||
|
build-time dependencies and passed to `checkInputs`.
|
||||||
|
|
||||||
The following example shows which arguments are given to `buildPythonPackage` in
|
The following example shows which arguments are given to `buildPythonPackage` in
|
||||||
order to build [`datashape`](https://github.com/blaze/datashape).
|
order to build [`datashape`](https://github.com/blaze/datashape).
|
||||||
@ -292,7 +293,7 @@ order to build [`datashape`](https://github.com/blaze/datashape).
|
|||||||
checkInputs = with self; [ pytest ];
|
checkInputs = with self; [ pytest ];
|
||||||
propagatedBuildInputs = with self; [ numpy multipledispatch dateutil ];
|
propagatedBuildInputs = with self; [ numpy multipledispatch dateutil ];
|
||||||
|
|
||||||
meta = {
|
meta = with lib; {
|
||||||
homepage = https://github.com/ContinuumIO/datashape;
|
homepage = https://github.com/ContinuumIO/datashape;
|
||||||
description = "A data description language";
|
description = "A data description language";
|
||||||
license = licenses.bsd2;
|
license = licenses.bsd2;
|
||||||
@ -326,7 +327,7 @@ when building the bindings and are therefore added as `buildInputs`.
|
|||||||
|
|
||||||
buildInputs = with self; [ pkgs.libxml2 pkgs.libxslt ];
|
buildInputs = with self; [ pkgs.libxml2 pkgs.libxslt ];
|
||||||
|
|
||||||
meta = {
|
meta = with lib; {
|
||||||
description = "Pythonic binding for the libxml2 and libxslt libraries";
|
description = "Pythonic binding for the libxml2 and libxslt libraries";
|
||||||
homepage = https://lxml.de;
|
homepage = https://lxml.de;
|
||||||
license = licenses.bsd3;
|
license = licenses.bsd3;
|
||||||
@ -370,9 +371,9 @@ and `CFLAGS`.
|
|||||||
export CFLAGS="-I${pkgs.fftw.dev}/include -I${pkgs.fftwFloat.dev}/include -I${pkgs.fftwLongDouble.dev}/include"
|
export CFLAGS="-I${pkgs.fftw.dev}/include -I${pkgs.fftwFloat.dev}/include -I${pkgs.fftwLongDouble.dev}/include"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = with lib; {
|
||||||
description = "A pythonic wrapper around FFTW, the FFT library, presenting a unified interface for all the supported transforms";
|
description = "A pythonic wrapper around FFTW, the FFT library, presenting a unified interface for all the supported transforms";
|
||||||
homepage = http://hgomersall.github.com/pyFFTW/;
|
homepage = http://hgomersall.github.com/pyFFTW;
|
||||||
license = with licenses; [ bsd2 bsd3 ];
|
license = with licenses; [ bsd2 bsd3 ];
|
||||||
maintainers = with maintainers; [ fridh ];
|
maintainers = with maintainers; [ fridh ];
|
||||||
};
|
};
|
||||||
@ -424,7 +425,7 @@ available.
|
|||||||
|
|
||||||
At some point you'll likely have multiple packages which you would
|
At some point you'll likely have multiple packages which you would
|
||||||
like to be able to use in different projects. In order to minimise unnecessary
|
like to be able to use in different projects. In order to minimise unnecessary
|
||||||
duplication we now look at how you can maintain yourself a repository with your
|
duplication we now look at how you can maintain a repository with your
|
||||||
own packages. The important functions here are `import` and `callPackage`.
|
own packages. The important functions here are `import` and `callPackage`.
|
||||||
|
|
||||||
### Including a derivation using `callPackage`
|
### Including a derivation using `callPackage`
|
||||||
@ -478,18 +479,16 @@ don't explicitly define which `python` derivation should be used. In the above
|
|||||||
example we use `buildPythonPackage` that is part of the set `python35Packages`,
|
example we use `buildPythonPackage` that is part of the set `python35Packages`,
|
||||||
and in this case the `python35` interpreter is automatically used.
|
and in this case the `python35` interpreter is automatically used.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Reference
|
## Reference
|
||||||
|
|
||||||
### Interpreters
|
### Interpreters
|
||||||
|
|
||||||
Versions 2.7, 3.4, 3.5, 3.6 and 3.7 of the CPython interpreter are available as
|
Versions 2.7, 3.5, 3.6 and 3.7 of the CPython interpreter are available as
|
||||||
respectively `python27`, `python34`, `python35` and `python36`. The PyPy interpreter
|
respectively `python27`, `python35`, `python36`, and `python37`. The PyPy
|
||||||
is available as `pypy`. The aliases `python2` and `python3` correspond to respectively `python27` and
|
interpreter is available as `pypy`. The aliases `python2` and `python3`
|
||||||
`python35`. The default interpreter, `python`, maps to `python2`.
|
correspond to respectively `python27` and `python37`. The default interpreter,
|
||||||
The Nix expressions for the interpreters can be found in
|
`python`, maps to `python2`. The Nix expressions for the interpreters can be
|
||||||
`pkgs/development/interpreters/python`.
|
found in `pkgs/development/interpreters/python`.
|
||||||
|
|
||||||
All packages depending on any Python interpreter get appended
|
All packages depending on any Python interpreter get appended
|
||||||
`out/{python.sitePackages}` to `$PYTHONPATH` if such directory
|
`out/{python.sitePackages}` to `$PYTHONPATH` if such directory
|
||||||
@ -508,7 +507,7 @@ Each interpreter has the following attributes:
|
|||||||
- `buildEnv`. Function to build python interpreter environments with extra packages bundled together. See section *python.buildEnv function* for usage and documentation.
|
- `buildEnv`. Function to build python interpreter environments with extra packages bundled together. See section *python.buildEnv function* for usage and documentation.
|
||||||
- `withPackages`. Simpler interface to `buildEnv`. See section *python.withPackages function* for usage and documentation.
|
- `withPackages`. Simpler interface to `buildEnv`. See section *python.withPackages function* for usage and documentation.
|
||||||
- `sitePackages`. Alias for `lib/${libPrefix}/site-packages`.
|
- `sitePackages`. Alias for `lib/${libPrefix}/site-packages`.
|
||||||
- `executable`. Name of the interpreter executable, e.g. `python3.4`.
|
- `executable`. Name of the interpreter executable, e.g. `python3.7`.
|
||||||
- `pkgs`. Set of Python packages for that specific interpreter. The package set can be modified by overriding the interpreter and passing `packageOverrides`.
|
- `pkgs`. Set of Python packages for that specific interpreter. The package set can be modified by overriding the interpreter and passing `packageOverrides`.
|
||||||
|
|
||||||
### Building packages and applications
|
### Building packages and applications
|
||||||
@ -530,7 +529,6 @@ attribute set is created for each available Python interpreter. The available
|
|||||||
sets are
|
sets are
|
||||||
|
|
||||||
* `pkgs.python27Packages`
|
* `pkgs.python27Packages`
|
||||||
* `pkgs.python34Packages`
|
|
||||||
* `pkgs.python35Packages`
|
* `pkgs.python35Packages`
|
||||||
* `pkgs.python36Packages`
|
* `pkgs.python36Packages`
|
||||||
* `pkgs.python37Packages`
|
* `pkgs.python37Packages`
|
||||||
@ -539,7 +537,7 @@ sets are
|
|||||||
and the aliases
|
and the aliases
|
||||||
|
|
||||||
* `pkgs.python2Packages` pointing to `pkgs.python27Packages`
|
* `pkgs.python2Packages` pointing to `pkgs.python27Packages`
|
||||||
* `pkgs.python3Packages` pointing to `pkgs.python36Packages`
|
* `pkgs.python3Packages` pointing to `pkgs.python37Packages`
|
||||||
* `pkgs.pythonPackages` pointing to `pkgs.python2Packages`
|
* `pkgs.pythonPackages` pointing to `pkgs.python2Packages`
|
||||||
|
|
||||||
#### `buildPythonPackage` function
|
#### `buildPythonPackage` function
|
||||||
@ -549,31 +547,31 @@ The `buildPythonPackage` function is implemented in
|
|||||||
|
|
||||||
The following is an example:
|
The following is an example:
|
||||||
```nix
|
```nix
|
||||||
|
{ lib, buildPythonPackage, fetchPypi, hypothesis, setuptools_scm, attrs, py, setuptools, six, pluggy }:
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
version = "3.3.1";
|
|
||||||
pname = "pytest";
|
pname = "pytest";
|
||||||
|
version = "3.3.1";
|
||||||
preCheck = ''
|
|
||||||
# don't test bash builtins
|
|
||||||
rm testing/test_argcomplete.py
|
|
||||||
'';
|
|
||||||
|
|
||||||
src = fetchPypi {
|
src = fetchPypi {
|
||||||
inherit pname version;
|
inherit pname version;
|
||||||
sha256 = "cf8436dc59d8695346fcd3ab296de46425ecab00d64096cebe79fb51ecb2eb93";
|
sha256 = "cf8436dc59d8695346fcd3ab296de46425ecab00d64096cebe79fb51ecb2eb93";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
# don't test bash builtins
|
||||||
|
rm testing/test_argcomplete.py
|
||||||
|
'';
|
||||||
|
|
||||||
checkInputs = [ hypothesis ];
|
checkInputs = [ hypothesis ];
|
||||||
buildInputs = [ setuptools_scm ];
|
buildInputs = [ setuptools_scm ];
|
||||||
propagatedBuildInputs = [ attrs py setuptools six pluggy ];
|
propagatedBuildInputs = [ attrs py setuptools six pluggy ];
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with lib; {
|
||||||
maintainers = with maintainers; [ domenkozar lovek323 madjar lsix ];
|
maintainers = with maintainers; [ domenkozar lovek323 madjar lsix ];
|
||||||
description = "Framework for writing tests";
|
description = "Framework for writing tests";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The `buildPythonPackage` mainly does four things:
|
The `buildPythonPackage` mainly does four things:
|
||||||
@ -645,9 +643,48 @@ in python.withPackages(ps: [ps.blaze])).env
|
|||||||
|
|
||||||
#### `buildPythonApplication` function
|
#### `buildPythonApplication` function
|
||||||
|
|
||||||
The `buildPythonApplication` function is practically the same as `buildPythonPackage`.
|
The `buildPythonApplication` function is practically the same as
|
||||||
The difference is that `buildPythonPackage` by default prefixes the names of the packages with the version of the interpreter.
|
`buildPythonPackage`. The main purpose of this function is to build a Python
|
||||||
Because with an application we're not interested in multiple version the prefix is dropped.
|
package where one is interested only in the executables, and not importable
|
||||||
|
modules. For that reason, when adding this package to a `python.buildEnv`, the
|
||||||
|
modules won't be made available.
|
||||||
|
|
||||||
|
Another difference is that `buildPythonPackage` by default prefixes the names of
|
||||||
|
the packages with the version of the interpreter. Because this is irrelevant for
|
||||||
|
applications, the prefix is omitted.
|
||||||
|
|
||||||
|
When packaging a python application with `buildPythonApplication`, it should be
|
||||||
|
called with `callPackage` and passed `python` or `pythonPackages` (possibly
|
||||||
|
specifying an interpreter version), like this:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ lib, python3Packages }:
|
||||||
|
|
||||||
|
python3Packages.buildPythonApplication rec {
|
||||||
|
pname = "luigi";
|
||||||
|
version = "2.7.9";
|
||||||
|
|
||||||
|
src = python3Packages.fetchPypi {
|
||||||
|
inherit pname version;
|
||||||
|
sha256 = "035w8gqql36zlan0xjrzz9j4lh9hs0qrsgnbyw07qs7lnkvbdv9x";
|
||||||
|
};
|
||||||
|
|
||||||
|
propagatedBuildInputs = with python3Packages; [ tornado_4 python-daemon ];
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
...
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This is then added to `all-packages.nix` just as any other application would be.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
luigi = callPackage ../applications/networking/cluster/luigi { };
|
||||||
|
```
|
||||||
|
|
||||||
|
Since the package is an application, a consumer doesn't need to care about
|
||||||
|
python versions or modules, which is why they don't go in `pythonPackages`.
|
||||||
|
|
||||||
#### `toPythonApplication` function
|
#### `toPythonApplication` function
|
||||||
|
|
||||||
@ -799,7 +836,7 @@ community to help save time. No tool is preferred at the moment.
|
|||||||
|
|
||||||
### Deterministic builds
|
### Deterministic builds
|
||||||
|
|
||||||
Python 2.7, 3.5 and 3.6 are now built deterministically and 3.4 mostly.
|
The Python interpreters are now built deterministically.
|
||||||
Minor modifications had to be made to the interpreters in order to generate
|
Minor modifications had to be made to the interpreters in order to generate
|
||||||
deterministic bytecode. This has security implications and is relevant for
|
deterministic bytecode. This has security implications and is relevant for
|
||||||
those using Python in a `nix-shell`.
|
those using Python in a `nix-shell`.
|
||||||
@ -1006,14 +1043,14 @@ folder and not downloaded again.
|
|||||||
If you need to change a package's attribute(s) from `configuration.nix` you could do:
|
If you need to change a package's attribute(s) from `configuration.nix` you could do:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
nixpkgs.config.packageOverrides = superP: {
|
nixpkgs.config.packageOverrides = super: {
|
||||||
pythonPackages = superP.pythonPackages.override {
|
python = super.python.override {
|
||||||
overrides = self: super: {
|
packageOverrides = python-self: python-super: {
|
||||||
bepasty-server = super.bepasty-server.overrideAttrs ( oldAttrs: {
|
zerobin = python-super.zerobin.overrideAttrs (oldAttrs: {
|
||||||
src = pkgs.fetchgit {
|
src = super.fetchgit {
|
||||||
url = "https://github.com/bepasty/bepasty-server";
|
url = "https://github.com/sametmax/0bin";
|
||||||
sha256 = "9ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
|
rev = "a344dbb18fe7a855d0742b9a1cede7ce423b34ec";
|
||||||
rev = "e2516e8cf4f2afb5185337073607eb9e84a61d2d";
|
sha256 = "16d769kmnrpbdr0ph0whyf4yff5df6zi4kmwx7sz1d3r6c8p6xji";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -1021,27 +1058,57 @@ If you need to change a package's attribute(s) from `configuration.nix` you coul
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are using the `bepasty-server` package somewhere, for example in `systemPackages` or indirectly from `services.bepasty`, then a `nixos-rebuild switch` will rebuild the system but with the `bepasty-server` package using a different `src` attribute. This way one can modify `python` based software/libraries easily. Using `self` and `super` one can also alter dependencies (`buildInputs`) between the old state (`self`) and new state (`super`).
|
`pythonPackages.zerobin` is now globally overridden. All packages and also the
|
||||||
|
`zerobin` NixOS service use the new definition.
|
||||||
|
Note that `python-super` refers to the old package set and `python-self`
|
||||||
|
to the new, overridden version.
|
||||||
|
|
||||||
|
To modify only a Python package set instead of a whole Python derivation, use this snippet:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
myPythonPackages = pythonPackages.override {
|
||||||
|
overrides = self: super: {
|
||||||
|
zerobin = ...;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### How to override a Python package using overlays?
|
### How to override a Python package using overlays?
|
||||||
|
|
||||||
To alter a python package using overlays, you would use the following approach:
|
Use the following overlay template:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
self: super:
|
self: super: {
|
||||||
{
|
|
||||||
python = super.python.override {
|
python = super.python.override {
|
||||||
packageOverrides = python-self: python-super: {
|
packageOverrides = python-self: python-super: {
|
||||||
bepasty-server = python-super.bepasty-server.overrideAttrs ( oldAttrs: {
|
zerobin = python-super.zerobin.overrideAttrs (oldAttrs: {
|
||||||
src = self.pkgs.fetchgit {
|
src = super.fetchgit {
|
||||||
url = "https://github.com/bepasty/bepasty-server";
|
url = "https://github.com/sametmax/0bin";
|
||||||
sha256 = "9ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
|
rev = "a344dbb18fe7a855d0742b9a1cede7ce423b34ec";
|
||||||
rev = "e2516e8cf4f2afb5185337073607eb9e84a61d2d";
|
sha256 = "16d769kmnrpbdr0ph0whyf4yff5df6zi4kmwx7sz1d3r6c8p6xji";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
pythonPackages = self.python.pkgs;
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### How to use Intel's MKL with numpy and scipy?
|
||||||
|
|
||||||
|
A `site.cfg` is created that configures BLAS based on the `blas` parameter
|
||||||
|
of the `numpy` derivation. By passing in `mkl`, `numpy` and packages depending
|
||||||
|
on `numpy` will be built with `mkl`.
|
||||||
|
|
||||||
|
The following is an overlay that configures `numpy` to use `mkl`:
|
||||||
|
```nix
|
||||||
|
self: super: {
|
||||||
|
python36 = super.python36.override {
|
||||||
|
packageOverrides = python-self: python-super: {
|
||||||
|
numpy = python-super.numpy.override {
|
||||||
|
blas = super.pkgs.mkl;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1056,4 +1123,5 @@ Following rules are desired to be respected:
|
|||||||
* Make sure libraries build for all Python interpreters.
|
* Make sure libraries build for all Python interpreters.
|
||||||
* By default we enable tests. Make sure the tests are found and, in the case of libraries, are passing for all interpreters. If certain tests fail they can be disabled individually. Try to avoid disabling the tests altogether. In any case, when you disable tests, leave a comment explaining why.
|
* By default we enable tests. Make sure the tests are found and, in the case of libraries, are passing for all interpreters. If certain tests fail they can be disabled individually. Try to avoid disabling the tests altogether. In any case, when you disable tests, leave a comment explaining why.
|
||||||
* Commit names of Python libraries should reflect that they are Python libraries, so write for example `pythonPackages.numpy: 1.11 -> 1.12`.
|
* Commit names of Python libraries should reflect that they are Python libraries, so write for example `pythonPackages.numpy: 1.11 -> 1.12`.
|
||||||
|
* Attribute names in `python-packages.nix` should be normalized according to [PEP 0503](https://www.python.org/dev/peps/pep-0503/#normalized-names).
|
||||||
|
This means that characters should be converted to lowercase and `.` and `_` should be replaced by a single `-` (foo-bar-baz instead of Foo__Bar.baz )
|
||||||
|
@ -50,6 +50,17 @@ bundlerEnv rec {
|
|||||||
future updates can be run easily.
|
future updates can be run easily.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Updating Ruby packages can then be done like this:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<screen>
|
||||||
|
<![CDATA[$ cd pkgs/servers/monitoring/sensu
|
||||||
|
$ nix-shell -p bundler --run 'bundle lock --update'
|
||||||
|
$ nix-shell -p bundix --run 'bundix'
|
||||||
|
]]>
|
||||||
|
</screen>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
For tools written in Ruby - i.e. where the desire is to install a package and
|
For tools written in Ruby - i.e. where the desire is to install a package and
|
||||||
then execute e.g. <command>rake</command> at the command line, there is an
|
then execute e.g. <command>rake</command> at the command line, there is an
|
||||||
|
@ -59,8 +59,10 @@ all crate sources of this package. Currently it is obtained by inserting a
|
|||||||
fake checksum into the expression and building the package once. The correct
|
fake checksum into the expression and building the package once. The correct
|
||||||
checksum can be then take from the failed build.
|
checksum can be then take from the failed build.
|
||||||
|
|
||||||
To install crates with nix there is also an experimental project called
|
When the `Cargo.lock`, provided by upstream, is not in sync with the
|
||||||
[nixcrates](https://github.com/fractalide/nixcrates).
|
`Cargo.toml`, it is possible to use `cargoPatches` to update it. All patches
|
||||||
|
added in `cargoPatches` will also be prepended to the patches in `patches` at
|
||||||
|
build-time.
|
||||||
|
|
||||||
## Compiling Rust crates using Nix instead of Cargo
|
## Compiling Rust crates using Nix instead of Cargo
|
||||||
|
|
||||||
@ -88,8 +90,8 @@ Now, the file produced by the call to `carnix`, called `hello.nix`, looks like:
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
|
# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
|
||||||
{ lib, buildPlatform, buildRustCrate, fetchgit }:
|
{ lib, stdenv, buildRustCrate, fetchgit }:
|
||||||
let kernel = buildPlatform.parsed.kernel.name;
|
let kernel = stdenv.buildPlatform.parsed.kernel.name;
|
||||||
# ... (content skipped)
|
# ... (content skipped)
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
@ -117,8 +119,8 @@ following nix file:
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
|
# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
|
||||||
{ lib, buildPlatform, buildRustCrate, fetchgit }:
|
{ lib, stdenv, buildRustCrate, fetchgit }:
|
||||||
let kernel = buildPlatform.parsed.kernel.name;
|
let kernel = stdenv.buildPlatform.parsed.kernel.name;
|
||||||
# ... (content skipped)
|
# ... (content skipped)
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
under attribute <varname>texlive</varname>.
|
under attribute <varname>texlive</varname>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<section>
|
<section xml:id="sec-language-texlive-users-guide">
|
||||||
<title>User's guide</title>
|
<title>User's guide</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
@ -68,7 +68,7 @@ nix-repl> texlive.collection-<TAB>
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="sec-language-texlive-known-problems">
|
||||||
<title>Known problems</title>
|
<title>Known problems</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
@ -5,11 +5,17 @@ date: 2016-06-25
|
|||||||
---
|
---
|
||||||
# User's Guide to Vim Plugins/Addons/Bundles/Scripts in Nixpkgs
|
# User's Guide to Vim Plugins/Addons/Bundles/Scripts in Nixpkgs
|
||||||
|
|
||||||
You'll get a vim(-your-suffix) in PATH also loading the plugins you want.
|
Both Neovim and Vim can be configured to include your favorite plugins
|
||||||
|
and additional libraries.
|
||||||
|
|
||||||
Loading can be deferred; see examples.
|
Loading can be deferred; see examples.
|
||||||
|
|
||||||
Vim packages, VAM (=vim-addon-manager) and Pathogen are supported to load
|
At the moment we support three different methods for managing plugins:
|
||||||
packages.
|
|
||||||
|
- Vim packages (*recommend*)
|
||||||
|
- VAM (=vim-addon-manager)
|
||||||
|
- Pathogen
|
||||||
|
- vim-plug
|
||||||
|
|
||||||
## Custom configuration
|
## Custom configuration
|
||||||
|
|
||||||
@ -17,6 +23,7 @@ Adding custom .vimrc lines can be done using the following code:
|
|||||||
|
|
||||||
```
|
```
|
||||||
vim_configurable.customize {
|
vim_configurable.customize {
|
||||||
|
# `name` specifies the name of the executable and package
|
||||||
name = "vim-with-plugins";
|
name = "vim-with-plugins";
|
||||||
|
|
||||||
vimrcConfig.customRC = ''
|
vimrcConfig.customRC = ''
|
||||||
@ -25,7 +32,21 @@ vim_configurable.customize {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Vim packages
|
This configuration is used when vim is invoked with the command specified as name, in this case `vim-with-plugins`.
|
||||||
|
|
||||||
|
For Neovim the `configure` argument can be overridden to achieve the same:
|
||||||
|
|
||||||
|
```
|
||||||
|
neovim.override {
|
||||||
|
configure = {
|
||||||
|
customRC = ''
|
||||||
|
# here your custom configuration goes!
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Managing plugins with Vim packages
|
||||||
|
|
||||||
To store you plugins in Vim packages the following example can be used:
|
To store you plugins in Vim packages the following example can be used:
|
||||||
|
|
||||||
@ -38,13 +59,80 @@ vim_configurable.customize {
|
|||||||
opt = [ phpCompletion elm-vim ];
|
opt = [ phpCompletion elm-vim ];
|
||||||
# To automatically load a plugin when opening a filetype, add vimrc lines like:
|
# To automatically load a plugin when opening a filetype, add vimrc lines like:
|
||||||
# autocmd FileType php :packadd phpCompletion
|
# autocmd FileType php :packadd phpCompletion
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## VAM
|
For Neovim the syntax is:
|
||||||
|
|
||||||
### dependencies by Vim plugins
|
```
|
||||||
|
neovim.override {
|
||||||
|
configure = {
|
||||||
|
customRC = ''
|
||||||
|
# here your custom configuration goes!
|
||||||
|
'';
|
||||||
|
packages.myVimPackage = with pkgs.vimPlugins; {
|
||||||
|
# see examples below how to use custom packages
|
||||||
|
start = [ ];
|
||||||
|
opt = [ ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The resulting package can be added to `packageOverrides` in `~/.nixpkgs/config.nix` to make it installable:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
packageOverrides = pkgs: with pkgs; {
|
||||||
|
myVim = vim_configurable.customize {
|
||||||
|
# `name` specifies the name of the executable and package
|
||||||
|
name = "vim-with-plugins";
|
||||||
|
# add here code from the example section
|
||||||
|
};
|
||||||
|
myNeovim = neovim.override {
|
||||||
|
configure = {
|
||||||
|
# add here code from the example section
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After that you can install your special grafted `myVim` or `myNeovim` packages.
|
||||||
|
|
||||||
|
## Managing plugins with vim-plug
|
||||||
|
|
||||||
|
To use [vim-plug](https://github.com/junegunn/vim-plug) to manage your Vim
|
||||||
|
plugins the following example can be used:
|
||||||
|
|
||||||
|
```
|
||||||
|
vim_configurable.customize {
|
||||||
|
vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
|
||||||
|
# loaded on launch
|
||||||
|
plug.plugins = [ youcompleteme fugitive phpCompletion elm-vim ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
For Neovim the syntax is:
|
||||||
|
|
||||||
|
```
|
||||||
|
neovim.override {
|
||||||
|
configure = {
|
||||||
|
customRC = ''
|
||||||
|
# here your custom configuration goes!
|
||||||
|
'';
|
||||||
|
plug.plugins = with pkgs.vimPlugins; [
|
||||||
|
vim-go
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Managing plugins with VAM
|
||||||
|
|
||||||
|
### Handling dependencies of Vim plugins
|
||||||
|
|
||||||
VAM introduced .json files supporting dependencies without versioning
|
VAM introduced .json files supporting dependencies without versioning
|
||||||
assuming that "using latest version" is ok most of the time.
|
assuming that "using latest version" is ok most of the time.
|
||||||
@ -125,6 +213,18 @@ Sample output2:
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
## Adding new plugins to nixpkgs
|
||||||
|
|
||||||
|
In `pkgs/misc/vim-plugins/vim-plugin-names` we store the plugin names
|
||||||
|
for all vim plugins we automatically generate plugins for.
|
||||||
|
The format of this file `github username/github repository`:
|
||||||
|
For example https://github.com/scrooloose/nerdtree becomes `scrooloose/nerdtree`.
|
||||||
|
After adding your plugin to this file run the `./update.py` in the same folder.
|
||||||
|
This will updated a file called `generated.nix` and make your plugin accessible in the
|
||||||
|
`vimPlugins` attribute set (`vimPlugins.nerdtree` in our example).
|
||||||
|
If additional steps to the build process of the plugin are required, add an
|
||||||
|
override to the `pkgs/misc/vim-plugins/default.nix` in the same directory.
|
||||||
|
|
||||||
## Important repositories
|
## Important repositories
|
||||||
|
|
||||||
- [vim-pi](https://bitbucket.org/vimcommunity/vim-pi) is a plugin repository
|
- [vim-pi](https://bitbucket.org/vimcommunity/vim-pi) is a plugin repository
|
||||||
|
85
doc/lib-function-locations.nix
Normal file
85
doc/lib-function-locations.nix
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
{ pkgs ? (import ./.. { }), nixpkgs ? { }}:
|
||||||
|
let
|
||||||
|
revision = pkgs.lib.trivial.revisionWithDefault (nixpkgs.revision or "master");
|
||||||
|
|
||||||
|
libDefPos = set:
|
||||||
|
builtins.map
|
||||||
|
(name: {
|
||||||
|
name = name;
|
||||||
|
location = builtins.unsafeGetAttrPos name set;
|
||||||
|
})
|
||||||
|
(builtins.attrNames set);
|
||||||
|
|
||||||
|
libset = toplib:
|
||||||
|
builtins.map
|
||||||
|
(subsetname: {
|
||||||
|
subsetname = subsetname;
|
||||||
|
functions = libDefPos toplib."${subsetname}";
|
||||||
|
})
|
||||||
|
(builtins.filter
|
||||||
|
(name: builtins.isAttrs toplib."${name}")
|
||||||
|
(builtins.attrNames toplib));
|
||||||
|
|
||||||
|
nixpkgsLib = pkgs.lib;
|
||||||
|
|
||||||
|
flattenedLibSubset = { subsetname, functions }:
|
||||||
|
builtins.map
|
||||||
|
(fn: {
|
||||||
|
name = "lib.${subsetname}.${fn.name}";
|
||||||
|
value = fn.location;
|
||||||
|
})
|
||||||
|
functions;
|
||||||
|
|
||||||
|
locatedlibsets = libs: builtins.map flattenedLibSubset (libset libs);
|
||||||
|
removeFilenamePrefix = prefix: filename:
|
||||||
|
let
|
||||||
|
prefixLen = (builtins.stringLength prefix) + 1; # +1 to remove the leading /
|
||||||
|
filenameLen = builtins.stringLength filename;
|
||||||
|
substr = builtins.substring prefixLen filenameLen filename;
|
||||||
|
in substr;
|
||||||
|
|
||||||
|
removeNixpkgs = removeFilenamePrefix (builtins.toString pkgs.path);
|
||||||
|
|
||||||
|
liblocations =
|
||||||
|
builtins.filter
|
||||||
|
(elem: elem.value != null)
|
||||||
|
(nixpkgsLib.lists.flatten
|
||||||
|
(locatedlibsets nixpkgsLib));
|
||||||
|
|
||||||
|
fnLocationRelative = { name, value }:
|
||||||
|
{
|
||||||
|
inherit name;
|
||||||
|
value = value // { file = removeNixpkgs value.file; };
|
||||||
|
};
|
||||||
|
|
||||||
|
relativeLocs = (builtins.map fnLocationRelative liblocations);
|
||||||
|
sanitizeId = builtins.replaceStrings
|
||||||
|
[ "'" ]
|
||||||
|
[ "-prime" ];
|
||||||
|
|
||||||
|
urlPrefix = "https://github.com/NixOS/nixpkgs/blob/${revision}";
|
||||||
|
xmlstrings = (nixpkgsLib.strings.concatMapStrings
|
||||||
|
({ name, value }:
|
||||||
|
''
|
||||||
|
<section><title>${name}</title>
|
||||||
|
<para xml:id="${sanitizeId name}">
|
||||||
|
Located at
|
||||||
|
<link
|
||||||
|
xlink:href="${urlPrefix}/${value.file}#L${builtins.toString value.line}">${value.file}:${builtins.toString value.line}</link>
|
||||||
|
in <literal><nixpkgs></literal>.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
'')
|
||||||
|
relativeLocs);
|
||||||
|
|
||||||
|
in pkgs.writeText
|
||||||
|
"locations.xml"
|
||||||
|
''
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
version="5">
|
||||||
|
<title>All the locations for every lib function</title>
|
||||||
|
<para>This file is only for inclusion by other files.</para>
|
||||||
|
${xmlstrings}
|
||||||
|
</section>
|
||||||
|
''
|
54
doc/meta.xml
54
doc/meta.xml
@ -250,6 +250,60 @@ meta.platforms = stdenv.lib.platforms.linux;
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>tests</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<warning>
|
||||||
|
<para>
|
||||||
|
This attribute is special in that it is not actually under the
|
||||||
|
<literal>meta</literal> attribute set but rather under the
|
||||||
|
<literal>passthru</literal> attribute set. This is due to a current
|
||||||
|
limitation of Nix, and will change as soon as Nixpkgs will be able to
|
||||||
|
depend on a new enough version of Nix. See
|
||||||
|
<link xlink:href="https://github.com/NixOS/nix/issues/2532">the relevant
|
||||||
|
issue</link> for more details.
|
||||||
|
</para>
|
||||||
|
</warning>
|
||||||
|
<para>
|
||||||
|
An attribute set with as values tests. A test is a derivation, which
|
||||||
|
builds successfully when the test passes, and fails to build otherwise. A
|
||||||
|
derivation that is a test needs to have <literal>meta.timeout</literal>
|
||||||
|
defined.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The NixOS tests are available as <literal>nixosTests</literal> in
|
||||||
|
parameters of derivations. For instance, the OpenSMTPD derivation
|
||||||
|
includes lines similar to:
|
||||||
|
<programlisting>
|
||||||
|
{ /* ... */, nixosTests }:
|
||||||
|
{
|
||||||
|
# ...
|
||||||
|
passthru.tests = {
|
||||||
|
basic-functionality-and-dovecot-integration = nixosTests.opensmtpd;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>timeout</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
A timeout (in seconds) for building the derivation. If the derivation
|
||||||
|
takes longer than this time to build, it can fail due to breaking the
|
||||||
|
timeout. However, all computers do not have the same computing power,
|
||||||
|
hence some builders may decide to apply a multiplicative factor to this
|
||||||
|
value. When filling this value in, try to keep it approximately
|
||||||
|
consistent with other values already present in
|
||||||
|
<literal>nixpkgs</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<varname>hydraPlatforms</varname>
|
<varname>hydraPlatforms</varname>
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
xml:id="chap-multiple-output">
|
xml:id="chap-multiple-output">
|
||||||
<title>Multiple-output packages</title>
|
<title>Multiple-output packages</title>
|
||||||
<section>
|
<section xml:id="sec-multiple-outputs-introduction">
|
||||||
<title>Introduction</title>
|
<title>Introduction</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The Nix language allows a derivation to produce multiple outputs, which is
|
The Nix language allows a derivation to produce multiple outputs, which is
|
||||||
similar to what is utilized by other Linux distribution packaging systems.
|
similar to what is utilized by other Linux distribution packaging systems.
|
||||||
The outputs reside in separate nix store paths, so they can be mostly
|
The outputs reside in separate Nix store paths, so they can be mostly
|
||||||
handled independently of each other, including passing to build inputs,
|
handled independently of each other, including passing to build inputs,
|
||||||
garbage collection or binary substitution. The exception is that building
|
garbage collection or binary substitution. The exception is that building
|
||||||
from source always produces all the outputs.
|
from source always produces all the outputs.
|
||||||
@ -38,7 +38,7 @@
|
|||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="sec-multiple-outputs-installing">
|
||||||
<title>Installing a split package</title>
|
<title>Installing a split package</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -84,7 +84,7 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="sec-multiple-outputs-using-split-packages">
|
||||||
<title>Using a split package</title>
|
<title>Using a split package</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -102,7 +102,7 @@
|
|||||||
also added. (See <xref linkend="multiple-output-file-type-groups" />.)
|
also added. (See <xref linkend="multiple-output-file-type-groups" />.)
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="sec-multiple-outputs-">
|
||||||
<title>Writing a split derivation</title>
|
<title>Writing a split derivation</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -283,7 +283,7 @@
|
|||||||
</variablelist>
|
</variablelist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="sec-multiple-outputs-caveats">
|
||||||
<title>Common caveats</title>
|
<title>Common caveats</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
@ -64,7 +64,7 @@ stdenv.mkDerivation {
|
|||||||
sha256 = "1ian3kwh2vg6hr3ymrv48s04gijs539vzrq62xr76bxbhbwnz2np";
|
sha256 = "1ian3kwh2vg6hr3ymrv48s04gijs539vzrq62xr76bxbhbwnz2np";
|
||||||
};
|
};
|
||||||
inherit noSysDirs;
|
inherit noSysDirs;
|
||||||
configureFlags = "--target=arm-linux";
|
configureFlags = [ "--target=arm-linux" ];
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ Step 2: build kernel headers for the target architecture
|
|||||||
---
|
---
|
||||||
{stdenv, fetchurl}:
|
{stdenv, fetchurl}:
|
||||||
|
|
||||||
assert stdenv.system == "i686-linux";
|
assert stdenv.buildPlatform.system == "i686-linux";
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "linux-headers-2.6.13.1-arm";
|
name = "linux-headers-2.6.13.1-arm";
|
||||||
|
197
doc/overlays.xml
197
doc/overlays.xml
@ -3,9 +3,9 @@
|
|||||||
xml:id="chap-overlays">
|
xml:id="chap-overlays">
|
||||||
<title>Overlays</title>
|
<title>Overlays</title>
|
||||||
<para>
|
<para>
|
||||||
This chapter describes how to extend and change Nixpkgs packages using
|
This chapter describes how to extend and change Nixpkgs using overlays.
|
||||||
overlays. Overlays are used to add layers in the fix-point used by Nixpkgs to
|
Overlays are used to add layers in the fixed-point used by Nixpkgs to compose
|
||||||
compose the set of all packages.
|
the set of all packages.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Nixpkgs can be configured with a list of overlays, which are applied in
|
Nixpkgs can be configured with a list of overlays, which are applied in
|
||||||
@ -17,91 +17,122 @@
|
|||||||
<title>Installing overlays</title>
|
<title>Installing overlays</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The list of overlays is determined as follows.
|
The list of overlays can be set either explicitly in a Nix expression, or
|
||||||
|
through <literal><nixpkgs-overlays></literal> or user configuration
|
||||||
|
files.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<section xml:id="sec-overlays-argument">
|
||||||
If the <varname>overlays</varname> argument is not provided explicitly, we
|
<title>Set overlays in NixOS or Nix expressions</title>
|
||||||
look for overlays in a path. The path is determined as follows:
|
|
||||||
<orderedlist>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
First, if an <varname>overlays</varname> argument to the nixpkgs function
|
|
||||||
itself is given, then that is used.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This can be passed explicitly when importing nipxkgs, for example
|
|
||||||
<literal>import <nixpkgs> { overlays = [ overlay1 overlay2 ];
|
|
||||||
}</literal>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Otherwise, if the Nix path entry <literal><nixpkgs-overlays></literal>
|
|
||||||
exists, we look for overlays at that path, as described below.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
See the section on <literal>NIX_PATH</literal> in the Nix manual for more
|
|
||||||
details on how to set a value for
|
|
||||||
<literal><nixpkgs-overlays>.</literal>
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
If one of <filename>~/.config/nixpkgs/overlays.nix</filename> and
|
|
||||||
<filename>~/.config/nixpkgs/overlays/</filename> exists, then we look for
|
|
||||||
overlays at that path, as described below. It is an error if both exist.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</orderedlist>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
If we are looking for overlays at a path, then there are two cases:
|
On a NixOS system the value of the <literal>nixpkgs.overlays</literal>
|
||||||
<itemizedlist>
|
option, if present, is passed to the system Nixpkgs directly as an
|
||||||
<listitem>
|
argument. Note that this does not affect the overlays for non-NixOS
|
||||||
<para>
|
operations (e.g. <literal>nix-env</literal>), which are
|
||||||
If the path is a file, then the file is imported as a Nix expression and
|
<link xlink:href="#sec-overlays-lookup">looked</link> up independently.
|
||||||
used as the list of overlays.
|
</para>
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
If the path is a directory, then we take the content of the directory,
|
|
||||||
order it lexicographically, and attempt to interpret each as an overlay
|
|
||||||
by:
|
|
||||||
<itemizedlist>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Importing the file, if it is a <literal>.nix</literal> file.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Importing a top-level <filename>default.nix</filename> file, if it is
|
|
||||||
a directory.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
On a NixOS system the value of the <literal>nixpkgs.overlays</literal>
|
The list of overlays can be passed explicitly when importing nixpkgs, for
|
||||||
option, if present, is passed to the system Nixpkgs directly as an argument.
|
example <literal>import <nixpkgs> { overlays = [ overlay1 overlay2 ];
|
||||||
Note that this does not affect the overlays for non-NixOS operations (e.g.
|
}</literal>.
|
||||||
<literal>nix-env</literal>), which are looked up independently.
|
</para>
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The <filename>overlays.nix</filename> option therefore provides a convenient
|
Further overlays can be added by calling the <literal>pkgs.extend</literal>
|
||||||
way to use the same overlays for a NixOS system configuration and user
|
or <literal>pkgs.appendOverlays</literal>, although it is often preferable
|
||||||
configuration: the same file can be used as
|
to avoid these functions, because they recompute the Nixpkgs fixpoint,
|
||||||
<filename>overlays.nix</filename> and imported as the value of
|
which is somewhat expensive to do.
|
||||||
<literal>nixpkgs.overlays</literal>.
|
</para>
|
||||||
</para>
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-overlays-lookup">
|
||||||
|
<title>Install overlays via configuration lookup</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The list of overlays is determined as follows.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<orderedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
First, if an
|
||||||
|
<link xlink:href="#sec-overlays-argument"><varname>overlays</varname>
|
||||||
|
argument</link> to the Nixpkgs function itself is given, then that is
|
||||||
|
used and no path lookup will be performed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Otherwise, if the Nix path entry
|
||||||
|
<literal><nixpkgs-overlays></literal> exists, we look for overlays at
|
||||||
|
that path, as described below.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
See the section on <literal>NIX_PATH</literal> in the Nix manual for
|
||||||
|
more details on how to set a value for
|
||||||
|
<literal><nixpkgs-overlays>.</literal>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
If one of <filename>~/.config/nixpkgs/overlays.nix</filename> and
|
||||||
|
<filename>~/.config/nixpkgs/overlays/</filename> exists, then we look
|
||||||
|
for overlays at that path, as described below. It is an error if both
|
||||||
|
exist.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</orderedlist>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
If we are looking for overlays at a path, then there are two cases:
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
If the path is a file, then the file is imported as a Nix expression and
|
||||||
|
used as the list of overlays.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
If the path is a directory, then we take the content of the directory,
|
||||||
|
order it lexicographically, and attempt to interpret each as an overlay
|
||||||
|
by:
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Importing the file, if it is a <literal>.nix</literal> file.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Importing a top-level <filename>default.nix</filename> file, if it is
|
||||||
|
a directory.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Because overlays that are set in NixOS configuration do not affect
|
||||||
|
non-NixOS operations such as <literal>nix-env</literal>, the
|
||||||
|
<filename>overlays.nix</filename> option provides a convenient way to use
|
||||||
|
the same overlays for a NixOS system configuration and user configuration:
|
||||||
|
the same file can be used as <filename>overlays.nix</filename> and imported
|
||||||
|
as the value of <literal>nixpkgs.overlays</literal>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- TODO: Example of sharing overlays between NixOS configuration
|
||||||
|
and configuration lookup. Also reference the example
|
||||||
|
from the sec-overlays-argument paragraph about NixOS.
|
||||||
|
-->
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<!--============================================================-->
|
<!--============================================================-->
|
||||||
<section xml:id="sec-overlays-definition">
|
<section xml:id="sec-overlays-definition">
|
||||||
|
@ -181,7 +181,7 @@ $ cat $(PRINT_PATH=1 nix-prefetch-url $i | tail -n 1) \
|
|||||||
</section>
|
</section>
|
||||||
<!--============================================================-->
|
<!--============================================================-->
|
||||||
<!--
|
<!--
|
||||||
<section>
|
<section xml:id="sec-package-notes-gnome">
|
||||||
<title>Gnome</title>
|
<title>Gnome</title>
|
||||||
<para>* Expression is auto-generated</para>
|
<para>* Expression is auto-generated</para>
|
||||||
<para>* How to update</para>
|
<para>* How to update</para>
|
||||||
@ -189,7 +189,7 @@ $ cat $(PRINT_PATH=1 nix-prefetch-url $i | tail -n 1) \
|
|||||||
-->
|
-->
|
||||||
<!--============================================================-->
|
<!--============================================================-->
|
||||||
<!--
|
<!--
|
||||||
<section>
|
<section xml:id="sec-package-notes-gcc">
|
||||||
<title>GCC</title>
|
<title>GCC</title>
|
||||||
<para>…</para>
|
<para>…</para>
|
||||||
</section>
|
</section>
|
||||||
@ -205,7 +205,7 @@ $ cat $(PRINT_PATH=1 nix-prefetch-url $i | tail -n 1) \
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
Nixpkgs provides a number of packages that will install Eclipse in its
|
Nixpkgs provides a number of packages that will install Eclipse in its
|
||||||
various forms, these range from the bare-bones Eclipse Platform to the more
|
various forms. These range from the bare-bones Eclipse Platform to the more
|
||||||
fully featured Eclipse SDK or Scala-IDE packages and multiple version are
|
fully featured Eclipse SDK or Scala-IDE packages and multiple version are
|
||||||
often available. It is possible to list available Eclipse packages by
|
often available. It is possible to list available Eclipse packages by
|
||||||
issuing the command:
|
issuing the command:
|
||||||
@ -413,11 +413,9 @@ packageOverrides = pkgs: {
|
|||||||
in your <filename>/etc/nixos/configuration.nix</filename>. You'll also need
|
in your <filename>/etc/nixos/configuration.nix</filename>. You'll also need
|
||||||
<programlisting>hardware.pulseaudio.support32Bit = true;</programlisting>
|
<programlisting>hardware.pulseaudio.support32Bit = true;</programlisting>
|
||||||
if you are using PulseAudio - this will enable 32bit ALSA apps integration.
|
if you are using PulseAudio - this will enable 32bit ALSA apps integration.
|
||||||
To use the Steam controller, you need to add
|
To use the Steam controller or other Steam supported controllers such as
|
||||||
<programlisting>services.udev.extraRules = ''
|
the DualShock 4 or Nintendo Switch Pro, you need to add
|
||||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", MODE="0666"
|
<programlisting>hardware.steam-hardware.enable = true;</programlisting>
|
||||||
KERNEL=="uinput", MODE="0660", GROUP="users", OPTIONS+="static_node=uinput"
|
|
||||||
'';</programlisting>
|
|
||||||
to your configuration.
|
to your configuration.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
@ -643,15 +641,15 @@ cp ${myEmacsConfig} $out/share/emacs/site-lisp/default.el
|
|||||||
required dependencies manually - but it's tedious and there is always a
|
required dependencies manually - but it's tedious and there is always a
|
||||||
possibility that an unwanted dependency will sneak in through some other
|
possibility that an unwanted dependency will sneak in through some other
|
||||||
package. To completely override such a package you can use
|
package. To completely override such a package you can use
|
||||||
<varname>overrideScope</varname>.
|
<varname>overrideScope'</varname>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<screen>
|
<screen>
|
||||||
overrides = super: self: rec {
|
overrides = self: super: rec {
|
||||||
haskell-mode = self.melpaPackages.haskell-mode;
|
haskell-mode = self.melpaPackages.haskell-mode;
|
||||||
...
|
...
|
||||||
};
|
};
|
||||||
((emacsPackagesNgGen emacs).overrideScope overrides).emacsWithPackages (p: with p; [
|
((emacsPackagesNgGen emacs).overrideScope' overrides).emacsWithPackages (p: with p; [
|
||||||
# here both these package will use haskell-mode of our own choice
|
# here both these package will use haskell-mode of our own choice
|
||||||
ghc-mod
|
ghc-mod
|
||||||
dante
|
dante
|
||||||
@ -671,6 +669,9 @@ overrides = super: self: rec {
|
|||||||
plugins = with availablePlugins; [ python perl ];
|
plugins = with availablePlugins; [ python perl ];
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
|
If the <literal>configure</literal> function returns an attrset without the
|
||||||
|
<literal>plugins</literal> attribute, <literal>availablePlugins</literal>
|
||||||
|
will be used automatically.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -680,10 +681,10 @@ overrides = super: self: rec {
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The python plugin allows the addition of extra libraries. For instance, the
|
The python and perl plugins allows the addition of extra libraries. For
|
||||||
<literal>inotify.py</literal> script in weechat-scripts requires D-Bus or
|
instance, the <literal>inotify.py</literal> script in weechat-scripts
|
||||||
libnotify, and the <literal>fish.py</literal> script requires pycrypto. To
|
requires D-Bus or libnotify, and the <literal>fish.py</literal> script
|
||||||
use these scripts, use the <literal>python</literal> plugin's
|
requires pycrypto. To use these scripts, use the plugin's
|
||||||
<literal>withPackages</literal> attribute:
|
<literal>withPackages</literal> attribute:
|
||||||
<programlisting>weechat.override { configure = {availablePlugins, ...}: {
|
<programlisting>weechat.override { configure = {availablePlugins, ...}: {
|
||||||
plugins = with availablePlugins; [
|
plugins = with availablePlugins; [
|
||||||
@ -704,5 +705,189 @@ overrides = super: self: rec {
|
|||||||
}; }
|
}; }
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
WeeChat allows to set defaults on startup using the
|
||||||
|
<literal>--run-command</literal>. The <literal>configure</literal> method
|
||||||
|
can be used to pass commands to the program:
|
||||||
|
<programlisting>weechat.override {
|
||||||
|
configure = { availablePlugins, ... }: {
|
||||||
|
init = ''
|
||||||
|
/set foo bar
|
||||||
|
/server add freenode chat.freenode.org
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}</programlisting>
|
||||||
|
Further values can be added to the list of commands when running
|
||||||
|
<literal>weechat --run-command "your-commands"</literal>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Additionally it's possible to specify scripts to be loaded when starting
|
||||||
|
<literal>weechat</literal>. These will be loaded before the commands from
|
||||||
|
<literal>init</literal>:
|
||||||
|
<programlisting>weechat.override {
|
||||||
|
configure = { availablePlugins, ... }: {
|
||||||
|
scripts = with pkgs.weechatScripts; [
|
||||||
|
weechat-xmpp weechat-matrix-bridge wee-slack
|
||||||
|
];
|
||||||
|
init = ''
|
||||||
|
/set plugins.var.python.jabber.key "val"
|
||||||
|
'':
|
||||||
|
};
|
||||||
|
}</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
In <literal>nixpkgs</literal> there's a subpackage which contains
|
||||||
|
derivations for WeeChat scripts. Such derivations expect a
|
||||||
|
<literal>passthru.scripts</literal> attribute which contains a list of all
|
||||||
|
scripts inside the store path. Furthermore all scripts have to live in
|
||||||
|
<literal>$out/share</literal>. An exemplary derivation looks like this:
|
||||||
|
<programlisting>{ stdenv, fetchurl }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "exemplary-weechat-script";
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://scripts.tld/your-scripts.tar.gz";
|
||||||
|
sha256 = "...";
|
||||||
|
};
|
||||||
|
passthru.scripts = [ "foo.py" "bar.lua" ];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir $out/share
|
||||||
|
cp foo.py $out/share
|
||||||
|
cp bar.lua $out/share
|
||||||
|
'';
|
||||||
|
}</programlisting>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
<section xml:id="sec-citrix">
|
||||||
|
<title>Citrix Receiver</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The <link xlink:href="https://www.citrix.com/products/receiver/">Citrix
|
||||||
|
Receiver</link> is a remote desktop viewer which provides access to
|
||||||
|
<link xlink:href="https://www.citrix.com/products/xenapp-xendesktop/">XenDesktop</link>
|
||||||
|
installations.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<section xml:id="sec-citrix-base">
|
||||||
|
<title>Basic usage</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The tarball archive needs to be downloaded manually as the licenses
|
||||||
|
agreements of the vendor need to be accepted first. This is available at
|
||||||
|
the
|
||||||
|
<link xlink:href="https://www.citrix.com/downloads/citrix-receiver/">download
|
||||||
|
page at citrix.com</link>. Then run <literal>nix-prefetch-url
|
||||||
|
file://$PWD/linuxx64-$version.tar.gz</literal>. With the archive available
|
||||||
|
in the store the package can be built and installed with Nix.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<emphasis>Note: it's recommended to install <literal>Citrix
|
||||||
|
Receiver</literal> using <literal>nix-env -i</literal> or globally to
|
||||||
|
ensure that the <literal>.desktop</literal> files are installed properly
|
||||||
|
into <literal>$XDG_CONFIG_DIRS</literal>. Otherwise it won't be possible to
|
||||||
|
open <literal>.ica</literal> files automatically from the browser to start
|
||||||
|
a Citrix connection.</emphasis>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-citrix-custom-certs">
|
||||||
|
<title>Custom certificates</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The <literal>Citrix Receiver</literal> in <literal>nixpkgs</literal> trusts
|
||||||
|
several certificates
|
||||||
|
<link xlink:href="https://curl.haxx.se/docs/caextract.html">from the
|
||||||
|
Mozilla database</link> by default. However several companies using Citrix
|
||||||
|
might require their own corporate certificate. On distros with imperative
|
||||||
|
packaging these certs can be stored easily in
|
||||||
|
<link xlink:href="https://developer-docs.citrix.com/projects/receiver-for-linux-command-reference/en/13.7/"><literal>$ICAROOT</literal></link>,
|
||||||
|
however this directory is a store path in <literal>nixpkgs</literal>. In
|
||||||
|
order to work around this issue the package provides a simple mechanism to
|
||||||
|
add custom certificates without rebuilding the entire package using
|
||||||
|
<literal>symlinkJoin</literal>:
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[with import <nixpkgs> { config.allowUnfree = true; };
|
||||||
|
let extraCerts = [ ./custom-cert-1.pem ./custom-cert-2.pem /* ... */ ]; in
|
||||||
|
citrix_receiver.override {
|
||||||
|
inherit extraCerts;
|
||||||
|
}]]>
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
<section xml:id="sec-ibus-typing-booster">
|
||||||
|
<title>ibus-engines.typing-booster</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This package is an ibus-based completion method to speed up typing.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<section xml:id="sec-ibus-typing-booster-activate">
|
||||||
|
<title>Activating the engine</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
IBus needs to be configured accordingly to activate
|
||||||
|
<literal>typing-booster</literal>. The configuration depends on the desktop
|
||||||
|
manager in use. For detailed instructions, please refer to the
|
||||||
|
<link xlink:href="https://mike-fabian.github.io/ibus-typing-booster/documentation.html">upstream
|
||||||
|
docs</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
On NixOS you need to explicitly enable <literal>ibus</literal> with given
|
||||||
|
engines before customizing your desktop to use
|
||||||
|
<literal>typing-booster</literal>. This can be achieved using the
|
||||||
|
<literal>ibus</literal> module:
|
||||||
|
<programlisting>{ pkgs, ... }: {
|
||||||
|
i18n.inputMethod = {
|
||||||
|
enabled = "ibus";
|
||||||
|
ibus.engines = with pkgs.ibus-engines; [ typing-booster ];
|
||||||
|
};
|
||||||
|
}</programlisting>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-ibus-typing-booster-customize-hunspell">
|
||||||
|
<title>Using custom hunspell dictionaries</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The IBus engine is based on <literal>hunspell</literal> to support
|
||||||
|
completion in many languages. By default the dictionaries
|
||||||
|
<literal>de-de</literal>, <literal>en-us</literal>,
|
||||||
|
<literal>es-es</literal>, <literal>it-it</literal>,
|
||||||
|
<literal>sv-se</literal> and <literal>sv-fi</literal> are in use. To add
|
||||||
|
another dictionary, the package can be overridden like this:
|
||||||
|
<programlisting>ibus-engines.typing-booster.override {
|
||||||
|
langs = [ "de-at" "en-gb" ];
|
||||||
|
}</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<emphasis>Note: each language passed to <literal>langs</literal> must be an
|
||||||
|
attribute name in <literal>pkgs.hunspellDicts</literal>.</emphasis>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-ibus-typing-booster-emoji-picker">
|
||||||
|
<title>Built-in emoji picker</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The <literal>ibus-engines.typing-booster</literal> package contains a
|
||||||
|
program named <literal>emoji-picker</literal>. To display all emojis
|
||||||
|
correctly, a special font such as <literal>noto-fonts-emoji</literal> is
|
||||||
|
needed:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
On NixOS it can be installed using the following expression:
|
||||||
|
<programlisting>{ pkgs, ... }: {
|
||||||
|
fonts.fonts = with pkgs; [ noto-fonts-emoji ];
|
||||||
|
}</programlisting>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<title>Darwin (macOS)</title>
|
<title>Darwin (macOS)</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Some common issues when packaging software for darwin:
|
Some common issues when packaging software for Darwin:
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The darwin <literal>stdenv</literal> uses clang instead of gcc. When
|
The Darwin <literal>stdenv</literal> uses clang instead of gcc. When
|
||||||
referring to the compiler <varname>$CC</varname> or <command>cc</command>
|
referring to the compiler <varname>$CC</varname> or <command>cc</command>
|
||||||
will work in both cases. Some builds hardcode gcc/g++ in their build
|
will work in both cases. Some builds hardcode gcc/g++ in their build
|
||||||
scripts, that can usually be fixed with using something like
|
scripts, that can usually be fixed with using something like
|
||||||
@ -31,7 +31,7 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
On darwin libraries are linked using absolute paths, libraries are
|
On Darwin, libraries are linked using absolute paths, libraries are
|
||||||
resolved by their <literal>install_name</literal> at link time. Sometimes
|
resolved by their <literal>install_name</literal> at link time. Sometimes
|
||||||
packages won't set this correctly causing the library lookups to fail at
|
packages won't set this correctly causing the library lookups to fail at
|
||||||
runtime. This can be fixed by adding extra linker flags or by running
|
runtime. This can be fixed by adding extra linker flags or by running
|
||||||
@ -46,6 +46,36 @@
|
|||||||
}
|
}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Even if the libraries are linked using absolute paths and resolved via
|
||||||
|
their <literal>install_name</literal> correctly, tests can sometimes fail
|
||||||
|
to run binaries. This happens because the <varname>checkPhase</varname>
|
||||||
|
runs before the libraries are installed.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
This can usually be solved by running the tests after the
|
||||||
|
<varname>installPhase</varname> or alternatively by using
|
||||||
|
<varname>DYLD_LIBRARY_PATH</varname>. More information about this variable
|
||||||
|
can be found in the <citerefentry>
|
||||||
|
<refentrytitle>dyld</refentrytitle>
|
||||||
|
<manvolnum>1</manvolnum></citerefentry> manpage.
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
dyld: Library not loaded: /nix/store/7hnmbscpayxzxrixrgxvvlifzlxdsdir-jq-1.5-lib/lib/libjq.1.dylib
|
||||||
|
Referenced from: /private/tmp/nix-build-jq-1.5.drv-0/jq-1.5/tests/../jq
|
||||||
|
Reason: image not found
|
||||||
|
./tests/jqtest: line 5: 75779 Abort trap: 6
|
||||||
|
</programlisting>
|
||||||
|
<programlisting>
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "libfoo-1.2.3";
|
||||||
|
# ...
|
||||||
|
doInstallCheck = true;
|
||||||
|
installCheckTarget = "check";
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Some packages assume xcode is available and use <command>xcrun</command>
|
Some packages assume xcode is available and use <command>xcrun</command>
|
||||||
@ -66,8 +96,8 @@
|
|||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
The package <literal>xcbuild</literal> can be used to build projects that
|
The package <literal>xcbuild</literal> can be used to build projects that
|
||||||
really depend on Xcode, however projects that build some kind of graphical
|
really depend on Xcode. However, this replacement is not 100%
|
||||||
interface won't work without using Xcode in an impure way.
|
compatible with Xcode and can occasionally cause issues.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<para>
|
<para>
|
||||||
Checkout the Nixpkgs source tree:
|
Checkout the Nixpkgs source tree:
|
||||||
<screen>
|
<screen>
|
||||||
$ git clone git://github.com/NixOS/nixpkgs.git
|
$ git clone https://github.com/NixOS/nixpkgs
|
||||||
$ cd nixpkgs</screen>
|
$ cd nixpkgs</screen>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -147,8 +147,8 @@ $ git add pkgs/development/libraries/libfoo/default.nix</screen>
|
|||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
You can use <command>nix-prefetch-url</command> (or similar
|
You can use <command>nix-prefetch-url</command>
|
||||||
nix-prefetch-git, etc) <replaceable>url</replaceable> to get the
|
<replaceable>url</replaceable> to get the
|
||||||
SHA-256 hash of source distributions. There are similar commands as
|
SHA-256 hash of source distributions. There are similar commands as
|
||||||
<command>nix-prefetch-git</command> and
|
<command>nix-prefetch-git</command> and
|
||||||
<command>nix-prefetch-hg</command> available in
|
<command>nix-prefetch-hg</command> available in
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<article xmlns="http://docbook.org/ns/docbook"
|
<article xmlns="http://docbook.org/ns/docbook"
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<title>Nixpkgs Release Notes</title>
|
<title>Nixpkgs Release Notes</title>
|
||||||
<section>
|
<section xml:id="release-notes-0.14">
|
||||||
<title>Release 0.14 (June 4, 2012)</title>
|
<title>Release 0.14 (June 4, 2012)</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
packages by numerous contributors. For details, see the commit logs.
|
packages by numerous contributors. For details, see the commit logs.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="release-notes-0.13">
|
||||||
<title>Release 0.13 (February 5, 2010)</title>
|
<title>Release 0.13 (February 5, 2010)</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -51,7 +51,7 @@
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="release-notes-0.12">
|
||||||
<title>Release 0.12 (April 24, 2009)</title>
|
<title>Release 0.12 (April 24, 2009)</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -145,7 +145,7 @@
|
|||||||
<literal>nix-dev</literal> mailing list.
|
<literal>nix-dev</literal> mailing list.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="release-notes-0.11">
|
||||||
<title>Release 0.11 (September 11, 2007)</title>
|
<title>Release 0.11 (September 11, 2007)</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -344,7 +344,7 @@ export NIX_MIRRORS_sourceforge=http://osdn.dl.sourceforge.net/sourceforge/</prog
|
|||||||
Bravenboer, Michael Raskin, Wouter den Breejen and Yury G. Kudryashov.
|
Bravenboer, Michael Raskin, Wouter den Breejen and Yury G. Kudryashov.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="release-notes-0.10">
|
||||||
<title>Release 0.10 (October 12, 2006)</title>
|
<title>Release 0.10 (October 12, 2006)</title>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
@ -547,7 +547,7 @@ stdenv.mkDerivation {
|
|||||||
Bravenboer, Merijn de Jonge, Rob Vermaas and Roy van den Broek.
|
Bravenboer, Merijn de Jonge, Rob Vermaas and Roy van den Broek.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="release-notes-0.9">
|
||||||
<title>Release 0.9 (January 31, 2006)</title>
|
<title>Release 0.9 (January 31, 2006)</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -676,7 +676,7 @@ stdenv.mkDerivation {
|
|||||||
Martin Bravenboer, Rob Vermaas and Roy van den Broek.
|
Martin Bravenboer, Rob Vermaas and Roy van den Broek.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="release-notes-0.8">
|
||||||
<title>Release 0.8 (April 11, 2005)</title>
|
<title>Release 0.8 (April 11, 2005)</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -700,7 +700,7 @@ stdenv.mkDerivation {
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="release-notes-0.7">
|
||||||
<title>Release 0.7 (March 14, 2005)</title>
|
<title>Release 0.7 (March 14, 2005)</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
@ -6,31 +6,31 @@
|
|||||||
<title>Reviewing contributions</title>
|
<title>Reviewing contributions</title>
|
||||||
<warning>
|
<warning>
|
||||||
<para>
|
<para>
|
||||||
The following section is a draft, and the policy for reviewing is still being
|
The following section is a draft, and the policy for reviewing is still
|
||||||
discussed in issues such as <link
|
being discussed in issues such as
|
||||||
|
<link
|
||||||
xlink:href="https://github.com/NixOS/nixpkgs/issues/11166">#11166
|
xlink:href="https://github.com/NixOS/nixpkgs/issues/11166">#11166
|
||||||
</link> and <link
|
</link> and
|
||||||
|
<link
|
||||||
xlink:href="https://github.com/NixOS/nixpkgs/issues/20836">#20836
|
xlink:href="https://github.com/NixOS/nixpkgs/issues/20836">#20836
|
||||||
</link>.
|
</link>.
|
||||||
</para>
|
</para>
|
||||||
</warning>
|
</warning>
|
||||||
<para>
|
<para>
|
||||||
The nixpkgs project receives a fairly high number of contributions via
|
The Nixpkgs project receives a fairly high number of contributions via GitHub
|
||||||
GitHub pull-requests. Reviewing and approving these is an important task and
|
pull requests. Reviewing and approving these is an important task and a way
|
||||||
a way to contribute to the project.
|
to contribute to the project.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The high change rate of nixpkgs makes any pull request that remains open for
|
The high change rate of Nixpkgs makes any pull request that remains open for
|
||||||
too long subject to conflicts that will require extra work from the submitter
|
too long subject to conflicts that will require extra work from the submitter
|
||||||
or the merger. Reviewing pull requests in a timely manner and being
|
or the merger. Reviewing pull requests in a timely manner and being responsive
|
||||||
responsive to the comments is the key to avoid these. GitHub provides sort
|
to the comments is the key to avoid this issue. GitHub provides sort filters
|
||||||
filters that can be used to see the
|
that can be used to see the <link
|
||||||
<link
|
xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc">most
|
||||||
xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc">most
|
recently</link> and the <link
|
||||||
recently</link> and the
|
xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-asc">least
|
||||||
<link
|
recently</link> updated pull requests. We highly encourage looking at
|
||||||
xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-asc">least
|
|
||||||
recently</link> updated pull-requests. We highly encourage looking at
|
|
||||||
<link xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+review%3Anone+status%3Asuccess+-label%3A%222.status%3A+work-in-progress%22+no%3Aproject+no%3Aassignee+no%3Amilestone">
|
<link xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+review%3Anone+status%3Asuccess+-label%3A%222.status%3A+work-in-progress%22+no%3Aproject+no%3Aassignee+no%3Amilestone">
|
||||||
this list of ready to merge, unreviewed pull requests</link>.
|
this list of ready to merge, unreviewed pull requests</link>.
|
||||||
</para>
|
</para>
|
||||||
@ -40,13 +40,13 @@
|
|||||||
to respect every community member and their work.
|
to respect every community member and their work.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
GitHub provides reactions as a simple and quick way to provide
|
GitHub provides reactions as a simple and quick way to provide feedback to
|
||||||
feedback to pull-requests or any comments. The thumb-down reaction should be
|
pull requests or any comments. The thumb-down reaction should be used with
|
||||||
used with care and if possible accompanied with some explanation so the
|
care and if possible accompanied with some explanation so the submitter has
|
||||||
submitter has directions to improve their contribution.
|
directions to improve their contribution.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Pull-request reviews should include a list of what has been reviewed in a
|
pull request reviews should include a list of what has been reviewed in a
|
||||||
comment, so other reviewers and mergers can know the state of the review.
|
comment, so other reviewers and mergers can know the state of the review.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
@ -54,12 +54,12 @@
|
|||||||
meant as examples. Their usage is optional and the reviewer is free to adapt
|
meant as examples. Their usage is optional and the reviewer is free to adapt
|
||||||
them to their liking.
|
them to their liking.
|
||||||
</para>
|
</para>
|
||||||
<section>
|
<section xml:id="reviewing-contributions-package-updates">
|
||||||
<title>Package updates</title>
|
<title>Package updates</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
A package update is the most trivial and common type of pull-request. These
|
A package update is the most trivial and common type of pull request. These
|
||||||
pull-requests mainly consist of updating the version part of the package
|
pull requests mainly consist of updating the version part of the package
|
||||||
name and the source hash.
|
name and the source hash.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -75,7 +75,7 @@
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Add labels to the pull-request. (Requires commit rights)
|
Add labels to the pull request. (Requires commit rights)
|
||||||
</para>
|
</para>
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -103,8 +103,9 @@
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
mention-bot usually notifies GitHub users based on the submitted changes,
|
<link xlink:href="https://help.github.com/articles/about-codeowners/">CODEOWNERS</link>
|
||||||
but it can happen that it misses some of the package maintainers.
|
will make GitHub notify users based on the submitted changes, but it can
|
||||||
|
happen that it misses some of the package maintainers.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
@ -116,8 +117,8 @@
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
License can change with version updates, so it should be checked to match
|
License can change with version updates, so it should be checked to
|
||||||
the upstream license.
|
match the upstream license.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -141,9 +142,9 @@
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Pull-requests are often targeted to the master or staging branch, and
|
pull requests are often targeted to the master or staging branch, and
|
||||||
building the pull-request locally when it is submitted can trigger
|
building the pull request locally when it is submitted can trigger many
|
||||||
many source builds.
|
source builds.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
It is possible to rebase the changes on nixos-unstable or
|
It is possible to rebase the changes on nixos-unstable or
|
||||||
@ -171,14 +172,14 @@ $ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD <co
|
|||||||
</callout>
|
</callout>
|
||||||
<callout arearefs='reviewing-rebase-3'>
|
<callout arearefs='reviewing-rebase-3'>
|
||||||
<para>
|
<para>
|
||||||
Fetching the pull-request changes, <varname>PRNUMBER</varname> is the
|
Fetching the pull request changes, <varname>PRNUMBER</varname> is the
|
||||||
number at the end of the pull-request title and
|
number at the end of the pull request title and
|
||||||
<varname>BASEBRANCH</varname> the base branch of the pull-request.
|
<varname>BASEBRANCH</varname> the base branch of the pull request.
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
<callout arearefs='reviewing-rebase-4'>
|
<callout arearefs='reviewing-rebase-4'>
|
||||||
<para>
|
<para>
|
||||||
Rebasing the pull-request changes to the nixos-unstable branch.
|
Rebasing the pull request changes to the nixos-unstable branch.
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
</calloutlist>
|
</calloutlist>
|
||||||
@ -187,10 +188,10 @@ $ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD <co
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The <link xlink:href="https://github.com/madjar/nox">nox</link> tool can
|
The <link xlink:href="https://github.com/madjar/nox">nox</link> tool can
|
||||||
be used to review a pull-request content in a single command. It doesn't
|
be used to review a pull request content in a single command. It doesn't
|
||||||
rebase on a channel branch so it might trigger multiple source builds.
|
rebase on a channel branch so it might trigger multiple source builds.
|
||||||
<varname>PRNUMBER</varname> should be replaced by the number at the end
|
<varname>PRNUMBER</varname> should be replaced by the number at the end
|
||||||
of the pull-request title.
|
of the pull request title.
|
||||||
</para>
|
</para>
|
||||||
<screen>
|
<screen>
|
||||||
$ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
$ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
||||||
@ -205,7 +206,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
<example>
|
<example xml:id="reviewing-contributions-sample-package-update">
|
||||||
<title>Sample template for a package update review</title>
|
<title>Sample template for a package update review</title>
|
||||||
<screen>
|
<screen>
|
||||||
##### Reviewed points
|
##### Reviewed points
|
||||||
@ -223,11 +224,11 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="reviewing-contributions-new-packages">
|
||||||
<title>New packages</title>
|
<title>New packages</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
New packages are a common type of pull-requests. These pull requests
|
New packages are a common type of pull requests. These pull requests
|
||||||
consists in adding a new nix-expression for a package.
|
consists in adding a new nix-expression for a package.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -238,7 +239,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Add labels to the pull-request. (Requires commit rights)
|
Add labels to the pull request. (Requires commit rights)
|
||||||
</para>
|
</para>
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -276,7 +277,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
A maintainer must be set, this can be the package submitter or a
|
A maintainer must be set. This can be the package submitter or a
|
||||||
community member that accepts to take maintainership of the package.
|
community member that accepts to take maintainership of the package.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -317,7 +318,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
<example>
|
<example xml:id="reviewing-contributions-sample-new-package">
|
||||||
<title>Sample template for a new package review</title>
|
<title>Sample template for a new package review</title>
|
||||||
<screen>
|
<screen>
|
||||||
##### Reviewed points
|
##### Reviewed points
|
||||||
@ -343,7 +344,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="reviewing-contributions-module-updates">
|
||||||
<title>Module updates</title>
|
<title>Module updates</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -358,7 +359,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Add labels to the pull-request. (Requires commit rights)
|
Add labels to the pull request. (Requires commit rights)
|
||||||
</para>
|
</para>
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -376,8 +377,9 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Mention-bot notify GitHub users based on the submitted changes, but it
|
<link xlink:href="https://help.github.com/articles/about-codeowners/">CODEOWNERS</link>
|
||||||
can happen that it miss some of the package maintainers.
|
will make GitHub notify users based on the submitted changes, but it can
|
||||||
|
happen that it misses some of the package maintainers.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
@ -439,7 +441,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
<example>
|
<example xml:id="reviewing-contributions-sample-module-update">
|
||||||
<title>Sample template for a module update review</title>
|
<title>Sample template for a module update review</title>
|
||||||
<screen>
|
<screen>
|
||||||
##### Reviewed points
|
##### Reviewed points
|
||||||
@ -460,7 +462,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="reviewing-contributions-new-modules">
|
||||||
<title>New modules</title>
|
<title>New modules</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -470,7 +472,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Add labels to the pull-request. (Requires commit rights)
|
Add labels to the pull request. (Requires commit rights)
|
||||||
</para>
|
</para>
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -538,7 +540,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
<example>
|
<example xml:id="reviewing-contributions-sample-new-module">
|
||||||
<title>Sample template for a new module review</title>
|
<title>Sample template for a new module review</title>
|
||||||
<screen>
|
<screen>
|
||||||
##### Reviewed points
|
##### Reviewed points
|
||||||
@ -560,7 +562,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="reviewing-contributions-other-submissions">
|
||||||
<title>Other submissions</title>
|
<title>Other submissions</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -572,7 +574,7 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
like to be a long-term reviewer for related submissions, please contact the
|
like to be a long-term reviewer for related submissions, please contact the
|
||||||
current reviewers for that topic. They will give you information about the
|
current reviewers for that topic. They will give you information about the
|
||||||
reviewing process. The main reviewers for a topic can be hard to find as
|
reviewing process. The main reviewers for a topic can be hard to find as
|
||||||
there is no list, but checking past pull-requests to see who reviewed or
|
there is no list, but checking past pull requests to see who reviewed or
|
||||||
git-blaming the code to see who committed to that topic can give some hints.
|
git-blaming the code to see who committed to that topic can give some hints.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -581,8 +583,8 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER"
|
|||||||
pull requests fitting this category.
|
pull requests fitting this category.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="reviewing-contributions--merging-pull-requests">
|
||||||
<title>Merging pull-requests</title>
|
<title>Merging pull requests</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
It is possible for community members that have enough knowledge and
|
It is possible for community members that have enough knowledge and
|
||||||
@ -604,9 +606,11 @@ policy.
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
In a case a contributor leaves definitively the Nix community, he should
|
In a case a contributor leaves definitively the Nix community, he should
|
||||||
create an issue or notify the mailing list with references of packages and
|
create an issue or post on
|
||||||
modules he maintains so the maintainership can be taken over by other
|
<link
|
||||||
contributors.
|
xlink:href="https://discourse.nixos.org">Discourse</link> with
|
||||||
|
references of packages and modules he maintains so the maintainership can be
|
||||||
|
taken over by other contributors.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{ pkgs ? import ../. {} }:
|
{ pkgs ? import ../. {} }:
|
||||||
(import ./default.nix).overrideAttrs (x: {
|
(import ./default.nix {}).overrideAttrs (x: {
|
||||||
buildInputs = x.buildInputs ++ [ pkgs.xmloscopy pkgs.ruby ];
|
buildInputs = x.buildInputs ++ [ pkgs.xmloscopy pkgs.ruby ];
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
title: pkgs.mkShell
|
|
||||||
author: zimbatm
|
|
||||||
date: 2017-10-30
|
|
||||||
---
|
|
||||||
|
|
||||||
# mkShell
|
|
||||||
|
|
||||||
pkgs.mkShell is a special kind of derivation that is only useful when using
|
|
||||||
it combined with nix-shell. It will in fact fail to instantiate when invoked
|
|
||||||
with nix-build.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```nix
|
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
|
||||||
pkgs.mkShell {
|
|
||||||
# this will make all the build inputs from hello and gnutar available to the shell environment
|
|
||||||
inputsFrom = with pkgs; [ hello gnutar ];
|
|
||||||
buildInputs = [ pkgs.gnumake ];
|
|
||||||
}
|
|
||||||
```
|
|
656
doc/stdenv.xml
656
doc/stdenv.xml
@ -212,7 +212,7 @@ genericBuild
|
|||||||
platforms relative to the new derivation's, and whether they are propagated.
|
platforms relative to the new derivation's, and whether they are propagated.
|
||||||
The platform distinctions are motivated by cross compilation; see
|
The platform distinctions are motivated by cross compilation; see
|
||||||
<xref linkend="chap-cross"/> for exactly what each platform means.
|
<xref linkend="chap-cross"/> for exactly what each platform means.
|
||||||
<footnote>
|
<footnote xml:id="footnote-stdenv-ignored-build-platform">
|
||||||
<para>
|
<para>
|
||||||
The build platform is ignored because it is a mere implementation detail
|
The build platform is ignored because it is a mere implementation detail
|
||||||
of the package satisfying the dependency: As a general programming
|
of the package satisfying the dependency: As a general programming
|
||||||
@ -228,18 +228,19 @@ genericBuild
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The extension of <envar>PATH</envar> with dependencies, alluded to above,
|
The extension of <envar>PATH</envar> with dependencies, alluded to
|
||||||
proceeds according to the relative platforms alone. The process is carried
|
above, proceeds according to the relative platforms alone. The
|
||||||
out only for dependencies whose host platform matches the new derivation's
|
process is carried out only for dependencies whose host platform
|
||||||
build platform–i.e. which run on the platform where the new derivation
|
matches the new derivation's build platform i.e. dependencies which
|
||||||
will be built.
|
run on the platform where the new derivation will be built.
|
||||||
<footnote>
|
<footnote xml:id="footnote-stdenv-native-dependencies-in-path">
|
||||||
<para>
|
<para>
|
||||||
Currently, that means for native builds all dependencies are put on the
|
Currently, this means for native builds all dependencies are put
|
||||||
<envar>PATH</envar>. But in the future that may not be the case for sake
|
on the <envar>PATH</envar>. But in the future that may not be the
|
||||||
of matching cross: the platforms would be assumed to be unique for native
|
case for sake of matching cross: the platforms would be assumed
|
||||||
and cross builds alike, so only the <varname>depsBuild*</varname> and
|
to be unique for native and cross builds alike, so only the
|
||||||
<varname>nativeBuildDependencies</varname> dependencies would affect the
|
<varname>depsBuild*</varname> and
|
||||||
|
<varname>nativeBuildInputs</varname> would be added to the
|
||||||
<envar>PATH</envar>.
|
<envar>PATH</envar>.
|
||||||
</para>
|
</para>
|
||||||
</footnote>
|
</footnote>
|
||||||
@ -251,28 +252,27 @@ genericBuild
|
|||||||
<para>
|
<para>
|
||||||
The dependency is propagated when it forces some of its other-transitive
|
The dependency is propagated when it forces some of its other-transitive
|
||||||
(non-immediate) downstream dependencies to also take it on as an immediate
|
(non-immediate) downstream dependencies to also take it on as an immediate
|
||||||
dependency. Nix itself already takes a package's transitive dependencies
|
dependency. Nix itself already takes a package's transitive dependencies into
|
||||||
into account, but this propagation ensures nixpkgs-specific infrastructure
|
account, but this propagation ensures nixpkgs-specific infrastructure like
|
||||||
like setup hooks (mentioned above) also are run as if the propagated
|
setup hooks (mentioned above) also are run as if the propagated dependency.
|
||||||
dependency.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
It is important to note dependencies are not necessary propagated as the
|
It is important to note that dependencies are not necessarily propagated as
|
||||||
same sort of dependency that they were before, but rather as the
|
the same sort of dependency that they were before, but rather as the
|
||||||
corresponding sort so that the platform rules still line up. The exact rules
|
corresponding sort so that the platform rules still line up. The exact rules
|
||||||
for dependency propagation can be given by assigning each sort of dependency
|
for dependency propagation can be given by assigning to each dependency two
|
||||||
two integers based one how it's host and target platforms are offset from
|
integers based one how its host and target platforms are offset from the
|
||||||
the depending derivation's platforms. Those offsets are given are given
|
depending derivation's platforms. Those offsets are given below in the
|
||||||
below in the descriptions of each dependency list attribute.
|
descriptions of each dependency list attribute. Algorithmically, we traverse
|
||||||
Algorithmically, we traverse propagated inputs, accumulating every
|
propagated inputs, accumulating every propagated dependency's propagated
|
||||||
propagated dep's propagated deps and adjusting them to account for the
|
dependencies and adjusting them to account for the "shift in perspective"
|
||||||
"shift in perspective" described by the current dep's platform offsets. This
|
described by the current dependency's platform offsets. This results in sort
|
||||||
results in sort a transitive closure of the dependency relation, with the
|
a transitive closure of the dependency relation, with the offsets being
|
||||||
offsets being approximately summed when two dependency links are combined.
|
approximately summed when two dependency links are combined. We also prune
|
||||||
We also prune transitive deps whose combined offsets go out-of-bounds, which
|
transitive dependencies whose combined offsets go out-of-bounds, which can be
|
||||||
can be viewed as a filter over that transitive closure removing dependencies
|
viewed as a filter over that transitive closure removing dependencies that
|
||||||
that are blatantly absurd.
|
are blatantly absurd.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -280,15 +280,15 @@ genericBuild
|
|||||||
<link xlink:href="https://en.wikipedia.org/wiki/Natural_deduction">Natural
|
<link xlink:href="https://en.wikipedia.org/wiki/Natural_deduction">Natural
|
||||||
Deduction</link> using the inference rules. This probably seems a bit
|
Deduction</link> using the inference rules. This probably seems a bit
|
||||||
obtuse, but so is the bash code that actually implements it!
|
obtuse, but so is the bash code that actually implements it!
|
||||||
<footnote>
|
<footnote xml:id="footnote-stdenv-find-inputs-location">
|
||||||
<para>
|
<para>
|
||||||
The <function>findInputs</function> function, currently residing in
|
The <function>findInputs</function> function, currently residing in
|
||||||
<filename>pkgs/stdenv/generic/setup.sh</filename>, implements the
|
<filename>pkgs/stdenv/generic/setup.sh</filename>, implements the
|
||||||
propagation logic.
|
propagation logic.
|
||||||
</para>
|
</para>
|
||||||
</footnote>
|
</footnote>
|
||||||
They're confusing in very different ways so...hopefully if something doesn't
|
They're confusing in very different ways so... hopefully if something doesn't
|
||||||
make sense in one presentation, it does in the other!
|
make sense in one presentation, it will in the other!
|
||||||
<programlisting>
|
<programlisting>
|
||||||
let mapOffset(h, t, i) = i + (if i <= 0 then h else t - 1)
|
let mapOffset(h, t, i) = i + (if i <= 0 then h else t - 1)
|
||||||
|
|
||||||
@ -307,13 +307,13 @@ dep(h0, _, A, B)
|
|||||||
propagated-dep(h1, t1, B, C)
|
propagated-dep(h1, t1, B, C)
|
||||||
h0 + h1 in {-1, 0, 1}
|
h0 + h1 in {-1, 0, 1}
|
||||||
h0 + t1 in {-1, 0, -1}
|
h0 + t1 in {-1, 0, -1}
|
||||||
-------------------------------------- Take immediate deps' propagated deps
|
----------------------------- Take immediate dependencies' propagated dependencies
|
||||||
propagated-dep(mapOffset(h0, t0, h1),
|
propagated-dep(mapOffset(h0, t0, h1),
|
||||||
mapOffset(h0, t0, t1),
|
mapOffset(h0, t0, t1),
|
||||||
A, C)</programlisting>
|
A, C)</programlisting>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
propagated-dep(h, t, A, B)
|
propagated-dep(h, t, A, B)
|
||||||
-------------------------------------- Propagated deps count as deps
|
----------------------------- Propagated dependencies count as dependencies
|
||||||
dep(h, t, A, B)</programlisting>
|
dep(h, t, A, B)</programlisting>
|
||||||
Some explanation of this monstrosity is in order. In the common case, the
|
Some explanation of this monstrosity is in order. In the common case, the
|
||||||
target offset of a dependency is the successor to the target offset:
|
target offset of a dependency is the successor to the target offset:
|
||||||
@ -324,31 +324,31 @@ let f(h, h + 1, i) = i + (if i <= 0 then h else (h + 1) - 1)
|
|||||||
let f(h, h + 1, i) = i + (if i <= 0 then h else h)
|
let f(h, h + 1, i) = i + (if i <= 0 then h else h)
|
||||||
let f(h, h + 1, i) = i + h
|
let f(h, h + 1, i) = i + h
|
||||||
</programlisting>
|
</programlisting>
|
||||||
This is where the "sum-like" comes from above: We can just sum all the host
|
This is where "sum-like" comes in from above: We can just sum all of the host
|
||||||
offset to get the host offset of the transitive dependency. The target
|
offsets to get the host offset of the transitive dependency. The target
|
||||||
offset is the transitive dep is simply the host offset + 1, just as it was
|
offset is the transitive dependency is simply the host offset + 1, just as it
|
||||||
with the dependencies composed to make this transitive one; it can be
|
was with the dependencies composed to make this transitive one; it can be
|
||||||
ignored as it doesn't add any new information.
|
ignored as it doesn't add any new information.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Because of the bounds checks, the uncommon cases are <literal>h =
|
Because of the bounds checks, the uncommon cases are <literal>h = t</literal>
|
||||||
t</literal> and <literal>h + 2 = t</literal>. In the former case, the
|
and <literal>h + 2 = t</literal>. In the former case, the motivation for
|
||||||
motivation for <function>mapOffset</function> is that since its host and
|
<function>mapOffset</function> is that since its host and target platforms
|
||||||
target platforms are the same, no transitive dep of it should be able to
|
are the same, no transitive dependency of it should be able to "discover" an
|
||||||
"discover" an offset greater than its reduced target offsets.
|
offset greater than its reduced target offsets.
|
||||||
<function>mapOffset</function> effectively "squashes" all its transitive
|
<function>mapOffset</function> effectively "squashes" all its transitive
|
||||||
dependencies' offsets so that none will ever be greater than the target
|
dependencies' offsets so that none will ever be greater than the target
|
||||||
offset of the original <literal>h = t</literal> package. In the other case,
|
offset of the original <literal>h = t</literal> package. In the other case,
|
||||||
<literal>h + 1</literal> is skipped over between the host and target
|
<literal>h + 1</literal> is skipped over between the host and target offsets.
|
||||||
offsets. Instead of squashing the offsets, we need to "rip" them apart so no
|
Instead of squashing the offsets, we need to "rip" them apart so no
|
||||||
transitive dependencies' offset is that one.
|
transitive dependencies' offset is that one.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Overall, the unifying theme here is that propagation shouldn't be
|
Overall, the unifying theme here is that propagation shouldn't be introducing
|
||||||
introducing transitive dependencies involving platforms the needing package
|
transitive dependencies involving platforms the depending package is unaware
|
||||||
is unaware of. The offset bounds checking and definition of
|
of. The offset bounds checking and definition of
|
||||||
<function>mapOffset</function> together ensure that this is the case.
|
<function>mapOffset</function> together ensure that this is the case.
|
||||||
Discovering a new offset is discovering a new platform, and since those
|
Discovering a new offset is discovering a new platform, and since those
|
||||||
platforms weren't in the derivation "spec" of the needing package, they
|
platforms weren't in the derivation "spec" of the needing package, they
|
||||||
@ -369,20 +369,20 @@ let f(h, h + 1, i) = i + h
|
|||||||
A list of dependencies whose host and target platforms are the new
|
A list of dependencies whose host and target platforms are the new
|
||||||
derivation's build platform. This means a <literal>-1</literal> host and
|
derivation's build platform. This means a <literal>-1</literal> host and
|
||||||
<literal>-1</literal> target offset from the new derivation's platforms.
|
<literal>-1</literal> target offset from the new derivation's platforms.
|
||||||
They are programs/libraries used at build time that furthermore produce
|
These are programs and libraries used at build time that produce programs
|
||||||
programs/libraries also used at build time. If the dependency doesn't
|
and libraries also used at build time. If the dependency doesn't care
|
||||||
care about the target platform (i.e. isn't a compiler or similar tool),
|
about the target platform (i.e. isn't a compiler or similar tool), put it
|
||||||
put it in <varname>nativeBuildInputs</varname>instead. The most common
|
in <varname>nativeBuildInputs</varname> instead. The most common use of
|
||||||
use for this <literal>buildPackages.stdenv.cc</literal>, the default C
|
this <literal>buildPackages.stdenv.cc</literal>, the default C compiler
|
||||||
compiler for this role. That example crops up more than one might think
|
for this role. That example crops up more than one might think in old
|
||||||
in old commonly used C libraries.
|
commonly used C libraries.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Since these packages are able to be run at build time, that are always
|
Since these packages are able to be run at build-time, they are always
|
||||||
added to the <envar>PATH</envar>, as described above. But since these
|
added to the <envar>PATH</envar>, as described above. But since these
|
||||||
packages are only guaranteed to be able to run then, they shouldn't
|
packages are only guaranteed to be able to run then, they shouldn't
|
||||||
persist as run-time dependencies. This isn't currently enforced, but
|
persist as run-time dependencies. This isn't currently enforced, but could
|
||||||
could be in the future.
|
be in the future.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -395,21 +395,20 @@ let f(h, h + 1, i) = i + h
|
|||||||
A list of dependencies whose host platform is the new derivation's build
|
A list of dependencies whose host platform is the new derivation's build
|
||||||
platform, and target platform is the new derivation's host platform. This
|
platform, and target platform is the new derivation's host platform. This
|
||||||
means a <literal>-1</literal> host offset and <literal>0</literal> target
|
means a <literal>-1</literal> host offset and <literal>0</literal> target
|
||||||
offset from the new derivation's platforms. They are programs/libraries
|
offset from the new derivation's platforms. These are programs and
|
||||||
used at build time that, if they are a compiler or similar tool, produce
|
libraries used at build-time that, if they are a compiler or similar tool,
|
||||||
code to run at run time—i.e. tools used to build the new derivation. If
|
produce code to run at run-time—i.e. tools used to build the new
|
||||||
the dependency doesn't care about the target platform (i.e. isn't a
|
derivation. If the dependency doesn't care about the target platform (i.e.
|
||||||
compiler or similar tool), put it here, rather than in
|
isn't a compiler or similar tool), put it here, rather than in
|
||||||
<varname>depsBuildBuild</varname> or <varname>depsBuildTarget</varname>.
|
<varname>depsBuildBuild</varname> or <varname>depsBuildTarget</varname>.
|
||||||
This would be called <varname>depsBuildHost</varname> but for historical
|
This could be called <varname>depsBuildHost</varname> but
|
||||||
continuity.
|
<varname>nativeBuildInputs</varname> is used for historical continuity.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Since these packages are able to be run at build time, that are added to
|
Since these packages are able to be run at build-time, they are added to
|
||||||
the <envar>PATH</envar>, as described above. But since these packages
|
the <envar>PATH</envar>, as described above. But since these packages are
|
||||||
only are guaranteed to be able to run then, they shouldn't persist as
|
only guaranteed to be able to run then, they shouldn't persist as run-time
|
||||||
run-time dependencies. This isn't currently enforced, but could be in the
|
dependencies. This isn't currently enforced, but could be in the future.
|
||||||
future.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -422,34 +421,33 @@ let f(h, h + 1, i) = i + h
|
|||||||
A list of dependencies whose host platform is the new derivation's build
|
A list of dependencies whose host platform is the new derivation's build
|
||||||
platform, and target platform is the new derivation's target platform.
|
platform, and target platform is the new derivation's target platform.
|
||||||
This means a <literal>-1</literal> host offset and <literal>1</literal>
|
This means a <literal>-1</literal> host offset and <literal>1</literal>
|
||||||
target offset from the new derivation's platforms. They are programs used
|
target offset from the new derivation's platforms. These are programs used
|
||||||
at build time that produce code to run at run with code produced by the
|
at build time that produce code to run with code produced by the depending
|
||||||
depending package. Most commonly, these would tools used to build the
|
package. Most commonly, these are tools used to build the runtime or
|
||||||
runtime or standard library the currently-being-built compiler will
|
standard library that the currently-being-built compiler will inject into
|
||||||
inject into any code it compiles. In many cases, the currently-being
|
any code it compiles. In many cases, the currently-being-built-compiler is
|
||||||
built compiler is itself employed for that task, but when that compiler
|
itself employed for that task, but when that compiler won't run (i.e. its
|
||||||
won't run (i.e. its build and host platform differ) this is not possible.
|
build and host platform differ) this is not possible. Other times, the
|
||||||
Other times, the compiler relies on some other tool, like binutils, that
|
compiler relies on some other tool, like binutils, that is always built
|
||||||
is always built separately so the dependency is unconditional.
|
separately so that the dependency is unconditional.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
This is a somewhat confusing dependency to wrap ones head around, and for
|
This is a somewhat confusing concept to wrap one’s head around, and for
|
||||||
good reason. As the only one where the platform offsets are not adjacent
|
good reason. As the only dependency type where the platform offsets are
|
||||||
integers, it requires thinking of a bootstrapping stage
|
not adjacent integers, it requires thinking of a bootstrapping stage
|
||||||
<emphasis>two</emphasis> away from the current one. It and it's use-case
|
<emphasis>two</emphasis> away from the current one. It and its use-case go
|
||||||
go hand in hand and are both considered poor form: try not to need this
|
hand in hand and are both considered poor form: try to not need this sort
|
||||||
sort dependency, and try not avoid building standard libraries / runtimes
|
of dependency, and try to avoid building standard libraries and runtimes
|
||||||
in the same derivation as the compiler produces code using them. Instead
|
in the same derivation as the compiler produces code using them. Instead
|
||||||
strive to build those like a normal library, using the newly-built
|
strive to build those like a normal library, using the newly-built
|
||||||
compiler just as a normal library would. In short, do not use this
|
compiler just as a normal library would. In short, do not use this
|
||||||
attribute unless you are packaging a compiler and are sure it is needed.
|
attribute unless you are packaging a compiler and are sure it is needed.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Since these packages are able to be run at build time, that are added to
|
Since these packages are able to run at build time, they are added to the
|
||||||
the <envar>PATH</envar>, as described above. But since these packages
|
<envar>PATH</envar>, as described above. But since these packages are only
|
||||||
only are guaranteed to be able to run then, they shouldn't persist as
|
guaranteed to be able to run then, they shouldn't persist as run-time
|
||||||
run-time dependencies. This isn't currently enforced, but could be in the
|
dependencies. This isn't currently enforced, but could be in the future.
|
||||||
future.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -460,15 +458,15 @@ let f(h, h + 1, i) = i + h
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
A list of dependencies whose host and target platforms match the new
|
A list of dependencies whose host and target platforms match the new
|
||||||
derivation's host platform. This means a both <literal>0</literal> host
|
derivation's host platform. This means a <literal>0</literal> host offset
|
||||||
offset and <literal>0</literal> target offset from the new derivation's
|
and <literal>0</literal> target offset from the new derivation's host
|
||||||
host platform. These are packages used at run-time to generate code also
|
platform. These are packages used at run-time to generate code also used
|
||||||
used at run-time. In practice, that would usually be tools used by
|
at run-time. In practice, this would usually be tools used by compilers
|
||||||
compilers for metaprogramming/macro systems, or libraries used by the
|
for macros or a metaprogramming system, or libraries used by the macros or
|
||||||
macros/metaprogramming code itself. It's always preferable to use a
|
metaprogramming code itself. It's always preferable to use a
|
||||||
<varname>depsBuildBuild</varname> dependency in the derivation being
|
<varname>depsBuildBuild</varname> dependency in the derivation being built
|
||||||
built than a <varname>depsHostHost</varname> on the tool doing the
|
over a <varname>depsHostHost</varname> on the tool doing the building for
|
||||||
building for this purpose.
|
this purpose.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -479,20 +477,20 @@ let f(h, h + 1, i) = i + h
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
A list of dependencies whose host platform and target platform match the
|
A list of dependencies whose host platform and target platform match the
|
||||||
new derivation's. This means a <literal>0</literal> host offset and
|
new derivation's. This means a <literal>0</literal> host offset and a
|
||||||
<literal>1</literal> target offset from the new derivation's host
|
<literal>1</literal> target offset from the new derivation's host
|
||||||
platform. This would be called <varname>depsHostTarget</varname> but for
|
platform. This would be called <varname>depsHostTarget</varname> but for
|
||||||
historical continuity. If the dependency doesn't care about the target
|
historical continuity. If the dependency doesn't care about the target
|
||||||
platform (i.e. isn't a compiler or similar tool), put it here, rather
|
platform (i.e. isn't a compiler or similar tool), put it here, rather than
|
||||||
than in <varname>depsBuildBuild</varname>.
|
in <varname>depsBuildBuild</varname>.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
These often are programs/libraries used by the new derivation at
|
These are often programs and libraries used by the new derivation at
|
||||||
<emphasis>run</emphasis>-time, but that isn't always the case. For
|
<emphasis>run</emphasis>-time, but that isn't always the case. For
|
||||||
example, the machine code in a statically linked library is only used at
|
example, the machine code in a statically-linked library is only used at
|
||||||
run time, but the derivation containing the library is only needed at
|
run-time, but the derivation containing the library is only needed at
|
||||||
build time. Even in the dynamic case, the library may also be needed at
|
build-time. Even in the dynamic case, the library may also be needed at
|
||||||
build time to appease the linker.
|
build-time to appease the linker.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -581,7 +579,7 @@ let f(h, h + 1, i) = i + h
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<varname>depsTargetTarget</varname>
|
<varname>depsTargetTargetPropagated</varname>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
@ -604,10 +602,10 @@ let f(h, h + 1, i) = i + h
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
A natural number indicating how much information to log. If set to 1 or
|
A natural number indicating how much information to log. If set to 1 or
|
||||||
higher, <literal>stdenv</literal> will print moderate debug information
|
higher, <literal>stdenv</literal> will print moderate debugging
|
||||||
during the build. In particular, the <command>gcc</command> and
|
information during the build. In particular, the <command>gcc</command>
|
||||||
<command>ld</command> wrapper scripts will print out the complete command
|
and <command>ld</command> wrapper scripts will print out the complete
|
||||||
line passed to the wrapped tools. If set to 6 or higher, the
|
command line passed to the wrapped tools. If set to 6 or higher, the
|
||||||
<literal>stdenv</literal> setup script will be run with <literal>set
|
<literal>stdenv</literal> setup script will be run with <literal>set
|
||||||
-x</literal> tracing. If set to 7 or higher, the <command>gcc</command>
|
-x</literal> tracing. If set to 7 or higher, the <command>gcc</command>
|
||||||
and <command>ld</command> wrapper scripts will also be run with
|
and <command>ld</command> wrapper scripts will also be run with
|
||||||
@ -618,7 +616,7 @@ let f(h, h + 1, i) = i + h
|
|||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
<title>Variables affecting build properties</title>
|
<title>Attributes affecting build properties</title>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<varname>enableParallelBuilding</varname>
|
<varname>enableParallelBuilding</varname>
|
||||||
@ -637,21 +635,6 @@ let f(h, h + 1, i) = i + h
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<varname>preferLocalBuild</varname>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
If set, specifies that the package is so lightweight in terms of build
|
|
||||||
operations (e.g. write a text file from a Nix string to the store) that
|
|
||||||
there's no need to look for it in binary caches -- it's faster to just
|
|
||||||
build it locally. It also tells Hydra and other facilities that this
|
|
||||||
package doesn't need to be exported in binary caches (noone would use it,
|
|
||||||
after all).
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
@ -681,11 +664,10 @@ passthru = {
|
|||||||
<literal>hello.baz.value1</literal>. We don't specify any usage or schema
|
<literal>hello.baz.value1</literal>. We don't specify any usage or schema
|
||||||
of <literal>passthru</literal> - it is meant for values that would be
|
of <literal>passthru</literal> - it is meant for values that would be
|
||||||
useful outside the derivation in other parts of a Nix expression (e.g. in
|
useful outside the derivation in other parts of a Nix expression (e.g. in
|
||||||
other derivations). An example would be to convey some specific
|
other derivations). An example would be to convey some specific dependency
|
||||||
dependency of your derivation which contains a program with plugins
|
of your derivation which contains a program with plugins support. Later,
|
||||||
support. Later, others who make derivations with plugins can use
|
others who make derivations with plugins can use passed-through dependency
|
||||||
passed-through dependency to ensure that their plugin would be
|
to ensure that their plugin would be binary-compatible with built program.
|
||||||
binary-compatible with built program.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -836,9 +818,10 @@ passthru = {
|
|||||||
These can optionally be compressed using <command>gzip</command>
|
These can optionally be compressed using <command>gzip</command>
|
||||||
(<filename>.tar.gz</filename>, <filename>.tgz</filename> or
|
(<filename>.tar.gz</filename>, <filename>.tgz</filename> or
|
||||||
<filename>.tar.Z</filename>), <command>bzip2</command>
|
<filename>.tar.Z</filename>), <command>bzip2</command>
|
||||||
(<filename>.tar.bz2</filename> or <filename>.tbz2</filename>) or
|
(<filename>.tar.bz2</filename>, <filename>.tbz2</filename> or
|
||||||
<command>xz</command> (<filename>.tar.xz</filename> or
|
<filename>.tbz</filename>) or <command>xz</command>
|
||||||
<filename>.tar.lzma</filename>).
|
(<filename>.tar.xz</filename>, <filename>.tar.lzma</filename> or
|
||||||
|
<filename>.txz</filename>).
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -850,7 +833,7 @@ passthru = {
|
|||||||
<para>
|
<para>
|
||||||
Zip files are unpacked using <command>unzip</command>. However,
|
Zip files are unpacked using <command>unzip</command>. However,
|
||||||
<command>unzip</command> is not in the standard environment, so you
|
<command>unzip</command> is not in the standard environment, so you
|
||||||
should add it to <varname>buildInputs</varname> yourself.
|
should add it to <varname>nativeBuildInputs</varname> yourself.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -1090,6 +1073,17 @@ passthru = {
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>prefixKey</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The key to use when specifying the prefix. By default, this is set to
|
||||||
|
<option>--prefix=</option> as that is used by the majority of packages.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<varname>dontAddDisableDepTrack</varname>
|
<varname>dontAddDisableDepTrack</varname>
|
||||||
@ -1111,7 +1105,7 @@ passthru = {
|
|||||||
By default, the configure phase applies some special hackery to all
|
By default, the configure phase applies some special hackery to all
|
||||||
files called <filename>ltmain.sh</filename> before running the configure
|
files called <filename>ltmain.sh</filename> before running the configure
|
||||||
script in order to improve the purity of Libtool-based packages
|
script in order to improve the purity of Libtool-based packages
|
||||||
<footnote>
|
<footnote xml:id="footnote-stdenv-sys-lib-search-path">
|
||||||
<para>
|
<para>
|
||||||
It clears the
|
It clears the
|
||||||
<varname>sys_lib_<replaceable>*</replaceable>search_path</varname>
|
<varname>sys_lib_<replaceable>*</replaceable>search_path</varname>
|
||||||
@ -1147,12 +1141,11 @@ passthru = {
|
|||||||
By default, when cross compiling, the configure script has
|
By default, when cross compiling, the configure script has
|
||||||
<option>--build=...</option> and <option>--host=...</option> passed.
|
<option>--build=...</option> and <option>--host=...</option> passed.
|
||||||
Packages can instead pass <literal>[ "build" "host" "target" ]</literal>
|
Packages can instead pass <literal>[ "build" "host" "target" ]</literal>
|
||||||
or a subset to control exactly which platform flags are passed.
|
or a subset to control exactly which platform flags are passed. Compilers
|
||||||
Compilers and other tools should use this to also pass the target
|
and other tools can use this to also pass the target platform.
|
||||||
platform, for example.
|
<footnote xml:id="footnote-stdenv-build-time-guessing-impurity">
|
||||||
<footnote>
|
|
||||||
<para>
|
<para>
|
||||||
Eventually these will be passed when in native builds too, to improve
|
Eventually these will be passed building natively as well, to improve
|
||||||
determinism: build-time guessing, as is done today, is a risk of
|
determinism: build-time guessing, as is done today, is a risk of
|
||||||
impurity.
|
impurity.
|
||||||
</para>
|
</para>
|
||||||
@ -1217,17 +1210,6 @@ passthru = {
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
|
||||||
<term>
|
|
||||||
<varname>checkInputs</varname>
|
|
||||||
</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
A list of dependencies used by the phase. This gets included in
|
|
||||||
<varname>buildInputs</varname> when <varname>doCheck</varname> is set.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<varname>makeFlags</varname>
|
<varname>makeFlags</varname>
|
||||||
@ -1377,6 +1359,18 @@ makeFlagsArray=(CFLAGS="-O0 -g" LDFLAGS="-lfoo -lbar")
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>checkInputs</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
A list of dependencies used by the phase. This gets included in
|
||||||
|
<varname>nativeBuildInputs</varname> when <varname>doCheck</varname> is
|
||||||
|
set.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<varname>preCheck</varname>
|
<varname>preCheck</varname>
|
||||||
@ -1649,13 +1643,11 @@ installTargets = "install-bin install-doc";</programlisting>
|
|||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
A package can export a <link
|
A package can export a <link linkend="ssec-setup-hooks">setup hook</link>
|
||||||
linkend="ssec-setup-hooks">setup
|
by setting this variable. The setup hook, if defined, is copied to
|
||||||
hook</link> by setting this variable. The setup hook, if defined, is
|
<filename>$out/nix-support/setup-hook</filename>. Environment variables
|
||||||
copied to <filename>$out/nix-support/setup-hook</filename>. Environment
|
are then substituted in it using <function
|
||||||
variables are then substituted in it using
|
linkend="fun-substituteAll">substituteAll</function>.
|
||||||
<function
|
|
||||||
linkend="fun-substituteAll">substituteAll</function>.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -1739,6 +1731,29 @@ set debug-file-directory ~/.nix-profile/lib/debug
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>installCheckTarget</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The make target that runs the install tests. Defaults to
|
||||||
|
<literal>installcheck</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>installCheckFlags</varname> / <varname>installCheckFlagsArray</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
A list of strings passed as additional flags to <command>make</command>.
|
||||||
|
Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>,
|
||||||
|
but only used by the installCheck phase.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<varname>installCheckInputs</varname>
|
<varname>installCheckInputs</varname>
|
||||||
@ -2065,47 +2080,46 @@ someVar=$(stripHash $name)
|
|||||||
<title>Package setup hooks</title>
|
<title>Package setup hooks</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Nix itself considers a build-time dependency merely something that should
|
Nix itself considers a build-time dependency as merely something that should
|
||||||
previously be built and accessible at build time—packages themselves are
|
previously be built and accessible at build time—packages themselves are
|
||||||
on their own to perform any additional setup. In most cases, that is fine,
|
on their own to perform any additional setup. In most cases, that is fine,
|
||||||
and the downstream derivation can deal with it's own dependencies. But for a
|
and the downstream derivation can deal with its own dependencies. But for a
|
||||||
few common tasks, that would result in almost every package doing the same
|
few common tasks, that would result in almost every package doing the same
|
||||||
sort of setup work---depending not on the package itself, but entirely on
|
sort of setup work—depending not on the package itself, but entirely on
|
||||||
which dependencies were used.
|
which dependencies were used.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
In order to alleviate this burden, the <firstterm>setup
|
In order to alleviate this burden, the <firstterm>setup hook</firstterm>
|
||||||
hook></firstterm>mechanism was written, where any package can include a
|
mechanism was written, where any package can include a shell script that [by
|
||||||
shell script that [by convention rather than enforcement by Nix], any
|
convention rather than enforcement by Nix], any downstream
|
||||||
downstream reverse-dependency will source as part of its build process. That
|
reverse-dependency will source as part of its build process. That allows the
|
||||||
allows the downstream dependency to merely specify its dependencies, and
|
downstream dependency to merely specify its dependencies, and lets those
|
||||||
lets those dependencies effectively initialize themselves. No boilerplate
|
dependencies effectively initialize themselves. No boilerplate mirroring the
|
||||||
mirroring the list of dependencies is needed.
|
list of dependencies is needed.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The Setup hook mechanism is a bit of a sledgehammer though: a powerful
|
The setup hook mechanism is a bit of a sledgehammer though: a powerful
|
||||||
feature with a broad and indiscriminate area of effect. The combination of
|
feature with a broad and indiscriminate area of effect. The combination of
|
||||||
its power and implicit use may be expedient, but isn't without costs. Nix
|
its power and implicit use may be expedient, but isn't without costs. Nix
|
||||||
itself is unchanged, but the spirit of adding dependencies being effect-free
|
itself is unchanged, but the spirit of added dependencies being effect-free
|
||||||
is violated even if the letter isn't. For example, if a derivation path is
|
is violated even if the letter isn't. For example, if a derivation path is
|
||||||
mentioned more than once, Nix itself doesn't care and simply makes sure the
|
mentioned more than once, Nix itself doesn't care and simply makes sure the
|
||||||
dependency derivation is already built just the same—depending is just
|
dependency derivation is already built just the same—depending is just
|
||||||
needing something to exist, and needing is idempotent. However, a dependency
|
needing something to exist, and needing is idempotent. However, a dependency
|
||||||
specified twice will have its setup hook run twice, and that could easily
|
specified twice will have its setup hook run twice, and that could easily
|
||||||
change the build environment (though a well-written setup hook will
|
change the build environment (though a well-written setup hook will therefore
|
||||||
therefore strive to be idempotent so this is in fact not observable). More
|
strive to be idempotent so this is in fact not observable). More broadly,
|
||||||
broadly, setup hooks are anti-modular in that multiple dependencies, whether
|
setup hooks are anti-modular in that multiple dependencies, whether the same
|
||||||
the same or different, should not interfere and yet their setup hooks may
|
or different, should not interfere and yet their setup hooks may well do so.
|
||||||
well do so.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The most typical use of the setup hook is actually to add other hooks which
|
The most typical use of the setup hook is actually to add other hooks which
|
||||||
are then run (i.e. after all the setup hooks) on each dependency. For
|
are then run (i.e. after all the setup hooks) on each dependency. For
|
||||||
example, the C compiler wrapper's setup hook feeds itself flags for each
|
example, the C compiler wrapper's setup hook feeds itself flags for each
|
||||||
dependency that contains relevant libaries and headers. This is done by
|
dependency that contains relevant libraries and headers. This is done by
|
||||||
defining a bash function, and appending its name to one of
|
defining a bash function, and appending its name to one of
|
||||||
<envar>envBuildBuildHooks</envar>`, <envar>envBuildHostHooks</envar>`,
|
<envar>envBuildBuildHooks</envar>`, <envar>envBuildHostHooks</envar>`,
|
||||||
<envar>envBuildTargetHooks</envar>`, <envar>envHostHostHooks</envar>`,
|
<envar>envBuildTargetHooks</envar>`, <envar>envHostHostHooks</envar>`,
|
||||||
@ -2117,15 +2131,14 @@ someVar=$(stripHash $name)
|
|||||||
<para>
|
<para>
|
||||||
Packages adding a hook should not hard code a specific hook, but rather
|
Packages adding a hook should not hard code a specific hook, but rather
|
||||||
choose a variable <emphasis>relative</emphasis> to how they are included.
|
choose a variable <emphasis>relative</emphasis> to how they are included.
|
||||||
Returning to the C compiler wrapper example, if it itself is an
|
Returning to the C compiler wrapper example, if the wrapper itself is an
|
||||||
<literal>n</literal> dependency, then it only wants to accumulate flags from
|
<literal>n</literal> dependency, then it only wants to accumulate flags from
|
||||||
<literal>n + 1</literal> dependencies, as only those ones match the
|
<literal>n + 1</literal> dependencies, as only those ones match the
|
||||||
compiler's target platform. The <envar>hostOffset</envar> variable is
|
compiler's target platform. The <envar>hostOffset</envar> variable is defined
|
||||||
defined with the current dependency's host offset
|
with the current dependency's host offset <envar>targetOffset</envar> with
|
||||||
<envar>targetOffset</envar> with its target offset, before it's setup hook
|
its target offset, before its setup hook is sourced. Additionally, since most
|
||||||
is sourced. Additionally, since most environment hooks don't care about the
|
environment hooks don't care about the target platform, that means the setup
|
||||||
target platform, That means the setup hook can append to the right bash
|
hook can append to the right bash array by doing something like
|
||||||
array by doing something like
|
|
||||||
<programlisting language="bash">
|
<programlisting language="bash">
|
||||||
addEnvHooks "$hostOffset" myBashFunction
|
addEnvHooks "$hostOffset" myBashFunction
|
||||||
</programlisting>
|
</programlisting>
|
||||||
@ -2133,7 +2146,7 @@ addEnvHooks "$hostOffset" myBashFunction
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
The <emphasis>existence</emphasis> of setups hooks has long been documented
|
The <emphasis>existence</emphasis> of setups hooks has long been documented
|
||||||
and packages inside Nixpkgs are free to use these mechanism. Other packages,
|
and packages inside Nixpkgs are free to use this mechanism. Other packages,
|
||||||
however, should not rely on these mechanisms not changing between Nixpkgs
|
however, should not rely on these mechanisms not changing between Nixpkgs
|
||||||
versions. Because of the existing issues with this system, there's little
|
versions. Because of the existing issues with this system, there's little
|
||||||
benefit from mandating it be stable for any period of time.
|
benefit from mandating it be stable for any period of time.
|
||||||
@ -2150,19 +2163,19 @@ addEnvHooks "$hostOffset" myBashFunction
|
|||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Bintools Wrapper wraps the binary utilities for a bunch of miscellaneous
|
The Bintools Wrapper wraps the binary utilities for a bunch of
|
||||||
purposes. These are GNU Binutils when targetting Linux, and a mix of
|
miscellaneous purposes. These are GNU Binutils when targetting Linux, and
|
||||||
cctools and GNU binutils for Darwin. [The "Bintools" name is supposed to
|
a mix of cctools and GNU binutils for Darwin. [The "Bintools" name is
|
||||||
be a compromise between "Binutils" and "cctools" not denoting any
|
supposed to be a compromise between "Binutils" and "cctools" not denoting
|
||||||
specific implementation.] Specifically, the underlying bintools package,
|
any specific implementation.] Specifically, the underlying bintools
|
||||||
and a C standard library (glibc or Darwin's libSystem, just for the
|
package, and a C standard library (glibc or Darwin's libSystem, just for
|
||||||
dynamic loader) are all fed in, and dependency finding, hardening (see
|
the dynamic loader) are all fed in, and dependency finding, hardening
|
||||||
below), and purity checks for each are handled by Bintools Wrapper.
|
(see below), and purity checks for each are handled by the Bintools
|
||||||
Packages typically depend on CC Wrapper, which in turn (at run time)
|
Wrapper. Packages typically depend on CC Wrapper, which in turn (at run
|
||||||
depends on Bintools Wrapper.
|
time) depends on the Bintools Wrapper.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Bintools Wrapper was only just recently split off from CC Wrapper, so
|
The Bintools Wrapper was only just recently split off from CC Wrapper, so
|
||||||
the division of labor is still being worked out. For example, it
|
the division of labor is still being worked out. For example, it
|
||||||
shouldn't care about about the C standard library, but just take a
|
shouldn't care about about the C standard library, but just take a
|
||||||
derivation with the dynamic loader (which happens to be the glibc on
|
derivation with the dynamic loader (which happens to be the glibc on
|
||||||
@ -2170,26 +2183,26 @@ addEnvHooks "$hostOffset" myBashFunction
|
|||||||
to need to share, and probably the most important to understand. It is
|
to need to share, and probably the most important to understand. It is
|
||||||
currently accomplished by collecting directories of host-platform
|
currently accomplished by collecting directories of host-platform
|
||||||
dependencies (i.e. <varname>buildInputs</varname> and
|
dependencies (i.e. <varname>buildInputs</varname> and
|
||||||
<varname>nativeBuildInputs</varname>) in environment variables. Bintools
|
<varname>nativeBuildInputs</varname>) in environment variables. The
|
||||||
Wrapper's setup hook causes any <filename>lib</filename> and
|
Bintools Wrapper's setup hook causes any <filename>lib</filename> and
|
||||||
<filename>lib64</filename> subdirectories to be added to
|
<filename>lib64</filename> subdirectories to be added to
|
||||||
<envar>NIX_LDFLAGS</envar>. Since CC Wrapper and Bintools Wrapper use
|
<envar>NIX_LDFLAGS</envar>. Since the CC Wrapper and the Bintools Wrapper
|
||||||
the same strategy, most of the Bintools Wrapper code is sparsely
|
use the same strategy, most of the Bintools Wrapper code is sparsely
|
||||||
commented and refers to CC Wrapper. But CC Wrapper's code, by contrast,
|
commented and refers to the CC Wrapper. But the CC Wrapper's code, by
|
||||||
has quite lengthy comments. Bintools Wrapper merely cites those, rather
|
contrast, has quite lengthy comments. The Bintools Wrapper merely cites
|
||||||
than repeating them, to avoid falling out of sync.
|
those, rather than repeating them, to avoid falling out of sync.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
A final task of the setup hook is defining a number of standard
|
A final task of the setup hook is defining a number of standard
|
||||||
environment variables to tell build systems which executables full-fill
|
environment variables to tell build systems which executables fulfill
|
||||||
which purpose. They are defined to just be the base name of the tools,
|
which purpose. They are defined to just be the base name of the tools,
|
||||||
under the assumption that Bintools Wrapper's binaries will be on the
|
under the assumption that the Bintools Wrapper's binaries will be on the
|
||||||
path. Firstly, this helps poorly-written packages, e.g. ones that look
|
path. Firstly, this helps poorly-written packages, e.g. ones that look
|
||||||
for just <command>gcc</command> when <envar>CC</envar> isn't defined yet
|
for just <command>gcc</command> when <envar>CC</envar> isn't defined yet
|
||||||
<command>clang</command> is to be used. Secondly, this helps packages
|
<command>clang</command> is to be used. Secondly, this helps packages not
|
||||||
not get confused when cross-compiling, in which case multiple Bintools
|
get confused when cross-compiling, in which case multiple Bintools
|
||||||
Wrappers may simultaneously be in use.
|
Wrappers may simultaneously be in use.
|
||||||
<footnote>
|
<footnote xml:id="footnote-stdenv-per-platform-wrapper">
|
||||||
<para>
|
<para>
|
||||||
Each wrapper targets a single platform, so if binaries for multiple
|
Each wrapper targets a single platform, so if binaries for multiple
|
||||||
platforms are needed, the underlying binaries must be wrapped multiple
|
platforms are needed, the underlying binaries must be wrapped multiple
|
||||||
@ -2199,20 +2212,20 @@ addEnvHooks "$hostOffset" myBashFunction
|
|||||||
</para>
|
</para>
|
||||||
</footnote>
|
</footnote>
|
||||||
<envar>BUILD_</envar>- and <envar>TARGET_</envar>-prefixed versions of
|
<envar>BUILD_</envar>- and <envar>TARGET_</envar>-prefixed versions of
|
||||||
the normal environment variable are defined for the additional Bintools
|
the normal environment variable are defined for additional Bintools
|
||||||
Wrappers, properly disambiguating them.
|
Wrappers, properly disambiguating them.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
A problem with this final task is that Bintools Wrapper is honest and
|
A problem with this final task is that the Bintools Wrapper is honest and
|
||||||
defines <envar>LD</envar> as <command>ld</command>. Most packages,
|
defines <envar>LD</envar> as <command>ld</command>. Most packages,
|
||||||
however, firstly use the C compiler for linking, secondly use
|
however, firstly use the C compiler for linking, secondly use
|
||||||
<envar>LD</envar> anyways, defining it as the C compiler, and thirdly,
|
<envar>LD</envar> anyways, defining it as the C compiler, and thirdly,
|
||||||
only so define <envar>LD</envar> when it is undefined as a fallback.
|
only so define <envar>LD</envar> when it is undefined as a fallback. This
|
||||||
This triple-threat means Bintools Wrapper will break those packages, as
|
triple-threat means Bintools Wrapper will break those packages, as LD is
|
||||||
LD is already defined as the actual linker which the package won't
|
already defined as the actual linker which the package won't override yet
|
||||||
override yet doesn't want to use. The workaround is to define, just for
|
doesn't want to use. The workaround is to define, just for the
|
||||||
the problematic package, <envar>LD</envar> as the C compiler. A good way
|
problematic package, <envar>LD</envar> as the C compiler. A good way to
|
||||||
to do this would be <command>preConfigure = "LD=$CC"</command>.
|
do this would be <command>preConfigure = "LD=$CC"</command>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -2222,30 +2235,31 @@ addEnvHooks "$hostOffset" myBashFunction
|
|||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
CC Wrapper wraps a C toolchain for a bunch of miscellaneous purposes.
|
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
|
Specifically, a C compiler (GCC or Clang), wrapped binary tools, and a C
|
||||||
standard library (glibc or Darwin's libSystem, just for the dynamic
|
standard library (glibc or Darwin's libSystem, just for the dynamic
|
||||||
loader) are all fed in, and dependency finding, hardening (see below),
|
loader) are all fed in, and dependency finding, hardening (see below),
|
||||||
and purity checks for each are handled by CC Wrapper. Packages typically
|
and purity checks for each are handled by the CC Wrapper. Packages
|
||||||
depend on CC Wrapper, which in turn (at run time) depends on Bintools
|
typically depend on the CC Wrapper, which in turn (at run-time) depends
|
||||||
Wrapper.
|
on the Bintools Wrapper.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Dependency finding is undoubtedly the main task of CC Wrapper. This
|
Dependency finding is undoubtedly the main task of the CC Wrapper. This
|
||||||
works just like Bintools Wrapper, except that any
|
works just like the Bintools Wrapper, except that any
|
||||||
<filename>include</filename> subdirectory of any relevant dependency is
|
<filename>include</filename> subdirectory of any relevant dependency is
|
||||||
added to <envar>NIX_CFLAGS_COMPILE</envar>. The setup hook itself
|
added to <envar>NIX_CFLAGS_COMPILE</envar>. The setup hook itself
|
||||||
contains some lengthy comments describing the exact convoluted mechanism
|
contains some lengthy comments describing the exact convoluted mechanism
|
||||||
by which this is accomplished.
|
by which this is accomplished.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
CC Wrapper also like Bintools Wrapper defines standard environment
|
Similarly, the CC Wrapper follows the Bintools Wrapper in defining
|
||||||
variables with the names of the tools it wraps, for the same reasons
|
standard environment variables with the names of the tools it wraps, for
|
||||||
described above. Importantly, while it includes a <command>cc</command>
|
the same reasons described above. Importantly, while it includes a
|
||||||
symlink to the c compiler for portability, the <envar>CC</envar> will be
|
<command>cc</command> symlink to the c compiler for portability, the
|
||||||
defined using the compiler's "real name" (i.e. <command>gcc</command> or
|
<envar>CC</envar> will be defined using the compiler's "real name" (i.e.
|
||||||
<command>clang</command>). This helps lousy build systems that inspect
|
<command>gcc</command> or <command>clang</command>). This helps lousy
|
||||||
on the name of the compiler rather than run it.
|
build systems that inspect on the name of the compiler rather than run
|
||||||
|
it.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -2305,9 +2319,11 @@ addEnvHooks "$hostOffset" myBashFunction
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The <varname>autoreconfHook</varname> derivation adds
|
The <varname>autoreconfHook</varname> derivation adds
|
||||||
<varname>autoreconfPhase</varname>, which runs autoreconf, libtoolize
|
<varname>autoreconfPhase</varname>, which runs autoreconf, libtoolize and
|
||||||
and automake, essentially preparing the configure script in
|
automake, essentially preparing the configure script in autotools-based
|
||||||
autotools-based builds.
|
builds. Most autotools-based packages come with the configure script
|
||||||
|
pre-generated, but this hook is necessary for a few packages and when you
|
||||||
|
need to patch the package’s configure scripts.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -2351,9 +2367,9 @@ addEnvHooks "$hostOffset" myBashFunction
|
|||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Exports <envar>GDK_PIXBUF_MODULE_FILE</envar> environment variable the
|
Exports <envar>GDK_PIXBUF_MODULE_FILE</envar> environment variable to the
|
||||||
the builder. Add librsvg package to <varname>buildInputs</varname> to
|
builder. Add librsvg package to <varname>buildInputs</varname> to get svg
|
||||||
get svg support.
|
support.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -2390,7 +2406,7 @@ addEnvHooks "$hostOffset" myBashFunction
|
|||||||
PaX flags on Linux (where it is available by default; on all other
|
PaX flags on Linux (where it is available by default; on all other
|
||||||
platforms, <varname>paxmark</varname> is a no-op). For example, to
|
platforms, <varname>paxmark</varname> is a no-op). For example, to
|
||||||
disable secure memory protections on the executable
|
disable secure memory protections on the executable
|
||||||
<replaceable>foo</replaceable>:
|
<replaceable>foo</replaceable>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
postFixup = ''
|
postFixup = ''
|
||||||
paxmark m $out/bin/<replaceable>foo</replaceable>
|
paxmark m $out/bin/<replaceable>foo</replaceable>
|
||||||
@ -2412,16 +2428,164 @@ addEnvHooks "$hostOffset" myBashFunction
|
|||||||
<para>
|
<para>
|
||||||
This is a special setup hook which helps in packaging proprietary
|
This is a special setup hook which helps in packaging proprietary
|
||||||
software in that it automatically tries to find missing shared library
|
software in that it automatically tries to find missing shared library
|
||||||
dependencies of ELF files. All packages within the
|
dependencies of ELF files based on the given
|
||||||
<envar>runtimeDependencies</envar> environment variable are
|
<varname>buildInputs</varname> and <varname>nativeBuildInputs</varname>.
|
||||||
unconditionally added to executables, which is useful for programs that
|
</para>
|
||||||
use <citerefentry>
|
<para>
|
||||||
<refentrytitle>dlopen</refentrytitle>
|
You can also specify a <envar>runtimeDependencies</envar> environment
|
||||||
<manvolnum>3</manvolnum> </citerefentry> to load libraries at runtime.
|
variable which lists dependencies that are unconditionally added to all
|
||||||
|
executables.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
This is useful for programs that use <citerefentry>
|
||||||
|
<refentrytitle>dlopen</refentrytitle>
|
||||||
|
<manvolnum>3</manvolnum>
|
||||||
|
</citerefentry> to load libraries at runtime.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
In certain situations you may want to run the main command
|
||||||
|
(<command>autoPatchelf</command>) of the setup hook on a file or a set
|
||||||
|
of directories instead of unconditionally patching all outputs. This
|
||||||
|
can be done by setting the <envar>dontAutoPatchelf</envar> environment
|
||||||
|
variable to a non-empty value.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The <command>autoPatchelf</command> command also recognizes a
|
||||||
|
<parameter class="command">--no-recurse</parameter> command line flag,
|
||||||
|
which prevents it from recursing into subdirectories.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
breakpointHook
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
This hook will make a build pause instead of stopping when a failure
|
||||||
|
happen. It prevents nix to cleanup the build environment immediatly and
|
||||||
|
allows the user to attach to a build environment using the
|
||||||
|
<command>cntr</command> command. On build error it will print the
|
||||||
|
instruction that are neccessary for <command>cntr</command>. Installing
|
||||||
|
cntr and running the command will provide shell access to the build
|
||||||
|
sandbox of failed build. At <filename>/var/lib/cntr</filename> the
|
||||||
|
sandbox 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. Note that <command>cntr</command> also
|
||||||
|
needs to be executed on the machine that is doing the build, which might
|
||||||
|
be not the case when remote builders are enabled.
|
||||||
|
<command>cntr</command> is only supported on Linux-based platforms. To
|
||||||
|
use it first add <literal>cntr</literal> to your
|
||||||
|
<literal>environment.systemPackages</literal> on NixOS or alternatively to
|
||||||
|
the root user on non-NixOS systems. Then in the package that is supposed
|
||||||
|
to be inspected, add <literal>breakpointHook</literal> to
|
||||||
|
<literal>nativeBuildInputs</literal>.
|
||||||
|
<programlisting>
|
||||||
|
nativeBuildInputs = [ breakpointHook ];
|
||||||
|
</programlisting>
|
||||||
|
When a build failure happens there will be an instruction printed that
|
||||||
|
shows how to attach with <literal>cntr</literal> to the build sandbox.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
cmake
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
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.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
xcbuildHook
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
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.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
meson
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Overrides the configure phase to run meson to generate Ninja files. You
|
||||||
|
can disable this behavior by setting configurePhase to a custom value,
|
||||||
|
or by setting dontUseMesonConfigure. To run these files, you should
|
||||||
|
accompany meson with ninja. mesonFlags controls only the flags passed
|
||||||
|
to meson. By default, parallel building is enabled as Meson supports
|
||||||
|
parallel building almost everywhere.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
ninja
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
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.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
unzip
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
This setup hook will allow you to unzip .zip files specified in $src.
|
||||||
|
There are many similar packages like unrar, undmg, etc.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
wafHook
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Overrides the configure, build, and install phases. This will run the
|
||||||
|
"waf" script used by many projects. If 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.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
scons
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
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.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section xml:id="sec-purity-in-nixpkgs">
|
<section xml:id="sec-purity-in-nixpkgs">
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
xml:id="chap-submitting-changes">
|
xml:id="chap-submitting-changes">
|
||||||
<title>Submitting changes</title>
|
<title>Submitting changes</title>
|
||||||
<section>
|
<section xml:id="submitting-changes-making-patches">
|
||||||
<title>Making patches</title>
|
<title>Making patches</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
@ -205,7 +205,7 @@ Additional information.
|
|||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="submitting-changes-submitting-changes">
|
||||||
<title>Submitting changes</title>
|
<title>Submitting changes</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
@ -253,7 +253,7 @@ Additional information.
|
|||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="submitting-changes-pull-request-template">
|
||||||
<title>Pull Request Template</title>
|
<title>Pull Request Template</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -269,7 +269,7 @@ Additional information.
|
|||||||
below:
|
below:
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<section>
|
<section xml:id="submitting-changes-tested-with-sandbox">
|
||||||
<title>Tested using sandboxing</title>
|
<title>Tested using sandboxing</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -322,7 +322,7 @@ Additional information.
|
|||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="submitting-changes-platform-diversity">
|
||||||
<title>Built on platform(s)</title>
|
<title>Built on platform(s)</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -334,7 +334,7 @@ Additional information.
|
|||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="submitting-changes-nixos-tests">
|
||||||
<title>Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)</title>
|
<title>Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -350,7 +350,7 @@ Additional information.
|
|||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="submitting-changes-tested-compilation">
|
||||||
<title>Tested compilation of all pkgs that depend on this change using <command>nox-review</command></title>
|
<title>Tested compilation of all pkgs that depend on this change using <command>nox-review</command></title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -373,7 +373,7 @@ Additional information.
|
|||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="submitting-changes-tested-execution">
|
||||||
<title>Tested execution of all binary files (usually in <filename>./result/bin/</filename>)</title>
|
<title>Tested execution of all binary files (usually in <filename>./result/bin/</filename>)</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -387,8 +387,8 @@ Additional information.
|
|||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="submitting-changes-contribution-standards">
|
||||||
<title>Meets nixpkgs contribution standards</title>
|
<title>Meets Nixpkgs contribution standards</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The last checkbox is fits
|
The last checkbox is fits
|
||||||
@ -402,7 +402,7 @@ Additional information.
|
|||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="submitting-changes-hotfixing-pull-requests">
|
||||||
<title>Hotfixing pull requests</title>
|
<title>Hotfixing pull requests</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
@ -430,7 +430,7 @@ Additional information.
|
|||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="submitting-changes-commit-policy">
|
||||||
<title>Commit policy</title>
|
<title>Commit policy</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
@ -456,7 +456,7 @@ Additional information.
|
|||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
<section>
|
<section xml:id="submitting-changes-master-branch">
|
||||||
<title>Master branch</title>
|
<title>Master branch</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
@ -468,7 +468,7 @@ Additional information.
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="submitting-changes-staging-branch">
|
||||||
<title>Staging branch</title>
|
<title>Staging branch</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
@ -493,7 +493,7 @@ Additional information.
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section xml:id="submitting-changes-stable-release-branches">
|
||||||
<title>Stable release branches</title>
|
<title>Stable release branches</title>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
44
lib/asserts.nix
Normal file
44
lib/asserts.nix
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{ lib }:
|
||||||
|
|
||||||
|
rec {
|
||||||
|
|
||||||
|
/* Print a trace message if pred is false.
|
||||||
|
Intended to be used to augment asserts with helpful error messages.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
assertMsg false "nope"
|
||||||
|
=> false
|
||||||
|
stderr> trace: nope
|
||||||
|
|
||||||
|
assert (assertMsg ("foo" == "bar") "foo is not bar, silly"); ""
|
||||||
|
stderr> trace: foo is not bar, silly
|
||||||
|
stderr> assert failed at …
|
||||||
|
|
||||||
|
Type:
|
||||||
|
assertMsg :: Bool -> String -> Bool
|
||||||
|
*/
|
||||||
|
# TODO(Profpatsch): add tests that check stderr
|
||||||
|
assertMsg = pred: msg:
|
||||||
|
if pred
|
||||||
|
then true
|
||||||
|
else builtins.trace msg false;
|
||||||
|
|
||||||
|
/* Specialized `assertMsg` for checking if val is one of the elements
|
||||||
|
of a list. Useful for checking enums.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
let sslLibrary = "libressl"
|
||||||
|
in assertOneOf "sslLibrary" sslLibrary [ "openssl" "bearssl" ]
|
||||||
|
=> false
|
||||||
|
stderr> trace: sslLibrary must be one of "openssl", "bearssl", but is: "libressl"
|
||||||
|
|
||||||
|
Type:
|
||||||
|
assertOneOf :: String -> ComparableVal -> List ComparableVal -> Bool
|
||||||
|
*/
|
||||||
|
assertOneOf = name: val: xs: assertMsg
|
||||||
|
(lib.elem val xs)
|
||||||
|
"${name} must be one of ${
|
||||||
|
lib.generators.toPretty {} xs}, but is: ${
|
||||||
|
lib.generators.toPretty {} val}";
|
||||||
|
|
||||||
|
}
|
@ -145,7 +145,7 @@ rec {
|
|||||||
foldAttrs = op: nul: list_of_attrs:
|
foldAttrs = op: nul: list_of_attrs:
|
||||||
fold (n: a:
|
fold (n: a:
|
||||||
fold (name: o:
|
fold (name: o:
|
||||||
o // (listToAttrs [{inherit name; value = op n.${name} (a.${name} or nul); }])
|
o // { ${name} = op n.${name} (a.${name} or nul); }
|
||||||
) a (attrNames n)
|
) a (attrNames n)
|
||||||
) {} list_of_attrs;
|
) {} list_of_attrs;
|
||||||
|
|
||||||
@ -384,11 +384,12 @@ rec {
|
|||||||
recursiveUpdateUntil = pred: lhs: rhs:
|
recursiveUpdateUntil = pred: lhs: rhs:
|
||||||
let f = attrPath:
|
let f = attrPath:
|
||||||
zipAttrsWith (n: values:
|
zipAttrsWith (n: values:
|
||||||
|
let here = attrPath ++ [n]; in
|
||||||
if tail values == []
|
if tail values == []
|
||||||
|| pred attrPath (head (tail values)) (head values) then
|
|| pred here (head (tail values)) (head values) then
|
||||||
head values
|
head values
|
||||||
else
|
else
|
||||||
f (attrPath ++ [n]) values
|
f here values
|
||||||
);
|
);
|
||||||
in f [] [rhs lhs];
|
in f [] [rhs lhs];
|
||||||
|
|
||||||
@ -434,12 +435,15 @@ rec {
|
|||||||
useful for deep-overriding.
|
useful for deep-overriding.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
x = { a = { b = 4; c = 3; }; }
|
overrideExisting {} { a = 1; }
|
||||||
overrideExisting x { a = { b = 6; d = 2; }; }
|
=> {}
|
||||||
=> { a = { b = 6; d = 2; }; }
|
overrideExisting { b = 2; } { a = 1; }
|
||||||
|
=> { b = 2; }
|
||||||
|
overrideExisting { a = 3; b = 2; } { a = 1; }
|
||||||
|
=> { a = 1; b = 2; }
|
||||||
*/
|
*/
|
||||||
overrideExisting = old: new:
|
overrideExisting = old: new:
|
||||||
old // listToAttrs (map (attr: nameValuePair attr (attrByPath [attr] old.${attr} new)) (attrNames old));
|
mapAttrs (name: value: new.${name} or value) old;
|
||||||
|
|
||||||
/* Get a package output.
|
/* Get a package output.
|
||||||
If no output is found, fallback to `.out` and then to the default.
|
If no output is found, fallback to `.out` and then to the default.
|
||||||
|
@ -185,7 +185,7 @@ rec {
|
|||||||
/* Make a set of packages with a common scope. All packages called
|
/* Make a set of packages with a common scope. All packages called
|
||||||
with the provided `callPackage' will be evaluated with the same
|
with the provided `callPackage' will be evaluated with the same
|
||||||
arguments. Any package in the set may depend on any other. The
|
arguments. Any package in the set may depend on any other. The
|
||||||
`overrideScope' function allows subsequent modification of the package
|
`overrideScope'` function allows subsequent modification of the package
|
||||||
set in a consistent way, i.e. all packages in the set will be
|
set in a consistent way, i.e. all packages in the set will be
|
||||||
called with the overridden packages. The package sets may be
|
called with the overridden packages. The package sets may be
|
||||||
hierarchical: the packages in the set are called with the scope
|
hierarchical: the packages in the set are called with the scope
|
||||||
@ -195,9 +195,10 @@ rec {
|
|||||||
let self = f self // {
|
let self = f self // {
|
||||||
newScope = scope: newScope (self // scope);
|
newScope = scope: newScope (self // scope);
|
||||||
callPackage = self.newScope {};
|
callPackage = self.newScope {};
|
||||||
overrideScope = g:
|
overrideScope = g: lib.warn
|
||||||
makeScope newScope
|
"`overrideScope` (from `lib.makeScope`) is deprecated. Do `overrideScope' (self: super: { … })` instead of `overrideScope (super: self: { … })`. All other overrides have the parameters in that order, including other definitions of `overrideScope`. This was the only definition violating the pattern."
|
||||||
(self_: let super = f self_; in super // g super self_);
|
(makeScope newScope (lib.fixedPoints.extends (lib.flip g) f));
|
||||||
|
overrideScope' = g: makeScope newScope (lib.fixedPoints.extends g f);
|
||||||
packages = f;
|
packages = f;
|
||||||
};
|
};
|
||||||
in self;
|
in self;
|
||||||
|
@ -23,27 +23,54 @@ rec {
|
|||||||
|
|
||||||
# -- TRACING --
|
# -- TRACING --
|
||||||
|
|
||||||
/* Trace msg, but only if pred is true.
|
/* Conditionally trace the supplied message, based on a predicate.
|
||||||
|
|
||||||
|
Type: traceIf :: bool -> string -> a -> a
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
traceIf true "hello" 3
|
traceIf true "hello" 3
|
||||||
trace: hello
|
trace: hello
|
||||||
=> 3
|
=> 3
|
||||||
*/
|
*/
|
||||||
traceIf = pred: msg: x: if pred then trace msg x else x;
|
traceIf =
|
||||||
|
# Predicate to check
|
||||||
|
pred:
|
||||||
|
# Message that should be traced
|
||||||
|
msg:
|
||||||
|
# Value to return
|
||||||
|
x: if pred then trace msg x else x;
|
||||||
|
|
||||||
/* Trace the value and also return it.
|
/* Trace the supplied value after applying a function to it, and
|
||||||
|
return the original value.
|
||||||
|
|
||||||
|
Type: traceValFn :: (a -> b) -> a -> a
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
traceValFn (v: "mystring ${v}") "foo"
|
traceValFn (v: "mystring ${v}") "foo"
|
||||||
trace: mystring foo
|
trace: mystring foo
|
||||||
=> "foo"
|
=> "foo"
|
||||||
*/
|
*/
|
||||||
traceValFn = f: x: trace (f x) x;
|
traceValFn =
|
||||||
|
# Function to apply
|
||||||
|
f:
|
||||||
|
# Value to trace and return
|
||||||
|
x: trace (f x) x;
|
||||||
|
|
||||||
|
/* Trace the supplied value and return it.
|
||||||
|
|
||||||
|
Type: traceVal :: a -> a
|
||||||
|
|
||||||
|
Example:
|
||||||
|
traceVal 42
|
||||||
|
# trace: 42
|
||||||
|
=> 42
|
||||||
|
*/
|
||||||
traceVal = traceValFn id;
|
traceVal = traceValFn id;
|
||||||
|
|
||||||
/* `builtins.trace`, but the value is `builtins.deepSeq`ed first.
|
/* `builtins.trace`, but the value is `builtins.deepSeq`ed first.
|
||||||
|
|
||||||
|
Type: traceSeq :: a -> b -> b
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
trace { a.b.c = 3; } null
|
trace { a.b.c = 3; } null
|
||||||
trace: { a = <CODE>; }
|
trace: { a = <CODE>; }
|
||||||
@ -52,7 +79,11 @@ rec {
|
|||||||
trace: { a = { b = { c = 3; }; }; }
|
trace: { a = { b = { c = 3; }; }; }
|
||||||
=> null
|
=> null
|
||||||
*/
|
*/
|
||||||
traceSeq = x: y: trace (builtins.deepSeq x x) y;
|
traceSeq =
|
||||||
|
# The value to trace
|
||||||
|
x:
|
||||||
|
# The value to return
|
||||||
|
y: trace (builtins.deepSeq x x) y;
|
||||||
|
|
||||||
/* Like `traceSeq`, but only evaluate down to depth n.
|
/* Like `traceSeq`, but only evaluate down to depth n.
|
||||||
This is very useful because lots of `traceSeq` usages
|
This is very useful because lots of `traceSeq` usages
|
||||||
@ -76,27 +107,49 @@ rec {
|
|||||||
in trace (generators.toPretty { allowPrettyValues = true; }
|
in trace (generators.toPretty { allowPrettyValues = true; }
|
||||||
(modify depth snip x)) y;
|
(modify depth snip x)) y;
|
||||||
|
|
||||||
/* A combination of `traceVal` and `traceSeq` */
|
/* A combination of `traceVal` and `traceSeq` that applies a
|
||||||
traceValSeqFn = f: v: traceValFn f (builtins.deepSeq v v);
|
provided function to the value to be traced after `deepSeq`ing
|
||||||
|
it.
|
||||||
|
*/
|
||||||
|
traceValSeqFn =
|
||||||
|
# Function to apply
|
||||||
|
f:
|
||||||
|
# Value to trace
|
||||||
|
v: traceValFn f (builtins.deepSeq v v);
|
||||||
|
|
||||||
|
/* A combination of `traceVal` and `traceSeq`. */
|
||||||
traceValSeq = traceValSeqFn id;
|
traceValSeq = traceValSeqFn id;
|
||||||
|
|
||||||
|
/* A combination of `traceVal` and `traceSeqN` that applies a
|
||||||
|
provided function to the value to be traced. */
|
||||||
|
traceValSeqNFn =
|
||||||
|
# Function to apply
|
||||||
|
f:
|
||||||
|
depth:
|
||||||
|
# Value to trace
|
||||||
|
v: traceSeqN depth (f v) v;
|
||||||
|
|
||||||
/* A combination of `traceVal` and `traceSeqN`. */
|
/* A combination of `traceVal` and `traceSeqN`. */
|
||||||
traceValSeqNFn = f: depth: v: traceSeqN depth (f v) v;
|
|
||||||
traceValSeqN = traceValSeqNFn id;
|
traceValSeqN = traceValSeqNFn id;
|
||||||
|
|
||||||
|
|
||||||
# -- TESTING --
|
# -- TESTING --
|
||||||
|
|
||||||
/* Evaluate a set of tests. A test is an attribute set {expr,
|
/* Evaluate a set of tests. A test is an attribute set `{expr,
|
||||||
expected}, denoting an expression and its expected result. The
|
expected}`, denoting an expression and its expected result. The
|
||||||
result is a list of failed tests, each represented as {name,
|
result is a list of failed tests, each represented as `{name,
|
||||||
expected, actual}, denoting the attribute name of the failing
|
expected, actual}`, denoting the attribute name of the failing
|
||||||
test and its expected and actual results. Used for regression
|
test and its expected and actual results.
|
||||||
testing of the functions in lib; see tests.nix for an example.
|
|
||||||
Only tests having names starting with "test" are run.
|
Used for regression testing of the functions in lib; see
|
||||||
Add attr { tests = ["testName"]; } to run these test only
|
tests.nix for an example. Only tests having names starting with
|
||||||
|
"test" are run.
|
||||||
|
|
||||||
|
Add attr { tests = ["testName"]; } to run these tests only.
|
||||||
*/
|
*/
|
||||||
runTests = tests: lib.concatLists (lib.attrValues (lib.mapAttrs (name: test:
|
runTests =
|
||||||
|
# Tests to run
|
||||||
|
tests: lib.concatLists (lib.attrValues (lib.mapAttrs (name: test:
|
||||||
let testsToRun = if tests ? tests then tests.tests else [];
|
let testsToRun = if tests ? tests then tests.tests else [];
|
||||||
in if (substring 0 4 name == "test" || elem name testsToRun)
|
in if (substring 0 4 name == "test" || elem name testsToRun)
|
||||||
&& ((testsToRun == []) || elem name tests.tests)
|
&& ((testsToRun == []) || elem name tests.tests)
|
||||||
@ -105,8 +158,11 @@ rec {
|
|||||||
then [ { inherit name; expected = test.expected; result = test.expr; } ]
|
then [ { inherit name; expected = test.expected; result = test.expr; } ]
|
||||||
else [] ) tests));
|
else [] ) tests));
|
||||||
|
|
||||||
# create a test assuming that list elements are true
|
/* Create a test assuming that list elements are `true`.
|
||||||
# usage: { testX = allTrue [ true ]; }
|
|
||||||
|
Example:
|
||||||
|
{ testX = allTrue [ true ]; }
|
||||||
|
*/
|
||||||
testAllTrue = expr: { inherit expr; expected = map (x: true) expr; };
|
testAllTrue = expr: { inherit expr; expected = map (x: true) expr; };
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,10 +38,11 @@ let
|
|||||||
systems = callLibs ./systems;
|
systems = callLibs ./systems;
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
|
asserts = callLibs ./asserts.nix;
|
||||||
debug = callLibs ./debug.nix;
|
debug = callLibs ./debug.nix;
|
||||||
|
|
||||||
generators = callLibs ./generators.nix;
|
generators = callLibs ./generators.nix;
|
||||||
misc = callLibs ./deprecated.nix;
|
misc = callLibs ./deprecated.nix;
|
||||||
|
|
||||||
# domain-specific
|
# domain-specific
|
||||||
fetchers = callLibs ./fetchers.nix;
|
fetchers = callLibs ./fetchers.nix;
|
||||||
|
|
||||||
@ -60,7 +61,6 @@ let
|
|||||||
boolToString mergeAttrs flip mapNullable inNixShell min max
|
boolToString mergeAttrs flip mapNullable inNixShell min max
|
||||||
importJSON warn info nixpkgsVersion version mod compare
|
importJSON warn info nixpkgsVersion version mod compare
|
||||||
splitByAndCompare functionArgs setFunctionArgs isFunction;
|
splitByAndCompare functionArgs setFunctionArgs isFunction;
|
||||||
|
|
||||||
inherit (fixedPoints) fix fix' extends composeExtensions
|
inherit (fixedPoints) fix fix' extends composeExtensions
|
||||||
makeExtensible makeExtensibleWithCustomName;
|
makeExtensible makeExtensibleWithCustomName;
|
||||||
inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
|
inherit (attrsets) attrByPath hasAttrByPath setAttrByPath
|
||||||
@ -80,7 +80,7 @@ let
|
|||||||
inherit (strings) concatStrings concatMapStrings concatImapStrings
|
inherit (strings) concatStrings concatMapStrings concatImapStrings
|
||||||
intersperse concatStringsSep concatMapStringsSep
|
intersperse concatStringsSep concatMapStringsSep
|
||||||
concatImapStringsSep makeSearchPath makeSearchPathOutput
|
concatImapStringsSep makeSearchPath makeSearchPathOutput
|
||||||
makeLibraryPath makeBinPath makePerlPath optionalString
|
makeLibraryPath makeBinPath makePerlPath makeFullPerlPath optionalString
|
||||||
hasPrefix hasSuffix stringToCharacters stringAsChars escape
|
hasPrefix hasSuffix stringToCharacters stringAsChars escape
|
||||||
escapeShellArg escapeShellArgs replaceChars lowerChars
|
escapeShellArg escapeShellArgs replaceChars lowerChars
|
||||||
upperChars toLower toUpper addContextFrom splitString
|
upperChars toLower toUpper addContextFrom splitString
|
||||||
@ -117,6 +117,8 @@ let
|
|||||||
unknownModule mkOption;
|
unknownModule mkOption;
|
||||||
inherit (types) isType setType defaultTypeMerge defaultFunctor
|
inherit (types) isType setType defaultTypeMerge defaultFunctor
|
||||||
isOptionType mkOptionType;
|
isOptionType mkOptionType;
|
||||||
|
inherit (asserts)
|
||||||
|
assertMsg assertOneOf;
|
||||||
inherit (debug) addErrorContextToAttrs traceIf traceVal traceValFn
|
inherit (debug) addErrorContextToAttrs traceIf traceVal traceValFn
|
||||||
traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
|
traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
|
||||||
traceValSeqFn traceValSeqN traceValSeqNFn traceShowVal
|
traceValSeqFn traceValSeqN traceValSeqNFn traceShowVal
|
||||||
|
@ -41,6 +41,18 @@ rec {
|
|||||||
# think of it as an infix operator `g extends f` that mimics the syntax from
|
# think of it as an infix operator `g extends f` that mimics the syntax from
|
||||||
# Java. It may seem counter-intuitive to have the "base class" as the second
|
# Java. It may seem counter-intuitive to have the "base class" as the second
|
||||||
# argument, but it's nice this way if several uses of `extends` are cascaded.
|
# argument, but it's nice this way if several uses of `extends` are cascaded.
|
||||||
|
#
|
||||||
|
# To get a better understanding how `extends` turns a function with a fix
|
||||||
|
# point (the package set we start with) into a new function with a different fix
|
||||||
|
# point (the desired packages set) lets just see, how `extends g f`
|
||||||
|
# unfolds with `g` and `f` defined above:
|
||||||
|
#
|
||||||
|
# extends g f = self: let super = f self; in super // g self super;
|
||||||
|
# = self: let super = { foo = "foo"; bar = "bar"; foobar = self.foo + self.bar; }; in super // g self super
|
||||||
|
# = self: { foo = "foo"; bar = "bar"; foobar = self.foo + self.bar; } // g self { foo = "foo"; bar = "bar"; foobar = self.foo + self.bar; }
|
||||||
|
# = self: { foo = "foo"; bar = "bar"; foobar = self.foo + self.bar; } // { foo = "foo" + " + "; }
|
||||||
|
# = self: { foo = "foo + "; bar = "bar"; foobar = self.foo + self.bar; }
|
||||||
|
#
|
||||||
extends = f: rattrs: self: let super = rattrs self; in super // f self super;
|
extends = f: rattrs: self: let super = rattrs self; in super // f self super;
|
||||||
|
|
||||||
# Compose two extending functions of the type expected by 'extends'
|
# Compose two extending functions of the type expected by 'extends'
|
||||||
|
@ -143,6 +143,7 @@ rec {
|
|||||||
}@args: v: with builtins;
|
}@args: v: with builtins;
|
||||||
let isPath = v: typeOf v == "path";
|
let isPath = v: typeOf v == "path";
|
||||||
in if isInt v then toString v
|
in if isInt v then toString v
|
||||||
|
else if isFloat v then "~${toString v}"
|
||||||
else if isString v then ''"${libStr.escape [''"''] v}"''
|
else if isString v then ''"${libStr.escape [''"''] v}"''
|
||||||
else if true == v then "true"
|
else if true == v then "true"
|
||||||
else if false == v then "false"
|
else if false == v then "false"
|
||||||
|
@ -13,6 +13,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
* add it to this list. The URL mentioned above is a good source for inspiration.
|
* add it to this list. The URL mentioned above is a good source for inspiration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
abstyles = spdx {
|
||||||
|
spdxId = "Abstyles";
|
||||||
|
fullName = "Abstyles License";
|
||||||
|
};
|
||||||
|
|
||||||
afl21 = spdx {
|
afl21 = spdx {
|
||||||
spdxId = "AFL-2.1";
|
spdxId = "AFL-2.1";
|
||||||
fullName = "Academic Free License v2.1";
|
fullName = "Academic Free License v2.1";
|
||||||
@ -42,6 +47,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
amd = {
|
amd = {
|
||||||
fullName = "AMD License Agreement";
|
fullName = "AMD License Agreement";
|
||||||
url = http://developer.amd.com/amd-license-agreement/;
|
url = http://developer.amd.com/amd-license-agreement/;
|
||||||
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
apsl20 = spdx {
|
apsl20 = spdx {
|
||||||
@ -99,14 +105,10 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = ''BSD 4-clause "Original" or "Old" License'';
|
fullName = ''BSD 4-clause "Original" or "Old" License'';
|
||||||
};
|
};
|
||||||
|
|
||||||
bsl10 = {
|
|
||||||
fullName = "Business Source License 1.0";
|
|
||||||
url = https://mariadb.com/bsl10;
|
|
||||||
};
|
|
||||||
|
|
||||||
bsl11 = {
|
bsl11 = {
|
||||||
fullName = "Business Source License 1.1";
|
fullName = "Business Source License 1.1";
|
||||||
url = https://mariadb.com/bsl11;
|
url = https://mariadb.com/bsl11;
|
||||||
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
clArtistic = spdx {
|
clArtistic = spdx {
|
||||||
@ -210,6 +212,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = "Common Public License 1.0";
|
fullName = "Common Public License 1.0";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
curl = {
|
||||||
|
fullName = "MIT/X11 derivate";
|
||||||
|
url = "https://curl.haxx.se/docs/copyright.html";
|
||||||
|
};
|
||||||
|
|
||||||
doc = spdx {
|
doc = spdx {
|
||||||
spdxId = "DOC";
|
spdxId = "DOC";
|
||||||
fullName = "DOC License";
|
fullName = "DOC License";
|
||||||
@ -231,6 +238,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = "Eiffel Forum License v2.0";
|
fullName = "Eiffel Forum License v2.0";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
elastic = {
|
||||||
|
fullName = "ELASTIC LICENSE";
|
||||||
|
url = https://github.com/elastic/elasticsearch/blob/master/licenses/ELASTIC-LICENSE.txt;
|
||||||
|
free = false;
|
||||||
|
};
|
||||||
|
|
||||||
epl10 = spdx {
|
epl10 = spdx {
|
||||||
spdxId = "EPL-1.0";
|
spdxId = "EPL-1.0";
|
||||||
fullName = "Eclipse Public License 1.0";
|
fullName = "Eclipse Public License 1.0";
|
||||||
@ -298,6 +311,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = "GNU General Public License v2.0 only";
|
fullName = "GNU General Public License v2.0 only";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
gpl2Classpath = {
|
||||||
|
spdxId = "GPL-2.0-with-classpath-exception";
|
||||||
|
fullName = "GNU General Public License v2.0 only (with Classpath exception)";
|
||||||
|
url = https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception;
|
||||||
|
};
|
||||||
|
|
||||||
gpl2ClasspathPlus = {
|
gpl2ClasspathPlus = {
|
||||||
fullName = "GNU General Public License v2.0 or later (with Classpath exception)";
|
fullName = "GNU General Public License v2.0 or later (with Classpath exception)";
|
||||||
url = https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception;
|
url = https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception;
|
||||||
@ -344,6 +363,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = "Independent JPEG Group License";
|
fullName = "Independent JPEG Group License";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
imagemagick = spdx {
|
||||||
|
fullName = "ImageMagick License";
|
||||||
|
spdxId = "imagemagick";
|
||||||
|
};
|
||||||
|
|
||||||
inria-compcert = {
|
inria-compcert = {
|
||||||
fullName = "INRIA Non-Commercial License Agreement for the CompCert verified compiler";
|
fullName = "INRIA Non-Commercial License Agreement for the CompCert verified compiler";
|
||||||
url = "http://compcert.inria.fr/doc/LICENSE";
|
url = "http://compcert.inria.fr/doc/LICENSE";
|
||||||
@ -371,6 +395,18 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = "ISC License";
|
fullName = "ISC License";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Proprietary binaries; free to redistribute without modification.
|
||||||
|
issl = {
|
||||||
|
fullName = "Intel Simplified Software License";
|
||||||
|
url = https://software.intel.com/en-us/license/intel-simplified-software-license;
|
||||||
|
free = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
jasper = spdx {
|
||||||
|
spdxId = "JasPer-2.0";
|
||||||
|
fullName = "JasPer License";
|
||||||
|
};
|
||||||
|
|
||||||
lgpl2 = spdx {
|
lgpl2 = spdx {
|
||||||
spdxId = "LGPL-2.0";
|
spdxId = "LGPL-2.0";
|
||||||
fullName = "GNU Library General Public License v2 only";
|
fullName = "GNU Library General Public License v2 only";
|
||||||
@ -484,6 +520,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = "Non-Profit Open Software License 3.0";
|
fullName = "Non-Profit Open Software License 3.0";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ocamlpro_nc = {
|
||||||
|
fullName = "OCamlPro Non Commercial license version 1";
|
||||||
|
url = "https://alt-ergo.ocamlpro.com/http/alt-ergo-2.2.0/OCamlPro-Non-Commercial-License.pdf";
|
||||||
|
free = false;
|
||||||
|
};
|
||||||
|
|
||||||
ofl = spdx {
|
ofl = spdx {
|
||||||
spdxId = "OFL-1.1";
|
spdxId = "OFL-1.1";
|
||||||
fullName = "SIL Open Font License 1.1";
|
fullName = "SIL Open Font License 1.1";
|
||||||
@ -535,6 +577,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = "Public Domain";
|
fullName = "Public Domain";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
purdueBsd = {
|
||||||
|
fullName = " Purdue BSD-Style License"; # also know as lsof license
|
||||||
|
url = https://enterprise.dejacode.com/licenses/public/purdue-bsd;
|
||||||
|
};
|
||||||
|
|
||||||
qpl = spdx {
|
qpl = spdx {
|
||||||
spdxId = "QPL-1.0";
|
spdxId = "QPL-1.0";
|
||||||
fullName = "Q Public License 1.0";
|
fullName = "Q Public License 1.0";
|
||||||
@ -550,6 +597,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = "Ruby License";
|
fullName = "Ruby License";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sendmail = spdx {
|
||||||
|
spdxId = "Sendmail";
|
||||||
|
fullName = "Sendmail License";
|
||||||
|
};
|
||||||
|
|
||||||
sgi-b-20 = spdx {
|
sgi-b-20 = spdx {
|
||||||
spdxId = "SGI-B-2.0";
|
spdxId = "SGI-B-2.0";
|
||||||
fullName = "SGI Free Software License B v2.0";
|
fullName = "SGI Free Software License B v2.0";
|
||||||
@ -607,6 +659,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = "Vim License";
|
fullName = "Vim License";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtualbox-puel = {
|
||||||
|
fullName = "Oracle VM VirtualBox Extension Pack Personal Use and Evaluation License (PUEL)";
|
||||||
|
url = "https://www.virtualbox.org/wiki/VirtualBox_PUEL";
|
||||||
|
free = false;
|
||||||
|
};
|
||||||
|
|
||||||
vsl10 = spdx {
|
vsl10 = spdx {
|
||||||
spdxId = "VSL-1.0";
|
spdxId = "VSL-1.0";
|
||||||
fullName = "Vovida Software License v1.0";
|
fullName = "Vovida Software License v1.0";
|
||||||
@ -637,6 +695,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
|
|||||||
fullName = "wxWindows Library Licence, Version 3.1";
|
fullName = "wxWindows Library Licence, Version 3.1";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
xfig = {
|
||||||
|
fullName = "xfig";
|
||||||
|
url = "http://mcj.sourceforge.net/authors.html#xfig";
|
||||||
|
};
|
||||||
|
|
||||||
zlib = spdx {
|
zlib = spdx {
|
||||||
spdxId = "Zlib";
|
spdxId = "Zlib";
|
||||||
fullName = "zlib License";
|
fullName = "zlib License";
|
||||||
|
191
lib/lists.nix
191
lib/lists.nix
@ -1,4 +1,5 @@
|
|||||||
# General list operations.
|
# General list operations.
|
||||||
|
|
||||||
{ lib }:
|
{ lib }:
|
||||||
with lib.trivial;
|
with lib.trivial;
|
||||||
let
|
let
|
||||||
@ -8,21 +9,23 @@ rec {
|
|||||||
|
|
||||||
inherit (builtins) head tail length isList elemAt concatLists filter elem genList;
|
inherit (builtins) head tail length isList elemAt concatLists filter elem genList;
|
||||||
|
|
||||||
/* Create a list consisting of a single element. `singleton x' is
|
/* Create a list consisting of a single element. `singleton x` is
|
||||||
sometimes more convenient with respect to indentation than `[x]'
|
sometimes more convenient with respect to indentation than `[x]`
|
||||||
when x spans multiple lines.
|
when x spans multiple lines.
|
||||||
|
|
||||||
|
Type: singleton :: a -> [a]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
singleton "foo"
|
singleton "foo"
|
||||||
=> [ "foo" ]
|
=> [ "foo" ]
|
||||||
*/
|
*/
|
||||||
singleton = x: [x];
|
singleton = x: [x];
|
||||||
|
|
||||||
/* “right fold” a binary function `op' between successive elements of
|
/* “right fold” a binary function `op` between successive elements of
|
||||||
`list' with `nul' as the starting value, i.e.,
|
`list` with `nul' as the starting value, i.e.,
|
||||||
`foldr op nul [x_1 x_2 ... x_n] == op x_1 (op x_2 ... (op x_n nul))'.
|
`foldr op nul [x_1 x_2 ... x_n] == op x_1 (op x_2 ... (op x_n nul))`.
|
||||||
Type:
|
|
||||||
foldr :: (a -> b -> b) -> b -> [a] -> b
|
Type: foldr :: (a -> b -> b) -> b -> [a] -> b
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
concat = foldr (a: b: a + b) "z"
|
concat = foldr (a: b: a + b) "z"
|
||||||
@ -42,16 +45,15 @@ rec {
|
|||||||
else op (elemAt list n) (fold' (n + 1));
|
else op (elemAt list n) (fold' (n + 1));
|
||||||
in fold' 0;
|
in fold' 0;
|
||||||
|
|
||||||
/* `fold' is an alias of `foldr' for historic reasons */
|
/* `fold` is an alias of `foldr` for historic reasons */
|
||||||
# FIXME(Profpatsch): deprecate?
|
# FIXME(Profpatsch): deprecate?
|
||||||
fold = foldr;
|
fold = foldr;
|
||||||
|
|
||||||
|
|
||||||
/* “left fold”, like `foldr', but from the left:
|
/* “left fold”, like `foldr`, but from the left:
|
||||||
`foldl op nul [x_1 x_2 ... x_n] == op (... (op (op nul x_1) x_2) ... x_n)`.
|
`foldl op nul [x_1 x_2 ... x_n] == op (... (op (op nul x_1) x_2) ... x_n)`.
|
||||||
|
|
||||||
Type:
|
Type: foldl :: (b -> a -> b) -> b -> [a] -> b
|
||||||
foldl :: (b -> a -> b) -> b -> [a] -> b
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
lconcat = foldl (a: b: a + b) "z"
|
lconcat = foldl (a: b: a + b) "z"
|
||||||
@ -70,16 +72,20 @@ rec {
|
|||||||
else op (foldl' (n - 1)) (elemAt list n);
|
else op (foldl' (n - 1)) (elemAt list n);
|
||||||
in foldl' (length list - 1);
|
in foldl' (length list - 1);
|
||||||
|
|
||||||
/* Strict version of `foldl'.
|
/* Strict version of `foldl`.
|
||||||
|
|
||||||
The difference is that evaluation is forced upon access. Usually used
|
The difference is that evaluation is forced upon access. Usually used
|
||||||
with small whole results (in contract with lazily-generated list or large
|
with small whole results (in contract with lazily-generated list or large
|
||||||
lists where only a part is consumed.)
|
lists where only a part is consumed.)
|
||||||
|
|
||||||
|
Type: foldl' :: (b -> a -> b) -> b -> [a] -> b
|
||||||
*/
|
*/
|
||||||
foldl' = builtins.foldl' or foldl;
|
foldl' = builtins.foldl' or foldl;
|
||||||
|
|
||||||
/* Map with index starting from 0
|
/* Map with index starting from 0
|
||||||
|
|
||||||
|
Type: imap0 :: (int -> a -> b) -> [a] -> [b]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
imap0 (i: v: "${v}-${toString i}") ["a" "b"]
|
imap0 (i: v: "${v}-${toString i}") ["a" "b"]
|
||||||
=> [ "a-0" "b-1" ]
|
=> [ "a-0" "b-1" ]
|
||||||
@ -88,6 +94,8 @@ rec {
|
|||||||
|
|
||||||
/* Map with index starting from 1
|
/* Map with index starting from 1
|
||||||
|
|
||||||
|
Type: imap1 :: (int -> a -> b) -> [a] -> [b]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
imap1 (i: v: "${v}-${toString i}") ["a" "b"]
|
imap1 (i: v: "${v}-${toString i}") ["a" "b"]
|
||||||
=> [ "a-1" "b-2" ]
|
=> [ "a-1" "b-2" ]
|
||||||
@ -96,6 +104,8 @@ rec {
|
|||||||
|
|
||||||
/* Map and concatenate the result.
|
/* Map and concatenate the result.
|
||||||
|
|
||||||
|
Type: concatMap :: (a -> [b]) -> [a] -> [b]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
concatMap (x: [x] ++ ["z"]) ["a" "b"]
|
concatMap (x: [x] ++ ["z"]) ["a" "b"]
|
||||||
=> [ "a" "z" "b" "z" ]
|
=> [ "a" "z" "b" "z" ]
|
||||||
@ -118,15 +128,21 @@ rec {
|
|||||||
|
|
||||||
/* Remove elements equal to 'e' from a list. Useful for buildInputs.
|
/* Remove elements equal to 'e' from a list. Useful for buildInputs.
|
||||||
|
|
||||||
|
Type: remove :: a -> [a] -> [a]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
remove 3 [ 1 3 4 3 ]
|
remove 3 [ 1 3 4 3 ]
|
||||||
=> [ 1 4 ]
|
=> [ 1 4 ]
|
||||||
*/
|
*/
|
||||||
remove = e: filter (x: x != e);
|
remove =
|
||||||
|
# Element to remove from the list
|
||||||
|
e: filter (x: x != e);
|
||||||
|
|
||||||
/* Find the sole element in the list matching the specified
|
/* Find the sole element in the list matching the specified
|
||||||
predicate, returns `default' if no such element exists, or
|
predicate, returns `default` if no such element exists, or
|
||||||
`multiple' if there are multiple matching elements.
|
`multiple` if there are multiple matching elements.
|
||||||
|
|
||||||
|
Type: findSingle :: (a -> bool) -> a -> a -> [a] -> a
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
findSingle (x: x == 3) "none" "multiple" [ 1 3 3 ]
|
findSingle (x: x == 3) "none" "multiple" [ 1 3 3 ]
|
||||||
@ -136,14 +152,24 @@ rec {
|
|||||||
findSingle (x: x == 3) "none" "multiple" [ 1 9 ]
|
findSingle (x: x == 3) "none" "multiple" [ 1 9 ]
|
||||||
=> "none"
|
=> "none"
|
||||||
*/
|
*/
|
||||||
findSingle = pred: default: multiple: list:
|
findSingle =
|
||||||
|
# Predicate
|
||||||
|
pred:
|
||||||
|
# Default value to return if element was not found.
|
||||||
|
default:
|
||||||
|
# Default value to return if more than one element was found
|
||||||
|
multiple:
|
||||||
|
# Input list
|
||||||
|
list:
|
||||||
let found = filter pred list; len = length found;
|
let found = filter pred list; len = length found;
|
||||||
in if len == 0 then default
|
in if len == 0 then default
|
||||||
else if len != 1 then multiple
|
else if len != 1 then multiple
|
||||||
else head found;
|
else head found;
|
||||||
|
|
||||||
/* Find the first element in the list matching the specified
|
/* Find the first element in the list matching the specified
|
||||||
predicate or returns `default' if no such element exists.
|
predicate or return `default` if no such element exists.
|
||||||
|
|
||||||
|
Type: findFirst :: (a -> bool) -> a -> [a] -> a
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
findFirst (x: x > 3) 7 [ 1 6 4 ]
|
findFirst (x: x > 3) 7 [ 1 6 4 ]
|
||||||
@ -151,12 +177,20 @@ rec {
|
|||||||
findFirst (x: x > 9) 7 [ 1 6 4 ]
|
findFirst (x: x > 9) 7 [ 1 6 4 ]
|
||||||
=> 7
|
=> 7
|
||||||
*/
|
*/
|
||||||
findFirst = pred: default: list:
|
findFirst =
|
||||||
|
# Predicate
|
||||||
|
pred:
|
||||||
|
# Default value to return
|
||||||
|
default:
|
||||||
|
# Input list
|
||||||
|
list:
|
||||||
let found = filter pred list;
|
let found = filter pred list;
|
||||||
in if found == [] then default else head found;
|
in if found == [] then default else head found;
|
||||||
|
|
||||||
/* Return true iff function `pred' returns true for at least element
|
/* Return true if function `pred` returns true for at least one
|
||||||
of `list'.
|
element of `list`.
|
||||||
|
|
||||||
|
Type: any :: (a -> bool) -> [a] -> bool
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
any isString [ 1 "a" { } ]
|
any isString [ 1 "a" { } ]
|
||||||
@ -166,8 +200,10 @@ rec {
|
|||||||
*/
|
*/
|
||||||
any = builtins.any or (pred: foldr (x: y: if pred x then true else y) false);
|
any = builtins.any or (pred: foldr (x: y: if pred x then true else y) false);
|
||||||
|
|
||||||
/* Return true iff function `pred' returns true for all elements of
|
/* Return true if function `pred` returns true for all elements of
|
||||||
`list'.
|
`list`.
|
||||||
|
|
||||||
|
Type: all :: (a -> bool) -> [a] -> bool
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
all (x: x < 3) [ 1 2 ]
|
all (x: x < 3) [ 1 2 ]
|
||||||
@ -177,19 +213,25 @@ rec {
|
|||||||
*/
|
*/
|
||||||
all = builtins.all or (pred: foldr (x: y: if pred x then y else false) true);
|
all = builtins.all or (pred: foldr (x: y: if pred x then y else false) true);
|
||||||
|
|
||||||
/* Count how many times function `pred' returns true for the elements
|
/* Count how many elements of `list` match the supplied predicate
|
||||||
of `list'.
|
function.
|
||||||
|
|
||||||
|
Type: count :: (a -> bool) -> [a] -> int
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
count (x: x == 3) [ 3 2 3 4 6 ]
|
count (x: x == 3) [ 3 2 3 4 6 ]
|
||||||
=> 2
|
=> 2
|
||||||
*/
|
*/
|
||||||
count = pred: foldl' (c: x: if pred x then c + 1 else c) 0;
|
count =
|
||||||
|
# Predicate
|
||||||
|
pred: foldl' (c: x: if pred x then c + 1 else c) 0;
|
||||||
|
|
||||||
/* Return a singleton list or an empty list, depending on a boolean
|
/* Return a singleton list or an empty list, depending on a boolean
|
||||||
value. Useful when building lists with optional elements
|
value. Useful when building lists with optional elements
|
||||||
(e.g. `++ optional (system == "i686-linux") flashplayer').
|
(e.g. `++ optional (system == "i686-linux") flashplayer').
|
||||||
|
|
||||||
|
Type: optional :: bool -> a -> [a]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
optional true "foo"
|
optional true "foo"
|
||||||
=> [ "foo" ]
|
=> [ "foo" ]
|
||||||
@ -200,13 +242,19 @@ rec {
|
|||||||
|
|
||||||
/* Return a list or an empty list, depending on a boolean value.
|
/* Return a list or an empty list, depending on a boolean value.
|
||||||
|
|
||||||
|
Type: optionals :: bool -> [a] -> [a]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
optionals true [ 2 3 ]
|
optionals true [ 2 3 ]
|
||||||
=> [ 2 3 ]
|
=> [ 2 3 ]
|
||||||
optionals false [ 2 3 ]
|
optionals false [ 2 3 ]
|
||||||
=> [ ]
|
=> [ ]
|
||||||
*/
|
*/
|
||||||
optionals = cond: elems: if cond then elems else [];
|
optionals =
|
||||||
|
# Condition
|
||||||
|
cond:
|
||||||
|
# List to return if condition is true
|
||||||
|
elems: if cond then elems else [];
|
||||||
|
|
||||||
|
|
||||||
/* If argument is a list, return it; else, wrap it in a singleton
|
/* If argument is a list, return it; else, wrap it in a singleton
|
||||||
@ -223,20 +271,28 @@ rec {
|
|||||||
|
|
||||||
/* Return a list of integers from `first' up to and including `last'.
|
/* Return a list of integers from `first' up to and including `last'.
|
||||||
|
|
||||||
|
Type: range :: int -> int -> [int]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
range 2 4
|
range 2 4
|
||||||
=> [ 2 3 4 ]
|
=> [ 2 3 4 ]
|
||||||
range 3 2
|
range 3 2
|
||||||
=> [ ]
|
=> [ ]
|
||||||
*/
|
*/
|
||||||
range = first: last:
|
range =
|
||||||
|
# First integer in the range
|
||||||
|
first:
|
||||||
|
# Last integer in the range
|
||||||
|
last:
|
||||||
if first > last then
|
if first > last then
|
||||||
[]
|
[]
|
||||||
else
|
else
|
||||||
genList (n: first + n) (last - first + 1);
|
genList (n: first + n) (last - first + 1);
|
||||||
|
|
||||||
/* Splits the elements of a list in two lists, `right' and
|
/* Splits the elements of a list in two lists, `right` and
|
||||||
`wrong', depending on the evaluation of a predicate.
|
`wrong`, depending on the evaluation of a predicate.
|
||||||
|
|
||||||
|
Type: (a -> bool) -> [a] -> { right :: [a], wrong :: [a] }
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
partition (x: x > 2) [ 5 1 2 3 4 ]
|
partition (x: x > 2) [ 5 1 2 3 4 ]
|
||||||
@ -252,7 +308,7 @@ rec {
|
|||||||
/* Splits the elements of a list into many lists, using the return value of a predicate.
|
/* Splits the elements of a list into many lists, using the return value of a predicate.
|
||||||
Predicate should return a string which becomes keys of attrset `groupBy' returns.
|
Predicate should return a string which becomes keys of attrset `groupBy' returns.
|
||||||
|
|
||||||
`groupBy'' allows to customise the combining function and initial value
|
`groupBy'` allows to customise the combining function and initial value
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
groupBy (x: boolToString (x > 2)) [ 5 1 2 3 4 ]
|
groupBy (x: boolToString (x > 2)) [ 5 1 2 3 4 ]
|
||||||
@ -268,10 +324,6 @@ rec {
|
|||||||
xfce = [ { name = "xfce"; script = "xfce4-session &"; } ];
|
xfce = [ { name = "xfce"; script = "xfce4-session &"; } ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
groupBy' allows to customise the combining function and initial value
|
|
||||||
|
|
||||||
Example:
|
|
||||||
groupBy' builtins.add 0 (x: boolToString (x > 2)) [ 5 1 2 3 4 ]
|
groupBy' builtins.add 0 (x: boolToString (x > 2)) [ 5 1 2 3 4 ]
|
||||||
=> { true = 12; false = 3; }
|
=> { true = 12; false = 3; }
|
||||||
*/
|
*/
|
||||||
@ -289,17 +341,27 @@ rec {
|
|||||||
the merging stops at the shortest. How both lists are merged is defined
|
the merging stops at the shortest. How both lists are merged is defined
|
||||||
by the first argument.
|
by the first argument.
|
||||||
|
|
||||||
|
Type: zipListsWith :: (a -> b -> c) -> [a] -> [b] -> [c]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
zipListsWith (a: b: a + b) ["h" "l"] ["e" "o"]
|
zipListsWith (a: b: a + b) ["h" "l"] ["e" "o"]
|
||||||
=> ["he" "lo"]
|
=> ["he" "lo"]
|
||||||
*/
|
*/
|
||||||
zipListsWith = f: fst: snd:
|
zipListsWith =
|
||||||
|
# Function to zip elements of both lists
|
||||||
|
f:
|
||||||
|
# First list
|
||||||
|
fst:
|
||||||
|
# Second list
|
||||||
|
snd:
|
||||||
genList
|
genList
|
||||||
(n: f (elemAt fst n) (elemAt snd n)) (min (length fst) (length snd));
|
(n: f (elemAt fst n) (elemAt snd n)) (min (length fst) (length snd));
|
||||||
|
|
||||||
/* Merges two lists of the same size together. If the sizes aren't the same
|
/* Merges two lists of the same size together. If the sizes aren't the same
|
||||||
the merging stops at the shortest.
|
the merging stops at the shortest.
|
||||||
|
|
||||||
|
Type: zipLists :: [a] -> [b] -> [{ fst :: a, snd :: b}]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
zipLists [ 1 2 ] [ "a" "b" ]
|
zipLists [ 1 2 ] [ "a" "b" ]
|
||||||
=> [ { fst = 1; snd = "a"; } { fst = 2; snd = "b"; } ]
|
=> [ { fst = 1; snd = "a"; } { fst = 2; snd = "b"; } ]
|
||||||
@ -308,6 +370,8 @@ rec {
|
|||||||
|
|
||||||
/* Reverse the order of the elements of a list.
|
/* Reverse the order of the elements of a list.
|
||||||
|
|
||||||
|
Type: reverseList :: [a] -> [a]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
reverseList [ "b" "o" "j" ]
|
reverseList [ "b" "o" "j" ]
|
||||||
@ -321,8 +385,7 @@ rec {
|
|||||||
`before a b == true` means that `b` depends on `a` (there's an
|
`before a b == true` means that `b` depends on `a` (there's an
|
||||||
edge from `b` to `a`).
|
edge from `b` to `a`).
|
||||||
|
|
||||||
Examples:
|
Example:
|
||||||
|
|
||||||
listDfs true hasPrefix [ "/home/user" "other" "/" "/home" ]
|
listDfs true hasPrefix [ "/home/user" "other" "/" "/home" ]
|
||||||
== { minimal = "/"; # minimal element
|
== { minimal = "/"; # minimal element
|
||||||
visited = [ "/home/user" ]; # seen elements (in reverse order)
|
visited = [ "/home/user" ]; # seen elements (in reverse order)
|
||||||
@ -336,7 +399,6 @@ rec {
|
|||||||
rest = [ "/home" "other" ]; # everything else
|
rest = [ "/home" "other" ]; # everything else
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
listDfs = stopOnCycles: before: list:
|
listDfs = stopOnCycles: before: list:
|
||||||
let
|
let
|
||||||
dfs' = us: visited: rest:
|
dfs' = us: visited: rest:
|
||||||
@ -361,7 +423,7 @@ rec {
|
|||||||
`before a b == true` means that `b` should be after `a`
|
`before a b == true` means that `b` should be after `a`
|
||||||
in the result.
|
in the result.
|
||||||
|
|
||||||
Examples:
|
Example:
|
||||||
|
|
||||||
toposort hasPrefix [ "/home/user" "other" "/" "/home" ]
|
toposort hasPrefix [ "/home/user" "other" "/" "/home" ]
|
||||||
== { result = [ "/" "/home" "/home/user" "other" ]; }
|
== { result = [ "/" "/home" "/home/user" "other" ]; }
|
||||||
@ -376,7 +438,6 @@ rec {
|
|||||||
toposort (a: b: a < b) [ 3 2 1 ] == { result = [ 1 2 3 ]; }
|
toposort (a: b: a < b) [ 3 2 1 ] == { result = [ 1 2 3 ]; }
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
toposort = before: list:
|
toposort = before: list:
|
||||||
let
|
let
|
||||||
dfsthis = listDfs true before list;
|
dfsthis = listDfs true before list;
|
||||||
@ -467,26 +528,38 @@ rec {
|
|||||||
|
|
||||||
/* Return the first (at most) N elements of a list.
|
/* Return the first (at most) N elements of a list.
|
||||||
|
|
||||||
|
Type: take :: int -> [a] -> [a]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
take 2 [ "a" "b" "c" "d" ]
|
take 2 [ "a" "b" "c" "d" ]
|
||||||
=> [ "a" "b" ]
|
=> [ "a" "b" ]
|
||||||
take 2 [ ]
|
take 2 [ ]
|
||||||
=> [ ]
|
=> [ ]
|
||||||
*/
|
*/
|
||||||
take = count: sublist 0 count;
|
take =
|
||||||
|
# Number of elements to take
|
||||||
|
count: sublist 0 count;
|
||||||
|
|
||||||
/* Remove the first (at most) N elements of a list.
|
/* Remove the first (at most) N elements of a list.
|
||||||
|
|
||||||
|
Type: drop :: int -> [a] -> [a]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
drop 2 [ "a" "b" "c" "d" ]
|
drop 2 [ "a" "b" "c" "d" ]
|
||||||
=> [ "c" "d" ]
|
=> [ "c" "d" ]
|
||||||
drop 2 [ ]
|
drop 2 [ ]
|
||||||
=> [ ]
|
=> [ ]
|
||||||
*/
|
*/
|
||||||
drop = count: list: sublist count (length list) list;
|
drop =
|
||||||
|
# Number of elements to drop
|
||||||
|
count:
|
||||||
|
# Input list
|
||||||
|
list: sublist count (length list) list;
|
||||||
|
|
||||||
/* Return a list consisting of at most ‘count’ elements of ‘list’,
|
/* Return a list consisting of at most `count` elements of `list`,
|
||||||
starting at index ‘start’.
|
starting at index `start`.
|
||||||
|
|
||||||
|
Type: sublist :: int -> int -> [a] -> [a]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
sublist 1 3 [ "a" "b" "c" "d" "e" ]
|
sublist 1 3 [ "a" "b" "c" "d" "e" ]
|
||||||
@ -494,7 +567,13 @@ rec {
|
|||||||
sublist 1 3 [ ]
|
sublist 1 3 [ ]
|
||||||
=> [ ]
|
=> [ ]
|
||||||
*/
|
*/
|
||||||
sublist = start: count: list:
|
sublist =
|
||||||
|
# Index at which to start the sublist
|
||||||
|
start:
|
||||||
|
# Number of elements to take
|
||||||
|
count:
|
||||||
|
# Input list
|
||||||
|
list:
|
||||||
let len = length list; in
|
let len = length list; in
|
||||||
genList
|
genList
|
||||||
(n: elemAt list (n + start))
|
(n: elemAt list (n + start))
|
||||||
@ -504,23 +583,34 @@ rec {
|
|||||||
|
|
||||||
/* Return the last element of a list.
|
/* Return the last element of a list.
|
||||||
|
|
||||||
|
This function throws an error if the list is empty.
|
||||||
|
|
||||||
|
Type: last :: [a] -> a
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
last [ 1 2 3 ]
|
last [ 1 2 3 ]
|
||||||
=> 3
|
=> 3
|
||||||
*/
|
*/
|
||||||
last = list:
|
last = list:
|
||||||
assert list != []; elemAt list (length list - 1);
|
assert lib.assertMsg (list != []) "lists.last: list must not be empty!";
|
||||||
|
elemAt list (length list - 1);
|
||||||
|
|
||||||
/* Return all elements but the last
|
/* Return all elements but the last.
|
||||||
|
|
||||||
|
This function throws an error if the list is empty.
|
||||||
|
|
||||||
|
Type: init :: [a] -> [a]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
init [ 1 2 3 ]
|
init [ 1 2 3 ]
|
||||||
=> [ 1 2 ]
|
=> [ 1 2 ]
|
||||||
*/
|
*/
|
||||||
init = list: assert list != []; take (length list - 1) list;
|
init = list:
|
||||||
|
assert lib.assertMsg (list != []) "lists.init: list must not be empty!";
|
||||||
|
take (length list - 1) list;
|
||||||
|
|
||||||
|
|
||||||
/* return the image of the cross product of some lists by a function
|
/* Return the image of the cross product of some lists by a function.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
crossLists (x:y: "${toString x}${toString y}") [[1 2] [3 4]]
|
crossLists (x:y: "${toString x}${toString y}") [[1 2] [3 4]]
|
||||||
@ -531,8 +621,9 @@ rec {
|
|||||||
|
|
||||||
/* Remove duplicate elements from the list. O(n^2) complexity.
|
/* Remove duplicate elements from the list. O(n^2) complexity.
|
||||||
|
|
||||||
Example:
|
Type: unique :: [a] -> [a]
|
||||||
|
|
||||||
|
Example:
|
||||||
unique [ 3 2 3 4 ]
|
unique [ 3 2 3 4 ]
|
||||||
=> [ 3 2 4 ]
|
=> [ 3 2 4 ]
|
||||||
*/
|
*/
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
# Expose the minimum required version for evaluating Nixpkgs
|
# Expose the minimum required version for evaluating Nixpkgs
|
||||||
"1.11"
|
"2.0"
|
||||||
|
@ -192,29 +192,53 @@ rec {
|
|||||||
(concatMap (m: map (config: { inherit (m) file; inherit config; }) (pushDownProperties m.config)) modules);
|
(concatMap (m: map (config: { inherit (m) file; inherit config; }) (pushDownProperties m.config)) modules);
|
||||||
|
|
||||||
mergeModules' = prefix: options: configs:
|
mergeModules' = prefix: options: configs:
|
||||||
listToAttrs (map (name: {
|
let
|
||||||
|
/* byName is like foldAttrs, but will look for attributes to merge in the
|
||||||
|
specified attribute name.
|
||||||
|
|
||||||
|
byName "foo" (module: value: ["module.hidden=${module.hidden},value=${value}"])
|
||||||
|
[
|
||||||
|
{
|
||||||
|
hidden="baz";
|
||||||
|
foo={qux="bar"; gla="flop";};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
hidden="fli";
|
||||||
|
foo={qux="gne"; gli="flip";};
|
||||||
|
}
|
||||||
|
]
|
||||||
|
===>
|
||||||
|
{
|
||||||
|
gla = [ "module.hidden=baz,value=flop" ];
|
||||||
|
gli = [ "module.hidden=fli,value=flip" ];
|
||||||
|
qux = [ "module.hidden=baz,value=bar" "module.hidden=fli,value=gne" ];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
byName = attr: f: modules: foldl' (acc: module:
|
||||||
|
foldl' (inner: name:
|
||||||
|
inner // { ${name} = (acc.${name} or []) ++ (f module module.${attr}.${name}); }
|
||||||
|
) acc (attrNames module.${attr})
|
||||||
|
) {} modules;
|
||||||
|
# an attrset 'name' => list of submodules that declare ‘name’.
|
||||||
|
declsByName = byName "options"
|
||||||
|
(module: option: [{ inherit (module) file; options = option; }])
|
||||||
|
options;
|
||||||
|
# an attrset 'name' => list of submodules that define ‘name’.
|
||||||
|
defnsByName = byName "config" (module: value:
|
||||||
|
map (config: { inherit (module) file; inherit config; }) (pushDownProperties value)
|
||||||
|
) configs;
|
||||||
|
# extract the definitions for each loc
|
||||||
|
defnsByName' = byName "config"
|
||||||
|
(module: value: [{ inherit (module) file; inherit value; }])
|
||||||
|
configs;
|
||||||
|
in
|
||||||
|
(flip mapAttrs declsByName (name: decls:
|
||||||
# We're descending into attribute ‘name’.
|
# We're descending into attribute ‘name’.
|
||||||
inherit name;
|
|
||||||
value =
|
|
||||||
let
|
let
|
||||||
loc = prefix ++ [name];
|
loc = prefix ++ [name];
|
||||||
# Get all submodules that declare ‘name’.
|
defns = defnsByName.${name} or [];
|
||||||
decls = concatMap (m:
|
defns' = defnsByName'.${name} or [];
|
||||||
if m.options ? ${name}
|
|
||||||
then [ { inherit (m) file; options = m.options.${name}; } ]
|
|
||||||
else []
|
|
||||||
) options;
|
|
||||||
# Get all submodules that define ‘name’.
|
|
||||||
defns = concatMap (m:
|
|
||||||
if m.config ? ${name}
|
|
||||||
then map (config: { inherit (m) file; inherit config; })
|
|
||||||
(pushDownProperties m.config.${name})
|
|
||||||
else []
|
|
||||||
) configs;
|
|
||||||
nrOptions = count (m: isOption m.options) decls;
|
nrOptions = count (m: isOption m.options) decls;
|
||||||
# Extract the definitions for this loc
|
|
||||||
defns' = map (m: { inherit (m) file; value = m.config.${name}; })
|
|
||||||
(filter (m: m.config ? ${name}) configs);
|
|
||||||
in
|
in
|
||||||
if nrOptions == length decls then
|
if nrOptions == length decls then
|
||||||
let opt = fixupOptionType loc (mergeOptionDecls loc decls);
|
let opt = fixupOptionType loc (mergeOptionDecls loc decls);
|
||||||
@ -226,8 +250,8 @@ rec {
|
|||||||
in
|
in
|
||||||
throw "The option `${showOption loc}' in `${firstOption.file}' is a prefix of options in `${firstNonOption.file}'."
|
throw "The option `${showOption loc}' in `${firstOption.file}' is a prefix of options in `${firstNonOption.file}'."
|
||||||
else
|
else
|
||||||
mergeModules' loc decls defns;
|
mergeModules' loc decls defns
|
||||||
}) (concatMap (m: attrNames m.options) options))
|
))
|
||||||
// { _definedNames = map (m: { inherit (m) file; names = attrNames m.config; }) configs; };
|
// { _definedNames = map (m: { inherit (m) file; names = attrNames m.config; }) configs; };
|
||||||
|
|
||||||
/* Merge multiple option declarations into a single declaration. In
|
/* Merge multiple option declarations into a single declaration. In
|
||||||
|
120
lib/options.nix
120
lib/options.nix
@ -8,33 +8,72 @@ with lib.strings;
|
|||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
/* Returns true when the given argument is an option
|
||||||
|
|
||||||
|
Type: isOption :: a -> bool
|
||||||
|
|
||||||
|
Example:
|
||||||
|
isOption 1 // => false
|
||||||
|
isOption (mkOption {}) // => true
|
||||||
|
*/
|
||||||
isOption = lib.isType "option";
|
isOption = lib.isType "option";
|
||||||
|
|
||||||
|
/* Creates an Option attribute set. mkOption accepts an attribute set with the following keys:
|
||||||
|
|
||||||
|
All keys default to `null` when not given.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
mkOption { } // => { _type = "option"; }
|
||||||
|
mkOption { defaultText = "foo"; } // => { _type = "option"; defaultText = "foo"; }
|
||||||
|
*/
|
||||||
mkOption =
|
mkOption =
|
||||||
{ default ? null # Default value used when no definition is given in the configuration.
|
{
|
||||||
, defaultText ? null # Textual representation of the default, for in the manual.
|
# Default value used when no definition is given in the configuration.
|
||||||
, example ? null # Example value used in the manual.
|
default ? null,
|
||||||
, description ? null # String describing the option.
|
# Textual representation of the default, for the manual.
|
||||||
, relatedPackages ? null # Related packages used in the manual (see `genRelatedPackages` in ../nixos/doc/manual/default.nix).
|
defaultText ? null,
|
||||||
, type ? null # Option type, providing type-checking and value merging.
|
# Example value used in the manual.
|
||||||
, apply ? null # Function that converts the option value to something else.
|
example ? null,
|
||||||
, internal ? null # Whether the option is for NixOS developers only.
|
# String describing the option.
|
||||||
, visible ? null # Whether the option shows up in the manual.
|
description ? null,
|
||||||
, readOnly ? null # Whether the option can be set only once
|
# Related packages used in the manual (see `genRelatedPackages` in ../nixos/doc/manual/default.nix).
|
||||||
, options ? null # Obsolete, used by types.optionSet.
|
relatedPackages ? null,
|
||||||
|
# Option type, providing type-checking and value merging.
|
||||||
|
type ? null,
|
||||||
|
# Function that converts the option value to something else.
|
||||||
|
apply ? null,
|
||||||
|
# Whether the option is for NixOS developers only.
|
||||||
|
internal ? null,
|
||||||
|
# Whether the option shows up in the manual.
|
||||||
|
visible ? null,
|
||||||
|
# Whether the option can be set only once
|
||||||
|
readOnly ? null,
|
||||||
|
# Obsolete, used by types.optionSet.
|
||||||
|
options ? null
|
||||||
} @ attrs:
|
} @ attrs:
|
||||||
attrs // { _type = "option"; };
|
attrs // { _type = "option"; };
|
||||||
|
|
||||||
mkEnableOption = name: mkOption {
|
/* Creates an Option attribute set for a boolean value option i.e an
|
||||||
|
option to be toggled on or off:
|
||||||
|
|
||||||
|
Example:
|
||||||
|
mkEnableOption "foo"
|
||||||
|
=> { _type = "option"; default = false; description = "Whether to enable foo."; example = true; type = { ... }; }
|
||||||
|
*/
|
||||||
|
mkEnableOption =
|
||||||
|
# Name for the created option
|
||||||
|
name: mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
example = true;
|
example = true;
|
||||||
description = "Whether to enable ${name}.";
|
description = "Whether to enable ${name}.";
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
# This option accept anything, but it does not produce any result. This
|
/* This option accepts anything, but it does not produce any result.
|
||||||
# is useful for sharing a module across different module sets without
|
|
||||||
# having to implement similar features as long as the value of the options
|
This is useful for sharing a module across different module sets
|
||||||
# are not expected.
|
without having to implement similar features as long as the
|
||||||
|
values of the options are not accessed. */
|
||||||
mkSinkUndeclaredOptions = attrs: mkOption ({
|
mkSinkUndeclaredOptions = attrs: mkOption ({
|
||||||
internal = true;
|
internal = true;
|
||||||
visible = false;
|
visible = false;
|
||||||
@ -74,7 +113,24 @@ rec {
|
|||||||
else
|
else
|
||||||
val) (head defs).value defs;
|
val) (head defs).value defs;
|
||||||
|
|
||||||
|
/* Extracts values of all "value" keys of the given list.
|
||||||
|
|
||||||
|
Type: getValues :: [ { value :: a } ] -> [a]
|
||||||
|
|
||||||
|
Example:
|
||||||
|
getValues [ { value = 1; } { value = 2; } ] // => [ 1 2 ]
|
||||||
|
getValues [ ] // => [ ]
|
||||||
|
*/
|
||||||
getValues = map (x: x.value);
|
getValues = map (x: x.value);
|
||||||
|
|
||||||
|
/* Extracts values of all "file" keys of the given list
|
||||||
|
|
||||||
|
Type: getFiles :: [ { file :: a } ] -> [a]
|
||||||
|
|
||||||
|
Example:
|
||||||
|
getFiles [ { file = "file1"; } { file = "file2"; } ] // => [ "file1" "file2" ]
|
||||||
|
getFiles [ ] // => [ ]
|
||||||
|
*/
|
||||||
getFiles = map (x: x.file);
|
getFiles = map (x: x.file);
|
||||||
|
|
||||||
# Generate documentation template from the list of option declaration like
|
# Generate documentation template from the list of option declaration like
|
||||||
@ -107,10 +163,13 @@ rec {
|
|||||||
|
|
||||||
|
|
||||||
/* This function recursively removes all derivation attributes from
|
/* This function recursively removes all derivation attributes from
|
||||||
`x' except for the `name' attribute. This is to make the
|
`x` except for the `name` attribute.
|
||||||
generation of `options.xml' much more efficient: the XML
|
|
||||||
representation of derivations is very large (on the order of
|
This is to make the generation of `options.xml` much more
|
||||||
megabytes) and is not actually used by the manual generator. */
|
efficient: the XML representation of derivations is very large
|
||||||
|
(on the order of megabytes) and is not actually used by the
|
||||||
|
manual generator.
|
||||||
|
*/
|
||||||
scrubOptionValue = x:
|
scrubOptionValue = x:
|
||||||
if isDerivation x then
|
if isDerivation x then
|
||||||
{ type = "derivation"; drvPath = x.name; outPath = x.name; name = x.name; }
|
{ type = "derivation"; drvPath = x.name; outPath = x.name; name = x.name; }
|
||||||
@ -119,20 +178,21 @@ rec {
|
|||||||
else x;
|
else x;
|
||||||
|
|
||||||
|
|
||||||
/* For use in the ‘example’ option attribute. It causes the given
|
/* For use in the `example` option attribute. It causes the given
|
||||||
text to be included verbatim in documentation. This is necessary
|
text to be included verbatim in documentation. This is necessary
|
||||||
for example values that are not simple values, e.g.,
|
for example values that are not simple values, e.g., functions.
|
||||||
functions. */
|
*/
|
||||||
literalExample = text: { _type = "literalExample"; inherit text; };
|
literalExample = text: { _type = "literalExample"; inherit text; };
|
||||||
|
|
||||||
|
# Helper functions.
|
||||||
|
|
||||||
/* Helper functions. */
|
/* Convert an option, described as a list of the option parts in to a
|
||||||
|
safe, human readable version.
|
||||||
|
|
||||||
# Convert an option, described as a list of the option parts in to a
|
Example:
|
||||||
# safe, human readable version. ie:
|
(showOption ["foo" "bar" "baz"]) == "foo.bar.baz"
|
||||||
#
|
(showOption ["foo" "bar.baz" "tux"]) == "foo.\"bar.baz\".tux"
|
||||||
# (showOption ["foo" "bar" "baz"]) == "foo.bar.baz"
|
*/
|
||||||
# (showOption ["foo" "bar.baz" "tux"]) == "foo.\"bar.baz\".tux"
|
|
||||||
showOption = parts: let
|
showOption = parts: let
|
||||||
escapeOptionPart = part:
|
escapeOptionPart = part:
|
||||||
let
|
let
|
||||||
|
@ -26,6 +26,10 @@ rec {
|
|||||||
(type == "symlink" && lib.hasPrefix "result" baseName)
|
(type == "symlink" && lib.hasPrefix "result" baseName)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Filters a source tree removing version control files and directories using cleanSourceWith
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# cleanSource ./.
|
||||||
cleanSource = src: cleanSourceWith { filter = cleanSourceFilter; inherit src; };
|
cleanSource = src: cleanSourceWith { filter = cleanSourceFilter; inherit src; };
|
||||||
|
|
||||||
# Like `builtins.filterSource`, except it will compose with itself,
|
# Like `builtins.filterSource`, except it will compose with itself,
|
||||||
@ -69,7 +73,7 @@ rec {
|
|||||||
# Get the commit id of a git repo
|
# Get the commit id of a git repo
|
||||||
# Example: commitIdFromGitRepo <nixpkgs/.git>
|
# Example: commitIdFromGitRepo <nixpkgs/.git>
|
||||||
commitIdFromGitRepo =
|
commitIdFromGitRepo =
|
||||||
let readCommitFromFile = path: file:
|
let readCommitFromFile = file: path:
|
||||||
with builtins;
|
with builtins;
|
||||||
let fileName = toString path + "/" + file;
|
let fileName = toString path + "/" + file;
|
||||||
packedRefsName = toString path + "/packed-refs";
|
packedRefsName = toString path + "/packed-refs";
|
||||||
@ -81,7 +85,7 @@ rec {
|
|||||||
matchRef = match "^ref: (.*)$" fileContent;
|
matchRef = match "^ref: (.*)$" fileContent;
|
||||||
in if isNull matchRef
|
in if isNull matchRef
|
||||||
then fileContent
|
then fileContent
|
||||||
else readCommitFromFile path (lib.head matchRef)
|
else readCommitFromFile (lib.head matchRef) path
|
||||||
# Sometimes, the file isn't there at all and has been packed away in the
|
# Sometimes, the file isn't there at all and has been packed away in the
|
||||||
# packed-refs file, so we have to grep through it:
|
# packed-refs file, so we have to grep through it:
|
||||||
else if lib.pathExists packedRefsName
|
else if lib.pathExists packedRefsName
|
||||||
@ -92,7 +96,7 @@ rec {
|
|||||||
then throw ("Could not find " + file + " in " + packedRefsName)
|
then throw ("Could not find " + file + " in " + packedRefsName)
|
||||||
else lib.head matchRef
|
else lib.head matchRef
|
||||||
else throw ("Not a .git directory: " + path);
|
else throw ("Not a .git directory: " + path);
|
||||||
in lib.flip readCommitFromFile "HEAD";
|
in readCommitFromFile "HEAD";
|
||||||
|
|
||||||
pathHasContext = builtins.hasContext or (lib.hasPrefix builtins.storeDir);
|
pathHasContext = builtins.hasContext or (lib.hasPrefix builtins.storeDir);
|
||||||
|
|
||||||
|
232
lib/strings.nix
232
lib/strings.nix
@ -12,6 +12,8 @@ rec {
|
|||||||
|
|
||||||
/* Concatenate a list of strings.
|
/* Concatenate a list of strings.
|
||||||
|
|
||||||
|
Type: concatStrings :: [string] -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
concatStrings ["foo" "bar"]
|
concatStrings ["foo" "bar"]
|
||||||
=> "foobar"
|
=> "foobar"
|
||||||
@ -20,15 +22,19 @@ rec {
|
|||||||
|
|
||||||
/* Map a function over a list and concatenate the resulting strings.
|
/* Map a function over a list and concatenate the resulting strings.
|
||||||
|
|
||||||
|
Type: concatMapStrings :: (a -> string) -> [a] -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
concatMapStrings (x: "a" + x) ["foo" "bar"]
|
concatMapStrings (x: "a" + x) ["foo" "bar"]
|
||||||
=> "afooabar"
|
=> "afooabar"
|
||||||
*/
|
*/
|
||||||
concatMapStrings = f: list: concatStrings (map f list);
|
concatMapStrings = f: list: concatStrings (map f list);
|
||||||
|
|
||||||
/* Like `concatMapStrings' except that the f functions also gets the
|
/* Like `concatMapStrings` except that the f functions also gets the
|
||||||
position as a parameter.
|
position as a parameter.
|
||||||
|
|
||||||
|
Type: concatImapStrings :: (int -> a -> string) -> [a] -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
concatImapStrings (pos: x: "${toString pos}-${x}") ["foo" "bar"]
|
concatImapStrings (pos: x: "${toString pos}-${x}") ["foo" "bar"]
|
||||||
=> "1-foo2-bar"
|
=> "1-foo2-bar"
|
||||||
@ -37,17 +43,25 @@ rec {
|
|||||||
|
|
||||||
/* Place an element between each element of a list
|
/* Place an element between each element of a list
|
||||||
|
|
||||||
|
Type: intersperse :: a -> [a] -> [a]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
intersperse "/" ["usr" "local" "bin"]
|
intersperse "/" ["usr" "local" "bin"]
|
||||||
=> ["usr" "/" "local" "/" "bin"].
|
=> ["usr" "/" "local" "/" "bin"].
|
||||||
*/
|
*/
|
||||||
intersperse = separator: list:
|
intersperse =
|
||||||
|
# Separator to add between elements
|
||||||
|
separator:
|
||||||
|
# Input list
|
||||||
|
list:
|
||||||
if list == [] || length list == 1
|
if list == [] || length list == 1
|
||||||
then list
|
then list
|
||||||
else tail (lib.concatMap (x: [separator x]) list);
|
else tail (lib.concatMap (x: [separator x]) list);
|
||||||
|
|
||||||
/* Concatenate a list of strings with a separator between each element
|
/* Concatenate a list of strings with a separator between each element
|
||||||
|
|
||||||
|
Type: concatStringsSep :: string -> [string] -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
concatStringsSep "/" ["usr" "local" "bin"]
|
concatStringsSep "/" ["usr" "local" "bin"]
|
||||||
=> "usr/local/bin"
|
=> "usr/local/bin"
|
||||||
@ -55,43 +69,77 @@ rec {
|
|||||||
concatStringsSep = builtins.concatStringsSep or (separator: list:
|
concatStringsSep = builtins.concatStringsSep or (separator: list:
|
||||||
concatStrings (intersperse separator list));
|
concatStrings (intersperse separator list));
|
||||||
|
|
||||||
/* First maps over the list and then concatenates it.
|
/* Maps a function over a list of strings and then concatenates the
|
||||||
|
result with the specified separator interspersed between
|
||||||
|
elements.
|
||||||
|
|
||||||
|
Type: concatMapStringsSep :: string -> (string -> string) -> [string] -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
concatMapStringsSep "-" (x: toUpper x) ["foo" "bar" "baz"]
|
concatMapStringsSep "-" (x: toUpper x) ["foo" "bar" "baz"]
|
||||||
=> "FOO-BAR-BAZ"
|
=> "FOO-BAR-BAZ"
|
||||||
*/
|
*/
|
||||||
concatMapStringsSep = sep: f: list: concatStringsSep sep (map f list);
|
concatMapStringsSep =
|
||||||
|
# Separator to add between elements
|
||||||
|
sep:
|
||||||
|
# Function to map over the list
|
||||||
|
f:
|
||||||
|
# List of input strings
|
||||||
|
list: concatStringsSep sep (map f list);
|
||||||
|
|
||||||
/* First imaps over the list and then concatenates it.
|
/* Same as `concatMapStringsSep`, but the mapping function
|
||||||
|
additionally receives the position of its argument.
|
||||||
|
|
||||||
|
Type: concatMapStringsSep :: string -> (int -> string -> string) -> [string] -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
concatImapStringsSep "-" (pos: x: toString (x / pos)) [ 6 6 6 ]
|
concatImapStringsSep "-" (pos: x: toString (x / pos)) [ 6 6 6 ]
|
||||||
=> "6-3-2"
|
=> "6-3-2"
|
||||||
*/
|
*/
|
||||||
concatImapStringsSep = sep: f: list: concatStringsSep sep (lib.imap1 f list);
|
concatImapStringsSep =
|
||||||
|
# Separator to add between elements
|
||||||
|
sep:
|
||||||
|
# Function that receives elements and their positions
|
||||||
|
f:
|
||||||
|
# List of input strings
|
||||||
|
list: concatStringsSep sep (lib.imap1 f list);
|
||||||
|
|
||||||
/* Construct a Unix-style search path consisting of each `subDir"
|
/* Construct a Unix-style, colon-separated search path consisting of
|
||||||
directory of the given list of packages.
|
the given `subDir` appended to each of the given paths.
|
||||||
|
|
||||||
|
Type: makeSearchPath :: string -> [string] -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
makeSearchPath "bin" ["/root" "/usr" "/usr/local"]
|
makeSearchPath "bin" ["/root" "/usr" "/usr/local"]
|
||||||
=> "/root/bin:/usr/bin:/usr/local/bin"
|
=> "/root/bin:/usr/bin:/usr/local/bin"
|
||||||
makeSearchPath "bin" ["/"]
|
makeSearchPath "bin" [""]
|
||||||
=> "//bin"
|
=> "/bin"
|
||||||
*/
|
*/
|
||||||
makeSearchPath = subDir: packages:
|
makeSearchPath =
|
||||||
concatStringsSep ":" (map (path: path + "/" + subDir) (builtins.filter (x: x != null) packages));
|
# Directory name to append
|
||||||
|
subDir:
|
||||||
|
# List of base paths
|
||||||
|
paths:
|
||||||
|
concatStringsSep ":" (map (path: path + "/" + subDir) (builtins.filter (x: x != null) paths));
|
||||||
|
|
||||||
/* Construct a Unix-style search path, using given package output.
|
/* Construct a Unix-style search path by appending the given
|
||||||
If no output is found, fallback to `.out` and then to the default.
|
`subDir` to the specified `output` of each of the packages. If no
|
||||||
|
output by the given name is found, fallback to `.out` and then to
|
||||||
|
the default.
|
||||||
|
|
||||||
|
Type: string -> string -> [package] -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
makeSearchPathOutput "dev" "bin" [ pkgs.openssl pkgs.zlib ]
|
makeSearchPathOutput "dev" "bin" [ pkgs.openssl pkgs.zlib ]
|
||||||
=> "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev/bin:/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/bin"
|
=> "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev/bin:/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/bin"
|
||||||
*/
|
*/
|
||||||
makeSearchPathOutput = output: subDir: pkgs: makeSearchPath subDir (map (lib.getOutput output) pkgs);
|
makeSearchPathOutput =
|
||||||
|
# Package output to use
|
||||||
|
output:
|
||||||
|
# Directory name to append
|
||||||
|
subDir:
|
||||||
|
# List of packages
|
||||||
|
pkgs: makeSearchPath subDir (map (lib.getOutput output) pkgs);
|
||||||
|
|
||||||
/* Construct a library search path (such as RPATH) containing the
|
/* Construct a library search path (such as RPATH) containing the
|
||||||
libraries for a set of packages
|
libraries for a set of packages
|
||||||
@ -117,46 +165,71 @@ rec {
|
|||||||
|
|
||||||
/* Construct a perl search path (such as $PERL5LIB)
|
/* Construct a perl search path (such as $PERL5LIB)
|
||||||
|
|
||||||
FIXME(zimbatm): this should be moved in perl-specific code
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
pkgs = import <nixpkgs> { }
|
pkgs = import <nixpkgs> { }
|
||||||
makePerlPath [ pkgs.perlPackages.libnet ]
|
makePerlPath [ pkgs.perlPackages.libnet ]
|
||||||
=> "/nix/store/n0m1fk9c960d8wlrs62sncnadygqqc6y-perl-Net-SMTP-1.25/lib/perl5/site_perl"
|
=> "/nix/store/n0m1fk9c960d8wlrs62sncnadygqqc6y-perl-Net-SMTP-1.25/lib/perl5/site_perl"
|
||||||
*/
|
*/
|
||||||
|
# FIXME(zimbatm): this should be moved in perl-specific code
|
||||||
makePerlPath = makeSearchPathOutput "lib" "lib/perl5/site_perl";
|
makePerlPath = makeSearchPathOutput "lib" "lib/perl5/site_perl";
|
||||||
|
|
||||||
|
/* Construct a perl search path recursively including all dependencies (such as $PERL5LIB)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
pkgs = import <nixpkgs> { }
|
||||||
|
makeFullPerlPath [ pkgs.perlPackages.CGI ]
|
||||||
|
=> "/nix/store/fddivfrdc1xql02h9q500fpnqy12c74n-perl-CGI-4.38/lib/perl5/site_perl:/nix/store/8hsvdalmsxqkjg0c5ifigpf31vc4vsy2-perl-HTML-Parser-3.72/lib/perl5/site_perl:/nix/store/zhc7wh0xl8hz3y3f71nhlw1559iyvzld-perl-HTML-Tagset-3.20/lib/perl5/site_perl"
|
||||||
|
*/
|
||||||
|
makeFullPerlPath = deps: makePerlPath (lib.misc.closePropagation deps);
|
||||||
|
|
||||||
/* Depending on the boolean `cond', return either the given string
|
/* Depending on the boolean `cond', return either the given string
|
||||||
or the empty string. Useful to concatenate against a bigger string.
|
or the empty string. Useful to concatenate against a bigger string.
|
||||||
|
|
||||||
|
Type: optionalString :: bool -> string -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
optionalString true "some-string"
|
optionalString true "some-string"
|
||||||
=> "some-string"
|
=> "some-string"
|
||||||
optionalString false "some-string"
|
optionalString false "some-string"
|
||||||
=> ""
|
=> ""
|
||||||
*/
|
*/
|
||||||
optionalString = cond: string: if cond then string else "";
|
optionalString =
|
||||||
|
# Condition
|
||||||
|
cond:
|
||||||
|
# String to return if condition is true
|
||||||
|
string: if cond then string else "";
|
||||||
|
|
||||||
/* Determine whether a string has given prefix.
|
/* Determine whether a string has given prefix.
|
||||||
|
|
||||||
|
Type: hasPrefix :: string -> string -> bool
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
hasPrefix "foo" "foobar"
|
hasPrefix "foo" "foobar"
|
||||||
=> true
|
=> true
|
||||||
hasPrefix "foo" "barfoo"
|
hasPrefix "foo" "barfoo"
|
||||||
=> false
|
=> false
|
||||||
*/
|
*/
|
||||||
hasPrefix = pref: str:
|
hasPrefix =
|
||||||
substring 0 (stringLength pref) str == pref;
|
# Prefix to check for
|
||||||
|
pref:
|
||||||
|
# Input string
|
||||||
|
str: substring 0 (stringLength pref) str == pref;
|
||||||
|
|
||||||
/* Determine whether a string has given suffix.
|
/* Determine whether a string has given suffix.
|
||||||
|
|
||||||
|
Type: hasSuffix :: string -> string -> bool
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
hasSuffix "foo" "foobar"
|
hasSuffix "foo" "foobar"
|
||||||
=> false
|
=> false
|
||||||
hasSuffix "foo" "barfoo"
|
hasSuffix "foo" "barfoo"
|
||||||
=> true
|
=> true
|
||||||
*/
|
*/
|
||||||
hasSuffix = suffix: content:
|
hasSuffix =
|
||||||
|
# Suffix to check for
|
||||||
|
suffix:
|
||||||
|
# Input string
|
||||||
|
content:
|
||||||
let
|
let
|
||||||
lenContent = stringLength content;
|
lenContent = stringLength content;
|
||||||
lenSuffix = stringLength suffix;
|
lenSuffix = stringLength suffix;
|
||||||
@ -171,6 +244,8 @@ rec {
|
|||||||
Also note that Nix treats strings as a list of bytes and thus doesn't
|
Also note that Nix treats strings as a list of bytes and thus doesn't
|
||||||
handle unicode.
|
handle unicode.
|
||||||
|
|
||||||
|
Type: stringtoCharacters :: string -> [string]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
stringToCharacters ""
|
stringToCharacters ""
|
||||||
=> [ ]
|
=> [ ]
|
||||||
@ -185,18 +260,25 @@ rec {
|
|||||||
/* Manipulate a string character by character and replace them by
|
/* Manipulate a string character by character and replace them by
|
||||||
strings before concatenating the results.
|
strings before concatenating the results.
|
||||||
|
|
||||||
|
Type: stringAsChars :: (string -> string) -> string -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
stringAsChars (x: if x == "a" then "i" else x) "nax"
|
stringAsChars (x: if x == "a" then "i" else x) "nax"
|
||||||
=> "nix"
|
=> "nix"
|
||||||
*/
|
*/
|
||||||
stringAsChars = f: s:
|
stringAsChars =
|
||||||
concatStrings (
|
# Function to map over each individual character
|
||||||
|
f:
|
||||||
|
# Input string
|
||||||
|
s: concatStrings (
|
||||||
map f (stringToCharacters s)
|
map f (stringToCharacters s)
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Escape occurrence of the elements of ‘list’ in ‘string’ by
|
/* Escape occurrence of the elements of `list` in `string` by
|
||||||
prefixing it with a backslash.
|
prefixing it with a backslash.
|
||||||
|
|
||||||
|
Type: escape :: [string] -> string -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
escape ["(" ")"] "(foo)"
|
escape ["(" ")"] "(foo)"
|
||||||
=> "\\(foo\\)"
|
=> "\\(foo\\)"
|
||||||
@ -205,6 +287,8 @@ rec {
|
|||||||
|
|
||||||
/* Quote string to be used safely within the Bourne shell.
|
/* Quote string to be used safely within the Bourne shell.
|
||||||
|
|
||||||
|
Type: escapeShellArg :: string -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
escapeShellArg "esc'ape\nme"
|
escapeShellArg "esc'ape\nme"
|
||||||
=> "'esc'\\''ape\nme'"
|
=> "'esc'\\''ape\nme'"
|
||||||
@ -213,6 +297,8 @@ rec {
|
|||||||
|
|
||||||
/* Quote all arguments to be safely passed to the Bourne shell.
|
/* Quote all arguments to be safely passed to the Bourne shell.
|
||||||
|
|
||||||
|
Type: escapeShellArgs :: [string] -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
escapeShellArgs ["one" "two three" "four'five"]
|
escapeShellArgs ["one" "two three" "four'five"]
|
||||||
=> "'one' 'two three' 'four'\\''five'"
|
=> "'one' 'two three' 'four'\\''five'"
|
||||||
@ -221,13 +307,15 @@ rec {
|
|||||||
|
|
||||||
/* Turn a string into a Nix expression representing that string
|
/* Turn a string into a Nix expression representing that string
|
||||||
|
|
||||||
|
Type: string -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
escapeNixString "hello\${}\n"
|
escapeNixString "hello\${}\n"
|
||||||
=> "\"hello\\\${}\\n\""
|
=> "\"hello\\\${}\\n\""
|
||||||
*/
|
*/
|
||||||
escapeNixString = s: escape ["$"] (builtins.toJSON s);
|
escapeNixString = s: escape ["$"] (builtins.toJSON s);
|
||||||
|
|
||||||
/* Obsolete - use replaceStrings instead. */
|
# Obsolete - use replaceStrings instead.
|
||||||
replaceChars = builtins.replaceStrings or (
|
replaceChars = builtins.replaceStrings or (
|
||||||
del: new: s:
|
del: new: s:
|
||||||
let
|
let
|
||||||
@ -247,6 +335,8 @@ rec {
|
|||||||
|
|
||||||
/* Converts an ASCII string to lower-case.
|
/* Converts an ASCII string to lower-case.
|
||||||
|
|
||||||
|
Type: toLower :: string -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
toLower "HOME"
|
toLower "HOME"
|
||||||
=> "home"
|
=> "home"
|
||||||
@ -255,6 +345,8 @@ rec {
|
|||||||
|
|
||||||
/* Converts an ASCII string to upper-case.
|
/* Converts an ASCII string to upper-case.
|
||||||
|
|
||||||
|
Type: toUpper :: string -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
toUpper "home"
|
toUpper "home"
|
||||||
=> "HOME"
|
=> "HOME"
|
||||||
@ -264,7 +356,7 @@ rec {
|
|||||||
/* Appends string context from another string. This is an implementation
|
/* Appends string context from another string. This is an implementation
|
||||||
detail of Nix.
|
detail of Nix.
|
||||||
|
|
||||||
Strings in Nix carry an invisible `context' which is a list of strings
|
Strings in Nix carry an invisible `context` which is a list of strings
|
||||||
representing store paths. If the string is later used in a derivation
|
representing store paths. If the string is later used in a derivation
|
||||||
attribute, the derivation will properly populate the inputDrvs and
|
attribute, the derivation will properly populate the inputDrvs and
|
||||||
inputSrcs.
|
inputSrcs.
|
||||||
@ -310,8 +402,9 @@ rec {
|
|||||||
in
|
in
|
||||||
recurse 0 0;
|
recurse 0 0;
|
||||||
|
|
||||||
/* Return the suffix of the second argument if the first argument matches
|
/* Return a string without the specified prefix, if the prefix matches.
|
||||||
its prefix.
|
|
||||||
|
Type: string -> string -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
removePrefix "foo." "foo.bar.baz"
|
removePrefix "foo." "foo.bar.baz"
|
||||||
@ -319,18 +412,23 @@ rec {
|
|||||||
removePrefix "xxx" "foo.bar.baz"
|
removePrefix "xxx" "foo.bar.baz"
|
||||||
=> "foo.bar.baz"
|
=> "foo.bar.baz"
|
||||||
*/
|
*/
|
||||||
removePrefix = pre: s:
|
removePrefix =
|
||||||
|
# Prefix to remove if it matches
|
||||||
|
prefix:
|
||||||
|
# Input string
|
||||||
|
str:
|
||||||
let
|
let
|
||||||
preLen = stringLength pre;
|
preLen = stringLength prefix;
|
||||||
sLen = stringLength s;
|
sLen = stringLength str;
|
||||||
in
|
in
|
||||||
if hasPrefix pre s then
|
if hasPrefix prefix str then
|
||||||
substring preLen (sLen - preLen) s
|
substring preLen (sLen - preLen) str
|
||||||
else
|
else
|
||||||
s;
|
str;
|
||||||
|
|
||||||
/* Return the prefix of the second argument if the first argument matches
|
/* Return a string without the specified suffix, if the suffix matches.
|
||||||
its suffix.
|
|
||||||
|
Type: string -> string -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
removeSuffix "front" "homefront"
|
removeSuffix "front" "homefront"
|
||||||
@ -338,17 +436,21 @@ rec {
|
|||||||
removeSuffix "xxx" "homefront"
|
removeSuffix "xxx" "homefront"
|
||||||
=> "homefront"
|
=> "homefront"
|
||||||
*/
|
*/
|
||||||
removeSuffix = suf: s:
|
removeSuffix =
|
||||||
|
# Suffix to remove if it matches
|
||||||
|
suffix:
|
||||||
|
# Input string
|
||||||
|
str:
|
||||||
let
|
let
|
||||||
sufLen = stringLength suf;
|
sufLen = stringLength suffix;
|
||||||
sLen = stringLength s;
|
sLen = stringLength str;
|
||||||
in
|
in
|
||||||
if sufLen <= sLen && suf == substring (sLen - sufLen) sufLen s then
|
if sufLen <= sLen && suffix == substring (sLen - sufLen) sufLen str then
|
||||||
substring 0 (sLen - sufLen) s
|
substring 0 (sLen - sufLen) str
|
||||||
else
|
else
|
||||||
s;
|
str;
|
||||||
|
|
||||||
/* Return true iff string v1 denotes a version older than v2.
|
/* Return true if string v1 denotes a version older than v2.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
versionOlder "1.1" "1.2"
|
versionOlder "1.1" "1.2"
|
||||||
@ -358,7 +460,7 @@ rec {
|
|||||||
*/
|
*/
|
||||||
versionOlder = v1: v2: builtins.compareVersions v2 v1 == 1;
|
versionOlder = v1: v2: builtins.compareVersions v2 v1 == 1;
|
||||||
|
|
||||||
/* Return true iff string v1 denotes a version equal to or newer than v2.
|
/* Return true if string v1 denotes a version equal to or newer than v2.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
versionAtLeast "1.1" "1.0"
|
versionAtLeast "1.1" "1.0"
|
||||||
@ -401,7 +503,7 @@ rec {
|
|||||||
components = splitString "/" url;
|
components = splitString "/" url;
|
||||||
filename = lib.last components;
|
filename = lib.last components;
|
||||||
name = builtins.head (splitString sep filename);
|
name = builtins.head (splitString sep filename);
|
||||||
in assert name != filename; name;
|
in assert name != filename; name;
|
||||||
|
|
||||||
/* Create an --{enable,disable}-<feat> string that can be passed to
|
/* Create an --{enable,disable}-<feat> string that can be passed to
|
||||||
standard GNU Autoconf scripts.
|
standard GNU Autoconf scripts.
|
||||||
@ -450,6 +552,11 @@ rec {
|
|||||||
/* Create a fixed width string with additional prefix to match
|
/* Create a fixed width string with additional prefix to match
|
||||||
required width.
|
required width.
|
||||||
|
|
||||||
|
This function will fail if the input string is longer than the
|
||||||
|
requested length.
|
||||||
|
|
||||||
|
Type: fixedWidthString :: int -> string -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
fixedWidthString 5 "0" (toString 15)
|
fixedWidthString 5 "0" (toString 15)
|
||||||
=> "00015"
|
=> "00015"
|
||||||
@ -459,7 +566,10 @@ rec {
|
|||||||
strw = lib.stringLength str;
|
strw = lib.stringLength str;
|
||||||
reqWidth = width - (lib.stringLength filler);
|
reqWidth = width - (lib.stringLength filler);
|
||||||
in
|
in
|
||||||
assert strw <= width;
|
assert lib.assertMsg (strw <= width)
|
||||||
|
"fixedWidthString: requested string length (${
|
||||||
|
toString width}) must not be shorter than actual length (${
|
||||||
|
toString strw})";
|
||||||
if strw == width then str else filler + fixedWidthString reqWidth filler str;
|
if strw == width then str else filler + fixedWidthString reqWidth filler str;
|
||||||
|
|
||||||
/* Format a number adding leading zeroes up to fixed width.
|
/* Format a number adding leading zeroes up to fixed width.
|
||||||
@ -490,12 +600,16 @@ rec {
|
|||||||
=> false
|
=> false
|
||||||
*/
|
*/
|
||||||
isStorePath = x:
|
isStorePath = x:
|
||||||
isCoercibleToString x
|
if isCoercibleToString x then
|
||||||
&& builtins.substring 0 1 (toString x) == "/"
|
let str = toString x; in
|
||||||
&& dirOf (builtins.toPath x) == builtins.storeDir;
|
builtins.substring 0 1 str == "/"
|
||||||
|
&& dirOf str == builtins.storeDir
|
||||||
|
else
|
||||||
|
false;
|
||||||
|
|
||||||
/* Convert string to int
|
/* Parse a string string as an int.
|
||||||
Obviously, it is a bit hacky to use fromJSON that way.
|
|
||||||
|
Type: string -> int
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
toInt "1337"
|
toInt "1337"
|
||||||
@ -505,17 +619,18 @@ rec {
|
|||||||
toInt "3.14"
|
toInt "3.14"
|
||||||
=> error: floating point JSON numbers are not supported
|
=> error: floating point JSON numbers are not supported
|
||||||
*/
|
*/
|
||||||
|
# Obviously, it is a bit hacky to use fromJSON this way.
|
||||||
toInt = str:
|
toInt = str:
|
||||||
let may_be_int = builtins.fromJSON str; in
|
let may_be_int = builtins.fromJSON str; in
|
||||||
if builtins.isInt may_be_int
|
if builtins.isInt may_be_int
|
||||||
then may_be_int
|
then may_be_int
|
||||||
else throw "Could not convert ${str} to int.";
|
else throw "Could not convert ${str} to int.";
|
||||||
|
|
||||||
/* Read a list of paths from `file', relative to the `rootPath'. Lines
|
/* Read a list of paths from `file`, relative to the `rootPath`.
|
||||||
beginning with `#' are treated as comments and ignored. Whitespace
|
Lines beginning with `#` are treated as comments and ignored.
|
||||||
is significant.
|
Whitespace is significant.
|
||||||
|
|
||||||
NOTE: this function is not performant and should be avoided
|
NOTE: This function is not performant and should be avoided.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
readPathsFromFile /prefix
|
readPathsFromFile /prefix
|
||||||
@ -528,16 +643,17 @@ rec {
|
|||||||
*/
|
*/
|
||||||
readPathsFromFile = rootPath: file:
|
readPathsFromFile = rootPath: file:
|
||||||
let
|
let
|
||||||
root = toString rootPath;
|
|
||||||
lines = lib.splitString "\n" (builtins.readFile file);
|
lines = lib.splitString "\n" (builtins.readFile file);
|
||||||
removeComments = lib.filter (line: line != "" && !(lib.hasPrefix "#" line));
|
removeComments = lib.filter (line: line != "" && !(lib.hasPrefix "#" line));
|
||||||
relativePaths = removeComments lines;
|
relativePaths = removeComments lines;
|
||||||
absolutePaths = builtins.map (path: builtins.toPath (root + "/" + path)) relativePaths;
|
absolutePaths = builtins.map (path: rootPath + "/${path}") relativePaths;
|
||||||
in
|
in
|
||||||
absolutePaths;
|
absolutePaths;
|
||||||
|
|
||||||
/* Read the contents of a file removing the trailing \n
|
/* Read the contents of a file removing the trailing \n
|
||||||
|
|
||||||
|
Type: fileContents :: path -> string
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
$ echo "1.0" > ./version
|
$ echo "1.0" > ./version
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ rec {
|
|||||||
else if final.isUClibc then "uclibc"
|
else if final.isUClibc then "uclibc"
|
||||||
else if final.isAndroid then "bionic"
|
else if final.isAndroid then "bionic"
|
||||||
else if final.isLinux /* default */ then "glibc"
|
else if final.isLinux /* default */ then "glibc"
|
||||||
|
else if final.isAvr then "avrlibc"
|
||||||
# TODO(@Ericson2314) think more about other operating systems
|
# TODO(@Ericson2314) think more about other operating systems
|
||||||
else "native/impure";
|
else "native/impure";
|
||||||
extensions = {
|
extensions = {
|
||||||
@ -46,6 +47,65 @@ rec {
|
|||||||
# Misc boolean options
|
# Misc boolean options
|
||||||
useAndroidPrebuilt = false;
|
useAndroidPrebuilt = false;
|
||||||
useiOSPrebuilt = false;
|
useiOSPrebuilt = false;
|
||||||
|
|
||||||
|
# Output from uname
|
||||||
|
uname = {
|
||||||
|
# uname -s
|
||||||
|
system = {
|
||||||
|
"linux" = "Linux";
|
||||||
|
"windows" = "Windows";
|
||||||
|
"darwin" = "Darwin";
|
||||||
|
"netbsd" = "NetBSD";
|
||||||
|
"freebsd" = "FreeBSD";
|
||||||
|
"openbsd" = "OpenBSD";
|
||||||
|
}.${final.parsed.kernel.name} or null;
|
||||||
|
|
||||||
|
# uname -p
|
||||||
|
processor = final.parsed.cpu.name;
|
||||||
|
|
||||||
|
# uname -r
|
||||||
|
release = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
qemuArch =
|
||||||
|
if final.isArm then "arm"
|
||||||
|
else if final.isx86_64 then "x86_64"
|
||||||
|
else if final.isx86 then "i386"
|
||||||
|
else {
|
||||||
|
"powerpc" = "ppc";
|
||||||
|
"powerpc64" = "ppc64";
|
||||||
|
"powerpc64le" = "ppc64";
|
||||||
|
"mips64" = "mips";
|
||||||
|
"mipsel64" = "mipsel";
|
||||||
|
}.${final.parsed.cpu.name} or final.parsed.cpu.name;
|
||||||
|
|
||||||
|
emulator = pkgs: let
|
||||||
|
qemu-user = pkgs.qemu.override {
|
||||||
|
smartcardSupport = false;
|
||||||
|
spiceSupport = false;
|
||||||
|
openGLSupport = false;
|
||||||
|
virglSupport = false;
|
||||||
|
vncSupport = false;
|
||||||
|
gtkSupport = false;
|
||||||
|
sdlSupport = false;
|
||||||
|
pulseSupport = false;
|
||||||
|
smbdSupport = false;
|
||||||
|
seccompSupport = false;
|
||||||
|
hostCpuTargets = ["${final.qemuArch}-linux-user"];
|
||||||
|
};
|
||||||
|
wine-name = "wine${toString final.parsed.cpu.bits}";
|
||||||
|
wine = (pkgs.winePackagesFor wine-name).minimal;
|
||||||
|
in
|
||||||
|
if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name &&
|
||||||
|
(final.parsed.cpu.name == pkgs.stdenv.hostPlatform.parsed.cpu.name ||
|
||||||
|
(final.platform.isi686 && pkgs.stdenv.hostPlatform.isx86_64))
|
||||||
|
then pkgs.runtimeShell
|
||||||
|
else if final.isWindows
|
||||||
|
then "${wine}/bin/${wine-name}"
|
||||||
|
else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux
|
||||||
|
then "${qemu-user}/bin/qemu-${final.qemuArch}"
|
||||||
|
else throw "Don't know how to run ${final.config} executables.";
|
||||||
|
|
||||||
} // mapAttrs (n: v: v final.parsed) inspect.predicates
|
} // mapAttrs (n: v: v final.parsed) inspect.predicates
|
||||||
// args;
|
// args;
|
||||||
in assert final.useAndroidPrebuilt -> final.isAndroid;
|
in assert final.useAndroidPrebuilt -> final.isAndroid;
|
||||||
|
@ -15,6 +15,8 @@ let
|
|||||||
|
|
||||||
"x86_64-cygwin" "x86_64-darwin" "x86_64-freebsd" "x86_64-linux"
|
"x86_64-cygwin" "x86_64-darwin" "x86_64-freebsd" "x86_64-linux"
|
||||||
"x86_64-netbsd" "x86_64-openbsd" "x86_64-solaris"
|
"x86_64-netbsd" "x86_64-openbsd" "x86_64-solaris"
|
||||||
|
|
||||||
|
"x86_64-windows" "i686-windows"
|
||||||
];
|
];
|
||||||
|
|
||||||
allParsed = map parse.mkSystemFromString all;
|
allParsed = map parse.mkSystemFromString all;
|
||||||
@ -36,13 +38,14 @@ in rec {
|
|||||||
cygwin = filterDoubles predicates.isCygwin;
|
cygwin = filterDoubles predicates.isCygwin;
|
||||||
darwin = filterDoubles predicates.isDarwin;
|
darwin = filterDoubles predicates.isDarwin;
|
||||||
freebsd = filterDoubles predicates.isFreeBSD;
|
freebsd = filterDoubles predicates.isFreeBSD;
|
||||||
# Should be better, but MinGW is unclear, and HURD is bit-rotted.
|
# Should be better, but MinGW is unclear.
|
||||||
gnu = filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnu; });
|
gnu = filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnu; }) ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabi; }) ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabihf; });
|
||||||
illumos = filterDoubles predicates.isSunOS;
|
illumos = filterDoubles predicates.isSunOS;
|
||||||
linux = filterDoubles predicates.isLinux;
|
linux = filterDoubles predicates.isLinux;
|
||||||
netbsd = filterDoubles predicates.isNetBSD;
|
netbsd = filterDoubles predicates.isNetBSD;
|
||||||
openbsd = filterDoubles predicates.isOpenBSD;
|
openbsd = filterDoubles predicates.isOpenBSD;
|
||||||
unix = filterDoubles predicates.isUnix;
|
unix = filterDoubles predicates.isUnix;
|
||||||
|
windows = filterDoubles predicates.isWindows;
|
||||||
|
|
||||||
mesaPlatforms = ["i686-linux" "x86_64-linux" "x86_64-darwin" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "aarch64-linux"];
|
mesaPlatforms = ["i686-linux" "x86_64-linux" "x86_64-darwin" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "aarch64-linux" "powerpc64le-linux"];
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,27 @@
|
|||||||
# `crossSystem`. They are put here for user convenience, but also used by cross
|
# `crossSystem`. They are put here for user convenience, but also used by cross
|
||||||
# tests and linux cross stdenv building, so handle with care!
|
# tests and linux cross stdenv building, so handle with care!
|
||||||
{ lib }:
|
{ lib }:
|
||||||
let platforms = import ./platforms.nix { inherit lib; }; in
|
let
|
||||||
|
platforms = import ./platforms.nix { inherit lib; };
|
||||||
|
|
||||||
|
riscv = bits: {
|
||||||
|
config = "riscv${bits}-unknown-linux-gnu";
|
||||||
|
platform = platforms.riscv-multiplatform bits;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
#
|
#
|
||||||
# Linux
|
# Linux
|
||||||
#
|
#
|
||||||
|
powernv = {
|
||||||
|
config = "powerpc64le-unknown-linux-gnu";
|
||||||
|
platform = platforms.powernv;
|
||||||
|
};
|
||||||
|
musl-power = {
|
||||||
|
config = "powerpc64le-unknown-linux-musl";
|
||||||
|
platform = platforms.powernv;
|
||||||
|
};
|
||||||
|
|
||||||
sheevaplug = rec {
|
sheevaplug = rec {
|
||||||
config = "armv5tel-unknown-linux-gnueabi";
|
config = "armv5tel-unknown-linux-gnueabi";
|
||||||
@ -20,7 +35,7 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
armv7l-hf-multiplatform = rec {
|
armv7l-hf-multiplatform = rec {
|
||||||
config = "armv7a-unknown-linux-gnueabihf";
|
config = "armv7l-unknown-linux-gnueabihf";
|
||||||
platform = platforms.armv7l-hf-multiplatform;
|
platform = platforms.armv7l-hf-multiplatform;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,7 +55,7 @@ rec {
|
|||||||
armv7a-android-prebuilt = rec {
|
armv7a-android-prebuilt = rec {
|
||||||
config = "armv7a-unknown-linux-androideabi";
|
config = "armv7a-unknown-linux-androideabi";
|
||||||
sdkVer = "24";
|
sdkVer = "24";
|
||||||
ndkVer = "17";
|
ndkVer = "17c";
|
||||||
platform = platforms.armv7a-android;
|
platform = platforms.armv7a-android;
|
||||||
useAndroidPrebuilt = true;
|
useAndroidPrebuilt = true;
|
||||||
};
|
};
|
||||||
@ -48,7 +63,7 @@ rec {
|
|||||||
aarch64-android-prebuilt = rec {
|
aarch64-android-prebuilt = rec {
|
||||||
config = "aarch64-unknown-linux-android";
|
config = "aarch64-unknown-linux-android";
|
||||||
sdkVer = "24";
|
sdkVer = "24";
|
||||||
ndkVer = "17";
|
ndkVer = "17c";
|
||||||
platform = platforms.aarch64-multiplatform;
|
platform = platforms.aarch64-multiplatform;
|
||||||
useAndroidPrebuilt = true;
|
useAndroidPrebuilt = true;
|
||||||
};
|
};
|
||||||
@ -84,13 +99,52 @@ rec {
|
|||||||
musl64 = { config = "x86_64-unknown-linux-musl"; };
|
musl64 = { config = "x86_64-unknown-linux-musl"; };
|
||||||
musl32 = { config = "i686-unknown-linux-musl"; };
|
musl32 = { config = "i686-unknown-linux-musl"; };
|
||||||
|
|
||||||
riscv = bits: {
|
|
||||||
config = "riscv${bits}-unknown-linux-gnu";
|
|
||||||
platform = platforms.riscv-multiplatform bits;
|
|
||||||
};
|
|
||||||
riscv64 = riscv "64";
|
riscv64 = riscv "64";
|
||||||
riscv32 = riscv "32";
|
riscv32 = riscv "32";
|
||||||
|
|
||||||
|
avr = {
|
||||||
|
config = "avr";
|
||||||
|
};
|
||||||
|
|
||||||
|
arm-embedded = {
|
||||||
|
config = "arm-none-eabi";
|
||||||
|
libc = "newlib";
|
||||||
|
};
|
||||||
|
|
||||||
|
aarch64-embedded = {
|
||||||
|
config = "aarch64-none-elf";
|
||||||
|
libc = "newlib";
|
||||||
|
};
|
||||||
|
|
||||||
|
aarch64be-embedded = {
|
||||||
|
config = "aarch64_be-none-elf";
|
||||||
|
libc = "newlib";
|
||||||
|
};
|
||||||
|
|
||||||
|
ppc-embedded = {
|
||||||
|
config = "powerpc-none-eabi";
|
||||||
|
libc = "newlib";
|
||||||
|
};
|
||||||
|
|
||||||
|
ppcle-embedded = {
|
||||||
|
config = "powerpcle-none-eabi";
|
||||||
|
libc = "newlib";
|
||||||
|
};
|
||||||
|
|
||||||
|
alpha-embedded = {
|
||||||
|
config = "alpha-elf";
|
||||||
|
libc = "newlib";
|
||||||
|
};
|
||||||
|
|
||||||
|
i686-embedded = {
|
||||||
|
config = "i686-elf";
|
||||||
|
libc = "newlib";
|
||||||
|
};
|
||||||
|
|
||||||
|
x86_64-embedded = {
|
||||||
|
config = "x86_64-elf";
|
||||||
|
libc = "newlib";
|
||||||
|
};
|
||||||
|
|
||||||
#
|
#
|
||||||
# Darwin
|
# Darwin
|
||||||
|
@ -20,7 +20,7 @@ in rec {
|
|||||||
cygwin = [ patterns.isCygwin ];
|
cygwin = [ patterns.isCygwin ];
|
||||||
darwin = [ patterns.isDarwin ];
|
darwin = [ patterns.isDarwin ];
|
||||||
freebsd = [ patterns.isFreeBSD ];
|
freebsd = [ patterns.isFreeBSD ];
|
||||||
# Should be better, but MinGW is unclear, and HURD is bit-rotted.
|
# Should be better, but MinGW is unclear.
|
||||||
gnu = [
|
gnu = [
|
||||||
{ kernel = parse.kernels.linux; abi = abis.gnu; }
|
{ kernel = parse.kernels.linux; abi = abis.gnu; }
|
||||||
{ kernel = parse.kernels.linux; abi = abis.gnueabi; }
|
{ kernel = parse.kernels.linux; abi = abis.gnueabi; }
|
||||||
|
@ -11,12 +11,15 @@ rec {
|
|||||||
isi686 = { cpu = cpuTypes.i686; };
|
isi686 = { cpu = cpuTypes.i686; };
|
||||||
isx86_64 = { cpu = cpuTypes.x86_64; };
|
isx86_64 = { cpu = cpuTypes.x86_64; };
|
||||||
isPowerPC = { cpu = cpuTypes.powerpc; };
|
isPowerPC = { cpu = cpuTypes.powerpc; };
|
||||||
|
isPower = { cpu = { family = "power"; }; };
|
||||||
isx86 = { cpu = { family = "x86"; }; };
|
isx86 = { cpu = { family = "x86"; }; };
|
||||||
isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
|
isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
|
||||||
isAarch64 = { cpu = { family = "arm"; bits = 64; }; };
|
isAarch64 = { cpu = { family = "arm"; bits = 64; }; };
|
||||||
isMips = { cpu = { family = "mips"; }; };
|
isMips = { cpu = { family = "mips"; }; };
|
||||||
isRiscV = { cpu = { family = "riscv"; }; };
|
isRiscV = { cpu = { family = "riscv"; }; };
|
||||||
|
isSparc = { cpu = { family = "sparc"; }; };
|
||||||
isWasm = { cpu = { family = "wasm"; }; };
|
isWasm = { cpu = { family = "wasm"; }; };
|
||||||
|
isAvr = { cpu = { family = "avr"; }; };
|
||||||
|
|
||||||
is32bit = { cpu = { bits = 32; }; };
|
is32bit = { cpu = { bits = 32; }; };
|
||||||
is64bit = { cpu = { bits = 64; }; };
|
is64bit = { cpu = { bits = 64; }; };
|
||||||
@ -25,14 +28,13 @@ rec {
|
|||||||
|
|
||||||
isBSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
|
isBSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
|
||||||
isDarwin = { kernel = { families = { inherit (kernelFamilies) darwin; }; }; };
|
isDarwin = { kernel = { families = { inherit (kernelFamilies) darwin; }; }; };
|
||||||
isUnix = [ isBSD isDarwin isLinux isSunOS isHurd isCygwin ];
|
isUnix = [ isBSD isDarwin isLinux isSunOS isCygwin ];
|
||||||
|
|
||||||
isMacOS = { kernel = kernels.macos; };
|
isMacOS = { kernel = kernels.macos; };
|
||||||
isiOS = { kernel = kernels.ios; };
|
isiOS = { kernel = kernels.ios; };
|
||||||
isLinux = { kernel = kernels.linux; };
|
isLinux = { kernel = kernels.linux; };
|
||||||
isSunOS = { kernel = kernels.solaris; };
|
isSunOS = { kernel = kernels.solaris; };
|
||||||
isFreeBSD = { kernel = kernels.freebsd; };
|
isFreeBSD = { kernel = kernels.freebsd; };
|
||||||
isHurd = { kernel = kernels.hurd; };
|
|
||||||
isNetBSD = { kernel = kernels.netbsd; };
|
isNetBSD = { kernel = kernels.netbsd; };
|
||||||
isOpenBSD = { kernel = kernels.openbsd; };
|
isOpenBSD = { kernel = kernels.openbsd; };
|
||||||
isWindows = { kernel = kernels.windows; };
|
isWindows = { kernel = kernels.windows; };
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
with lib.lists;
|
with lib.lists;
|
||||||
with lib.types;
|
with lib.types;
|
||||||
with lib.attrsets;
|
with lib.attrsets;
|
||||||
|
with lib.strings;
|
||||||
with (import ./inspect.nix { inherit lib; }).predicates;
|
with (import ./inspect.nix { inherit lib; }).predicates;
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -79,7 +80,11 @@ rec {
|
|||||||
armv8r = { bits = 32; significantByte = littleEndian; family = "arm"; version = "8"; };
|
armv8r = { bits = 32; significantByte = littleEndian; family = "arm"; version = "8"; };
|
||||||
armv8m = { bits = 32; significantByte = littleEndian; family = "arm"; version = "8"; };
|
armv8m = { bits = 32; significantByte = littleEndian; family = "arm"; version = "8"; };
|
||||||
aarch64 = { bits = 64; significantByte = littleEndian; family = "arm"; version = "8"; };
|
aarch64 = { bits = 64; significantByte = littleEndian; family = "arm"; version = "8"; };
|
||||||
|
aarch64_be = { bits = 64; significantByte = bigEndian; family = "arm"; version = "8"; };
|
||||||
|
|
||||||
|
i386 = { bits = 32; significantByte = littleEndian; family = "x86"; };
|
||||||
|
i486 = { bits = 32; significantByte = littleEndian; family = "x86"; };
|
||||||
|
i586 = { bits = 32; significantByte = littleEndian; family = "x86"; };
|
||||||
i686 = { bits = 32; significantByte = littleEndian; family = "x86"; };
|
i686 = { bits = 32; significantByte = littleEndian; family = "x86"; };
|
||||||
x86_64 = { bits = 64; significantByte = littleEndian; family = "x86"; };
|
x86_64 = { bits = 64; significantByte = littleEndian; family = "x86"; };
|
||||||
|
|
||||||
@ -89,12 +94,22 @@ rec {
|
|||||||
mips64el = { bits = 64; significantByte = littleEndian; family = "mips"; };
|
mips64el = { bits = 64; significantByte = littleEndian; family = "mips"; };
|
||||||
|
|
||||||
powerpc = { bits = 32; significantByte = bigEndian; family = "power"; };
|
powerpc = { bits = 32; significantByte = bigEndian; family = "power"; };
|
||||||
|
powerpc64 = { bits = 64; significantByte = bigEndian; family = "power"; };
|
||||||
|
powerpc64le = { bits = 64; significantByte = littleEndian; family = "power"; };
|
||||||
|
powerpcle = { bits = 32; significantByte = littleEndian; family = "power"; };
|
||||||
|
|
||||||
riscv32 = { bits = 32; significantByte = littleEndian; family = "riscv"; };
|
riscv32 = { bits = 32; significantByte = littleEndian; family = "riscv"; };
|
||||||
riscv64 = { bits = 64; significantByte = littleEndian; family = "riscv"; };
|
riscv64 = { bits = 64; significantByte = littleEndian; family = "riscv"; };
|
||||||
|
|
||||||
|
sparc = { bits = 32; significantByte = bigEndian; family = "sparc"; };
|
||||||
|
sparc64 = { bits = 64; significantByte = bigEndian; family = "sparc"; };
|
||||||
|
|
||||||
wasm32 = { bits = 32; significantByte = littleEndian; family = "wasm"; };
|
wasm32 = { bits = 32; significantByte = littleEndian; family = "wasm"; };
|
||||||
wasm64 = { bits = 64; significantByte = littleEndian; family = "wasm"; };
|
wasm64 = { bits = 64; significantByte = littleEndian; family = "wasm"; };
|
||||||
|
|
||||||
|
alpha = { bits = 64; significantByte = littleEndian; family = "alpha"; };
|
||||||
|
|
||||||
|
avr = { bits = 8; family = "avr"; };
|
||||||
};
|
};
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -111,6 +126,7 @@ rec {
|
|||||||
apple = {};
|
apple = {};
|
||||||
pc = {};
|
pc = {};
|
||||||
|
|
||||||
|
none = {};
|
||||||
unknown = {};
|
unknown = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -166,7 +182,6 @@ rec {
|
|||||||
macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; };
|
macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; };
|
||||||
ios = { execFormat = macho; families = { inherit darwin; }; };
|
ios = { execFormat = macho; families = { inherit darwin; }; };
|
||||||
freebsd = { execFormat = elf; families = { inherit bsd; }; };
|
freebsd = { execFormat = elf; families = { inherit bsd; }; };
|
||||||
hurd = { execFormat = elf; families = { }; };
|
|
||||||
linux = { execFormat = elf; families = { }; };
|
linux = { execFormat = elf; families = { }; };
|
||||||
netbsd = { execFormat = elf; families = { inherit bsd; }; };
|
netbsd = { execFormat = elf; families = { inherit bsd; }; };
|
||||||
none = { execFormat = unknown; families = { }; };
|
none = { execFormat = unknown; families = { }; };
|
||||||
@ -176,9 +191,6 @@ rec {
|
|||||||
} // { # aliases
|
} // { # aliases
|
||||||
# 'darwin' is the kernel for all of them. We choose macOS by default.
|
# 'darwin' is the kernel for all of them. We choose macOS by default.
|
||||||
darwin = kernels.macos;
|
darwin = kernels.macos;
|
||||||
# TODO(@Ericson2314): Handle these Darwin version suffixes more generally.
|
|
||||||
darwin10 = kernels.macos;
|
|
||||||
darwin14 = kernels.macos;
|
|
||||||
watchos = kernels.ios;
|
watchos = kernels.ios;
|
||||||
tvos = kernels.ios;
|
tvos = kernels.ios;
|
||||||
win32 = kernels.windows;
|
win32 = kernels.windows;
|
||||||
@ -198,6 +210,7 @@ rec {
|
|||||||
cygnus = {};
|
cygnus = {};
|
||||||
msvc = {};
|
msvc = {};
|
||||||
eabi = {};
|
eabi = {};
|
||||||
|
elf = {};
|
||||||
|
|
||||||
androideabi = {};
|
androideabi = {};
|
||||||
android = {
|
android = {
|
||||||
@ -253,11 +266,16 @@ rec {
|
|||||||
setType "system" components;
|
setType "system" components;
|
||||||
|
|
||||||
mkSkeletonFromList = l: {
|
mkSkeletonFromList = l: {
|
||||||
|
"1" = if elemAt l 0 == "avr"
|
||||||
|
then { cpu = elemAt l 0; kernel = "none"; abi = "unknown"; }
|
||||||
|
else throw "Target specification with 1 components is ambiguous";
|
||||||
"2" = # We only do 2-part hacks for things Nix already supports
|
"2" = # We only do 2-part hacks for things Nix already supports
|
||||||
if elemAt l 1 == "cygwin"
|
if elemAt l 1 == "cygwin"
|
||||||
then { cpu = elemAt l 0; kernel = "windows"; abi = "cygnus"; }
|
then { cpu = elemAt l 0; kernel = "windows"; abi = "cygnus"; }
|
||||||
else if elemAt l 1 == "gnu"
|
else if (elemAt l 1 == "eabi")
|
||||||
then { cpu = elemAt l 0; kernel = "hurd"; abi = "gnu"; }
|
then { cpu = elemAt l 0; vendor = "none"; kernel = "none"; abi = elemAt l 1; }
|
||||||
|
else if (elemAt l 1 == "elf")
|
||||||
|
then { cpu = elemAt l 0; vendor = "none"; kernel = "none"; abi = elemAt l 1; }
|
||||||
else { cpu = elemAt l 0; kernel = elemAt l 1; };
|
else { cpu = elemAt l 0; kernel = elemAt l 1; };
|
||||||
"3" = # Awkwards hacks, beware!
|
"3" = # Awkwards hacks, beware!
|
||||||
if elemAt l 1 == "apple"
|
if elemAt l 1 == "apple"
|
||||||
@ -266,6 +284,12 @@ rec {
|
|||||||
then { cpu = elemAt l 0; kernel = elemAt l 1; abi = elemAt l 2; }
|
then { cpu = elemAt l 0; kernel = elemAt l 1; abi = elemAt l 2; }
|
||||||
else if (elemAt l 2 == "mingw32") # autotools breaks on -gnu for window
|
else if (elemAt l 2 == "mingw32") # autotools breaks on -gnu for window
|
||||||
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows"; abi = "gnu"; }
|
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows"; abi = "gnu"; }
|
||||||
|
else if hasPrefix "netbsd" (elemAt l 2)
|
||||||
|
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; }
|
||||||
|
else if (elemAt l 2 == "eabi")
|
||||||
|
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "none"; abi = elemAt l 2; }
|
||||||
|
else if (elemAt l 2 == "elf")
|
||||||
|
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "none"; abi = elemAt l 2; }
|
||||||
else throw "Target specification with 3 components is ambiguous";
|
else throw "Target specification with 3 components is ambiguous";
|
||||||
"4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
|
"4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
|
||||||
}.${toString (length l)}
|
}.${toString (length l)}
|
||||||
@ -292,7 +316,9 @@ rec {
|
|||||||
else if isDarwin parsed then vendors.apple
|
else if isDarwin parsed then vendors.apple
|
||||||
else if isWindows parsed then vendors.pc
|
else if isWindows parsed then vendors.pc
|
||||||
else vendors.unknown;
|
else vendors.unknown;
|
||||||
kernel = getKernel args.kernel;
|
kernel = if hasPrefix "darwin" args.kernel then getKernel "darwin"
|
||||||
|
else if hasPrefix "netbsd" args.kernel then getKernel "netbsd"
|
||||||
|
else getKernel args.kernel;
|
||||||
abi =
|
abi =
|
||||||
/**/ if args ? abi then getAbi args.abi
|
/**/ if args ? abi then getAbi args.abi
|
||||||
else if isLinux parsed then
|
else if isLinux parsed then
|
||||||
|
@ -20,6 +20,22 @@ rec {
|
|||||||
kernelAutoModules = false;
|
kernelAutoModules = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
powernv = {
|
||||||
|
name = "PowerNV";
|
||||||
|
kernelArch = "powerpc";
|
||||||
|
kernelBaseConfig = "powernv_defconfig";
|
||||||
|
kernelTarget = "zImage";
|
||||||
|
kernelInstallTarget = "install";
|
||||||
|
kernelFile = "vmlinux";
|
||||||
|
kernelAutoModules = true;
|
||||||
|
# avoid driver/FS trouble arising from unusual page size
|
||||||
|
kernelExtraConfig = ''
|
||||||
|
PPC_64K_PAGES n
|
||||||
|
PPC_4K_PAGES y
|
||||||
|
IPV6 y
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
##
|
##
|
||||||
## ARM
|
## ARM
|
||||||
##
|
##
|
||||||
@ -455,8 +471,10 @@ rec {
|
|||||||
"x86_64-linux" = pc64;
|
"x86_64-linux" = pc64;
|
||||||
"armv5tel-linux" = sheevaplug;
|
"armv5tel-linux" = sheevaplug;
|
||||||
"armv6l-linux" = raspberrypi;
|
"armv6l-linux" = raspberrypi;
|
||||||
|
"armv7a-linux" = armv7l-hf-multiplatform;
|
||||||
"armv7l-linux" = armv7l-hf-multiplatform;
|
"armv7l-linux" = armv7l-hf-multiplatform;
|
||||||
"aarch64-linux" = aarch64-multiplatform;
|
"aarch64-linux" = aarch64-multiplatform;
|
||||||
"mipsel-linux" = fuloong2f_n32;
|
"mipsel-linux" = fuloong2f_n32;
|
||||||
|
"powerpc64le-linux" = powernv;
|
||||||
}.${system} or pcBase;
|
}.${system} or pcBase;
|
||||||
}
|
}
|
||||||
|
7
lib/tests/check-eval.nix
Normal file
7
lib/tests/check-eval.nix
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Throws an error if any of our lib tests fail.
|
||||||
|
|
||||||
|
let tests = [ "misc" "systems" ];
|
||||||
|
all = builtins.concatLists (map (f: import (./. + "/${f}.nix")) tests);
|
||||||
|
in if all == []
|
||||||
|
then null
|
||||||
|
else throw (builtins.toJSON all)
|
@ -112,7 +112,7 @@ runTests {
|
|||||||
storePathAppendix = isStorePath
|
storePathAppendix = isStorePath
|
||||||
"${goodPath}/bin/python";
|
"${goodPath}/bin/python";
|
||||||
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
|
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
|
||||||
asPath = isStorePath (builtins.toPath goodPath);
|
asPath = isStorePath (/. + goodPath);
|
||||||
otherPath = isStorePath "/something/else";
|
otherPath = isStorePath "/something/else";
|
||||||
otherVals = {
|
otherVals = {
|
||||||
attrset = isStorePath {};
|
attrset = isStorePath {};
|
||||||
@ -213,6 +213,44 @@ runTests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
# ATTRSETS
|
||||||
|
|
||||||
|
# code from the example
|
||||||
|
testRecursiveUpdateUntil = {
|
||||||
|
expr = recursiveUpdateUntil (path: l: r: path == ["foo"]) {
|
||||||
|
# first attribute set
|
||||||
|
foo.bar = 1;
|
||||||
|
foo.baz = 2;
|
||||||
|
bar = 3;
|
||||||
|
} {
|
||||||
|
#second attribute set
|
||||||
|
foo.bar = 1;
|
||||||
|
foo.quz = 2;
|
||||||
|
baz = 4;
|
||||||
|
};
|
||||||
|
expected = {
|
||||||
|
foo.bar = 1; # 'foo.*' from the second set
|
||||||
|
foo.quz = 2; #
|
||||||
|
bar = 3; # 'bar' from the first set
|
||||||
|
baz = 4; # 'baz' from the second set
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testOverrideExistingEmpty = {
|
||||||
|
expr = overrideExisting {} { a = 1; };
|
||||||
|
expected = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
testOverrideExistingDisjoint = {
|
||||||
|
expr = overrideExisting { b = 2; } { a = 1; };
|
||||||
|
expected = { b = 2; };
|
||||||
|
};
|
||||||
|
|
||||||
|
testOverrideExistingOverride = {
|
||||||
|
expr = overrideExisting { a = 3; b = 2; } { a = 1; };
|
||||||
|
expected = { a = 1; b = 2; };
|
||||||
|
};
|
||||||
|
|
||||||
# GENERATORS
|
# GENERATORS
|
||||||
# these tests assume attributes are converted to lists
|
# these tests assume attributes are converted to lists
|
||||||
# in alphabetical order
|
# in alphabetical order
|
||||||
@ -331,9 +369,10 @@ runTests {
|
|||||||
testToPretty = {
|
testToPretty = {
|
||||||
expr = mapAttrs (const (generators.toPretty {})) rec {
|
expr = mapAttrs (const (generators.toPretty {})) rec {
|
||||||
int = 42;
|
int = 42;
|
||||||
|
float = 0.1337;
|
||||||
bool = true;
|
bool = true;
|
||||||
string = ''fno"rd'';
|
string = ''fno"rd'';
|
||||||
path = /. + "/foo"; # toPath returns a string
|
path = /. + "/foo";
|
||||||
null_ = null;
|
null_ = null;
|
||||||
function = x: x;
|
function = x: x;
|
||||||
functionArgs = { arg ? 4, foo }: arg;
|
functionArgs = { arg ? 4, foo }: arg;
|
||||||
@ -343,6 +382,7 @@ runTests {
|
|||||||
};
|
};
|
||||||
expected = rec {
|
expected = rec {
|
||||||
int = "42";
|
int = "42";
|
||||||
|
float = "~0.133700";
|
||||||
bool = "true";
|
bool = "true";
|
||||||
string = ''"fno\"rd"'';
|
string = ''"fno\"rd"'';
|
||||||
path = "/foo";
|
path = "/foo";
|
||||||
|
@ -12,20 +12,21 @@ let
|
|||||||
expected = lib.sort lib.lessThan y;
|
expected = lib.sort lib.lessThan y;
|
||||||
};
|
};
|
||||||
in with lib.systems.doubles; lib.runTests {
|
in with lib.systems.doubles; lib.runTests {
|
||||||
all = assertTrue (mseteq all (linux ++ darwin ++ cygwin ++ freebsd ++ openbsd ++ netbsd ++ illumos));
|
testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ windows);
|
||||||
|
|
||||||
arm = assertTrue (mseteq arm [ "armv5tel-linux" "armv6l-linux" "armv7l-linux" ]);
|
testarm = mseteq arm [ "armv5tel-linux" "armv6l-linux" "armv7l-linux" ];
|
||||||
i686 = assertTrue (mseteq i686 [ "i686-linux" "i686-freebsd" "i686-netbsd" "i686-openbsd" "i686-cygwin" ]);
|
testi686 = mseteq i686 [ "i686-linux" "i686-freebsd" "i686-netbsd" "i686-openbsd" "i686-cygwin" "i686-windows" ];
|
||||||
mips = assertTrue (mseteq mips [ "mipsel-linux" ]);
|
testmips = mseteq mips [ "mipsel-linux" ];
|
||||||
x86_64 = assertTrue (mseteq x86_64 [ "x86_64-linux" "x86_64-darwin" "x86_64-freebsd" "x86_64-openbsd" "x86_64-netbsd" "x86_64-cygwin" "x86_64-solaris" ]);
|
testx86_64 = mseteq x86_64 [ "x86_64-linux" "x86_64-darwin" "x86_64-freebsd" "x86_64-openbsd" "x86_64-netbsd" "x86_64-cygwin" "x86_64-solaris" "x86_64-windows" ];
|
||||||
|
|
||||||
cygwin = assertTrue (mseteq cygwin [ "i686-cygwin" "x86_64-cygwin" ]);
|
testcygwin = mseteq cygwin [ "i686-cygwin" "x86_64-cygwin" ];
|
||||||
darwin = assertTrue (mseteq darwin [ "x86_64-darwin" ]);
|
testdarwin = mseteq darwin [ "x86_64-darwin" ];
|
||||||
freebsd = assertTrue (mseteq freebsd [ "i686-freebsd" "x86_64-freebsd" ]);
|
testfreebsd = mseteq freebsd [ "i686-freebsd" "x86_64-freebsd" ];
|
||||||
gnu = assertTrue (mseteq gnu (linux /* ++ hurd ++ kfreebsd ++ ... */));
|
testgnu = mseteq gnu (linux /* ++ kfreebsd ++ ... */);
|
||||||
illumos = assertTrue (mseteq illumos [ "x86_64-solaris" ]);
|
testillumos = mseteq illumos [ "x86_64-solaris" ];
|
||||||
linux = assertTrue (mseteq linux [ "i686-linux" "x86_64-linux" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "aarch64-linux" "mipsel-linux" ]);
|
testlinux = mseteq linux [ "i686-linux" "x86_64-linux" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "aarch64-linux" "mipsel-linux" ];
|
||||||
netbsd = assertTrue (mseteq netbsd [ "i686-netbsd" "x86_64-netbsd" ]);
|
testnetbsd = mseteq netbsd [ "i686-netbsd" "x86_64-netbsd" ];
|
||||||
openbsd = assertTrue (mseteq openbsd [ "i686-openbsd" "x86_64-openbsd" ]);
|
testopenbsd = mseteq openbsd [ "i686-openbsd" "x86_64-openbsd" ];
|
||||||
unix = assertTrue (mseteq unix (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos));
|
testwindows = mseteq windows [ "i686-cygwin" "x86_64-cygwin" "i686-windows" "x86_64-windows" ];
|
||||||
|
testunix = mseteq unix (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ cygwin);
|
||||||
}
|
}
|
||||||
|
250
lib/trivial.nix
250
lib/trivial.nix
@ -1,65 +1,45 @@
|
|||||||
{ lib }:
|
{ lib }:
|
||||||
let
|
|
||||||
zipIntBits = f: x: y:
|
|
||||||
let
|
|
||||||
# (intToBits 6) -> [ 0 1 1 ]
|
|
||||||
intToBits = x:
|
|
||||||
if x == 0 || x == -1 then
|
|
||||||
[]
|
|
||||||
else
|
|
||||||
let
|
|
||||||
headbit = if (x / 2) * 2 != x then 1 else 0; # x & 1
|
|
||||||
tailbits = if x < 0 then ((x + 1) / 2) - 1 else x / 2; # x >> 1
|
|
||||||
in
|
|
||||||
[headbit] ++ (intToBits tailbits);
|
|
||||||
|
|
||||||
# (bitsToInt [ 0 1 1 ] 0) -> 6
|
|
||||||
# (bitsToInt [ 0 1 0 ] 1) -> -6
|
|
||||||
bitsToInt = l: signum:
|
|
||||||
if l == [] then
|
|
||||||
(if signum == 0 then 0 else -1)
|
|
||||||
else
|
|
||||||
(builtins.head l) + (2 * (bitsToInt (builtins.tail l) signum));
|
|
||||||
|
|
||||||
xsignum = if x < 0 then 1 else 0;
|
|
||||||
ysignum = if y < 0 then 1 else 0;
|
|
||||||
zipListsWith' = fst: snd:
|
|
||||||
if fst==[] && snd==[] then
|
|
||||||
[]
|
|
||||||
else if fst==[] then
|
|
||||||
[(f xsignum (builtins.head snd))] ++ (zipListsWith' [] (builtins.tail snd))
|
|
||||||
else if snd==[] then
|
|
||||||
[(f (builtins.head fst) ysignum )] ++ (zipListsWith' (builtins.tail fst) [] )
|
|
||||||
else
|
|
||||||
[(f (builtins.head fst) (builtins.head snd))] ++ (zipListsWith' (builtins.tail fst) (builtins.tail snd));
|
|
||||||
in
|
|
||||||
assert (builtins.isInt x) && (builtins.isInt y);
|
|
||||||
bitsToInt (zipListsWith' (intToBits x) (intToBits y)) (f xsignum ysignum);
|
|
||||||
in
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
## Simple (higher order) functions
|
||||||
|
|
||||||
/* The identity function
|
/* The identity function
|
||||||
For when you need a function that does “nothing”.
|
For when you need a function that does “nothing”.
|
||||||
|
|
||||||
Type: id :: a -> a
|
Type: id :: a -> a
|
||||||
*/
|
*/
|
||||||
id = x: x;
|
id =
|
||||||
|
# The value to return
|
||||||
|
x: x;
|
||||||
|
|
||||||
/* The constant function
|
/* The constant function
|
||||||
Ignores the second argument.
|
|
||||||
Or: Construct a function that always returns a static value.
|
Ignores the second argument. If called with only one argument,
|
||||||
|
constructs a function that always returns a static value.
|
||||||
|
|
||||||
Type: const :: a -> b -> a
|
Type: const :: a -> b -> a
|
||||||
Example:
|
Example:
|
||||||
let f = const 5; in f 10
|
let f = const 5; in f 10
|
||||||
=> 5
|
=> 5
|
||||||
*/
|
*/
|
||||||
const = x: y: x;
|
const =
|
||||||
|
# Value to return
|
||||||
|
x:
|
||||||
|
# Value to ignore
|
||||||
|
y: x;
|
||||||
|
|
||||||
|
|
||||||
## Named versions corresponding to some builtin operators.
|
## Named versions corresponding to some builtin operators.
|
||||||
|
|
||||||
/* Concat two strings */
|
/* Concatenate two lists
|
||||||
|
|
||||||
|
Type: concat :: [a] -> [a] -> [a]
|
||||||
|
|
||||||
|
Example:
|
||||||
|
concat [ 1 2 ] [ 3 4 ]
|
||||||
|
=> [ 1 2 3 4 ]
|
||||||
|
*/
|
||||||
concat = x: y: x ++ y;
|
concat = x: y: x ++ y;
|
||||||
|
|
||||||
/* boolean “or” */
|
/* boolean “or” */
|
||||||
@ -69,35 +49,70 @@ rec {
|
|||||||
and = x: y: x && y;
|
and = x: y: x && y;
|
||||||
|
|
||||||
/* bitwise “and” */
|
/* bitwise “and” */
|
||||||
bitAnd = builtins.bitAnd or zipIntBits (a: b: if a==1 && b==1 then 1 else 0);
|
bitAnd = builtins.bitAnd
|
||||||
|
or (import ./zip-int-bits.nix
|
||||||
|
(a: b: if a==1 && b==1 then 1 else 0));
|
||||||
|
|
||||||
/* bitwise “or” */
|
/* bitwise “or” */
|
||||||
bitOr = builtins.bitOr or zipIntBits (a: b: if a==1 || b==1 then 1 else 0);
|
bitOr = builtins.bitOr
|
||||||
|
or (import ./zip-int-bits.nix
|
||||||
|
(a: b: if a==1 || b==1 then 1 else 0));
|
||||||
|
|
||||||
/* bitwise “xor” */
|
/* bitwise “xor” */
|
||||||
bitXor = builtins.bitXor or zipIntBits (a: b: if a!=b then 1 else 0);
|
bitXor = builtins.bitXor
|
||||||
|
or (import ./zip-int-bits.nix
|
||||||
|
(a: b: if a!=b then 1 else 0));
|
||||||
|
|
||||||
/* bitwise “not” */
|
/* bitwise “not” */
|
||||||
bitNot = builtins.sub (-1);
|
bitNot = builtins.sub (-1);
|
||||||
|
|
||||||
/* Convert a boolean to a string.
|
/* Convert a boolean to a string.
|
||||||
Note that toString on a bool returns "1" and "".
|
|
||||||
|
This function uses the strings "true" and "false" to represent
|
||||||
|
boolean values. Calling `toString` on a bool instead returns "1"
|
||||||
|
and "" (sic!).
|
||||||
|
|
||||||
|
Type: boolToString :: bool -> string
|
||||||
*/
|
*/
|
||||||
boolToString = b: if b then "true" else "false";
|
boolToString = b: if b then "true" else "false";
|
||||||
|
|
||||||
/* Merge two attribute sets shallowly, right side trumps left
|
/* Merge two attribute sets shallowly, right side trumps left
|
||||||
|
|
||||||
|
mergeAttrs :: attrs -> attrs -> attrs
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
mergeAttrs { a = 1; b = 2; } { b = 3; c = 4; }
|
mergeAttrs { a = 1; b = 2; } { b = 3; c = 4; }
|
||||||
=> { a = 1; b = 3; c = 4; }
|
=> { a = 1; b = 3; c = 4; }
|
||||||
*/
|
*/
|
||||||
mergeAttrs = x: y: x // y;
|
mergeAttrs =
|
||||||
|
# Left attribute set
|
||||||
|
x:
|
||||||
|
# Right attribute set (higher precedence for equal keys)
|
||||||
|
y: x // y;
|
||||||
|
|
||||||
# Flip the order of the arguments of a binary function.
|
/* Flip the order of the arguments of a binary function.
|
||||||
|
|
||||||
|
Type: flip :: (a -> b -> c) -> (b -> a -> c)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
flip concat [1] [2]
|
||||||
|
=> [ 2 1 ]
|
||||||
|
*/
|
||||||
flip = f: a: b: f b a;
|
flip = f: a: b: f b a;
|
||||||
|
|
||||||
# Apply function if argument is non-null
|
/* Apply function if the supplied argument is non-null.
|
||||||
mapNullable = f: a: if isNull a then a else f a;
|
|
||||||
|
Example:
|
||||||
|
mapNullable (x: x+1) null
|
||||||
|
=> null
|
||||||
|
mapNullable (x: x+1) 22
|
||||||
|
=> 23
|
||||||
|
*/
|
||||||
|
mapNullable =
|
||||||
|
# Function to call
|
||||||
|
f:
|
||||||
|
# Argument to check for null before passing it to `f`
|
||||||
|
a: if isNull a then a else f a;
|
||||||
|
|
||||||
# Pull in some builtins not included elsewhere.
|
# Pull in some builtins not included elsewhere.
|
||||||
inherit (builtins)
|
inherit (builtins)
|
||||||
@ -105,22 +120,61 @@ rec {
|
|||||||
isInt isFloat add sub lessThan
|
isInt isFloat add sub lessThan
|
||||||
seq deepSeq genericClosure;
|
seq deepSeq genericClosure;
|
||||||
|
|
||||||
inherit (lib.strings) fileContents;
|
|
||||||
|
|
||||||
release = fileContents ../.version;
|
## nixpks version strings
|
||||||
versionSuffix = let suffixFile = ../.version-suffix; in
|
|
||||||
if pathExists suffixFile then fileContents suffixFile else "pre-git";
|
|
||||||
|
|
||||||
# Return the Nixpkgs version number.
|
/* Returns the current full nixpkgs version number. */
|
||||||
version = release + versionSuffix;
|
version = release + versionSuffix;
|
||||||
|
|
||||||
|
/* Returns the current nixpkgs release number as string. */
|
||||||
|
release = lib.strings.fileContents ../.version;
|
||||||
|
|
||||||
|
/* Returns the current nixpkgs release code name.
|
||||||
|
|
||||||
|
On each release the first letter is bumped and a new animal is chosen
|
||||||
|
starting with that new letter.
|
||||||
|
*/
|
||||||
|
codeName = "Koi";
|
||||||
|
|
||||||
|
/* Returns the current nixpkgs version suffix as string. */
|
||||||
|
versionSuffix =
|
||||||
|
let suffixFile = ../.version-suffix;
|
||||||
|
in if pathExists suffixFile
|
||||||
|
then lib.strings.fileContents suffixFile
|
||||||
|
else "pre-git";
|
||||||
|
|
||||||
|
/* Attempts to return the the current revision of nixpkgs and
|
||||||
|
returns the supplied default value otherwise.
|
||||||
|
|
||||||
|
Type: revisionWithDefault :: string -> string
|
||||||
|
*/
|
||||||
|
revisionWithDefault =
|
||||||
|
# Default value to return if revision can not be determined
|
||||||
|
default:
|
||||||
|
let
|
||||||
|
revisionFile = "${toString ./..}/.git-revision";
|
||||||
|
gitRepo = "${toString ./..}/.git";
|
||||||
|
in if lib.pathIsDirectory gitRepo
|
||||||
|
then lib.commitIdFromGitRepo gitRepo
|
||||||
|
else if lib.pathExists revisionFile then lib.fileContents revisionFile
|
||||||
|
else default;
|
||||||
|
|
||||||
nixpkgsVersion = builtins.trace "`lib.nixpkgsVersion` is deprecated, use `lib.version` instead!" version;
|
nixpkgsVersion = builtins.trace "`lib.nixpkgsVersion` is deprecated, use `lib.version` instead!" version;
|
||||||
|
|
||||||
# Whether we're being called by nix-shell.
|
/* Determine whether the function is being called from inside a Nix
|
||||||
|
shell.
|
||||||
|
|
||||||
|
Type: inNixShell :: bool
|
||||||
|
*/
|
||||||
inNixShell = builtins.getEnv "IN_NIX_SHELL" != "";
|
inNixShell = builtins.getEnv "IN_NIX_SHELL" != "";
|
||||||
|
|
||||||
# Return minimum/maximum of two numbers.
|
|
||||||
|
## Integer operations
|
||||||
|
|
||||||
|
/* Return minimum of two numbers. */
|
||||||
min = x: y: if x < y then x else y;
|
min = x: y: if x < y then x else y;
|
||||||
|
|
||||||
|
/* Return maximum of two numbers. */
|
||||||
max = x: y: if x > y then x else y;
|
max = x: y: if x > y then x else y;
|
||||||
|
|
||||||
/* Integer modulus
|
/* Integer modulus
|
||||||
@ -133,6 +187,9 @@ rec {
|
|||||||
*/
|
*/
|
||||||
mod = base: int: base - (int * (builtins.div base int));
|
mod = base: int: base - (int * (builtins.div base int));
|
||||||
|
|
||||||
|
|
||||||
|
## Comparisons
|
||||||
|
|
||||||
/* C-style comparisons
|
/* C-style comparisons
|
||||||
|
|
||||||
a < b, compare a b => -1
|
a < b, compare a b => -1
|
||||||
@ -151,8 +208,9 @@ rec {
|
|||||||
second subtype, compare elements of a single subtype with `yes`
|
second subtype, compare elements of a single subtype with `yes`
|
||||||
and `no` respectively.
|
and `no` respectively.
|
||||||
|
|
||||||
Example:
|
Type: (a -> bool) -> (a -> a -> int) -> (a -> a -> int) -> (a -> a -> int)
|
||||||
|
|
||||||
|
Example:
|
||||||
let cmp = splitByAndCompare (hasPrefix "foo") compare compare; in
|
let cmp = splitByAndCompare (hasPrefix "foo") compare compare; in
|
||||||
|
|
||||||
cmp "a" "z" => -1
|
cmp "a" "z" => -1
|
||||||
@ -162,54 +220,78 @@ rec {
|
|||||||
cmp "fooa" "a" => -1
|
cmp "fooa" "a" => -1
|
||||||
# while
|
# while
|
||||||
compare "fooa" "a" => 1
|
compare "fooa" "a" => 1
|
||||||
|
|
||||||
*/
|
*/
|
||||||
splitByAndCompare = p: yes: no: a: b:
|
splitByAndCompare =
|
||||||
|
# Predicate
|
||||||
|
p:
|
||||||
|
# Comparison function if predicate holds for both values
|
||||||
|
yes:
|
||||||
|
# Comparison function if predicate holds for neither value
|
||||||
|
no:
|
||||||
|
# First value to compare
|
||||||
|
a:
|
||||||
|
# Second value to compare
|
||||||
|
b:
|
||||||
if p a
|
if p a
|
||||||
then if p b then yes a b else -1
|
then if p b then yes a b else -1
|
||||||
else if p b then 1 else no a b;
|
else if p b then 1 else no a b;
|
||||||
|
|
||||||
/* Reads a JSON file. */
|
|
||||||
|
/* Reads a JSON file.
|
||||||
|
|
||||||
|
Type :: path -> any
|
||||||
|
*/
|
||||||
importJSON = path:
|
importJSON = path:
|
||||||
builtins.fromJSON (builtins.readFile path);
|
builtins.fromJSON (builtins.readFile path);
|
||||||
|
|
||||||
/* See https://github.com/NixOS/nix/issues/749. Eventually we'd like these
|
|
||||||
to expand to Nix builtins that carry metadata so that Nix can filter out
|
|
||||||
the INFO messages without parsing the message string.
|
|
||||||
|
|
||||||
Usage:
|
## Warnings
|
||||||
{
|
|
||||||
foo = lib.warn "foo is deprecated" oldFoo;
|
# See https://github.com/NixOS/nix/issues/749. Eventually we'd like these
|
||||||
}
|
# to expand to Nix builtins that carry metadata so that Nix can filter out
|
||||||
|
# the INFO messages without parsing the message string.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# {
|
||||||
|
# foo = lib.warn "foo is deprecated" oldFoo;
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# TODO: figure out a clever way to integrate location information from
|
||||||
|
# something like __unsafeGetAttrPos.
|
||||||
|
|
||||||
TODO: figure out a clever way to integrate location information from
|
|
||||||
something like __unsafeGetAttrPos.
|
|
||||||
*/
|
|
||||||
warn = msg: builtins.trace "WARNING: ${msg}";
|
warn = msg: builtins.trace "WARNING: ${msg}";
|
||||||
info = msg: builtins.trace "INFO: ${msg}";
|
info = msg: builtins.trace "INFO: ${msg}";
|
||||||
|
|
||||||
# | Add metadata about expected function arguments to a function.
|
|
||||||
# The metadata should match the format given by
|
## Function annotations
|
||||||
# builtins.functionArgs, i.e. a set from expected argument to a bool
|
|
||||||
# representing whether that argument has a default or not.
|
/* Add metadata about expected function arguments to a function.
|
||||||
# setFunctionArgs : (a → b) → Map String Bool → (a → b)
|
The metadata should match the format given by
|
||||||
#
|
builtins.functionArgs, i.e. a set from expected argument to a bool
|
||||||
# This function is necessary because you can't dynamically create a
|
representing whether that argument has a default or not.
|
||||||
# function of the { a, b ? foo, ... }: format, but some facilities
|
setFunctionArgs : (a → b) → Map String Bool → (a → b)
|
||||||
# like callPackage expect to be able to query expected arguments.
|
|
||||||
|
This function is necessary because you can't dynamically create a
|
||||||
|
function of the { a, b ? foo, ... }: format, but some facilities
|
||||||
|
like callPackage expect to be able to query expected arguments.
|
||||||
|
*/
|
||||||
setFunctionArgs = f: args:
|
setFunctionArgs = f: args:
|
||||||
{ # TODO: Should we add call-time "type" checking like built in?
|
{ # TODO: Should we add call-time "type" checking like built in?
|
||||||
__functor = self: f;
|
__functor = self: f;
|
||||||
__functionArgs = args;
|
__functionArgs = args;
|
||||||
};
|
};
|
||||||
|
|
||||||
# | Extract the expected function arguments from a function.
|
/* Extract the expected function arguments from a function.
|
||||||
# This works both with nix-native { a, b ? foo, ... }: style
|
This works both with nix-native { a, b ? foo, ... }: style
|
||||||
# functions and functions with args set with 'setFunctionArgs'. It
|
functions and functions with args set with 'setFunctionArgs'. It
|
||||||
# has the same return type and semantics as builtins.functionArgs.
|
has the same return type and semantics as builtins.functionArgs.
|
||||||
# setFunctionArgs : (a → b) → Map String Bool.
|
setFunctionArgs : (a → b) → Map String Bool.
|
||||||
|
*/
|
||||||
functionArgs = f: f.__functionArgs or (builtins.functionArgs f);
|
functionArgs = f: f.__functionArgs or (builtins.functionArgs f);
|
||||||
|
|
||||||
|
/* Check whether something is a function or something
|
||||||
|
annotated with function args.
|
||||||
|
*/
|
||||||
isFunction = f: builtins.isFunction f ||
|
isFunction = f: builtins.isFunction f ||
|
||||||
(f ? __functor && isFunction (f.__functor f));
|
(f ? __functor && isFunction (f.__functor f));
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,9 @@ rec {
|
|||||||
let
|
let
|
||||||
betweenDesc = lowest: highest:
|
betweenDesc = lowest: highest:
|
||||||
"${toString lowest} and ${toString highest} (both inclusive)";
|
"${toString lowest} and ${toString highest} (both inclusive)";
|
||||||
between = lowest: highest: assert lowest <= highest;
|
between = lowest: highest:
|
||||||
|
assert lib.assertMsg (lowest <= highest)
|
||||||
|
"ints.between: lowest must be smaller than highest";
|
||||||
addCheck int (x: x >= lowest && x <= highest) // {
|
addCheck int (x: x >= lowest && x <= highest) // {
|
||||||
name = "intBetween";
|
name = "intBetween";
|
||||||
description = "integer between ${betweenDesc lowest highest}";
|
description = "integer between ${betweenDesc lowest highest}";
|
||||||
@ -167,6 +169,9 @@ rec {
|
|||||||
# s32 = sign 32 4294967296;
|
# s32 = sign 32 4294967296;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Alias of u16 for a port number
|
||||||
|
port = ints.u16;
|
||||||
|
|
||||||
float = mkOptionType rec {
|
float = mkOptionType rec {
|
||||||
name = "float";
|
name = "float";
|
||||||
description = "floating point number";
|
description = "floating point number";
|
||||||
@ -192,7 +197,10 @@ rec {
|
|||||||
# separator between the values).
|
# separator between the values).
|
||||||
separatedString = sep: mkOptionType rec {
|
separatedString = sep: mkOptionType rec {
|
||||||
name = "separatedString";
|
name = "separatedString";
|
||||||
description = "string";
|
description = if sep == ""
|
||||||
|
then "Concatenated string" # for types.string.
|
||||||
|
else "strings concatenated with ${builtins.toJSON sep}"
|
||||||
|
;
|
||||||
check = isString;
|
check = isString;
|
||||||
merge = loc: defs: concatStringsSep sep (getValues defs);
|
merge = loc: defs: concatStringsSep sep (getValues defs);
|
||||||
functor = (defaultFunctor name) // {
|
functor = (defaultFunctor name) // {
|
||||||
@ -439,7 +447,9 @@ rec {
|
|||||||
# Either value of type `finalType` or `coercedType`, the latter is
|
# Either value of type `finalType` or `coercedType`, the latter is
|
||||||
# converted to `finalType` using `coerceFunc`.
|
# converted to `finalType` using `coerceFunc`.
|
||||||
coercedTo = coercedType: coerceFunc: finalType:
|
coercedTo = coercedType: coerceFunc: finalType:
|
||||||
assert coercedType.getSubModules == null;
|
assert lib.assertMsg (coercedType.getSubModules == null)
|
||||||
|
"coercedTo: coercedType must not have submodules (it’s a ${
|
||||||
|
coercedType.description})";
|
||||||
mkOptionType rec {
|
mkOptionType rec {
|
||||||
name = "coercedTo";
|
name = "coercedTo";
|
||||||
description = "${finalType.description} or ${coercedType.description} convertible to it";
|
description = "${finalType.description} or ${coercedType.description} convertible to it";
|
||||||
|
39
lib/zip-int-bits.nix
Normal file
39
lib/zip-int-bits.nix
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* Helper function to implement a fallback for the bit operators
|
||||||
|
`bitAnd`, `bitOr` and `bitXOr` on older nix version.
|
||||||
|
See ./trivial.nix
|
||||||
|
*/
|
||||||
|
f: x: y:
|
||||||
|
let
|
||||||
|
# (intToBits 6) -> [ 0 1 1 ]
|
||||||
|
intToBits = x:
|
||||||
|
if x == 0 || x == -1 then
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
let
|
||||||
|
headbit = if (x / 2) * 2 != x then 1 else 0; # x & 1
|
||||||
|
tailbits = if x < 0 then ((x + 1) / 2) - 1 else x / 2; # x >> 1
|
||||||
|
in
|
||||||
|
[headbit] ++ (intToBits tailbits);
|
||||||
|
|
||||||
|
# (bitsToInt [ 0 1 1 ] 0) -> 6
|
||||||
|
# (bitsToInt [ 0 1 0 ] 1) -> -6
|
||||||
|
bitsToInt = l: signum:
|
||||||
|
if l == [] then
|
||||||
|
(if signum == 0 then 0 else -1)
|
||||||
|
else
|
||||||
|
(builtins.head l) + (2 * (bitsToInt (builtins.tail l) signum));
|
||||||
|
|
||||||
|
xsignum = if x < 0 then 1 else 0;
|
||||||
|
ysignum = if y < 0 then 1 else 0;
|
||||||
|
zipListsWith' = fst: snd:
|
||||||
|
if fst==[] && snd==[] then
|
||||||
|
[]
|
||||||
|
else if fst==[] then
|
||||||
|
[(f xsignum (builtins.head snd))] ++ (zipListsWith' [] (builtins.tail snd))
|
||||||
|
else if snd==[] then
|
||||||
|
[(f (builtins.head fst) ysignum )] ++ (zipListsWith' (builtins.tail fst) [] )
|
||||||
|
else
|
||||||
|
[(f (builtins.head fst) (builtins.head snd))] ++ (zipListsWith' (builtins.tail fst) (builtins.tail snd));
|
||||||
|
in
|
||||||
|
assert (builtins.isInt x) && (builtins.isInt y);
|
||||||
|
bitsToInt (zipListsWith' (intToBits x) (intToBits y)) (f xsignum ysignum)
|
File diff suppressed because it is too large
Load Diff
@ -4,14 +4,14 @@ all: manual-combined.xml format
|
|||||||
.PHONY: debug
|
.PHONY: debug
|
||||||
debug: generated manual-combined.xml
|
debug: generated manual-combined.xml
|
||||||
|
|
||||||
manual-combined.xml: generated *.xml
|
manual-combined.xml: generated *.xml **/*.xml
|
||||||
rm -f ./manual-combined.xml
|
rm -f ./manual-combined.xml
|
||||||
nix-shell --packages xmloscopy \
|
nix-shell --packages xmloscopy \
|
||||||
--run "xmloscopy --docbook5 ./manual.xml ./manual-combined.xml"
|
--run "xmloscopy --docbook5 ./manual.xml ./manual-combined.xml"
|
||||||
|
|
||||||
.PHONY: format
|
.PHONY: format
|
||||||
format:
|
format:
|
||||||
find . -iname '*.xml' -type f -print0 | xargs -0 -I{} -n1 \
|
find ../../ -iname '*.xml' -type f -print0 | xargs -0 -I{} -n1 \
|
||||||
xmlformat --config-file "../xmlformat.conf" -i {}
|
xmlformat --config-file "../xmlformat.conf" -i {}
|
||||||
|
|
||||||
.PHONY: fix-misc-xml
|
.PHONY: fix-misc-xml
|
||||||
|
@ -50,4 +50,14 @@ $ nix-store --optimise
|
|||||||
Since this command needs to read the entire Nix store, it can take quite a
|
Since this command needs to read the entire Nix store, it can take quite a
|
||||||
while to finish.
|
while to finish.
|
||||||
</para>
|
</para>
|
||||||
|
<section xml:id="sect-nixos-gc-boot-entries">
|
||||||
|
<title>NixOS Boot Entries</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
If your <filename>/boot</filename> partition runs out of space, after
|
||||||
|
clearing old profiles you must rebuild your system with
|
||||||
|
<literal>nixos-rebuild</literal> to update the <filename>/boot</filename>
|
||||||
|
partition and clear space.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
@ -52,4 +52,8 @@ $ ping -c1 10.233.4.2
|
|||||||
networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
|
networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
You may need to restart your system for the changes to take effect.
|
||||||
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
@ -15,7 +15,7 @@ containers.database =
|
|||||||
{ config =
|
{ config =
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
{ <xref linkend="opt-services.postgresql.enable"/> = true;
|
{ <xref linkend="opt-services.postgresql.enable"/> = true;
|
||||||
<xref linkend="opt-services.postgresql.package"/> = pkgs.postgresql96;
|
<xref linkend="opt-services.postgresql.package"/> = pkgs.postgresql_9_6;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
xlink:href="http://nixos.org/nixpkgs/manual">Nixpkgs
|
xlink:href="http://nixos.org/nixpkgs/manual">Nixpkgs
|
||||||
manual</link>. In short, you clone Nixpkgs:
|
manual</link>. In short, you clone Nixpkgs:
|
||||||
<screen>
|
<screen>
|
||||||
$ git clone git://github.com/NixOS/nixpkgs.git
|
$ git clone https://github.com/NixOS/nixpkgs
|
||||||
$ cd nixpkgs
|
$ cd nixpkgs
|
||||||
</screen>
|
</screen>
|
||||||
Then you write and test the package as described in the Nixpkgs manual.
|
Then you write and test the package as described in the Nixpkgs manual.
|
||||||
|
@ -197,10 +197,10 @@ swapDevices = [ { device = "/dev/disk/by-label/swap"; } ];
|
|||||||
pkgs.emacs
|
pkgs.emacs
|
||||||
];
|
];
|
||||||
|
|
||||||
<xref linkend="opt-services.postgresql.package"/> = pkgs.postgresql90;
|
<xref linkend="opt-services.postgresql.package"/> = pkgs.postgresql_10;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
The latter option definition changes the default PostgreSQL package used
|
The latter option definition changes the default PostgreSQL package used
|
||||||
by NixOS’s PostgreSQL service to 9.0. For more information on packages,
|
by NixOS’s PostgreSQL service to 10.x. For more information on packages,
|
||||||
including how to add new ones, see <xref linkend="sec-custom-packages"/>.
|
including how to add new ones, see <xref linkend="sec-custom-packages"/>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
@ -22,5 +22,6 @@
|
|||||||
<xi:include href="networking.xml" />
|
<xi:include href="networking.xml" />
|
||||||
<xi:include href="linux-kernel.xml" />
|
<xi:include href="linux-kernel.xml" />
|
||||||
<xi:include href="../generated/modules.xml" xpointer="xpointer(//section[@id='modules']/*)" />
|
<xi:include href="../generated/modules.xml" xpointer="xpointer(//section[@id='modules']/*)" />
|
||||||
|
<xi:include href="profiles.xml" />
|
||||||
<!-- Apache; libvirtd virtualisation -->
|
<!-- Apache; libvirtd virtualisation -->
|
||||||
</part>
|
</part>
|
||||||
|
@ -34,13 +34,4 @@
|
|||||||
Similarly, UDP port ranges can be opened through
|
Similarly, UDP port ranges can be opened through
|
||||||
<xref linkend="opt-networking.firewall.allowedUDPPortRanges"/>.
|
<xref linkend="opt-networking.firewall.allowedUDPPortRanges"/>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
|
||||||
Also of interest is
|
|
||||||
<programlisting>
|
|
||||||
<xref linkend="opt-networking.firewall.allowPing"/> = true;
|
|
||||||
</programlisting>
|
|
||||||
to allow the machine to respond to ping requests. (ICMPv6 pings are always
|
|
||||||
allowed.)
|
|
||||||
</para>
|
|
||||||
</section>
|
</section>
|
||||||
|
@ -66,14 +66,15 @@ nixpkgs.config.packageOverrides = pkgs:
|
|||||||
sets the kernel’s TCP keepalive time to 120 seconds. To see the available
|
sets the kernel’s TCP keepalive time to 120 seconds. To see the available
|
||||||
parameters, run <command>sysctl -a</command>.
|
parameters, run <command>sysctl -a</command>.
|
||||||
</para>
|
</para>
|
||||||
<section>
|
<section xml:id="sec-linux-config-customizing">
|
||||||
<title>Customize your kernel</title>
|
<title>Customize your kernel</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The first step before compiling the kernel is to generate an appropriate
|
The first step before compiling the kernel is to generate an appropriate
|
||||||
<literal>.config</literal> configuration. Either you pass your own config via
|
<literal>.config</literal> configuration. Either you pass your own config
|
||||||
the <literal>configfile</literal> setting of <literal>linuxManualConfig</literal>:
|
via the <literal>configfile</literal> setting of
|
||||||
<screen><![CDATA[
|
<literal>linuxManualConfig</literal>:
|
||||||
|
<screen><![CDATA[
|
||||||
custom-kernel = super.linuxManualConfig {
|
custom-kernel = super.linuxManualConfig {
|
||||||
inherit (super) stdenv hostPlatform;
|
inherit (super) stdenv hostPlatform;
|
||||||
inherit (linux_4_9) src;
|
inherit (linux_4_9) src;
|
||||||
@ -83,18 +84,17 @@ nixpkgs.config.packageOverrides = pkgs:
|
|||||||
allowImportFromDerivation = true;
|
allowImportFromDerivation = true;
|
||||||
};
|
};
|
||||||
]]></screen>
|
]]></screen>
|
||||||
|
You can edit the config with this snippet (by default <command>make
|
||||||
You can edit the config with this snippet (by default <command>make menuconfig</command> won't work
|
menuconfig</command> won't work out of the box on nixos):
|
||||||
out of the box on nixos):
|
<screen><![CDATA[
|
||||||
<screen><![CDATA[
|
|
||||||
nix-shell -E 'with import <nixpkgs> {}; kernelToOverride.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkgconfig ncurses ];})'
|
nix-shell -E 'with import <nixpkgs> {}; kernelToOverride.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkgconfig ncurses ];})'
|
||||||
]]></screen>
|
]]></screen>
|
||||||
|
or you can let nixpkgs generate the configuration. Nixpkgs generates it via
|
||||||
|
answering the interactive kernel utility <command>make config</command>. The
|
||||||
or you can let nixpkgs generate the configuration.
|
answers depend on parameters passed to
|
||||||
Nixpkgs generates it via answering the interactive kernel utility <command>make config</command>.
|
<filename>pkgs/os-specific/linux/kernel/generic.nix</filename> (which you
|
||||||
The answers depend on parameters passed to <filename>pkgs/os-specific/linux/kernel/generic.nix</filename>
|
can influence by overriding <literal>extraConfig, autoModules,
|
||||||
(which you can influence by overriding <literal>extraConfig, autoModules, modDirVersion, preferBuiltin, extraConfig</literal>).
|
modDirVersion, preferBuiltin, extraConfig</literal>).
|
||||||
<screen><![CDATA[
|
<screen><![CDATA[
|
||||||
|
|
||||||
mptcp93.override ({
|
mptcp93.override ({
|
||||||
@ -117,7 +117,7 @@ You can edit the config with this snippet (by default <command>make menuconfig</
|
|||||||
]]></screen>
|
]]></screen>
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section xml:id="sec-linux-config-developing-modules">
|
||||||
<title>Developing kernel modules</title>
|
<title>Developing kernel modules</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
@ -74,7 +74,7 @@ The unique option `services.httpd.adminAddr' is defined multiple times, in `/etc
|
|||||||
argument is for: it contains the complete, merged system configuration. That
|
argument is for: it contains the complete, merged system configuration. That
|
||||||
is, <varname>config</varname> is the result of combining the configurations
|
is, <varname>config</varname> is the result of combining the configurations
|
||||||
returned by every module
|
returned by every module
|
||||||
<footnote>
|
<footnote xml:id="footnote-nix-is-lazy">
|
||||||
<para>
|
<para>
|
||||||
If you’re wondering how it’s possible that the (indirect)
|
If you’re wondering how it’s possible that the (indirect)
|
||||||
<emphasis>result</emphasis> of a function is passed as an
|
<emphasis>result</emphasis> of a function is passed as an
|
||||||
@ -127,4 +127,23 @@ nix-repl> map (x: x.hostName) config.<xref linkend="opt-services.httpd.virtualHo
|
|||||||
[ "example.org" "example.gov" ]
|
[ "example.org" "example.gov" ]
|
||||||
</screen>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
While abstracting your configuration, you may find it useful to generate
|
||||||
|
modules using code, instead of writing files. The example
|
||||||
|
below would have the same effect as importing a file which sets those
|
||||||
|
options.
|
||||||
|
<screen>
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let netConfig = { hostName }: {
|
||||||
|
networking.hostName = hostName;
|
||||||
|
networking.useDHCP = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{ imports = [ (netConfig "nixos.localdomain") ]; }
|
||||||
|
</screen>
|
||||||
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
39
nixos/doc/manual/configuration/profiles.xml
Normal file
39
nixos/doc/manual/configuration/profiles.xml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="ch-profiles">
|
||||||
|
<title>Profiles</title>
|
||||||
|
<para>
|
||||||
|
In some cases, it may be desirable to take advantage of commonly-used,
|
||||||
|
predefined configurations provided by nixpkgs, but different from those that
|
||||||
|
come as default. This is a role fulfilled by NixOS's Profiles, which come as
|
||||||
|
files living in <filename><nixpkgs/nixos/modules/profiles></filename>.
|
||||||
|
That is to say, expected usage is to add them to the imports list of your
|
||||||
|
<filename>/etc/configuration.nix</filename> as such:
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
imports = [
|
||||||
|
<nixpkgs/nixos/modules/profiles/profile-name.nix>
|
||||||
|
];
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
Even if some of these profiles seem only useful in the context of
|
||||||
|
install media, many are actually intended to be used in real installs.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
What follows is a brief explanation on the purpose and use-case for each
|
||||||
|
profile. Detailing each option configured by each one is out of scope.
|
||||||
|
</para>
|
||||||
|
<xi:include href="profiles/all-hardware.xml" />
|
||||||
|
<xi:include href="profiles/base.xml" />
|
||||||
|
<xi:include href="profiles/clone-config.xml" />
|
||||||
|
<xi:include href="profiles/demo.xml" />
|
||||||
|
<xi:include href="profiles/docker-container.xml" />
|
||||||
|
<xi:include href="profiles/graphical.xml" />
|
||||||
|
<xi:include href="profiles/hardened.xml" />
|
||||||
|
<xi:include href="profiles/headless.xml" />
|
||||||
|
<xi:include href="profiles/installation-device.xml" />
|
||||||
|
<xi:include href="profiles/minimal.xml" />
|
||||||
|
<xi:include href="profiles/qemu-guest.xml" />
|
||||||
|
</chapter>
|
20
nixos/doc/manual/configuration/profiles/all-hardware.xml
Normal file
20
nixos/doc/manual/configuration/profiles/all-hardware.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-all-hardware">
|
||||||
|
<title>All Hardware</title>
|
||||||
|
<para>
|
||||||
|
Enables all hardware supported by NixOS: i.e., all firmware is
|
||||||
|
included, and all devices from which one may boot are enabled in the initrd.
|
||||||
|
Its primary use is in the NixOS installation CDs.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The enabled kernel modules include support for SATA and PATA, SCSI
|
||||||
|
(partially), USB, Firewire (untested), Virtio (QEMU, KVM, etc.), VMware, and
|
||||||
|
Hyper-V. Additionally, <xref linkend="opt-hardware.enableAllFirmware"/> is
|
||||||
|
enabled, and the firmware for the ZyDAS ZD1211 chipset is specifically
|
||||||
|
installed.
|
||||||
|
</para>
|
||||||
|
</section>
|
15
nixos/doc/manual/configuration/profiles/base.xml
Normal file
15
nixos/doc/manual/configuration/profiles/base.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-base">
|
||||||
|
<title>Base</title>
|
||||||
|
<para>
|
||||||
|
Defines the software packages included in the "minimal"
|
||||||
|
installation CD. It installs several utilities useful in a simple recovery or
|
||||||
|
install media, such as a text-mode web browser, and tools for manipulating
|
||||||
|
block devices, networking, hardware diagnostics, and filesystems (with their
|
||||||
|
respective kernel modules).
|
||||||
|
</para>
|
||||||
|
</section>
|
14
nixos/doc/manual/configuration/profiles/clone-config.xml
Normal file
14
nixos/doc/manual/configuration/profiles/clone-config.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-clone-config">
|
||||||
|
<title>Clone Config</title>
|
||||||
|
<para>
|
||||||
|
This profile is used in installer images.
|
||||||
|
It provides an editable configuration.nix that imports all the modules that
|
||||||
|
were also used when creating the image in the first place.
|
||||||
|
As a result it allows users to edit and rebuild the live-system.
|
||||||
|
</para>
|
||||||
|
</section>
|
13
nixos/doc/manual/configuration/profiles/demo.xml
Normal file
13
nixos/doc/manual/configuration/profiles/demo.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-demo">
|
||||||
|
<title>Demo</title>
|
||||||
|
<para>
|
||||||
|
This profile just enables a <systemitem class="username">demo</systemitem> user, with password <literal>demo</literal>, uid <literal>1000</literal>, <systemitem class="groupname">wheel</systemitem>
|
||||||
|
group and <link linkend="opt-services.xserver.displayManager.sddm.autoLogin">
|
||||||
|
autologin in the SDDM display manager</link>.
|
||||||
|
</para>
|
||||||
|
</section>
|
15
nixos/doc/manual/configuration/profiles/docker-container.xml
Normal file
15
nixos/doc/manual/configuration/profiles/docker-container.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-docker-container">
|
||||||
|
<title>Docker Container</title>
|
||||||
|
<para>
|
||||||
|
This is the profile from which the Docker images are generated. It prepares a
|
||||||
|
working system by importing the <link linkend="sec-profile-minimal">Minimal</link> and
|
||||||
|
<link linkend="sec-profile-clone-config">Clone Config</link> profiles, and setting appropriate
|
||||||
|
configuration options that are useful inside a container context, like
|
||||||
|
<xref linkend="opt-boot.isContainer"/>.
|
||||||
|
</para>
|
||||||
|
</section>
|
21
nixos/doc/manual/configuration/profiles/graphical.xml
Normal file
21
nixos/doc/manual/configuration/profiles/graphical.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-graphical">
|
||||||
|
<title>Graphical</title>
|
||||||
|
<para>
|
||||||
|
Defines a NixOS configuration with the Plasma 5 desktop. It's used by the
|
||||||
|
graphical installation CD.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
It sets <xref linkend="opt-services.xserver.enable"/>,
|
||||||
|
<xref linkend="opt-services.xserver.displayManager.sddm.enable"/>,
|
||||||
|
<xref linkend="opt-services.xserver.desktopManager.plasma5.enable"/> (
|
||||||
|
<link linkend="opt-services.xserver.desktopManager.plasma5.enableQt4Support">
|
||||||
|
without Qt4 Support</link>), and
|
||||||
|
<xref linkend="opt-services.xserver.libinput.enable"/> to true. It also
|
||||||
|
includes glxinfo and firefox in the system packages list.
|
||||||
|
</para>
|
||||||
|
</section>
|
22
nixos/doc/manual/configuration/profiles/hardened.xml
Normal file
22
nixos/doc/manual/configuration/profiles/hardened.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-hardened">
|
||||||
|
<title>Hardened</title>
|
||||||
|
<para>
|
||||||
|
A profile with most (vanilla) hardening options enabled by default,
|
||||||
|
potentially at the cost of features and performance.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
This includes a hardened kernel, and limiting the system information
|
||||||
|
available to processes through the <filename>/sys</filename> and
|
||||||
|
<filename>/proc</filename> filesystems. It also disables the User Namespaces
|
||||||
|
feature of the kernel, which stops Nix from being able to build anything
|
||||||
|
(this particular setting can be overriden via
|
||||||
|
<xref linkend="opt-security.allowUserNamespaces"/>). See the <literal
|
||||||
|
xlink:href="https://github.com/nixos/nixpkgs/tree/master/nixos/modules/profiles/hardened.nix">
|
||||||
|
profile source</literal> for further detail on which settings are altered.
|
||||||
|
</para>
|
||||||
|
</section>
|
18
nixos/doc/manual/configuration/profiles/headless.xml
Normal file
18
nixos/doc/manual/configuration/profiles/headless.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-headless">
|
||||||
|
<title>Headless</title>
|
||||||
|
<para>
|
||||||
|
Common configuration for headless machines (e.g., Amazon EC2 instances).
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Disables <link linkend="opt-sound.enable">sound</link>,
|
||||||
|
<link linkend="opt-boot.vesa">vesa</link>, serial consoles,
|
||||||
|
<link linkend="opt-systemd.enableEmergencyMode">emergency mode</link>,
|
||||||
|
<link linkend="opt-boot.loader.grub.splashImage">grub splash images</link> and
|
||||||
|
configures the kernel to reboot automatically on panic.
|
||||||
|
</para>
|
||||||
|
</section>
|
@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-installation-device">
|
||||||
|
<title>Installation Device</title>
|
||||||
|
<para>
|
||||||
|
Provides a basic configuration for installation devices like CDs. This means
|
||||||
|
enabling hardware scans, using the <link linkend="sec-profile-clone-config">
|
||||||
|
Clone Config profile</link> to guarantee
|
||||||
|
<filename>/etc/nixos/configuration.nix</filename> exists (for
|
||||||
|
<command>nixos-rebuild</command> to work), a copy of the Nixpkgs channel
|
||||||
|
snapshot used to create the install media.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Additionally, documentation for <link linkend="opt-documentation.enable">
|
||||||
|
Nixpkgs</link> and <link linkend="opt-documentation.nixos.enable">NixOS
|
||||||
|
</link> are forcefully enabled (to override the
|
||||||
|
<link linkend="sec-profile-minimal">Minimal profile</link> preference); the
|
||||||
|
NixOS manual is shown automatically on TTY 8, sudo and udisks are disabled.
|
||||||
|
Autologin is enabled as root.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
A message is shown to the user to start a display manager if needed,
|
||||||
|
ssh with <xref linkend="opt-services.openssh.permitRootLogin"/> are enabled (but
|
||||||
|
doesn't autostart). WPA Supplicant is also enabled without autostart.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Finally, vim is installed, root is set to not have a password, the kernel is
|
||||||
|
made more silent for remote public IP installs, and several settings are
|
||||||
|
tweaked so that the installer has a better chance of succeeding under
|
||||||
|
low-memory environments.
|
||||||
|
</para>
|
||||||
|
</section>
|
17
nixos/doc/manual/configuration/profiles/minimal.xml
Normal file
17
nixos/doc/manual/configuration/profiles/minimal.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-minimal">
|
||||||
|
<title>Minimal</title>
|
||||||
|
<para>
|
||||||
|
This profile defines a small NixOS configuration. It does not contain any
|
||||||
|
graphical stuff. It's a very short file that enables
|
||||||
|
<link linkend="opt-environment.noXlibs">noXlibs</link>, sets
|
||||||
|
<link linkend="opt-i18n.supportedLocales">i18n.supportedLocales</link>
|
||||||
|
to only support the user-selected locale,
|
||||||
|
<link linkend="opt-documentation.enable">disables packages' documentation
|
||||||
|
</link>, and <link linkend="opt-sound.enable">disables sound</link>.
|
||||||
|
</para>
|
||||||
|
</section>
|
16
nixos/doc/manual/configuration/profiles/qemu-guest.xml
Normal file
16
nixos/doc/manual/configuration/profiles/qemu-guest.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
version="5.0"
|
||||||
|
xml:id="sec-profile-qemu-guest">
|
||||||
|
<title>QEMU Guest</title>
|
||||||
|
<para>
|
||||||
|
This profile contains common configuration for virtual machines running under
|
||||||
|
QEMU (using virtio).
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
It makes virtio modules available on the initrd, sets the system time from
|
||||||
|
the hardware clock to work around a bug in qemu-kvm, and
|
||||||
|
<link linkend="opt-security.rngd.enable">enables rngd</link>.
|
||||||
|
</para>
|
||||||
|
</section>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user