mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 19:00:19 +08:00
Compare commits
274 Commits
init-uefor
...
21.05
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e9b0dff97 | ||
|
|
a8eeea419e | ||
|
|
9e2c334e52 | ||
|
|
3a2e0c36e7 | ||
|
|
cbe0e663ec | ||
|
|
75f90eedcf | ||
|
|
7b601ada77 | ||
|
|
0c2e856ea0 | ||
|
|
1c27669fea | ||
|
|
ab98a6e109 | ||
|
|
1293a26299 | ||
|
|
cdf6c6106b | ||
|
|
9bbf2ec131 | ||
|
|
9130b8c465 | ||
|
|
aa9f441226 | ||
|
|
ef423b1205 | ||
|
|
c87afd2553 | ||
|
|
a8b758696c | ||
|
|
9ad5d4d363 | ||
|
|
cbd00766e4 | ||
|
|
6cac8dd5d9 | ||
|
|
41734b6851 | ||
|
|
8479c43fa2 | ||
|
|
556951a923 | ||
|
|
b9fd21fe40 | ||
|
|
7ca8def3b9 | ||
|
|
2127c48d06 | ||
|
|
d25ea6a0d2 | ||
|
|
ad8e636a3e | ||
|
|
a30a33bbff | ||
|
|
3b7c820173 | ||
|
|
91efaf3393 | ||
|
|
3018bf4b9e | ||
|
|
aa2efdf901 | ||
|
|
ebdf00f038 | ||
|
|
7f016e24c7 | ||
|
|
a2e86da944 | ||
|
|
0a28f8dc51 | ||
|
|
b0e7f01080 | ||
|
|
fc924fc34e | ||
|
|
478f5d49f6 | ||
|
|
c91f853b0d | ||
|
|
76fcaa085f | ||
|
|
a2f6fc7092 | ||
|
|
07ca3a021f | ||
|
|
ec2d3871f7 | ||
|
|
a027e1fa05 | ||
|
|
cd8efe13e0 | ||
|
|
1834af74e3 | ||
|
|
0e2b7ebdde | ||
|
|
a74605831e | ||
|
|
439b6d5c2c | ||
|
|
4cd3fd238d | ||
|
|
95d4bdbaae | ||
|
|
e3a1e350ba | ||
|
|
4f9eadefdc | ||
|
|
c072a18797 | ||
|
|
0c39e877ec | ||
|
|
ab9f3f2f9e | ||
|
|
9fd05bb58f | ||
|
|
d9df705215 | ||
|
|
6ca456a1c9 | ||
|
|
2afcd85748 | ||
|
|
a33878b687 | ||
|
|
07796133d4 | ||
|
|
bae3f3be2a | ||
|
|
60c22bd341 | ||
|
|
2063939edd | ||
|
|
c399b0f178 | ||
|
|
4c4a45e284 | ||
|
|
f63370194e | ||
|
|
3d7ced7b59 | ||
|
|
bad208a3e6 | ||
|
|
b3197b1334 | ||
|
|
e3ddcfdf2c | ||
|
|
2a0ab9f511 | ||
|
|
0659aeb14f | ||
|
|
04d804d0ab | ||
|
|
9b98f80829 | ||
|
|
e04a17a37e | ||
|
|
20387998ce | ||
|
|
0557b7bfb1 | ||
|
|
52223c3d1d | ||
|
|
c99249df0f | ||
|
|
1f6295e555 | ||
|
|
042c54b758 | ||
|
|
a5a6efd9b4 | ||
|
|
6eac23ff6a | ||
|
|
a51efd1bb4 | ||
|
|
8a6d0863c5 | ||
|
|
4a4105f069 | ||
|
|
4330bdd244 | ||
|
|
81c84a9194 | ||
|
|
9cab6e0dd4 | ||
|
|
d27b376262 | ||
|
|
725af5376f | ||
|
|
a217eed6b8 | ||
|
|
e57ea488f9 | ||
|
|
efbb010dfb | ||
|
|
fb75a2a13f | ||
|
|
6460c5ce33 | ||
|
|
c1757ad15a | ||
|
|
7198e20169 | ||
|
|
fb64e7de78 | ||
|
|
8dc1b48597 | ||
|
|
58ba40336c | ||
|
|
f4d6d51a09 | ||
|
|
e7f90ce89c | ||
|
|
1166a744e3 | ||
|
|
c30d29421b | ||
|
|
78268a73a1 | ||
|
|
c258bb29a3 | ||
|
|
6eba052712 | ||
|
|
417b79b504 | ||
|
|
a68c14446b | ||
|
|
0bfc2cc9ea | ||
|
|
b423efaeeb | ||
|
|
4594e54063 | ||
|
|
ce5587e7bb | ||
|
|
c892433d7b | ||
|
|
6ca6be2bbf | ||
|
|
25115a31d7 | ||
|
|
a5cbb1a436 | ||
|
|
fa5915bebb | ||
|
|
c50592961a | ||
|
|
53ad00cfc3 | ||
|
|
b73e47d3d7 | ||
|
|
36f8feac81 | ||
|
|
8d914c1157 | ||
|
|
7b1072b4ff | ||
|
|
d981999780 | ||
|
|
ad947d5fa6 | ||
|
|
b08b7cd9b7 | ||
|
|
84fd858633 | ||
|
|
d5d7312426 | ||
|
|
8a5ec66c40 | ||
|
|
5b3858527f | ||
|
|
b1a828fa56 | ||
|
|
75d84510e1 | ||
|
|
18cd14175f | ||
|
|
5b52f151e1 | ||
|
|
831bf15565 | ||
|
|
47ed684380 | ||
|
|
d77e68bedf | ||
|
|
04fcd9e107 | ||
|
|
836e34d53a | ||
|
|
361dbda2ca | ||
|
|
2899292e07 | ||
|
|
9588f49304 | ||
|
|
eff32c3626 | ||
|
|
4e172daaa6 | ||
|
|
5621b77a7e | ||
|
|
6350467e7b | ||
|
|
7e7e91f8e2 | ||
|
|
02daee80bc | ||
|
|
fcddce0f10 | ||
|
|
79c5dbb549 | ||
|
|
80df101aa8 | ||
|
|
377de4787e | ||
|
|
078af61232 | ||
|
|
989c034206 | ||
|
|
8d31a9d644 | ||
|
|
1c212ecbb8 | ||
|
|
88144f9b91 | ||
|
|
6929dd4f0b | ||
|
|
2371e028f6 | ||
|
|
47c51cc3bf | ||
|
|
46a5d32fc9 | ||
|
|
6029acc019 | ||
|
|
5e74829b72 | ||
|
|
676ddafd3d | ||
|
|
611cedc127 | ||
|
|
ff00b8c0d1 | ||
|
|
17293ccdfc | ||
|
|
c8a75ccf74 | ||
|
|
a0011e1118 | ||
|
|
a2547d21eb | ||
|
|
e7e53babb6 | ||
|
|
0a086ee342 | ||
|
|
837f80023d | ||
|
|
83fb69d685 | ||
|
|
51cf39407b | ||
|
|
deb0a4259f | ||
|
|
5369265a53 | ||
|
|
84a08eb98d | ||
|
|
95f6c0b7e0 | ||
|
|
25eaf1083f | ||
|
|
4a40836097 | ||
|
|
573cdf2df2 | ||
|
|
169371366d | ||
|
|
ed35898dd1 | ||
|
|
8ac5876aac | ||
|
|
2c8139ee6b | ||
|
|
828cf19e1e | ||
|
|
b6f4ae45b7 | ||
|
|
fc8280a67c | ||
|
|
84ad09b57b | ||
|
|
97eba634e4 | ||
|
|
8eb8032b1d | ||
|
|
0b4994f714 | ||
|
|
6ac38da61b | ||
|
|
d2920be368 | ||
|
|
677fab12a9 | ||
|
|
6aa537a98d | ||
|
|
a6ac81209b | ||
|
|
b7ce7d761c | ||
|
|
feff71106d | ||
|
|
97fc742ae6 | ||
|
|
ff776b403a | ||
|
|
813b3b2a0c | ||
|
|
af053d10fb | ||
|
|
66fdd3939d | ||
|
|
65d4fff84d | ||
|
|
6e4f30b5a0 | ||
|
|
f75079b072 | ||
|
|
0a1ddb21f2 | ||
|
|
a555872f04 | ||
|
|
8418b1397c | ||
|
|
e3f7168d86 | ||
|
|
92e46f3619 | ||
|
|
ab28c480e2 | ||
|
|
60c98baf17 | ||
|
|
c2e9a51cdc | ||
|
|
bc71efad3e | ||
|
|
3f0d62871e | ||
|
|
7e49e3ea89 | ||
|
|
1b1608a7b8 | ||
|
|
befda3568c | ||
|
|
76e136bb5e | ||
|
|
b3a9a3e19f | ||
|
|
3c0ee5ac10 | ||
|
|
0ef2fe6f77 | ||
|
|
b7f77e07b2 | ||
|
|
baedf2c785 | ||
|
|
0ae5309111 | ||
|
|
0cebbdf687 | ||
|
|
97b94af4eb | ||
|
|
3cb8557ce1 | ||
|
|
a4b270df3a | ||
|
|
2bffd5fef9 | ||
|
|
0c67f4a204 | ||
|
|
c443ac73f2 | ||
|
|
ee76949241 | ||
|
|
40b3403d59 | ||
|
|
35f631618f | ||
|
|
d77ece7e27 | ||
|
|
036b557bd9 | ||
|
|
ecff4216d5 | ||
|
|
b0eb9dfebb | ||
|
|
62f3f8954c | ||
|
|
e3dc52bcb2 | ||
|
|
df25a8867f | ||
|
|
0548d93697 | ||
|
|
bfa9bc365d | ||
|
|
1c1e5094d9 | ||
|
|
3a165fda92 | ||
|
|
771d69953d | ||
|
|
7375cb1c0e | ||
|
|
b7e6b86c74 | ||
|
|
6514fc8f6b | ||
|
|
b39ac7cf2b | ||
|
|
1de0b0e5eb | ||
|
|
fadd5dd5ae | ||
|
|
075ab49dc2 | ||
|
|
13e13349bd | ||
|
|
ddc60bec55 | ||
|
|
11f5b3279d | ||
|
|
8e7956833a | ||
|
|
d547493e0c | ||
|
|
f05e41b6f4 | ||
|
|
4a974e6695 | ||
|
|
c294c2fb40 | ||
|
|
c2bb4bad68 | ||
|
|
12c5acf376 |
69
.github/CODEOWNERS
vendored
69
.github/CODEOWNERS
vendored
@@ -19,7 +19,7 @@
|
||||
|
||||
# Libraries
|
||||
/lib @edolstra @nbp @infinisil
|
||||
/lib/systems @alyssais @nbp @ericson2314 @matthewbauer
|
||||
/lib/systems @nbp @ericson2314 @matthewbauer
|
||||
/lib/generators.nix @edolstra @nbp @Profpatsch
|
||||
/lib/cli.nix @edolstra @nbp @Profpatsch
|
||||
/lib/debug.nix @edolstra @nbp @Profpatsch
|
||||
@@ -42,12 +42,6 @@
|
||||
# Nixpkgs build-support
|
||||
/pkgs/build-support/writers @lassulus @Profpatsch
|
||||
|
||||
# Nixpkgs documentation
|
||||
/maintainers/scripts/db-to-md.sh @jtojnar @ryantm
|
||||
/maintainers/scripts/doc @jtojnar @ryantm
|
||||
/doc/build-aux/pandoc-filters @jtojnar
|
||||
/doc/contributing/contributing-to-documentation.chapter.md @jtojnar
|
||||
|
||||
# NixOS Internals
|
||||
/nixos/default.nix @nbp @infinisil
|
||||
/nixos/lib/from-env.nix @nbp @infinisil
|
||||
@@ -65,7 +59,6 @@
|
||||
/nixos/doc/manual/development/writing-modules.xml @nbp
|
||||
/nixos/doc/manual/man-nixos-option.xml @nbp
|
||||
/nixos/modules/installer/tools/nixos-option.sh @nbp
|
||||
/nixos/modules/system @dasJ
|
||||
|
||||
# NixOS integration test driver
|
||||
/nixos/lib/test-driver @tfc
|
||||
@@ -78,32 +71,30 @@
|
||||
/pkgs/common-updater/scripts/update-source-version @jtojnar
|
||||
|
||||
# Python-related code and docs
|
||||
/maintainers/scripts/update-python-libraries @FRidh
|
||||
/pkgs/top-level/python-packages.nix @FRidh @jonringer
|
||||
/pkgs/development/interpreters/python @FRidh
|
||||
/pkgs/development/python-modules @FRidh @jonringer
|
||||
/doc/languages-frameworks/python.section.md @FRidh
|
||||
/pkgs/development/tools/poetry2nix @adisbladis
|
||||
/pkgs/development/interpreters/python/hooks @FRidh @jonringer @DavHau
|
||||
/pkgs/development/interpreters/python/conda @DavHau
|
||||
/maintainers/scripts/update-python-libraries @FRidh
|
||||
/pkgs/top-level/python-packages.nix @FRidh @jonringer
|
||||
/pkgs/development/interpreters/python @FRidh
|
||||
/pkgs/development/python-modules @FRidh @jonringer
|
||||
/doc/languages-frameworks/python.section.md @FRidh
|
||||
/pkgs/development/tools/poetry2nix @adisbladis
|
||||
|
||||
# Haskell
|
||||
/doc/languages-frameworks/haskell.section.md @cdepillabout @sternenseemann @maralorn @expipiplus1
|
||||
/maintainers/scripts/haskell @cdepillabout @sternenseemann @maralorn @expipiplus1
|
||||
/pkgs/development/compilers/ghc @cdepillabout @sternenseemann @maralorn @expipiplus1
|
||||
/pkgs/development/haskell-modules @cdepillabout @sternenseemann @maralorn @expipiplus1
|
||||
/pkgs/test/haskell @cdepillabout @sternenseemann @maralorn @expipiplus1
|
||||
/pkgs/top-level/release-haskell.nix @cdepillabout @sternenseemann @maralorn @expipiplus1
|
||||
/pkgs/top-level/haskell-packages.nix @cdepillabout @sternenseemann @maralorn @expipiplus1
|
||||
/doc/languages-frameworks/haskell.section.md @cdepillabout @sternenseemann @maralorn
|
||||
/maintainers/scripts/haskell @cdepillabout @sternenseemann @maralorn
|
||||
/pkgs/development/compilers/ghc @cdepillabout @sternenseemann @maralorn
|
||||
/pkgs/development/haskell-modules @cdepillabout @sternenseemann @maralorn
|
||||
/pkgs/test/haskell @cdepillabout @sternenseemann @maralorn
|
||||
/pkgs/top-level/release-haskell.nix @cdepillabout @sternenseemann @maralorn
|
||||
/pkgs/top-level/haskell-packages.nix @cdepillabout @sternenseemann @maralorn
|
||||
|
||||
# Perl
|
||||
/pkgs/development/interpreters/perl @volth @stigtsp @zakame
|
||||
/pkgs/top-level/perl-packages.nix @volth @stigtsp @zakame
|
||||
/pkgs/development/perl-modules @volth @stigtsp @zakame
|
||||
/pkgs/development/interpreters/perl @volth @stigtsp
|
||||
/pkgs/top-level/perl-packages.nix @volth @stigtsp
|
||||
/pkgs/development/perl-modules @volth @stigtsp
|
||||
|
||||
# R
|
||||
/pkgs/applications/science/math/R @jbedo @bcdarwin
|
||||
/pkgs/development/r-modules @jbedo @bcdarwin
|
||||
/pkgs/applications/science/math/R @peti
|
||||
/pkgs/development/r-modules @peti
|
||||
|
||||
# Ruby
|
||||
/pkgs/development/interpreters/ruby @marsam
|
||||
@@ -111,7 +102,7 @@
|
||||
|
||||
# Rust
|
||||
/pkgs/development/compilers/rust @Mic92 @LnL7 @zowoq
|
||||
/pkgs/build-support/rust @andir @zowoq
|
||||
/pkgs/build-support/rust @andir @danieldk @zowoq
|
||||
|
||||
# Darwin-related
|
||||
/pkgs/stdenv/darwin @NixOS/darwin-maintainers
|
||||
@@ -188,7 +179,8 @@
|
||||
/pkgs/top-level/emacs-packages.nix @adisbladis
|
||||
|
||||
# Neovim
|
||||
/pkgs/applications/editors/neovim @jonringer @teto
|
||||
/pkgs/applications/editors/neovim @jonringer
|
||||
/pkgs/applications/editors/neovim @teto
|
||||
|
||||
# VimPlugins
|
||||
/pkgs/misc/vim-plugins @jonringer @softinio
|
||||
@@ -202,12 +194,12 @@
|
||||
/nixos/tests/prometheus-exporters.nix @WilliButz
|
||||
|
||||
# PHP interpreter, packages, extensions, tests and documentation
|
||||
/doc/languages-frameworks/php.section.md @NixOS/php @aanderse @etu @globin @ma27 @talyz
|
||||
/nixos/tests/php @NixOS/php @aanderse @etu @globin @ma27 @talyz
|
||||
/pkgs/build-support/build-pecl.nix @NixOS/php @aanderse @etu @globin @ma27 @talyz
|
||||
/pkgs/development/interpreters/php @jtojnar @NixOS/php @aanderse @etu @globin @ma27 @talyz
|
||||
/pkgs/development/php-packages @NixOS/php @aanderse @etu @globin @ma27 @talyz
|
||||
/pkgs/top-level/php-packages.nix @jtojnar @NixOS/php @aanderse @etu @globin @ma27 @talyz
|
||||
/doc/languages-frameworks/php.section.md @NixOS/php
|
||||
/nixos/tests/php @NixOS/php
|
||||
/pkgs/build-support/build-pecl.nix @NixOS/php
|
||||
/pkgs/development/interpreters/php @NixOS/php
|
||||
/pkgs/development/php-packages @NixOS/php
|
||||
/pkgs/top-level/php-packages.nix @NixOS/php
|
||||
|
||||
# Podman, CRI-O modules and related
|
||||
/nixos/modules/virtualisation/containers.nix @NixOS/podman @zowoq
|
||||
@@ -232,8 +224,3 @@
|
||||
|
||||
# Cinnamon
|
||||
/pkgs/desktops/cinnamon @mkg20001
|
||||
|
||||
#nim
|
||||
/pkgs/development/compilers/nim @ehmry
|
||||
/pkgs/development/nim-packages @ehmry
|
||||
/pkgs/top-level/nim-packages.nix @ehmry
|
||||
|
||||
23
CONTRIBUTING.md → .github/CONTRIBUTING.md
vendored
23
CONTRIBUTING.md → .github/CONTRIBUTING.md
vendored
@@ -1,7 +1,7 @@
|
||||
# How to contribute
|
||||
|
||||
Note: contributing implies licensing those contributions
|
||||
under the terms of [COPYING](COPYING), which is an MIT-like license.
|
||||
under the terms of [COPYING](../COPYING), which is an MIT-like license.
|
||||
|
||||
## Opening issues
|
||||
|
||||
@@ -59,27 +59,6 @@ Follow these steps to backport a change into a release branch in compliance with
|
||||
5. Push to GitHub and open a backport pull request. Make sure to select the release branch (e.g. `release-20.09`) as the target branch of the pull request, and link to the pull request in which the original change was comitted to `master`. The pull request title should be the commit title with the release version as prefix, e.g. `[20.09]`.
|
||||
6. When the backport pull request is merged and you have the necessary privileges you can also replace the label `9.needs: port to stable` with `8.has: port to stable` on the original pull request. This way maintainers can keep track of missing backports easier.
|
||||
|
||||
## Criteria for Backporting changes
|
||||
|
||||
Anything that does not cause user or downstream dependency regressions can be backported. This includes:
|
||||
- New Packages / Modules
|
||||
- Security / Patch updates
|
||||
- Version updates which include new functionality (but no breaking changes)
|
||||
- Services which require a client to be up-to-date regardless. (E.g. `spotify`, `steam`, or `discord`)
|
||||
- Security critical applications (E.g. `firefox`)
|
||||
|
||||
## Generating 21.11 Release Notes
|
||||
|
||||
(This section also applies to backporting 21.05 release notes: substitute "rl-2111" for "rl-2105".)
|
||||
|
||||
Documentation in nixpkgs is transitioning to a markdown-centric workflow. Release notes now require a translation step to convert from markdown to a compatible docbook document.
|
||||
|
||||
Steps for updating 21.11 Release notes:
|
||||
|
||||
1. Edit `nixos/doc/manual/release-notes/rl-2111.section.md` with the desired changes
|
||||
2. Run `./nixos/doc/manual/md-to-db.sh` to render `nixos/doc/manual/from_md/release-notes/rl-2111.section.xml`
|
||||
3. Include changes to `rl-2111.section.md` and `rl-2111.section.xml` in the same commit.
|
||||
|
||||
## Reviewing contributions
|
||||
|
||||
See the nixpkgs manual for more details on how to [Review contributions](https://nixos.org/nixpkgs/manual/#chap-reviewing-contributions).
|
||||
19
.github/ISSUE_TEMPLATE/bug_report.md
vendored
19
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -7,38 +7,33 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Describe the bug
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
### Steps To Reproduce
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. ...
|
||||
2. ...
|
||||
3. ...
|
||||
|
||||
### Expected behavior
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
### Screenshots
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
### Additional context
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
### Notify maintainers
|
||||
**Notify maintainers**
|
||||
<!--
|
||||
Please @ people who are in the `meta.maintainers` list of the offending package or module.
|
||||
If in doubt, check `git blame` for whoever last touched something.
|
||||
-->
|
||||
|
||||
### Metadata
|
||||
**Metadata**
|
||||
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
|
||||
|
||||
```console
|
||||
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
|
||||
output here
|
||||
```
|
||||
|
||||
Maintainer information:
|
||||
```yaml
|
||||
# a list of nixpkgs attributes affected by the problem
|
||||
|
||||
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -15,21 +15,13 @@ Reviewing guidelines: https://nixos.org/manual/nixpkgs/unstable/#chap-reviewing-
|
||||
|
||||
<!-- Please check what applies. Note that these are not hard requirements but merely serve as information for reviewers. -->
|
||||
|
||||
- [ ] Tested using sandboxing ([nix.useSandbox](https://nixos.org/nixos/manual/options.html#opt-nix.useSandbox) on NixOS, or option `sandbox` in [`nix.conf`](https://nixos.org/nix/manual/#sec-conf-file) on non-NixOS linux)
|
||||
- Built on platform(s)
|
||||
- [ ] x86_64-linux
|
||||
- [ ] aarch64-linux
|
||||
- [ ] x86_64-darwin
|
||||
- [ ] aarch64-darwin
|
||||
- [ ] For non-Linux: Is `sandbox = true` set in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/#sec-conf-file))
|
||||
- [ ] Tested, as applicable:
|
||||
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
|
||||
- and/or [package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests)
|
||||
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
|
||||
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
|
||||
- [ ] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage)
|
||||
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
|
||||
- [21.11 Release Notes (or backporting 21.05 Release notes)](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#generating-2111-release-notes)
|
||||
- [ ] (Package updates) Added a release notes entry if the change is major or breaking
|
||||
- [ ] (Module updates) Added a release notes entry if the change is significant
|
||||
- [ ] (Module addition) Added a release notes entry if adding a new NixOS module
|
||||
- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
- [ ] NixOS
|
||||
- [ ] macOS
|
||||
- [ ] other Linux distributions
|
||||
- [ ] Tested via one or more NixOS test(s) if existing and applicable for the change (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
|
||||
- [ ] Tested compilation of all pkgs that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review wip"`
|
||||
- [ ] Tested execution of all binary files (usually in `./result/bin/`)
|
||||
- [ ] Added a release notes entry if the change is major or breaking
|
||||
- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md).
|
||||
|
||||
2
.github/STALE-BOT.md
vendored
2
.github/STALE-BOT.md
vendored
@@ -3,7 +3,7 @@
|
||||
- Thanks for your contribution!
|
||||
- To remove the stale label, just leave a new comment.
|
||||
- _How to find the right people to ping?_ → [`git blame`](https://git-scm.com/docs/git-blame) to the rescue! (or GitHub's history and blame buttons.)
|
||||
- You can always ask for help on [our Discourse Forum](https://discourse.nixos.org/), [our Matrix room](https://matrix.to/#/#nix:nixos.org), or on the [#nixos IRC channel](https://web.libera.chat/#nixos).
|
||||
- You can always ask for help on [our Discourse Forum](https://discourse.nixos.org/) or on the [#nixos IRC channel](https://webchat.freenode.net/#nixos).
|
||||
|
||||
## Suggestions for PRs
|
||||
|
||||
|
||||
7
.github/labeler.yml
vendored
7
.github/labeler.yml
vendored
@@ -70,13 +70,6 @@
|
||||
|
||||
"6.topic: nixos":
|
||||
- nixos/**/*
|
||||
- pkgs/os-specific/linux/nixos-rebuild/**/*
|
||||
|
||||
"6.topic: nim":
|
||||
- doc/languages-frameworks/nim.section.md
|
||||
- pkgs/development/compilers/nim/*
|
||||
- pkgs/development/nim-packages/**/*
|
||||
- pkgs/top-level/nim-packages.nix
|
||||
|
||||
"6.topic: ocaml":
|
||||
- doc/languages-frameworks/ocaml.section.md
|
||||
|
||||
29
.github/workflows/backport.yml
vendored
29
.github/workflows/backport.yml
vendored
@@ -1,29 +0,0 @@
|
||||
name: Backport
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [closed, labeled]
|
||||
jobs:
|
||||
backport:
|
||||
name: Backport Pull Request
|
||||
if: github.repository_owner == 'NixOS' && github.event.pull_request.merged == true && (github.event_name != 'labeled' || startsWith('backport', github.event.label.name))
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
# required to find all branches
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Create backport PRs
|
||||
# should be kept in sync with `version`
|
||||
uses: zeebe-io/backport-action@v0.0.5
|
||||
with:
|
||||
# Config README: https://github.com/zeebe-io/backport-action#backport-action
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
github_workspace: ${{ github.workspace }}
|
||||
# should be kept in sync with `uses`
|
||||
version: v0.0.5
|
||||
pull_description: |-
|
||||
Bot-based backport to `${target_branch}`, triggered by a label in #${pull_number}.
|
||||
|
||||
* [ ] Before merging, ensure that this backport complies with the [Criteria for Backporting](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#criteria-for-backporting-changes).
|
||||
* Even as a non-commiter, if you find that it does not comply, leave a comment.
|
||||
20
.github/workflows/basic-eval.yml
vendored
20
.github/workflows/basic-eval.yml
vendored
@@ -1,20 +0,0 @@
|
||||
name: Basic evaluation checks
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- release-**
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- release-**
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
# we don't limit this action to only NixOS repo since the checks are cheap and useful developer feedback
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: cachix/install-nix-action@v15
|
||||
# explicit list of supportedSystems is needed until aarch64-darwin becomes part of the trunk jobset
|
||||
- run: nix-build pkgs/top-level/release.nix -A tarball.nixpkgs-basic-release-checks --arg supportedSystems '[ "aarch64-darwin" "aarch64-linux" "x86_64-linux" "x86_64-darwin" ]'
|
||||
3
.github/workflows/direct-push.yml
vendored
3
.github/workflows/direct-push.yml
vendored
@@ -17,9 +17,6 @@ jobs:
|
||||
run: |
|
||||
ISMERGE=$(curl -H 'Accept: application/vnd.github.groot-preview+json' -H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ env.GITHUB_REPOSITORY }}/commits/${{ env.GITHUB_SHA }}/pulls | jq -r '.[] | select(.merge_commit_sha == "${{ env.GITHUB_SHA }}") | any')
|
||||
echo "::set-output name=ismerge::$ISMERGE"
|
||||
# github events are eventually consistent, so wait until changes propagate to thier DB
|
||||
- run: sleep 60
|
||||
if: steps.ismerge.outputs.ismerge != 'true'
|
||||
- name: Warn if the commit was a direct push
|
||||
if: steps.ismerge.outputs.ismerge != 'true'
|
||||
uses: peter-evans/commit-comment@v1
|
||||
|
||||
2
.github/workflows/editorconfig.yml
vendored
2
.github/workflows/editorconfig.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
if: env.PR_DIFF
|
||||
- uses: cachix/install-nix-action@v15
|
||||
- uses: cachix/install-nix-action@v13
|
||||
if: env.PR_DIFF
|
||||
with:
|
||||
# nixpkgs commit is pinned so that it doesn't break
|
||||
|
||||
5
.github/workflows/manual-nixos.yml
vendored
5
.github/workflows/manual-nixos.yml
vendored
@@ -12,17 +12,16 @@ on:
|
||||
jobs:
|
||||
nixos:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
- uses: cachix/install-nix-action@v15
|
||||
- uses: cachix/install-nix-action@v13
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
- uses: cachix/cachix-action@v10
|
||||
- uses: cachix/cachix-action@v9
|
||||
with:
|
||||
# This cache is for the nixos/nixpkgs manual builds and should not be trusted or used elsewhere.
|
||||
name: nixpkgs-ci
|
||||
|
||||
5
.github/workflows/manual-nixpkgs.yml
vendored
5
.github/workflows/manual-nixpkgs.yml
vendored
@@ -12,17 +12,16 @@ on:
|
||||
jobs:
|
||||
nixpkgs:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
- uses: cachix/install-nix-action@v15
|
||||
- uses: cachix/install-nix-action@v13
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
- uses: cachix/cachix-action@v10
|
||||
- uses: cachix/cachix-action@v9
|
||||
with:
|
||||
# This cache is for the nixos/nixpkgs manual builds and should not be trusted or used elsewhere.
|
||||
name: nixpkgs-ci
|
||||
|
||||
41
.github/workflows/merge-staging.yml
vendored
Normal file
41
.github/workflows/merge-staging.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
name: "merge staging(-next)"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# * is a special character in YAML so you have to quote this string
|
||||
# Merge every 6 hours
|
||||
- cron: '0 */6 * * *'
|
||||
|
||||
jobs:
|
||||
sync-branch:
|
||||
if: github.repository == 'NixOS/nixpkgs'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Merge master into staging-next
|
||||
id: staging_next
|
||||
uses: devmasx/merge-branch@v1.3.1
|
||||
with:
|
||||
type: now
|
||||
from_branch: master
|
||||
target_branch: staging-next
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Merge staging-next into staging
|
||||
id: staging
|
||||
uses: devmasx/merge-branch@v1.3.1
|
||||
with:
|
||||
type: now
|
||||
from_branch: staging-next
|
||||
target_branch: staging
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Comment on failure
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
issue-number: 105153
|
||||
body: |
|
||||
An automatic merge${{ (steps.staging_next.outcome == 'failure' && ' from master to staging-next') || ((steps.staging.outcome == 'failure' && ' from staging-next to staging') || '') }} [failed](https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}).
|
||||
|
||||
26
.github/workflows/nixos-manual.yml
vendored
26
.github/workflows/nixos-manual.yml
vendored
@@ -1,26 +0,0 @@
|
||||
name: NixOS manual checks
|
||||
|
||||
permissions: read-all
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
branches-ignore:
|
||||
- 'release-**'
|
||||
paths:
|
||||
- 'nixos/**/*.xml'
|
||||
- 'nixos/**/*.md'
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
- uses: cachix/install-nix-action@v15
|
||||
- name: Check DocBook files generated from Markdown are consistent
|
||||
run: |
|
||||
nixos/doc/manual/md-to-db.sh
|
||||
git diff --exit-code
|
||||
21
.github/workflows/no-channel.yml
vendored
21
.github/workflows/no-channel.yml
vendored
@@ -1,21 +0,0 @@
|
||||
name: "No channel PR"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- 'nixos-**'
|
||||
- 'nixpkgs-**'
|
||||
|
||||
jobs:
|
||||
fail:
|
||||
name: "This PR is is targeting a channel branch"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: |
|
||||
cat <<EOF
|
||||
The nixos-* and nixpkgs-* branches are pushed to by the channel
|
||||
release script and should not be merged into directly.
|
||||
|
||||
Please target the equivalent release-* branch or master instead.
|
||||
EOF
|
||||
exit 1
|
||||
53
.github/workflows/periodic-merge-24h.yml
vendored
53
.github/workflows/periodic-merge-24h.yml
vendored
@@ -1,53 +0,0 @@
|
||||
# This action periodically merges base branches into staging branches.
|
||||
# This is done to
|
||||
# * prevent conflicts or rather resolve them early
|
||||
# * make all potential breakage happen on the staging branch
|
||||
# * and make sure that all major rebuilds happen before the staging
|
||||
# branch get’s merged back into its base branch.
|
||||
|
||||
name: "Periodic Merges (24h)"
|
||||
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# * is a special character in YAML so you have to quote this string
|
||||
# Merge every 24 hours
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
jobs:
|
||||
periodic-merge:
|
||||
if: github.repository_owner == 'NixOS'
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
# don't fail fast, so that all pairs are tried
|
||||
fail-fast: false
|
||||
# certain branches need to be merged in order, like master->staging-next->staging
|
||||
# and disabling parallelism ensures the order of the pairs below.
|
||||
max-parallel: 1
|
||||
matrix:
|
||||
pairs:
|
||||
- from: master
|
||||
into: haskell-updates
|
||||
- from: release-21.05
|
||||
into: staging-next-21.05
|
||||
- from: staging-next-21.05
|
||||
into: staging-21.05
|
||||
name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
uses: devmasx/merge-branch@1.4.0
|
||||
with:
|
||||
type: now
|
||||
from_branch: ${{ matrix.pairs.from }}
|
||||
target_branch: ${{ matrix.pairs.into }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Comment on failure
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
issue-number: 105153
|
||||
body: |
|
||||
Periodic merge from `${{ matrix.pairs.from }}` into `${{ matrix.pairs.into }}` has [failed](https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}).
|
||||
51
.github/workflows/periodic-merge-6h.yml
vendored
51
.github/workflows/periodic-merge-6h.yml
vendored
@@ -1,51 +0,0 @@
|
||||
# This action periodically merges base branches into staging branches.
|
||||
# This is done to
|
||||
# * prevent conflicts or rather resolve them early
|
||||
# * make all potential breakage happen on the staging branch
|
||||
# * and make sure that all major rebuilds happen before the staging
|
||||
# branch get’s merged back into its base branch.
|
||||
|
||||
name: "Periodic Merges (6h)"
|
||||
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# * is a special character in YAML so you have to quote this string
|
||||
# Merge every 6 hours
|
||||
- cron: '0 */6 * * *'
|
||||
|
||||
jobs:
|
||||
periodic-merge:
|
||||
if: github.repository_owner == 'NixOS'
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
# don't fail fast, so that all pairs are tried
|
||||
fail-fast: false
|
||||
# certain branches need to be merged in order, like master->staging-next->staging
|
||||
# and disabling parallelism ensures the order of the pairs below.
|
||||
max-parallel: 1
|
||||
matrix:
|
||||
pairs:
|
||||
- from: master
|
||||
into: staging-next
|
||||
- from: staging-next
|
||||
into: staging
|
||||
name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
uses: devmasx/merge-branch@1.4.0
|
||||
with:
|
||||
type: now
|
||||
from_branch: ${{ matrix.pairs.from }}
|
||||
target_branch: ${{ matrix.pairs.into }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Comment on failure
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
issue-number: 105153
|
||||
body: |
|
||||
Periodic merge from `${{ matrix.pairs.from }}` into `${{ matrix.pairs.into }}` has [failed](https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}).
|
||||
134
.github/workflows/rebase.yml
vendored
Normal file
134
.github/workflows/rebase.yml
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
on:
|
||||
issue_comment:
|
||||
types:
|
||||
- created
|
||||
|
||||
# This action allows people with write access to the repo to rebase a PRs base branch
|
||||
# by commenting `/rebase ${branch}` on the PR while avoiding CODEOWNER notifications.
|
||||
|
||||
jobs:
|
||||
rebase:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS' && github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
|
||||
steps:
|
||||
- uses: peter-evans/create-or-update-comment@v1
|
||||
with:
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reactions: eyes
|
||||
- uses: scherermichael-oss/action-has-permission@1.0.6
|
||||
id: check-write-access
|
||||
with:
|
||||
required-permission: write
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: check permissions
|
||||
run: |
|
||||
echo "Commenter doesn't have write access to the repo"
|
||||
exit 1
|
||||
if: "! steps.check-write-access.outputs.has-permission"
|
||||
- name: setup
|
||||
run: |
|
||||
curl "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }}" 2>/dev/null >pr.json
|
||||
cat <<EOF >>"$GITHUB_ENV"
|
||||
CAN_MODIFY=$(jq -r '.maintainer_can_modify' pr.json)
|
||||
COMMITS=$(jq -r '.commits' pr.json)
|
||||
CURRENT_BASE=$(jq -r '.base.ref' pr.json)
|
||||
PR_BRANCH=$(jq -r '.head.ref' pr.json)
|
||||
COMMENT_BRANCH=$(echo ${{ github.event.comment.body }} | awk "/^\/rebase / {print \$2}")
|
||||
PULL_REQUEST=${{ github.event.issue.number }}
|
||||
EOF
|
||||
rm pr.json
|
||||
- name: check branch
|
||||
env:
|
||||
PERMANENT_BRANCHES: "haskell-updates|master|nixos|nixpkgs|python-unstable|release|staging"
|
||||
VALID_BRANCHES: "haskell-updates|master|python-unstable|release-20.09|staging|staging-20.09|staging-next"
|
||||
run: |
|
||||
message() {
|
||||
cat <<EOF
|
||||
Can't rebase $PR_BRANCH from $CURRENT_BASE onto $COMMENT_BRANCH (PR:$PULL_REQUEST COMMITS:$COMMITS)
|
||||
EOF
|
||||
}
|
||||
if ! [[ "$COMMENT_BRANCH" =~ ^($VALID_BRANCHES)$ ]]; then
|
||||
cat <<EOF
|
||||
Check that the branch from the comment is valid:
|
||||
|
||||
$(message)
|
||||
|
||||
This action can only rebase onto these branches:
|
||||
|
||||
$VALID_BRANCHES
|
||||
|
||||
\`/rebase \${branch}\` must be at the start of the line
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$COMMENT_BRANCH" == "$CURRENT_BASE" ]]; then
|
||||
cat <<EOF
|
||||
Check that the branch from the comment isn't the current base branch:
|
||||
|
||||
$(message)
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$COMMENT_BRANCH" == "$PR_BRANCH" ]]; then
|
||||
cat <<EOF
|
||||
Check that the branch from the comment isn't the current branch:
|
||||
|
||||
$(message)
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$PR_BRANCH" =~ ^($PERMANENT_BRANCHES) ]]; then
|
||||
cat <<EOF
|
||||
Check that the PR branch isn't a permanent branch:
|
||||
|
||||
$(message)
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$CAN_MODIFY" != "true" ]]; then
|
||||
cat <<EOF
|
||||
Check that maintainers can edit the PR branch:
|
||||
|
||||
$(message)
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: rebase pull request
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git fetch origin
|
||||
gh pr checkout "$PULL_REQUEST"
|
||||
git rebase \
|
||||
--onto="$(git merge-base origin/"$CURRENT_BASE" origin/"$COMMENT_BRANCH")" \
|
||||
"HEAD~$COMMITS"
|
||||
git push --force
|
||||
curl \
|
||||
-X POST \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
-H "Authorization: token $GITHUB_TOKEN" \
|
||||
-d "{ \"base\": \"$COMMENT_BRANCH\" }" \
|
||||
"https://api.github.com/repos/${{ github.repository }}/pulls/$PULL_REQUEST"
|
||||
curl \
|
||||
-X PATCH \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
-H "Authorization: token $GITHUB_TOKEN" \
|
||||
-d '{ "state": "closed" }' \
|
||||
"https://api.github.com/repos/${{ github.repository }}/pulls/$PULL_REQUEST"
|
||||
- uses: peter-evans/create-or-update-comment@v1
|
||||
with:
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
body: |
|
||||
Rebased, please reopen the pull request to restart CI
|
||||
- uses: peter-evans/create-or-update-comment@v1
|
||||
if: failure()
|
||||
with:
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
body: |
|
||||
[Failed to rebase](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,7 +2,6 @@
|
||||
,*
|
||||
.*.swp
|
||||
.*.swo
|
||||
.idea/
|
||||
result
|
||||
result-*
|
||||
/doc/NEWS.html
|
||||
|
||||
17
README.md
17
README.md
@@ -8,7 +8,7 @@
|
||||
</p>
|
||||
|
||||
[Nixpkgs](https://github.com/nixos/nixpkgs) is a collection of over
|
||||
80,000 software packages that can be installed with the
|
||||
60,000 software packages that can be installed with the
|
||||
[Nix](https://nixos.org/nix/) package manager. It also implements
|
||||
[NixOS](https://nixos.org/nixos/), a purely-functional Linux distribution.
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
# Community
|
||||
|
||||
* [Discourse Forum](https://discourse.nixos.org/)
|
||||
* [Matrix Chat](https://matrix.to/#/#community:nixos.org)
|
||||
* [IRC - #nixos on freenode.net](irc://irc.freenode.net/#nixos)
|
||||
* [NixOS Weekly](https://weekly.nixos.org/)
|
||||
* [Community-maintained wiki](https://nixos.wiki/)
|
||||
* [Community-maintained list of ways to get in touch](https://nixos.wiki/wiki/Get_In_Touch#Chat) (Discord, Telegram, IRC, etc.)
|
||||
* [Community-maintained list of ways to get in touch](https://nixos.wiki/wiki/Get_In_Touch#Chat) (Discord, Matrix, Telegram, other IRC channels, etc.)
|
||||
|
||||
# Other Project Repositories
|
||||
|
||||
@@ -46,14 +46,14 @@ Nixpkgs and NixOS are built and tested by our continuous integration
|
||||
system, [Hydra](https://hydra.nixos.org/).
|
||||
|
||||
* [Continuous package builds for unstable/master](https://hydra.nixos.org/jobset/nixos/trunk-combined)
|
||||
* [Continuous package builds for the NixOS 21.05 release](https://hydra.nixos.org/jobset/nixos/release-21.05)
|
||||
* [Continuous package builds for the NixOS 20.09 release](https://hydra.nixos.org/jobset/nixos/release-20.09)
|
||||
* [Tests for unstable/master](https://hydra.nixos.org/job/nixos/trunk-combined/tested#tabs-constituents)
|
||||
* [Tests for the NixOS 21.05 release](https://hydra.nixos.org/job/nixos/release-21.05/tested#tabs-constituents)
|
||||
* [Tests for the NixOS 20.09 release](https://hydra.nixos.org/job/nixos/release-20.09/tested#tabs-constituents)
|
||||
|
||||
Artifacts successfully built with Hydra are published to cache at
|
||||
https://cache.nixos.org/. When successful build and test criteria are
|
||||
met, the Nixpkgs expressions are distributed via [Nix
|
||||
channels](https://nixos.org/manual/nix/stable/package-management/channels.html).
|
||||
channels](https://nixos.org/nix/manual/#sec-channels).
|
||||
|
||||
# Contributing
|
||||
|
||||
@@ -87,7 +87,7 @@ Most contributions are based on and merged into these branches:
|
||||
deemed of sufficiently high quality
|
||||
|
||||
For more information about contributing to the project, please visit
|
||||
the [contributing page](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
|
||||
the [contributing page](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md).
|
||||
|
||||
# Donations
|
||||
|
||||
@@ -97,8 +97,7 @@ Foundation](https://nixos.org/nixos/foundation.html). To ensure the
|
||||
continuity and expansion of the NixOS infrastructure, we are looking
|
||||
for donations to our organization.
|
||||
|
||||
You can donate to the NixOS foundation through [SEPA bank
|
||||
transfers](https://nixos.org/donate.html) or by using Open Collective:
|
||||
You can donate to the NixOS foundation by using Open Collective:
|
||||
|
||||
<a href="https://opencollective.com/nixos#support"><img src="https://opencollective.com/nixos/tiers/supporter.svg?width=890" /></a>
|
||||
|
||||
|
||||
38
doc/Makefile
38
doc/Makefile
@@ -1,21 +1,5 @@
|
||||
MD_TARGETS=$(addsuffix .xml, $(basename $(shell find . -type f -regex '.*\.md$$' -not -name README.md)))
|
||||
|
||||
PANDOC ?= pandoc
|
||||
|
||||
pandoc_media_dir = media
|
||||
# NOTE: Keep in sync with NixOS manual (/nixos/doc/manual/md-to-db.sh) and conversion script (/maintainers/scripts/db-to-md.sh).
|
||||
# TODO: Remove raw-attribute when we can get rid of DocBook altogether.
|
||||
pandoc_commonmark_enabled_extensions = +attributes+fenced_divs+footnotes+bracketed_spans+definition_lists+pipe_tables+raw_attribute
|
||||
# Not needed:
|
||||
# - docbook-reader/citerefentry-to-rst-role.lua (only relevant for DocBook → MarkDown/rST/MyST)
|
||||
pandoc_flags = --extract-media=$(pandoc_media_dir) \
|
||||
--lua-filter=$(PANDOC_LUA_FILTERS_DIR)/diagram-generator.lua \
|
||||
--lua-filter=build-aux/pandoc-filters/myst-reader/roles.lua \
|
||||
--lua-filter=build-aux/pandoc-filters/link-unix-man-references.lua \
|
||||
--lua-filter=build-aux/pandoc-filters/docbook-writer/rst-roles.lua \
|
||||
--lua-filter=build-aux/pandoc-filters/docbook-writer/labelless-link-is-xref.lua \
|
||||
-f commonmark$(pandoc_commonmark_enabled_extensions)+smart
|
||||
|
||||
.PHONY: all
|
||||
all: validate format out/html/index.html out/epub/manual.epub
|
||||
|
||||
@@ -38,7 +22,7 @@ fix-misc-xml:
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f ${MD_TARGETS} doc-support/result .version manual-full.xml functions/library/locations.xml functions/library/generated
|
||||
rm -rf ./out/ ./highlightjs ./media
|
||||
rm -rf ./out/ ./highlightjs
|
||||
|
||||
.PHONY: validate
|
||||
validate: manual-full.xml doc-support/result
|
||||
@@ -55,7 +39,7 @@ out/html/index.html: doc-support/result manual-full.xml style.css highlightjs
|
||||
mkdir -p out/html/highlightjs/
|
||||
cp -r highlightjs out/html/
|
||||
|
||||
cp -r $(pandoc_media_dir) out/html/
|
||||
cp -r media out/html/
|
||||
cp ./overrides.css out/html/
|
||||
cp ./style.css out/html/style.css
|
||||
|
||||
@@ -70,7 +54,7 @@ out/epub/manual.epub: manual-full.xml
|
||||
doc-support/result/epub.xsl \
|
||||
./manual-full.xml
|
||||
|
||||
cp -r $(pandoc_media_dir) out/epub/scratch/OEBPS
|
||||
cp -r media out/epub/scratch/OEBPS
|
||||
cp ./overrides.css out/epub/scratch/OEBPS
|
||||
cp ./style.css out/epub/scratch/OEBPS
|
||||
mkdir -p out/epub/scratch/OEBPS/images/callouts/
|
||||
@@ -105,12 +89,16 @@ functions/library/generated: doc-support/result
|
||||
ln -rfs ./doc-support/result/function-docs functions/library/generated
|
||||
|
||||
%.section.xml: %.section.md
|
||||
$(PANDOC) $^ -t docbook \
|
||||
$(pandoc_flags) \
|
||||
-o $@
|
||||
pandoc $^ -t docbook \
|
||||
--extract-media=media \
|
||||
--lua-filter=$(PANDOC_LUA_FILTERS_DIR)/diagram-generator.lua \
|
||||
-f markdown+smart \
|
||||
| cat > $@
|
||||
|
||||
%.chapter.xml: %.chapter.md
|
||||
$(PANDOC) $^ -t docbook \
|
||||
pandoc $^ -t docbook \
|
||||
--top-level-division=chapter \
|
||||
$(pandoc_flags) \
|
||||
-o $@
|
||||
--extract-media=media \
|
||||
--lua-filter=$(PANDOC_LUA_FILTERS_DIR)/diagram-generator.lua \
|
||||
-f markdown+smart \
|
||||
| cat > $@
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
--[[
|
||||
Converts Code AST nodes produced by pandoc’s DocBook reader
|
||||
from citerefentry elements into AST for corresponding role
|
||||
for reStructuredText.
|
||||
|
||||
We use subset of MyST syntax (CommonMark with features from rST)
|
||||
so let’s use the rST AST for rST features.
|
||||
|
||||
Reference: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-manpage
|
||||
]]
|
||||
|
||||
function Code(elem)
|
||||
elem.classes = elem.classes:map(function (x)
|
||||
if x == 'citerefentry' then
|
||||
elem.attributes['role'] = 'manpage'
|
||||
return 'interpreted-text'
|
||||
else
|
||||
return x
|
||||
end
|
||||
end)
|
||||
|
||||
return elem
|
||||
end
|
||||
@@ -1,34 +0,0 @@
|
||||
--[[
|
||||
Converts Link AST nodes with empty label to DocBook xref elements.
|
||||
|
||||
This is a temporary script to be able use cross-references conveniently
|
||||
using syntax taken from MyST, while we still use docbook-xsl
|
||||
for generating the documentation.
|
||||
|
||||
Reference: https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing
|
||||
]]
|
||||
|
||||
local function starts_with(start, str)
|
||||
return str:sub(1, #start) == start
|
||||
end
|
||||
|
||||
local function escape_xml_arg(arg)
|
||||
amps = arg:gsub('&', '&')
|
||||
amps_quotes = amps:gsub('"', '"')
|
||||
amps_quotes_lt = amps_quotes:gsub('<', '<')
|
||||
|
||||
return amps_quotes_lt
|
||||
end
|
||||
|
||||
function Link(elem)
|
||||
has_no_content = #elem.content == 0
|
||||
targets_anchor = starts_with('#', elem.target)
|
||||
has_no_attributes = elem.title == '' and elem.identifier == '' and #elem.classes == 0 and #elem.attributes == 0
|
||||
|
||||
if has_no_content and targets_anchor and has_no_attributes then
|
||||
-- xref expects idref without the pound-sign
|
||||
target_without_hash = elem.target:sub(2, #elem.target)
|
||||
|
||||
return pandoc.RawInline('docbook', '<xref linkend="' .. escape_xml_arg(target_without_hash) .. '" />')
|
||||
end
|
||||
end
|
||||
@@ -1,36 +0,0 @@
|
||||
--[[
|
||||
Converts AST for reStructuredText roles into corresponding
|
||||
DocBook elements.
|
||||
|
||||
Currently, only a subset of roles is supported.
|
||||
|
||||
Reference:
|
||||
List of roles:
|
||||
https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html
|
||||
manpage:
|
||||
https://tdg.docbook.org/tdg/5.1/citerefentry.html
|
||||
file:
|
||||
https://tdg.docbook.org/tdg/5.1/filename.html
|
||||
]]
|
||||
|
||||
function Code(elem)
|
||||
if elem.classes:includes('interpreted-text') then
|
||||
local tag = nil
|
||||
local content = elem.text
|
||||
if elem.attributes['role'] == 'manpage' then
|
||||
tag = 'citerefentry'
|
||||
local title, volnum = content:match('^(.+)%((%w+)%)$')
|
||||
if title == nil then
|
||||
-- No volnum in parentheses.
|
||||
title = content
|
||||
end
|
||||
content = '<refentrytitle>' .. title .. '</refentrytitle>' .. (volnum ~= nil and ('<manvolnum>' .. volnum .. '</manvolnum>') or '')
|
||||
elseif elem.attributes['role'] == 'file' then
|
||||
tag = 'filename'
|
||||
end
|
||||
|
||||
if tag ~= nil then
|
||||
return pandoc.RawInline('docbook', '<' .. tag .. '>' .. content .. '</' .. tag .. '>')
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,18 +0,0 @@
|
||||
--[[
|
||||
Turns a manpage reference into a link, when a mapping is defined
|
||||
in the unix-man-urls.lua file.
|
||||
]]
|
||||
|
||||
local man_urls = {
|
||||
["tmpfiles.d(5)"] = "https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html",
|
||||
["nix.conf(5)"] = "https://nixos.org/manual/nix/stable/#sec-conf-file",
|
||||
["systemd.time(7)"] = "https://www.freedesktop.org/software/systemd/man/systemd.time.html",
|
||||
["systemd.timer(5)"] = "https://www.freedesktop.org/software/systemd/man/systemd.timer.html",
|
||||
}
|
||||
|
||||
function Code(elem)
|
||||
local is_man_role = elem.classes:includes('interpreted-text') and elem.attributes['role'] == 'manpage'
|
||||
if is_man_role and man_urls[elem.text] ~= nil then
|
||||
return pandoc.Link(elem, man_urls[elem.text])
|
||||
end
|
||||
end
|
||||
@@ -1,29 +0,0 @@
|
||||
--[[
|
||||
Replaces Str AST nodes containing {role}, followed by a Code node
|
||||
by a Code node with attrs that would be produced by rST reader
|
||||
from the role syntax.
|
||||
|
||||
This is to emulate MyST syntax in Pandoc.
|
||||
(MyST is a CommonMark flavour with rST features mixed in.)
|
||||
|
||||
Reference: https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#roles-an-in-line-extension-point
|
||||
]]
|
||||
|
||||
function Inlines(inlines)
|
||||
for i = #inlines-1,1,-1 do
|
||||
local first = inlines[i]
|
||||
local second = inlines[i+1]
|
||||
local correct_tags = first.tag == 'Str' and second.tag == 'Code'
|
||||
if correct_tags then
|
||||
-- docutils supports alphanumeric strings separated by [-._:]
|
||||
-- We are slightly more liberal for simplicity.
|
||||
local role = first.text:match('^{([-._+:%w]+)}$')
|
||||
if role ~= nil then
|
||||
inlines:remove(i)
|
||||
second.attributes['role'] = role
|
||||
second.classes:insert('interpreted-text')
|
||||
end
|
||||
end
|
||||
end
|
||||
return inlines
|
||||
end
|
||||
@@ -1,25 +0,0 @@
|
||||
--[[
|
||||
Replaces Code nodes with attrs that would be produced by rST reader
|
||||
from the role syntax by a Str AST node containing {role}, followed by a Code node.
|
||||
|
||||
This is to emulate MyST syntax in Pandoc.
|
||||
(MyST is a CommonMark flavour with rST features mixed in.)
|
||||
|
||||
Reference: https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#roles-an-in-line-extension-point
|
||||
]]
|
||||
|
||||
function Code(elem)
|
||||
local role = elem.attributes['role']
|
||||
|
||||
if elem.classes:includes('interpreted-text') and role ~= nil then
|
||||
elem.classes = elem.classes:filter(function (c)
|
||||
return c ~= 'interpreted-text'
|
||||
end)
|
||||
elem.attributes['role'] = nil
|
||||
|
||||
return {
|
||||
pandoc.Str('{' .. role .. '}'),
|
||||
elem,
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -1,16 +1,8 @@
|
||||
# Fetchers {#chap-pkgs-fetchers}
|
||||
|
||||
When using Nix, you will frequently need to download source code and other files from the internet. For this purpose, Nix provides the [_fixed output derivation_](https://nixos.org/manual/nix/stable/#fixed-output-drvs) feature and Nixpkgs provides various functions that implement the actual fetching from various protocols and services.
|
||||
When using Nix, you will frequently need to download source code and other files from the internet. Nixpkgs comes with a few helper functions that allow you to fetch fixed-output derivations in a structured way.
|
||||
|
||||
## Caveats
|
||||
|
||||
Because fixed output derivations are _identified_ by their hash, a common mistake is to update a fetcher's URL or a version parameter, without updating the hash. **This will cause the old contents to be used.** So remember to always invalidate the hash argument.
|
||||
|
||||
For those who develop and maintain fetchers, a similar problem arises with changes to the implementation of a fetcher. These may cause a fixed output derivation to fail, but won't normally be caught by tests because the supposed output is already in the store or cache. For the purpose of testing, you can use a trick that is embodied by the [`invalidateFetcherByDrvHash`](#sec-pkgs-invalidateFetcherByDrvHash) function. It uses the derivation `name` to create a unique output path per fetcher implementation, defeating the caching precisely where it would be harmful.
|
||||
|
||||
## `fetchurl` and `fetchzip` {#fetchurl}
|
||||
|
||||
Two basic fetchers are `fetchurl` and `fetchzip`. Both of these have two required arguments, a URL and a hash. The hash is typically `sha256`, although many more hash algorithms are supported. Nixpkgs contributors are currently recommended to use `sha256`. This hash will be used by Nix to identify your source. A typical usage of fetchurl is provided below.
|
||||
The two fetcher primitives are `fetchurl` and `fetchzip`. Both of these have two required arguments, a URL and a hash. The hash is typically `sha256`, although many more hash algorithms are supported. Nixpkgs contributors are currently recommended to use `sha256`. This hash will be used by Nix to identify your source. A typical usage of fetchurl is provided below.
|
||||
|
||||
```nix
|
||||
{ stdenv, fetchurl }:
|
||||
@@ -28,58 +20,59 @@ The main difference between `fetchurl` and `fetchzip` is in how they store the c
|
||||
|
||||
`fetchpatch` works very similarly to `fetchurl` with the same arguments expected. It expects patch files as a source and performs normalization on them before computing the checksum. For example it will remove comments or other unstable parts that are sometimes added by version control systems and can change over time.
|
||||
|
||||
Most other fetchers return a directory rather than a single file.
|
||||
|
||||
## `fetchsvn` {#fetchsvn}
|
||||
Other fetcher functions allow you to add source code directly from a VCS such as subversion or git. These are mostly straightforward nambes based on the name of the command used with the VCS system. Because they give you a working repository, they act most like `fetchzip`.
|
||||
|
||||
## `fetchsvn`
|
||||
|
||||
Used with Subversion. Expects `url` to a Subversion directory, `rev`, and `sha256`.
|
||||
|
||||
## `fetchgit` {#fetchgit}
|
||||
## `fetchgit`
|
||||
|
||||
Used with Git. Expects `url` to a Git repo, `rev`, and `sha256`. `rev` in this case can be full the git commit id (SHA1 hash) or a tag name like `refs/tags/v1.0`.
|
||||
|
||||
Additionally the following optional arguments can be given: `fetchSubmodules = true` makes `fetchgit` also fetch the submodules of a repository. If `deepClone` is set to true, the entire repository is cloned as opposing to just creating a shallow clone. `deepClone = true` also implies `leaveDotGit = true` which means that the `.git` directory of the clone won't be removed after checkout.
|
||||
|
||||
## `fetchfossil` {#fetchfossil}
|
||||
## `fetchfossil`
|
||||
|
||||
Used with Fossil. Expects `url` to a Fossil archive, `rev`, and `sha256`.
|
||||
|
||||
## `fetchcvs` {#fetchcvs}
|
||||
## `fetchcvs`
|
||||
|
||||
Used with CVS. Expects `cvsRoot`, `tag`, and `sha256`.
|
||||
|
||||
## `fetchhg` {#fetchhg}
|
||||
## `fetchhg`
|
||||
|
||||
Used with Mercurial. Expects `url`, `rev`, and `sha256`.
|
||||
|
||||
A number of fetcher functions wrap part of `fetchurl` and `fetchzip`. They are mainly convenience functions intended for commonly used destinations of source code in Nixpkgs. These wrapper fetchers are listed below.
|
||||
|
||||
## `fetchFromGitHub` {#fetchfromgithub}
|
||||
## `fetchFromGitHub`
|
||||
|
||||
`fetchFromGitHub` expects four arguments. `owner` is a string corresponding to the GitHub user or organization that controls this repository. `repo` corresponds to the name of the software repository. These are located at the top of every GitHub HTML page as `owner`/`repo`. `rev` corresponds to the Git commit hash or tag (e.g `v1.0`) that will be downloaded from Git. Finally, `sha256` corresponds to the hash of the extracted directory. Again, other hash algorithms are also available but `sha256` is currently preferred.
|
||||
|
||||
`fetchFromGitHub` uses `fetchzip` to download the source archive generated by GitHub for the specified revision. If `leaveDotGit`, `deepClone` or `fetchSubmodules` are set to `true`, `fetchFromGitHub` will use `fetchgit` instead. Refer to its section for documentation of these options.
|
||||
|
||||
## `fetchFromGitLab` {#fetchfromgitlab}
|
||||
## `fetchFromGitLab`
|
||||
|
||||
This is used with GitLab repositories. The arguments expected are very similar to fetchFromGitHub above.
|
||||
|
||||
## `fetchFromGitiles` {#fetchfromgitiles}
|
||||
## `fetchFromGitiles`
|
||||
|
||||
This is used with Gitiles repositories. The arguments expected are similar to fetchgit.
|
||||
|
||||
## `fetchFromBitbucket` {#fetchfrombitbucket}
|
||||
## `fetchFromBitbucket`
|
||||
|
||||
This is used with BitBucket repositories. The arguments expected are very similar to fetchFromGitHub above.
|
||||
|
||||
## `fetchFromSavannah` {#fetchfromsavannah}
|
||||
## `fetchFromSavannah`
|
||||
|
||||
This is used with Savannah repositories. The arguments expected are very similar to fetchFromGitHub above.
|
||||
|
||||
## `fetchFromRepoOrCz` {#fetchfromrepoorcz}
|
||||
## `fetchFromRepoOrCz`
|
||||
|
||||
This is used with repo.or.cz repositories. The arguments expected are very similar to fetchFromGitHub above.
|
||||
|
||||
## `fetchFromSourcehut` {#fetchfromsourcehut}
|
||||
## `fetchFromSourcehut`
|
||||
|
||||
This is used with sourcehut repositories. The arguments expected are very similar to fetchFromGitHub above. Don't forget the tilde (~) in front of the user name!
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`pkgs.appimageTools` is a set of functions for extracting and wrapping [AppImage](https://appimage.org/) files. They are meant to be used if traditional packaging from source is infeasible, or it would take too long. To quickly run an AppImage file, `pkgs.appimage-run` can be used as well.
|
||||
|
||||
::: {.warning}
|
||||
::: warning
|
||||
The `appimageTools` API is unstable and may be subject to backwards-incompatible changes in the future.
|
||||
:::
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# pkgs.dockerTools {#sec-pkgs-dockerTools}
|
||||
|
||||
`pkgs.dockerTools` is a set of functions for creating and manipulating Docker images according to the [Docker Image Specification v1.2.0](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120). Docker itself is not used to perform any of the operations done by these functions.
|
||||
`pkgs.dockerTools` is a set of functions for creating and manipulating Docker images according to the [ Docker Image Specification v1.2.0 ](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120). Docker itself is not used to perform any of the operations done by these functions.
|
||||
|
||||
## buildImage {#ssec-pkgs-dockerTools-buildImage}
|
||||
|
||||
@@ -52,7 +52,7 @@ The above example will build a Docker image `redis/latest` from the given base i
|
||||
|
||||
> **_NOTE:_** Using this parameter requires the `kvm` device to be available.
|
||||
|
||||
- `config` is used to specify the configuration of the containers that will be started off the built image in Docker. The available options are listed in the [Docker Image Specification v1.2.0](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions).
|
||||
- `config` is used to specify the configuration of the containers that will be started off the built image in Docker. The available options are listed in the [ Docker Image Specification v1.2.0 ](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions).
|
||||
|
||||
After the new layer has been created, its closure (to which `contents`, `config` and `runAsRoot` contribute) will be copied in the layer itself. Only new dependencies that are not already in the existing layers will be copied.
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Currently, `makeSnap` does not support creating GUI stubs.
|
||||
|
||||
The following expression packages GNU Hello as a Snapcraft snap.
|
||||
|
||||
``` {#ex-snapTools-buildSnap-hello .nix}
|
||||
```{#ex-snapTools-buildSnap-hello .nix}
|
||||
let
|
||||
inherit (import <nixpkgs> { }) snapTools hello;
|
||||
in snapTools.makeSnap {
|
||||
@@ -35,7 +35,7 @@ in snapTools.makeSnap {
|
||||
|
||||
Graphical programs require many more integrations with the host. This example uses Firefox as an example, because it is one of the most complicated programs we could package.
|
||||
|
||||
``` {#ex-snapTools-buildSnap-firefox .nix}
|
||||
```{#ex-snapTools-buildSnap-firefox .nix}
|
||||
let
|
||||
inherit (import <nixpkgs> { }) snapTools firefox;
|
||||
in snapTools.makeSnap {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Cataclysm: Dark Days Ahead {#cataclysm-dark-days-ahead}
|
||||
|
||||
## How to install Cataclysm DDA {#how-to-install-cataclysm-dda}
|
||||
## How to install Cataclysm DDA
|
||||
|
||||
To install the latest stable release of Cataclysm DDA to your profile, execute
|
||||
`nix-env -f "<nixpkgs>" -iA cataclysm-dda`. For the curses build (build
|
||||
@@ -34,7 +34,7 @@ cataclysm-dda.override {
|
||||
}
|
||||
```
|
||||
|
||||
## Important note for overriding packages {#important-note-for-overriding-packages}
|
||||
## Important note for overriding packages
|
||||
|
||||
After applying `overrideAttrs`, you need to fix `passthru.pkgs` and
|
||||
`passthru.withMods` attributes either manually or by using `attachPkgs`:
|
||||
@@ -69,7 +69,7 @@ in
|
||||
goodExample2.withMods (_: []) # parallel building enabled
|
||||
```
|
||||
|
||||
## Customizing with mods {#customizing-with-mods}
|
||||
## Customizing with mods
|
||||
|
||||
To install Cataclysm DDA with mods of your choice, you can use `withMods`
|
||||
attribute:
|
||||
|
||||
@@ -6,6 +6,6 @@ To start a development environment do
|
||||
nix-shell -p elmPackages.elm elmPackages.elm-format
|
||||
```
|
||||
|
||||
To update the Elm compiler, see `nixpkgs/pkgs/development/compilers/elm/README.md`.
|
||||
To update the Elm compiler, see <filename>nixpkgs/pkgs/development/compilers/elm/README.md</filename>.
|
||||
|
||||
To package Elm applications, [read about elm2nix](https://github.com/hercules-ci/elm2nix#elm2nix).
|
||||
|
||||
@@ -110,7 +110,7 @@ overrides = self: super: rec {
|
||||
haskell-mode = self.melpaPackages.haskell-mode;
|
||||
...
|
||||
};
|
||||
((emacsPackagesFor emacs).overrideScope' overrides).withPackages
|
||||
((emacsPackagesFor emacs).overrideScope' overrides).emacs.pkgs.withPackages
|
||||
(p: with p; [
|
||||
# here both these package will use haskell-mode of our own choice
|
||||
ghc-mod
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# /etc files {#etc}
|
||||
|
||||
Certain calls in glibc require access to runtime files found in /etc such as `/etc/protocols` or `/etc/services` -- [getprotobyname](https://linux.die.net/man/3/getprotobyname) is one such function.
|
||||
|
||||
On non-NixOS distributions these files are typically provided by packages (i.e. [netbase](https://packages.debian.org/sid/netbase)) if not already pre-installed in your distribution. This can cause non-reproducibility for code if they rely on these files being present.
|
||||
|
||||
If [iana-etc](https://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.iana-etc.x86_64-linux) is part of your _buildInputs_ then it will set the environment varaibles `NIX_ETC_PROTOCOLS` and `NIX_ETC_SERVICES` to the corresponding files in the package through a _setup-hook_.
|
||||
|
||||
|
||||
```bash
|
||||
> nix-shell -p iana-etc
|
||||
|
||||
[nix-shell:~]$ env | grep NIX_ETC
|
||||
NIX_ETC_SERVICES=/nix/store/aj866hr8fad8flnggwdhrldm0g799ccz-iana-etc-20210225/etc/services
|
||||
NIX_ETC_PROTOCOLS=/nix/store/aj866hr8fad8flnggwdhrldm0g799ccz-iana-etc-20210225/etc/protocols
|
||||
```
|
||||
|
||||
Nixpkg's version of [glibc](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/glibc/default.nix) has been patched to check for the existence of these environment variables. If the environment variable are *not set*, then it will attempt to find the files at the default location within _/etc_.
|
||||
@@ -1,13 +1,12 @@
|
||||
# Firefox {#sec-firefox}
|
||||
|
||||
## Build wrapped Firefox with extensions and policies {#build-wrapped-firefox-with-extensions-and-policies}
|
||||
## Build wrapped Firefox with extensions and policies
|
||||
|
||||
The `wrapFirefox` function allows to pass policies, preferences and extension that are available to Firefox. With the help of `fetchFirefoxAddon` this allows build a Firefox version that already comes with addons pre-installed:
|
||||
The `wrapFirefox` function allows to pass policies, preferences and extension that are available to firefox. With the help of `fetchFirefoxAddon` this allows build a firefox version that already comes with addons pre-installed:
|
||||
|
||||
```nix
|
||||
{
|
||||
# Nix firefox addons only work with the firefox-esr package.
|
||||
myFirefox = wrapFirefox firefox-esr-unwrapped {
|
||||
myFirefox = wrapFirefox firefox-unwrapped {
|
||||
nixExtensions = [
|
||||
(fetchFirefoxAddon {
|
||||
name = "ublock"; # Has to be unique!
|
||||
@@ -46,7 +45,5 @@ or type into the Firefox url bar: `about:policies#documentation`.
|
||||
Nix installed addons do not have a valid signature, which is why signature verification is disabled. This does not compromise security because downloaded addons are checksumed and manual addons can't be installed. Also make sure that the `name` field of fetchFirefoxAddon is unique. If you remove an addon from the nixExtensions array, rebuild and start Firefox the removed addon will be completly removed with all of its settings.
|
||||
|
||||
## Troubleshooting {#sec-firefox-troubleshooting}
|
||||
If addons are marked as broken or the signature is invalid, make sure you have Firefox ESR installed. Normal Firefox does not provide the ability anymore to disable signature verification for addons thus nix addons get disabled by the normal Firefox binary.
|
||||
|
||||
If addons do not appear installed although they have been defined in your nix configuration file reset the local addon state of your Firefox profile by clicking `help -> restart with addons disabled -> restart -> refresh firefox`. This can happen if you switch from manual addon mode to nix addon mode and then back to manual mode and then again to nix addon mode.
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
<xi:include href="kakoune.section.xml" />
|
||||
<xi:include href="linux.section.xml" />
|
||||
<xi:include href="locales.section.xml" />
|
||||
<xi:include href="etc-files.section.xml" />
|
||||
<xi:include href="nginx.section.xml" />
|
||||
<xi:include href="opengl.section.xml" />
|
||||
<xi:include href="shell-helpers.section.xml" />
|
||||
|
||||
@@ -16,7 +16,7 @@ How to add a new (major) version of the Linux kernel to Nixpkgs:
|
||||
|
||||
1. Copy the old Nix expression (e.g. `linux-2.6.21.nix`) to the new one (e.g. `linux-2.6.22.nix`) and update it.
|
||||
|
||||
2. Add the new kernel to the `kernels` attribute set in `linux-kernels.nix` (e.g., create an attribute `kernel_2_6_22`).
|
||||
2. Add the new kernel to `all-packages.nix` (e.g., create an attribute `kernel_2_6_22`).
|
||||
|
||||
3. Now we’re going to update the kernel configuration. First unpack the kernel. Then for each supported platform (`i686`, `x86_64`, `uml`) do the following:
|
||||
|
||||
@@ -36,6 +36,6 @@ How to add a new (major) version of the Linux kernel to Nixpkgs:
|
||||
|
||||
5. Copy `.config` over the new config file (e.g. `config-2.6.22-i686-smp`).
|
||||
|
||||
4. Test building the kernel: `nix-build -A linuxKernel.kernels.kernel_2_6_22`. If it compiles, ship it! For extra credit, try booting NixOS with it.
|
||||
4. Test building the kernel: `nix-build -A kernel_2_6_22`. If it compiles, ship it! For extra credit, try booting NixOS with it.
|
||||
|
||||
5. It may be that the new kernel requires updating the external kernel modules and kernel-dependent packages listed in the `linuxPackagesFor` function in `linux-kernels.nix` (such as the NVIDIA drivers, AUFS, etc.). If the updated packages aren’t backwards compatible with older kernels, you may need to keep the older versions around.
|
||||
5. It may be that the new kernel requires updating the external kernel modules and kernel-dependent packages listed in the `linuxPackagesFor` function in `all-packages.nix` (such as the NVIDIA drivers, AUFS, etc.). If the updated packages aren’t backwards compatible with older kernels, you may need to keep the older versions around.
|
||||
|
||||
@@ -4,11 +4,11 @@ OpenGL support varies depending on which hardware is used and which drivers are
|
||||
|
||||
Broadly, we support both GL vendors: Mesa and NVIDIA.
|
||||
|
||||
## NixOS Desktop {#nixos-desktop}
|
||||
## NixOS Desktop
|
||||
|
||||
The NixOS desktop or other non-headless configurations are the primary target for OpenGL libraries and applications. The current solution for discovering which drivers are available is based on [libglvnd](https://gitlab.freedesktop.org/glvnd/libglvnd). `libglvnd` performs "vendor-neutral dispatch", trying a variety of techniques to find the system's GL implementation. In practice, this will be either via standard GLX for X11 users or EGL for Wayland users, and supporting either NVIDIA or Mesa extensions.
|
||||
|
||||
## Nix on GNU/Linux {#nix-on-gnulinux}
|
||||
## Nix on GNU/Linux
|
||||
|
||||
If you are using a non-NixOS GNU/Linux/X11 desktop with free software video drivers, consider launching OpenGL-dependent programs from Nixpkgs with Nixpkgs versions of `libglvnd` and `mesa.drivers` in `LD_LIBRARY_PATH`. For Mesa drivers, the Linux kernel version doesn't have to match nixpkgs.
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ Use `programs.steam.enable = true;` if you want to add steam to systemPackages a
|
||||
## Troubleshooting {#sec-steam-troub}
|
||||
|
||||
- **Steam fails to start. What do I do?**
|
||||
|
||||
Try to run
|
||||
|
||||
```ShellSession
|
||||
@@ -33,30 +32,37 @@ Use `programs.steam.enable = true;` if you want to add steam to systemPackages a
|
||||
|
||||
- The `newStdcpp` parameter was removed since NixOS 17.09 and should not be needed anymore.
|
||||
- Steam ships statically linked with a version of libcrypto that conflics with the one dynamically loaded by radeonsi_dri.so. If you get the error
|
||||
|
||||
```
|
||||
steam.sh: line 713: 7842 Segmentation fault (core dumped)
|
||||
```
|
||||
|
||||
have a look at [this pull request](https://github.com/NixOS/nixpkgs/pull/20269).
|
||||
|
||||
- **Java**
|
||||
|
||||
1. There is no java in steam chrootenv by default. If you get a message like
|
||||
|
||||
```
|
||||
/home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found
|
||||
```
|
||||
```
|
||||
/home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found
|
||||
```
|
||||
|
||||
you need to add
|
||||
You need to add
|
||||
|
||||
```nix
|
||||
steam.override { withJava = true; };
|
||||
```
|
||||
```nix
|
||||
steam.override { withJava = true; };
|
||||
```
|
||||
|
||||
## steam-run {#sec-steam-run}
|
||||
|
||||
The FHS-compatible chroot used for Steam can also be used to run other Linux games that expect a FHS environment. To use it, install the `steam-run-native` package and run the game with
|
||||
The FHS-compatible chroot used for steam can also be used to run other linux games that expect a FHS environment. To do it, add
|
||||
|
||||
```nix
|
||||
pkgs.steam.override ({
|
||||
nativeOnly = true;
|
||||
newStdcpp = true;
|
||||
}).run
|
||||
```
|
||||
|
||||
to your configuration, rebuild, and run the game with
|
||||
|
||||
```
|
||||
steam-run ./foo
|
||||
|
||||
@@ -41,7 +41,7 @@ weechat.override {
|
||||
configure = { availablePlugins, ... }: {
|
||||
init = ''
|
||||
/set foo bar
|
||||
/server add libera irc.libera.chat
|
||||
/server add freenode chat.freenode.org
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
The Nix expressions for the X.org packages reside in `pkgs/servers/x11/xorg/default.nix`. This file is automatically generated from lists of tarballs in an X.org release. As such it should not be modified directly; rather, you should modify the lists, the generator script or the file `pkgs/servers/x11/xorg/overrides.nix`, in which you can override or add to the derivations produced by the generator.
|
||||
|
||||
## Katamari Tarballs {#katamari-tarballs}
|
||||
## Katamari Tarballs
|
||||
|
||||
X.org upstream releases used to include [katamari](https://en.wiktionary.org/wiki/%E3%81%8B%E3%81%9F%E3%81%BE%E3%82%8A) releases, which included a holistic recommended version for each tarball, up until 7.7. To create a list of tarballs in a katamari release:
|
||||
|
||||
@@ -14,11 +14,11 @@ cat $(PRINT_PATH=1 nix-prefetch-url $url | tail -n 1) \
|
||||
| sort > "tarballs-$release.list"
|
||||
```
|
||||
|
||||
## Individual Tarballs {#individual-tarballs}
|
||||
## Individual Tarballs
|
||||
|
||||
The upstream release process for [X11R7.8](https://x.org/wiki/Releases/7.8/) does not include a planned katamari. Instead, each component of X.org is released as its own tarball. We maintain `pkgs/servers/x11/xorg/tarballs.list` as a list of tarballs for each individual package. This list includes X.org core libraries and protocol descriptions, extra newer X11 interface libraries, like `xorg.libxcb`, and classic utilities which are largely unused but still available if needed, like `xorg.imake`.
|
||||
|
||||
## Generating Nix Expressions {#generating-nix-expressions}
|
||||
## Generating Nix Expressions
|
||||
|
||||
The generator is invoked as follows:
|
||||
|
||||
@@ -29,6 +29,6 @@ cd pkgs/servers/x11/xorg
|
||||
|
||||
For each of the tarballs in the `.list` files, the script downloads it, unpacks it, and searches its `configure.ac` and `*.pc.in` files for dependencies. This information is used to generate `default.nix`. The generator caches downloaded tarballs between runs. Pay close attention to the `NOT FOUND: $NAME` messages at the end of the run, since they may indicate missing dependencies. (Some might be optional dependencies, however.)
|
||||
|
||||
## Overriding the Generator {#overriding-the-generator}
|
||||
## Overriding the Generator
|
||||
|
||||
If the expression for a package requires derivation attributes that the generator cannot figure out automatically (say, `patches` or a `postInstall` hook), you should modify `pkgs/servers/x11/xorg/overrides.nix`.
|
||||
|
||||
@@ -7,5 +7,4 @@
|
||||
</para>
|
||||
<xi:include href="special/fhs-environments.section.xml" />
|
||||
<xi:include href="special/mkshell.section.xml" />
|
||||
<xi:include href="special/invalidateFetcherByDrvHash.section.xml" />
|
||||
</chapter>
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
Additional commands to be executed for finalizing the derivation with runner script.
|
||||
- `runScript`
|
||||
A command that would be executed inside the sandbox and passed all the command line arguments. It defaults to `bash`.
|
||||
- `profile`
|
||||
Optional script for `/etc/profile` within the sandbox.
|
||||
|
||||
One can create a simple environment using a `shell.nix` like that:
|
||||
|
||||
@@ -30,7 +28,7 @@ One can create a simple environment using a `shell.nix` like that:
|
||||
name = "simple-x11-env";
|
||||
targetPkgs = pkgs: (with pkgs;
|
||||
[ udev
|
||||
alsa-lib
|
||||
alsaLib
|
||||
]) ++ (with pkgs.xorg;
|
||||
[ libX11
|
||||
libXcursor
|
||||
@@ -38,7 +36,7 @@ One can create a simple environment using a `shell.nix` like that:
|
||||
]);
|
||||
multiPkgs = pkgs: (with pkgs;
|
||||
[ udev
|
||||
alsa-lib
|
||||
alsaLib
|
||||
]);
|
||||
runScript = "bash";
|
||||
}).env
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
|
||||
## `invalidateFetcherByDrvHash` {#sec-pkgs-invalidateFetcherByDrvHash}
|
||||
|
||||
Use the derivation hash to invalidate the output via name, for testing.
|
||||
|
||||
Type: `(a@{ name, ... } -> Derivation) -> a -> Derivation`
|
||||
|
||||
Normally, fixed output derivations can and should be cached by their output
|
||||
hash only, but for testing we want to re-fetch everytime the fetcher changes.
|
||||
|
||||
Changes to the fetcher become apparent in the drvPath, which is a hash of
|
||||
how to fetch, rather than a fixed store path.
|
||||
By inserting this hash into the name, we can make sure to re-run the fetcher
|
||||
every time the fetcher changes.
|
||||
|
||||
This relies on the assumption that Nix isn't clever enough to reuse its
|
||||
database of local store contents to optimize fetching.
|
||||
|
||||
You might notice that the "salted" name derives from the normal invocation,
|
||||
not the final derivation. `invalidateFetcherByDrvHash` has to invoke the fetcher
|
||||
function twice: once to get a derivation hash, and again to produce the final
|
||||
fixed output derivation.
|
||||
|
||||
Example:
|
||||
|
||||
tests.fetchgit = invalidateFetcherByDrvHash fetchgit {
|
||||
name = "nix-source";
|
||||
url = "https://github.com/NixOS/nix";
|
||||
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
|
||||
sha256 = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY=";
|
||||
};
|
||||
@@ -37,7 +37,7 @@ This works just like `runCommand`. The only difference is that it also provides
|
||||
|
||||
Variant of `runCommand` that forces the derivation to be built locally, it is not substituted. This is intended for very cheap commands (<1s execution time). It saves on the network roundrip and can speed up a build.
|
||||
|
||||
::: {.note}
|
||||
::: note
|
||||
This sets [`allowSubstitutes` to `false`](https://nixos.org/nix/manual/#adv-attr-allowSubstitutes), so only use `runCommandLocal` if you are certain the user will always have a builder for the `system` of the derivation. This should be true for most trivial use cases (e.g. just copying some files to a different location or adding symlinks), because there the `system` is usually the same as `builtins.currentSystem`.
|
||||
:::
|
||||
|
||||
@@ -47,28 +47,6 @@ These functions write `text` to the Nix store. This is useful for creating scrip
|
||||
|
||||
Many more commands wrap `writeTextFile` including `writeText`, `writeTextDir`, `writeScript`, and `writeScriptBin`. These are convenience functions over `writeTextFile`.
|
||||
|
||||
## `writeShellApplication` {#trivial-builder-writeShellApplication}
|
||||
|
||||
This can be used to easily produce a shell script that has some dependencies (`runtimeInputs`). It automatically sets the `PATH` of the script to contain all of the listed inputs, sets some sanity shellopts (`errexit`, `nounset`, `pipefail`), and checks the resulting script with [`shellcheck`](https://github.com/koalaman/shellcheck).
|
||||
|
||||
For example, look at the following code:
|
||||
|
||||
```nix
|
||||
writeShellApplication {
|
||||
name = "show-nixos-org";
|
||||
|
||||
runtimeInputs = [ curl w3m ];
|
||||
|
||||
text = ''
|
||||
curl -s 'https://nixos.org' | w3m -dump -T text/html
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
Unlike with normal `writeShellScriptBin`, there is no need to manually write out `${curl}/bin/curl`, setting the PATH
|
||||
was handled by `writeShellApplication`. Moreover, the script is being checked with `shellcheck` for more strict
|
||||
validation.
|
||||
|
||||
## `symlinkJoin` {#trivial-builder-symlinkJoin}
|
||||
|
||||
This can be used to put many derivations into the same directory structure. It works by creating a new derivation and adding symlinks to each of the paths listed. It expects two arguments, `name`, and `paths`. `name` is the name used in the Nix store path for the created derivation. `paths` is a list of paths that will be symlinked. These paths can be to Nix store derivations or any other subdirectory contained within.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
- Do not use tab characters, i.e. configure your editor to use soft tabs. For instance, use `(setq-default indent-tabs-mode nil)` in Emacs. Everybody has different tab settings so it’s asking for trouble.
|
||||
|
||||
- Use `lowerCamelCase` for variable names, not `UpperCamelCase`. Note, this rule does not apply to package attribute names, which instead follow the rules in [](#sec-package-naming).
|
||||
- Use `lowerCamelCase` for variable names, not `UpperCamelCase`. Note, this rule does not apply to package attribute names, which instead follow the rules in <xref linkend="sec-package-naming"/>.
|
||||
|
||||
- Function calls with attribute set arguments are written as
|
||||
|
||||
@@ -181,23 +181,11 @@
|
||||
rev = "${version}";
|
||||
```
|
||||
|
||||
- Building lists conditionally _should_ be done with `lib.optional(s)` instead of using `if cond then [ ... ] else null` or `if cond then [ ... ] else [ ]`.
|
||||
|
||||
```nix
|
||||
buildInputs = lib.optional stdenv.isDarwin iconv;
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```nix
|
||||
buildInputs = if stdenv.isDarwin then [ iconv ] else null;
|
||||
```
|
||||
|
||||
As an exception, an explicit conditional expression with null can be used when fixing a important bug without triggering a mass rebuild.
|
||||
If this is done a follow up pull request _should_ be created to change the code to `lib.optional(s)`.
|
||||
|
||||
- Arguments should be listed in the order they are used, with the exception of `lib`, which always goes first.
|
||||
|
||||
- The top-level `lib` must be used in the master and 21.05 branch over its alias `stdenv.lib` as it now causes evaluation errors when aliases are disabled which is the case for ofborg.
|
||||
`lib` is unrelated to `stdenv`, and so `stdenv.lib` should only be used as a convenience alias when developing locally to avoid having to modify the function inputs just to test something out.
|
||||
|
||||
## Package naming {#sec-package-naming}
|
||||
|
||||
The key words _must_, _must not_, _required_, _shall_, _shall not_, _should_, _should not_, _recommended_, _may_, and _optional_ in this section are to be interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119). Only _emphasized_ words are to be interpreted in this way.
|
||||
@@ -224,7 +212,7 @@ There are a few naming guidelines:
|
||||
|
||||
- Dashes in the package name _should_ be preserved in new variable names, rather than converted to underscores or camel cased — e.g., `http-parser` instead of `http_parser` or `httpParser`. The hyphenated style is preferred in all three package names.
|
||||
|
||||
- If there are multiple versions of a package, this _should_ be reflected in the variable names in `all-packages.nix`, e.g. `json-c-0-9` and `json-c-0-11`. If there is an obvious “default” version, make an attribute like `json-c = json-c-0-9;`. See also [](#sec-versioning)
|
||||
- If there are multiple versions of a package, this _should_ be reflected in the variable names in `all-packages.nix`, e.g. `json-c-0-9` and `json-c-0-11`. If there is an obvious “default” version, make an attribute like `json-c = json-c-0-9;`. See also <xref linkend="sec-versioning" />
|
||||
|
||||
## File naming and organisation {#sec-organisation}
|
||||
|
||||
@@ -477,9 +465,9 @@ Preferred source hash type is sha256. There are several ways to get it.
|
||||
|
||||
For package updates it is enough to change one symbol to make hash fake. For new packages, you can use `lib.fakeSha256`, `lib.fakeSha512` or any other fake hash.
|
||||
|
||||
This is last resort method when reconstructing source URL is non-trivial and `nix-prefetch-url -A` isn’t applicable (for example, [one of `kodi` dependencies](https://github.com/NixOS/nixpkgs/blob/d2ab091dd308b99e4912b805a5eb088dd536adb9/pkgs/applications/video/kodi/default.nix#L73)). The easiest way then would be replace hash with a fake one and rebuild. Nix build will fail and error message will contain desired hash.
|
||||
This is last resort method when reconstructing source URL is non-trivial and `nix-prefetch-url -A` isn't applicable (for example, [one of `kodi` dependencies](https://github.com/NixOS/nixpkgs/blob/d2ab091dd308b99e4912b805a5eb088dd536adb9/pkgs/applications/video/kodi/default.nix#L73")). The easiest way then would be replace hash with a fake one and rebuild. Nix build will fail and error message will contain desired hash.
|
||||
|
||||
::: {.warning}
|
||||
::: warning
|
||||
This method has security problems. Check below for details.
|
||||
:::
|
||||
|
||||
@@ -535,7 +523,7 @@ If you do need to do create this sort of patch file, one way to do so is with gi
|
||||
4. Use git to create a diff, and pipe the output to a patch file:
|
||||
|
||||
```ShellSession
|
||||
$ git diff -a > nixpkgs/pkgs/the/package/0001-changes.patch
|
||||
$ git diff > nixpkgs/pkgs/the/package/0001-changes.patch
|
||||
```
|
||||
|
||||
If a patch is available online but does not cleanly apply, it can be modified in some fixed ways by using additional optional arguments for `fetchpatch`:
|
||||
@@ -552,34 +540,9 @@ Note that because the checksum is computed after applying these effects, using o
|
||||
|
||||
Tests are important to ensure quality and make reviews and automatic updates easy.
|
||||
|
||||
The following types of tests exists:
|
||||
Nix package tests are a lightweight alternative to [NixOS module tests](https://nixos.org/manual/nixos/stable/#sec-nixos-tests). They can be used to create simple integration tests for packages while the module tests are used to test services or programs with a graphical user interface on a NixOS VM. Unittests that are included in the source code of a package should be executed in the `checkPhase`.
|
||||
|
||||
* [NixOS **module tests**](https://nixos.org/manual/nixos/stable/#sec-nixos-tests), which spawn one or more NixOS VMs. They exercise both NixOS modules and the packaged programs used within them. For example, a NixOS module test can start a web server VM running the `nginx` module, and a client VM running `curl` or a graphical `firefox`, and test that they can talk to each other and display the correct content.
|
||||
* Nix **package tests** are a lightweight alternative to NixOS module tests. They should be used to create simple integration tests for packages, but cannot test NixOS services, and some programs with graphical user interfaces may also be difficult to test with them.
|
||||
* The **`checkPhase` of a package**, which should execute the unit tests that are included in the source code of a package.
|
||||
|
||||
Here in the nixpkgs manual we describe mostly _package tests_; for _module tests_ head over to the corresponding [section in the NixOS manual](https://nixos.org/manual/nixos/stable/#sec-nixos-tests).
|
||||
|
||||
### Writing inline package tests {#ssec-inline-package-tests-writing}
|
||||
|
||||
For very simple tests, they can be written inline:
|
||||
|
||||
```nix
|
||||
{ …, yq-go }:
|
||||
|
||||
buildGoModule rec {
|
||||
…
|
||||
|
||||
passthru.tests = {
|
||||
simple = runCommand "${pname}-test" {} ''
|
||||
echo "test: 1" | ${yq-go}/bin/yq eval -j > $out
|
||||
[ "$(cat $out | tr -d $'\n ')" = '{"test":1}' ]
|
||||
'';
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Writing larger package tests {#ssec-package-tests-writing}
|
||||
### Writing package tests {#ssec-package-tests-writing}
|
||||
|
||||
This is an example using the `phoronix-test-suite` package with the current best practices.
|
||||
|
||||
@@ -608,7 +571,7 @@ let
|
||||
inherit (phoronix-test-suite) pname version;
|
||||
in
|
||||
|
||||
runCommand "${pname}-tests" { meta.timeout = 60; }
|
||||
runCommand "${pname}-tests" { meta.timeout = 3; }
|
||||
''
|
||||
# automatic initial setup to prevent interactive questions
|
||||
${phoronix-test-suite}/bin/phoronix-test-suite enterprise-setup >/dev/null
|
||||
@@ -642,23 +605,3 @@ Here are examples of package tests:
|
||||
- [Spacy annotation test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/spacy/annotation-test/default.nix)
|
||||
- [Libtorch test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/science/math/libtorch/test/default.nix)
|
||||
- [Multiple tests for nanopb](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/nanopb/default.nix)
|
||||
|
||||
### Linking NixOS module tests to a package {#ssec-nixos-tests-linking}
|
||||
|
||||
Like [package tests](#ssec-package-tests-writing) as shown above, [NixOS module tests](https://nixos.org/manual/nixos/stable/#sec-nixos-tests) can also be linked to a package, so that the tests can be easily run when changing the related package.
|
||||
|
||||
For example, assuming we're packaging `nginx`, we can link its module test via `passthru.tests`:
|
||||
|
||||
```nix
|
||||
{ stdenv, lib, nixosTests }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
...
|
||||
|
||||
passthru.tests = {
|
||||
nginx = nixosTests.nginx;
|
||||
};
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Contributing to this documentation {#chap-contributing}
|
||||
|
||||
The sources of the Nixpkgs manual are in the [doc](https://github.com/NixOS/nixpkgs/tree/master/doc) subdirectory of the Nixpkgs repository. The manual is still partially written in DocBook but it is progressively being converted to [Markdown](#sec-contributing-markup).
|
||||
The DocBook sources of the Nixpkgs manual are in the [doc](https://github.com/NixOS/nixpkgs/tree/master/doc) subdirectory of the Nixpkgs repository.
|
||||
|
||||
You can quickly check your edits with `make`:
|
||||
|
||||
```ShellSession
|
||||
$ cd /path/to/nixpkgs/doc
|
||||
$ nix-shell
|
||||
[nix-shell]$ make
|
||||
[nix-shell]$ make $makeFlags
|
||||
```
|
||||
|
||||
If you experience problems, run `make debug` to help understand the docbook errors.
|
||||
@@ -22,85 +22,3 @@ $ nix-shell
|
||||
```
|
||||
|
||||
If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`.
|
||||
|
||||
## Syntax {#sec-contributing-markup}
|
||||
|
||||
As per [RFC 0072](https://github.com/NixOS/rfcs/pull/72), all new documentation content should be written in [CommonMark](https://commonmark.org/) Markdown dialect.
|
||||
|
||||
Additionally, the following syntax extensions are currently used:
|
||||
|
||||
- []{#ssec-contributing-markup-anchors}
|
||||
Explicitly defined **anchors** on headings, to allow linking to sections. These should be always used, to ensure the anchors can be linked even when the heading text changes, and to prevent conflicts between [automatically assigned identifiers](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/auto_identifiers.md).
|
||||
|
||||
It uses the widely compatible [header attributes](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md) syntax:
|
||||
|
||||
```markdown
|
||||
## Syntax {#sec-contributing-markup}
|
||||
```
|
||||
|
||||
- []{#ssec-contributing-markup-anchors-inline}
|
||||
**Inline anchors**, which allow linking arbitrary place in the text (e.g. individual list items, sentences…).
|
||||
|
||||
They are defined using a hybrid of the link syntax with the attributes syntax known from headings, called [bracketed spans](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/bracketed_spans.md):
|
||||
|
||||
```markdown
|
||||
- []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`.
|
||||
```
|
||||
|
||||
- []{#ssec-contributing-markup-automatic-links}
|
||||
If you **omit a link text** for a link pointing to a section, the text will be substituted automatically. For example, `[](#chap-contributing)` will result in [](#chap-contributing).
|
||||
|
||||
This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing).
|
||||
|
||||
- []{#ssec-contributing-markup-inline-roles}
|
||||
If you want to link to a man page, you can use `` {manpage}`nix.conf(5)` ``, which will turn into {manpage}`nix.conf(5)`.
|
||||
|
||||
The references will turn into links when a mapping exists in {file}`doc/build-aux/pandoc-filters/unix-man-urls.lua`.
|
||||
|
||||
This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/syntax/syntax.html#roles-an-in-line-extension-point). Though, the feature originates from [reStructuredText](https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-manpage) with slightly different syntax.
|
||||
|
||||
- []{#ssec-contributing-markup-admonitions}
|
||||
**Admonitions**, set off from the text to bring attention to something.
|
||||
|
||||
It uses pandoc’s [fenced `div`s syntax](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md):
|
||||
|
||||
```markdown
|
||||
::: {.warning}
|
||||
This is a warning
|
||||
:::
|
||||
```
|
||||
|
||||
which renders as
|
||||
|
||||
> ::: {.warning}
|
||||
> This is a warning.
|
||||
> :::
|
||||
|
||||
The following are supported:
|
||||
|
||||
- [`caution`](https://tdg.docbook.org/tdg/5.0/caution.html)
|
||||
- [`important`](https://tdg.docbook.org/tdg/5.0/important.html)
|
||||
- [`note`](https://tdg.docbook.org/tdg/5.0/note.html)
|
||||
- [`tip`](https://tdg.docbook.org/tdg/5.0/tip.html)
|
||||
- [`warning`](https://tdg.docbook.org/tdg/5.0/warning.html)
|
||||
|
||||
- []{#ssec-contributing-markup-definition-lists}
|
||||
[**Definition lists**](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/definition_lists.md), for defining a group of terms:
|
||||
|
||||
```markdown
|
||||
pear
|
||||
: green or yellow bulbous fruit
|
||||
|
||||
watermelon
|
||||
: green fruit with red flesh
|
||||
```
|
||||
|
||||
which renders as
|
||||
|
||||
> pear
|
||||
> : green or yellow bulbous fruit
|
||||
>
|
||||
> watermelon
|
||||
> : green fruit with red flesh
|
||||
|
||||
For contributing to the legacy parts, please see [DocBook: The Definitive Guide](https://tdg.docbook.org/) or the [DocBook rocks! primer](https://web.archive.org/web/20200816233747/https://docbook.rocks/).
|
||||
|
||||
@@ -9,7 +9,7 @@ To add a package to Nixpkgs:
|
||||
$ cd nixpkgs
|
||||
```
|
||||
|
||||
2. Find a good place in the Nixpkgs tree to add the Nix expression for your package. For instance, a library package typically goes into `pkgs/development/libraries/pkgname`, while a web browser goes into `pkgs/applications/networking/browsers/pkgname`. See [](#sec-organisation) for some hints on the tree organisation. Create a directory for your package, e.g.
|
||||
2. Find a good place in the Nixpkgs tree to add the Nix expression for your package. For instance, a library package typically goes into `pkgs/development/libraries/pkgname`, while a web browser goes into `pkgs/applications/networking/browsers/pkgname`. See <xref linkend="sec-organisation" /> for some hints on the tree organisation. Create a directory for your package, e.g.
|
||||
|
||||
```ShellSession
|
||||
$ mkdir pkgs/development/libraries/libfoo
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Reviewing contributions {#chap-reviewing-contributions}
|
||||
|
||||
::: {.warning}
|
||||
::: warning
|
||||
The following section is a draft, and the policy for reviewing is still being discussed in issues such as [#11166](https://github.com/NixOS/nixpkgs/issues/11166) and [#20836](https://github.com/NixOS/nixpkgs/issues/20836).
|
||||
:::
|
||||
|
||||
@@ -35,18 +35,15 @@ Reviewing process:
|
||||
- Building the package locally.
|
||||
- pull requests are often targeted to the master or staging branch, and building the pull request locally when it is submitted can trigger many source builds.
|
||||
- It is possible to rebase the changes on nixos-unstable or nixpkgs-unstable for easier review by running the following commands from a nixpkgs clone.
|
||||
|
||||
```ShellSession
|
||||
$ git fetch origin nixos-unstable
|
||||
$ git fetch origin pull/PRNUMBER/head
|
||||
$ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD
|
||||
```
|
||||
|
||||
- The first command fetches the nixos-unstable branch.
|
||||
- The second command fetches the pull request changes, `PRNUMBER` is the number at the end of the pull request title and `BASEBRANCH` the base branch of the pull request.
|
||||
- The third command rebases the pull request changes to the nixos-unstable branch.
|
||||
- The [nixpkgs-review](https://github.com/Mic92/nixpkgs-review) tool can be used to review a pull request content in a single command. `PRNUMBER` should be replaced by the number at the end of the pull request title. You can also provide the full github pull request url.
|
||||
|
||||
```ShellSession
|
||||
$ nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER"
|
||||
```
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
- Push your changes to your fork of nixpkgs.
|
||||
- Create the pull request
|
||||
- Follow [the contribution guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#submitting-changes).
|
||||
- Follow [the contribution guidelines](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md#submitting-changes).
|
||||
|
||||
## Submitting security fixes {#submitting-changes-submitting-security-fixes}
|
||||
|
||||
@@ -71,7 +71,6 @@ Security fixes are submitted in the same way as other changes and thus the same
|
||||
- If a new version fixing the vulnerability has been released, update the package;
|
||||
- If the security fix comes in the form of a patch and a CVE is available, then add the patch to the Nixpkgs tree, and apply it to the package.
|
||||
The name of the patch should be the CVE identifier, so e.g. `CVE-2019-13636.patch`; If a patch is fetched the name needs to be set as well, e.g.:
|
||||
|
||||
```nix
|
||||
(fetchpatch {
|
||||
name = "CVE-2019-11068.patch";
|
||||
@@ -90,7 +89,7 @@ There is currently no policy when to remove a package.
|
||||
|
||||
Before removing a package, one should try to find a new maintainer or fix smaller issues first.
|
||||
|
||||
### Steps to remove a package from Nixpkgs {#steps-to-remove-a-package-from-nixpkgs}
|
||||
### Steps to remove a package from Nixpkgs
|
||||
|
||||
We use jbidwatcher as an example for a discontinued project here.
|
||||
|
||||
@@ -101,7 +100,6 @@ We use jbidwatcher as an example for a discontinued project here.
|
||||
1. Add an alias for the package name in `pkgs/top-level/aliases.nix` (There is also `pkgs/misc/vim-plugins/aliases.nix`. Package sets typically do not have aliases, so we can't add them there.)
|
||||
|
||||
For example in this case:
|
||||
|
||||
```
|
||||
jbidwatcher = throw "jbidwatcher was discontinued in march 2021"; # added 2021-03-15
|
||||
```
|
||||
@@ -193,7 +191,7 @@ It’s important to test any executables generated by a build when you change or
|
||||
|
||||
### Meets Nixpkgs contribution standards {#submitting-changes-contribution-standards}
|
||||
|
||||
The last checkbox is fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md). The contributing document has detailed information on standards the Nix community has for commit messages, reviews, licensing of contributions you make to the project, etc\... Everyone should read and understand the standards the community has for contributing before submitting a pull request.
|
||||
The last checkbox is fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md). The contributing document has detailed information on standards the Nix community has for commit messages, reviews, licensing of contributions you make to the project, etc\... Everyone should read and understand the standards the community has for contributing before submitting a pull request.
|
||||
|
||||
## Hotfixing pull requests {#submitting-changes-hotfixing-pull-requests}
|
||||
|
||||
@@ -240,7 +238,7 @@ The `staging` branch is a development branch where mass-rebuilds go. It should o
|
||||
|
||||
### Staging-next branch {#submitting-changes-staging-next-branch}
|
||||
|
||||
The `staging-next` branch is for stabilizing mass-rebuilds submitted to the `staging` branch prior to merging them into `master`. Mass-rebuilds must go via the `staging` branch. It must only see non-breaking commits that are fixing issues blocking it from being merged into the `master ` branch.
|
||||
The `staging-next` branch is for stabilizing mass-rebuilds submitted to the `staging` branch prior to merging them into `master`. Mass-rebuilds should go via the `staging` branch. It should only see non-breaking commits that are fixing issues blocking it from being merged into the `master ` branch.
|
||||
|
||||
If the branch is already in a broken state, please refrain from adding extra new breakages. Stabilize it for a few days and then merge into master.
|
||||
|
||||
@@ -250,8 +248,6 @@ For cherry-picking a commit to a stable release branch (“backporting”), use
|
||||
|
||||
Add a reason for the backport by using `git cherry-pick -xe <original commit>` instead when it is not obvious from the original commit message. It is not needed when it's a minor version update that includes security and bug fixes but don't add new features or when the commit fixes an otherwise broken package.
|
||||
|
||||
For backporting Pull Requests to stable branches, assign label `backport <branch>` to the original Pull Requests and automation should take care of the rest once the Pull Requests is merged.
|
||||
|
||||
Here is an example of a cherry-picked commit message with good reason description:
|
||||
|
||||
```
|
||||
@@ -269,14 +265,3 @@ Other examples of reasons are:
|
||||
- Previously the build would fail due to, e.g., `getaddrinfo` not being defined
|
||||
- The previous download links were all broken
|
||||
- Crash when starting on some X11 systems
|
||||
|
||||
#### Acceptable backport criteria
|
||||
|
||||
The stable branch does have some changes which cannot be backported. Most notable are breaking changes. The desire is to have stable users be uninterrupted when updating packages.
|
||||
|
||||
However, many changes are able to be backported, including:
|
||||
- New Packages / Modules
|
||||
- Security / Patch updates
|
||||
- Version updates which include new functionality (but no breaking changes)
|
||||
- Services which require a client to be up-to-date regardless. (E.g. `spotify`, `steam`, or `discord`)
|
||||
- Security critical applications (E.g. `firefox`)
|
||||
|
||||
@@ -17,6 +17,10 @@ in pkgs.stdenv.mkDerivation {
|
||||
|
||||
src = lib.cleanSource ./.;
|
||||
|
||||
makeFlags = [
|
||||
"PANDOC_LUA_FILTERS_DIR=${pkgs.pandoc-lua-filters}/share/pandoc/filters"
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
ln -s ${doc-support} ./doc-support/result
|
||||
'';
|
||||
@@ -33,7 +37,4 @@ in pkgs.stdenv.mkDerivation {
|
||||
echo "doc manual $dest manual.html" >> $out/nix-support/hydra-build-products
|
||||
echo "doc manual $dest nixpkgs-manual.epub" >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
|
||||
# Environment variables
|
||||
PANDOC_LUA_FILTERS_DIR = "${pkgs.pandoc-lua-filters}/share/pandoc/filters";
|
||||
}
|
||||
|
||||
@@ -22,6 +22,5 @@ with pkgs; stdenv.mkDerivation {
|
||||
docgen lists 'List manipulation functions'
|
||||
docgen debug 'Debugging functions'
|
||||
docgen options 'NixOS / nixpkgs option handling'
|
||||
docgen sources 'Source filtering functions'
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
The nixpkgs repository has several utility functions to manipulate Nix expressions.
|
||||
</para>
|
||||
<xi:include href="functions/library.xml" />
|
||||
<xi:include href="functions/generators.section.xml" />
|
||||
<xi:include href="functions/debug.section.xml" />
|
||||
<xi:include href="functions/prefer-remote-fetch.section.xml" />
|
||||
<xi:include href="functions/nix-gitignore.section.xml" />
|
||||
<xi:include href="functions/generators.xml" />
|
||||
<xi:include href="functions/debug.xml" />
|
||||
<xi:include href="functions/prefer-remote-fetch.xml" />
|
||||
<xi:include href="functions/nix-gitignore.xml" />
|
||||
</chapter>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Debugging Nix Expressions {#sec-debug}
|
||||
|
||||
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.
|
||||
|
||||
In the `lib/debug.nix` file you will find a number of functions that help (pretty-)printing values while evaluation is running. You can even specify how deep these values should be printed recursively, and transform them on the fly. Please consult the docstrings in `lib/debug.nix` for usage information.
|
||||
14
doc/functions/debug.xml
Normal file
14
doc/functions/debug.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"
|
||||
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>
|
||||
@@ -1,56 +0,0 @@
|
||||
# Generators {#sec-generators}
|
||||
Generators are functions that create file formats from nix data structures, e. g. for configuration files. There are generators available for: `INI`, `JSON` and `YAML`
|
||||
|
||||
All generators follow a similar call interface: `generatorName configFunctions data`, where `configFunctions` 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 `mkSectionName ? (name: libStr.escape [ "[" "]" ] name)` from the `INI` generator. It receives the name of a section and sanitizes it. The default `mkSectionName` escapes `[` and `]` with a backslash.
|
||||
|
||||
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 `: ` as separator, the strings `"yes"`/`"no"` as boolean values and requires all string values to be quoted:
|
||||
|
||||
```nix
|
||||
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";
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
This will produce the following INI file as nix string:
|
||||
|
||||
```INI
|
||||
[main]
|
||||
autopush:"no"
|
||||
host:"localhost"
|
||||
port:42
|
||||
pushinfo:"yes"
|
||||
str\:ange:"very::strange"
|
||||
|
||||
[mergetool]
|
||||
merge:"diff3"
|
||||
```
|
||||
|
||||
::: {.note}
|
||||
Nix store paths can be converted to strings by enclosing a derivation attribute like so: `"${drv}"`.
|
||||
:::
|
||||
|
||||
Detailed documentation for each generator can be found in `lib/generators.nix`.
|
||||
74
doc/functions/generators.xml
Normal file
74
doc/functions/generators.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<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>
|
||||
@@ -25,6 +25,4 @@
|
||||
<xi:include href="./library/generated/debug.xml" />
|
||||
|
||||
<xi:include href="./library/generated/options.xml" />
|
||||
|
||||
<xi:include href="./library/generated/sources.xml" />
|
||||
</section>
|
||||
|
||||
@@ -772,7 +772,7 @@ nameValuePair "some" 6
|
||||
<title>Modifying each value of an attribute set</title>
|
||||
<programlisting><![CDATA[
|
||||
lib.attrsets.mapAttrs
|
||||
(name: value: name + "-" + value)
|
||||
(name: value: name + "-" value)
|
||||
{ x = "foo"; y = "bar"; }
|
||||
=> { x = "x-foo"; y = "y-bar"; }
|
||||
]]></programlisting>
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
# pkgs.nix-gitignore {#sec-pkgs-nix-gitignore}
|
||||
|
||||
`pkgs.nix-gitignore` is a function that acts similarly to `builtins.filterSource` but also allows filtering with the help of the gitignore format.
|
||||
|
||||
## Usage {#sec-pkgs-nix-gitignore-usage}
|
||||
|
||||
`pkgs.nix-gitignore` exports a number of functions, but you\'ll most likely need either `gitignoreSource` or `gitignoreSourcePure`. As their first argument, they both accept either 1. a file with gitignore lines or 2. a string with gitignore lines, or 3. a list of either of the two. They will be concatenated into a single big string.
|
||||
|
||||
```nix
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
nix-gitignore.gitignoreSource [] ./source
|
||||
# Simplest version
|
||||
|
||||
nix-gitignore.gitignoreSource "supplemental-ignores\n" ./source
|
||||
# This one reads the ./source/.gitignore and concats the auxiliary ignores
|
||||
|
||||
nix-gitignore.gitignoreSourcePure "ignore-this\nignore-that\n" ./source
|
||||
# Use this string as gitignore, don't read ./source/.gitignore.
|
||||
|
||||
nix-gitignore.gitignoreSourcePure ["ignore-this\nignore-that\n", ~/.gitignore] ./source
|
||||
# It also accepts a list (of strings and paths) that will be concatenated
|
||||
# once the paths are turned to strings via readFile.
|
||||
```
|
||||
|
||||
These functions are derived from the `Filter` functions by setting the first filter argument to `(_: _: true)`:
|
||||
|
||||
```nix
|
||||
gitignoreSourcePure = gitignoreFilterSourcePure (_: _: true);
|
||||
gitignoreSource = gitignoreFilterSource (_: _: true);
|
||||
```
|
||||
|
||||
Those filter functions accept the same arguments the `builtins.filterSource` function would pass to its filters, thus `fn: gitignoreFilterSourcePure fn ""` should be extensionally equivalent to `filterSource`. The file is blacklisted if it\'s blacklisted by either your filter or the gitignoreFilter.
|
||||
|
||||
If you want to make your own filter from scratch, you may use
|
||||
|
||||
```nix
|
||||
gitignoreFilter = ign: root: filterPattern (gitignoreToPatterns ign) root;
|
||||
```
|
||||
|
||||
## gitignore files in subdirectories {#sec-pkgs-nix-gitignore-usage-recursive}
|
||||
|
||||
If you wish to use a filter that would search for .gitignore files in subdirectories, just like git does by default, use this function:
|
||||
|
||||
```nix
|
||||
gitignoreFilterRecursiveSource = filter: patterns: root:
|
||||
# OR
|
||||
gitignoreRecursiveSource = gitignoreFilterSourcePure (_: _: true);
|
||||
```
|
||||
70
doc/functions/nix-gitignore.xml
Normal file
70
doc/functions/nix-gitignore.xml
Normal file
@@ -0,0 +1,70 @@
|
||||
<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-nix-gitignore">
|
||||
<title>pkgs.nix-gitignore</title>
|
||||
|
||||
<para>
|
||||
<function>pkgs.nix-gitignore</function> is a function that acts similarly to <literal>builtins.filterSource</literal> but also allows filtering with the help of the gitignore format.
|
||||
</para>
|
||||
|
||||
<section xml:id="sec-pkgs-nix-gitignore-usage">
|
||||
<title>Usage</title>
|
||||
|
||||
<para>
|
||||
<literal>pkgs.nix-gitignore</literal> exports a number of functions, but you'll most likely need either <literal>gitignoreSource</literal> or <literal>gitignoreSourcePure</literal>. As their first argument, they both accept either 1. a file with gitignore lines or 2. a string with gitignore lines, or 3. a list of either of the two. They will be concatenated into a single big string.
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
nix-gitignore.gitignoreSource [] ./source
|
||||
# Simplest version
|
||||
|
||||
nix-gitignore.gitignoreSource "supplemental-ignores\n" ./source
|
||||
# This one reads the ./source/.gitignore and concats the auxiliary ignores
|
||||
|
||||
nix-gitignore.gitignoreSourcePure "ignore-this\nignore-that\n" ./source
|
||||
# Use this string as gitignore, don't read ./source/.gitignore.
|
||||
|
||||
nix-gitignore.gitignoreSourcePure ["ignore-this\nignore-that\n", ~/.gitignore] ./source
|
||||
# It also accepts a list (of strings and paths) that will be concatenated
|
||||
# once the paths are turned to strings via readFile.
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
These functions are derived from the <literal>Filter</literal> functions by setting the first filter argument to <literal>(_: _: true)</literal>:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
gitignoreSourcePure = gitignoreFilterSourcePure (_: _: true);
|
||||
gitignoreSource = gitignoreFilterSource (_: _: true);
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
Those filter functions accept the same arguments the <literal>builtins.filterSource</literal> function would pass to its filters, thus <literal>fn: gitignoreFilterSourcePure fn ""</literal> should be extensionally equivalent to <literal>filterSource</literal>. The file is blacklisted iff it's blacklisted by either your filter or the gitignoreFilter.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If you want to make your own filter from scratch, you may use
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
gitignoreFilter = ign: root: filterPattern (gitignoreToPatterns ign) root;
|
||||
]]></programlisting>
|
||||
</section>
|
||||
|
||||
<section xml:id="sec-pkgs-nix-gitignore-usage-recursive">
|
||||
<title>gitignore files in subdirectories</title>
|
||||
|
||||
<para>
|
||||
If you wish to use a filter that would search for .gitignore files in subdirectories, just like git does by default, use this function:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
gitignoreFilterRecursiveSource = filter: patterns: root:
|
||||
# OR
|
||||
gitignoreRecursiveSource = gitignoreFilterSourcePure (_: _: true);
|
||||
]]></programlisting>
|
||||
</section>
|
||||
</section>
|
||||
@@ -1,17 +0,0 @@
|
||||
# prefer-remote-fetch overlay {#sec-prefer-remote-fetch}
|
||||
|
||||
`prefer-remote-fetch` is an overlay that download sources on remote builder. This is useful when the evaluating machine has a slow upload while the builder can fetch faster directly from the source. To use it, put the following snippet as a new overlay:
|
||||
|
||||
```nix
|
||||
self: super:
|
||||
(super.prefer-remote-fetch self super)
|
||||
```
|
||||
|
||||
A full configuration example for that sets the overlay up for your own account, could look like this
|
||||
|
||||
```ShellSession
|
||||
$ mkdir ~/.config/nixpkgs/overlays/
|
||||
$ cat > ~/.config/nixpkgs/overlays/prefer-remote-fetch.nix <<EOF
|
||||
self: super: super.prefer-remote-fetch self super
|
||||
EOF
|
||||
```
|
||||
21
doc/functions/prefer-remote-fetch.xml
Normal file
21
doc/functions/prefer-remote-fetch.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-prefer-remote-fetch">
|
||||
<title>prefer-remote-fetch overlay</title>
|
||||
|
||||
<para>
|
||||
<function>prefer-remote-fetch</function> is an overlay that download sources on remote builder. This is useful when the evaluating machine has a slow upload while the builder can fetch faster directly from the source. To use it, put the following snippet as a new overlay:
|
||||
<programlisting>
|
||||
self: super:
|
||||
(super.prefer-remote-fetch self super)
|
||||
</programlisting>
|
||||
A full configuration example for that sets the overlay up for your own account, could look like this
|
||||
<screen>
|
||||
<prompt>$ </prompt>mkdir ~/.config/nixpkgs/overlays/
|
||||
<prompt>$ </prompt>cat > ~/.config/nixpkgs/overlays/prefer-remote-fetch.nix <<EOF
|
||||
self: super: super.prefer-remote-fetch self super
|
||||
EOF
|
||||
</screen>
|
||||
</para>
|
||||
</section>
|
||||
@@ -1,6 +1,6 @@
|
||||
# Agda {#agda}
|
||||
|
||||
## How to use Agda {#how-to-use-agda}
|
||||
## How to use Agda
|
||||
|
||||
Agda is available as the [agda](https://search.nixos.org/packages?channel=unstable&show=agda&from=0&size=30&sort=relevance&query=agda)
|
||||
package.
|
||||
@@ -43,7 +43,6 @@ agda.withPackages (p: [
|
||||
```
|
||||
|
||||
You can also reference a GitHub repository
|
||||
|
||||
```nix
|
||||
agda.withPackages (p: [
|
||||
(p.standard-library.overrideAttrs (oldAttrs: {
|
||||
@@ -60,7 +59,6 @@ agda.withPackages (p: [
|
||||
|
||||
If you want to use a library not added to Nixpkgs, you can add a
|
||||
dependency to a local library by calling `agdaPackages.mkDerivation`.
|
||||
|
||||
```nix
|
||||
agda.withPackages (p: [
|
||||
(p.mkDerivation {
|
||||
@@ -94,21 +92,20 @@ See [Building Agda Packages](#building-agda-packages) for more information on `m
|
||||
Agda will not by default use these libraries. To tell Agda to use a library we have some options:
|
||||
|
||||
* Call `agda` with the library flag:
|
||||
```ShellSession
|
||||
$ agda -l standard-library -i . MyFile.agda
|
||||
```
|
||||
```ShellSession
|
||||
$ agda -l standard-library -i . MyFile.agda
|
||||
```
|
||||
* Write a `my-library.agda-lib` file for the project you are working on which may look like:
|
||||
```
|
||||
name: my-library
|
||||
include: .
|
||||
depend: standard-library
|
||||
```
|
||||
```
|
||||
name: my-library
|
||||
include: .
|
||||
depend: standard-library
|
||||
```
|
||||
* Create the file `~/.agda/defaults` and add any libraries you want to use by default.
|
||||
|
||||
More information can be found in the [official Agda documentation on library management](https://agda.readthedocs.io/en/v2.6.1/tools/package-system.html).
|
||||
|
||||
## Compiling Agda {#compiling-agda}
|
||||
|
||||
## Compiling Agda
|
||||
Agda modules can be compiled using the GHC backend with the `--compile` flag. A version of `ghc` with `ieee754` is made available to the Agda program via the `--with-compiler` flag.
|
||||
This can be overridden by a different version of `ghc` as follows:
|
||||
|
||||
@@ -119,8 +116,7 @@ agda.withPackages {
|
||||
}
|
||||
```
|
||||
|
||||
## Writing Agda packages {#writing-agda-packages}
|
||||
|
||||
## Writing Agda packages
|
||||
To write a nix derivation for an Agda library, first check that the library has a `*.agda-lib` file.
|
||||
|
||||
A derivation can then be written using `agdaPackages.mkDerivation`. This has similar arguments to `stdenv.mkDerivation` with the following additions:
|
||||
@@ -144,37 +140,19 @@ agdaPackages.mkDerivation {
|
||||
}
|
||||
```
|
||||
|
||||
### Building Agda packages {#building-agda-packages}
|
||||
|
||||
### Building Agda packages
|
||||
The default build phase for `agdaPackages.mkDerivation` simply runs `agda` on the `Everything.agda` file.
|
||||
If something else is needed to build the package (e.g. `make`) then the `buildPhase` should be overridden.
|
||||
Additionally, a `preBuild` or `configurePhase` can be used if there are steps that need to be done prior to checking the `Everything.agda` file.
|
||||
`agda` and the Agda libraries contained in `buildInputs` are made available during the build phase.
|
||||
|
||||
### Installing Agda packages {#installing-agda-packages}
|
||||
|
||||
### Installing Agda packages
|
||||
The default install phase copies Agda source files, Agda interface files (`*.agdai`) and `*.agda-lib` files to the output directory.
|
||||
This can be overridden.
|
||||
|
||||
By default, Agda sources are files ending on `.agda`, or literate Agda files ending on `.lagda`, `.lagda.tex`, `.lagda.org`, `.lagda.md`, `.lagda.rst`. The list of recognised Agda source extensions can be extended by setting the `extraExtensions` config variable.
|
||||
|
||||
## Maintaining the Agda package set on Nixpkgs {#maintaining-the-agda-package-set-on-nixpkgs}
|
||||
|
||||
We are aiming at providing all common Agda libraries as packages on `nixpkgs`,
|
||||
and keeping them up to date.
|
||||
Contributions and maintenance help is always appreciated,
|
||||
but the maintenance effort is typically low since the Agda ecosystem is quite small.
|
||||
|
||||
The `nixpkgs` Agda package set tries to take up a role similar to that of [Stackage](https://www.stackage.org/) in the Haskell world.
|
||||
It is a curated set of libraries that:
|
||||
|
||||
1. Always work together.
|
||||
2. Are as up-to-date as possible.
|
||||
|
||||
While the Haskell ecosystem is huge, and Stackage is highly automatised,
|
||||
the Agda package set is small and can (still) be maintained by hand.
|
||||
|
||||
### Adding Agda packages to Nixpkgs {#adding-agda-packages-to-nixpkgs}
|
||||
## Adding Agda packages to Nixpkgs
|
||||
|
||||
To add an Agda package to `nixpkgs`, the derivation should be written to `pkgs/development/libraries/agda/${library-name}/` and an entry should be added to `pkgs/top-level/agda-packages.nix`. Here it is called in a scope with access to all other Agda libraries, so the top line of the `default.nix` can look like:
|
||||
|
||||
@@ -204,53 +182,6 @@ mkDerivation {
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
This library has a file called `.agda-lib`, and so we give an empty string to `libraryFile` as nothing precedes `.agda-lib` in the filename. This file contains `name: IAL-1.3`, and so we let `libraryName = "IAL-1.3"`. This library does not use an `Everything.agda` file and instead has a Makefile, so there is no need to set `everythingFile` and we set a custom `buildPhase`.
|
||||
|
||||
When writing an Agda package it is essential to make sure that no `.agda-lib` file gets added to the store as a single file (for example by using `writeText`). This causes Agda to think that the nix store is a Agda library and it will attempt to write to it whenever it typechecks something. See [https://github.com/agda/agda/issues/4613](https://github.com/agda/agda/issues/4613).
|
||||
|
||||
In the pull request adding this library,
|
||||
you can test whether it builds correctly by writing in a comment:
|
||||
|
||||
```
|
||||
@ofborg build agdaPackages.iowa-stdlib
|
||||
```
|
||||
|
||||
### Maintaining Agda packages
|
||||
|
||||
As mentioned before, the aim is to have a compatible, and up-to-date package set.
|
||||
These two conditions sometimes exclude each other:
|
||||
For example, if we update `agdaPackages.standard-library` because there was an upstream release,
|
||||
this will typically break many reverse dependencies,
|
||||
i.e. downstream Agda libraries that depend on the standard library.
|
||||
In `nixpkgs` we are typically among the first to notice this,
|
||||
since we have build tests in place to check this.
|
||||
|
||||
In a pull request updating e.g. the standard library, you should write the following comment:
|
||||
|
||||
```
|
||||
@ofborg build agdaPackages.standard-library.passthru.tests
|
||||
```
|
||||
|
||||
This will build all reverse dependencies of the standard library,
|
||||
for example `agdaPackages.agda-categories`, or `agdaPackages.generic`.
|
||||
|
||||
In some cases it is useful to build _all_ Agda packages.
|
||||
This can be done with the following Github comment:
|
||||
|
||||
```
|
||||
@ofborg build agda.passthru.tests.allPackages
|
||||
```
|
||||
|
||||
Sometimes, the builds of the reverse dependencies fail because they have not yet been updated and released.
|
||||
You should drop the maintainers a quick issue notifying them of the breakage,
|
||||
citing the build error (which you can get from the ofborg logs).
|
||||
If you are motivated, you might even send a pull request that fixes it.
|
||||
Usually, the maintainers will answer within a week or two with a new release.
|
||||
Bumping the version of that reverse dependency should be a further commit on your PR.
|
||||
|
||||
In the rare case that a new release is not to be expected within an acceptable time,
|
||||
simply mark the broken package as broken by setting `meta.broken = true;`.
|
||||
This will exclude it from the build test.
|
||||
It can be added later when it is fixed,
|
||||
and does not hinder the advancement of the whole package set in the meantime.
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
The Android build environment provides three major features and a number of
|
||||
supporting features.
|
||||
|
||||
## Deploying an Android SDK installation with plugins {#deploying-an-android-sdk-installation-with-plugins}
|
||||
|
||||
Deploying an Android SDK installation with plugins
|
||||
--------------------------------------------------
|
||||
The first use case is deploying the SDK with a desired set of plugins or subsets
|
||||
of an SDK.
|
||||
|
||||
@@ -136,8 +136,8 @@ in
|
||||
androidComposition.platform-tools
|
||||
```
|
||||
|
||||
## Using predefined Android package compositions {#using-predefined-android-package-compositions}
|
||||
|
||||
Using predefined Android package compositions
|
||||
---------------------------------------------
|
||||
In addition to composing an Android package set manually, it is also possible
|
||||
to use a predefined composition that contains all basic packages for a specific
|
||||
Android version, such as version 9.0 (API-level 28).
|
||||
@@ -159,13 +159,12 @@ with import <nixpkgs> {};
|
||||
androidenv.androidPkgs_9_0.platform-tools
|
||||
```
|
||||
|
||||
## Building an Android application {#building-an-android-application}
|
||||
|
||||
Building an Android application
|
||||
-------------------------------
|
||||
In addition to the SDK, it is also possible to build an Ant-based Android
|
||||
project and automatically deploy all the Android plugins that a project
|
||||
requires.
|
||||
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
|
||||
@@ -200,8 +199,8 @@ to build Android apps. An Android APK gets exposed as a build product and can be
|
||||
installed on any Android device with a web browser by navigating to the build
|
||||
result page.
|
||||
|
||||
## Spawning emulator instances {#spawning-emulator-instances}
|
||||
|
||||
Spawning emulator instances
|
||||
---------------------------
|
||||
For testing purposes, it can also be quite convenient to automatically generate
|
||||
scripts that spawn emulator instances with all desired configuration settings.
|
||||
|
||||
@@ -242,8 +241,8 @@ androidenv.emulateApp {
|
||||
In addition to prebuilt APKs, you can also bind the APK parameter to a
|
||||
`buildApp {}` function invocation shown in the previous example.
|
||||
|
||||
## Notes on environment variables in Android projects {#notes-on-environment-variables-in-android-projects}
|
||||
|
||||
Notes on environment variables in Android projects
|
||||
--------------------------------------------------
|
||||
* `ANDROID_SDK_ROOT` should point to the Android SDK. In your Nix expressions, this should be
|
||||
`${androidComposition.androidsdk}/libexec/android-sdk`. Note that `ANDROID_HOME` is deprecated,
|
||||
but if you rely on tools that need it, you can export it too.
|
||||
@@ -301,8 +300,8 @@ This shell.nix includes a shell hook that overwrites local.properties with the c
|
||||
sdk.dir and ndk.dir values. This will ensure that the SDK and NDK directories will
|
||||
both be correct when you run Android Studio inside nix-shell.
|
||||
|
||||
## Notes on improving build.gradle compatibility {#notes-on-improving-build.gradle-compatibility}
|
||||
|
||||
Notes on improving build.gradle compatibility
|
||||
---------------------------------------------
|
||||
Ensure that your buildToolsVersion and ndkVersion match what is declared in androidenv.
|
||||
If you are using cmake, make sure its declared version is correct too.
|
||||
|
||||
@@ -322,8 +321,8 @@ android {
|
||||
|
||||
```
|
||||
|
||||
## Querying the available versions of each plugin {#querying-the-available-versions-of-each-plugin}
|
||||
|
||||
Querying the available versions of each plugin
|
||||
----------------------------------------------
|
||||
repo.json provides all the options in one file now.
|
||||
|
||||
A shell script in the `pkgs/development/mobile/androidenv/` subdirectory can be used to retrieve all
|
||||
@@ -335,8 +334,8 @@ possible options:
|
||||
|
||||
The above command-line instruction queries all package versions in repo.json.
|
||||
|
||||
## Updating the generated expressions {#updating-the-generated-expressions}
|
||||
|
||||
Updating the generated expressions
|
||||
----------------------------------
|
||||
repo.json is generated from XML files that the Android Studio package manager uses.
|
||||
To update the expressions run the `generate.sh` script that is stored in the
|
||||
`pkgs/development/mobile/androidenv/` subdirectory:
|
||||
|
||||
@@ -4,19 +4,13 @@
|
||||
|
||||
In this document and related Nix expressions, we use the term, _BEAM_, to describe the environment. BEAM is the name of the Erlang Virtual Machine and, as far as we're concerned, from a packaging perspective, all languages that run on the BEAM are interchangeable. That which varies, like the build system, is transparent to users of any given BEAM package, so we make no distinction.
|
||||
|
||||
## Available versions and deprecations schedule {#available-versions-and-deprecations-schedule}
|
||||
|
||||
### Elixir {#elixir}
|
||||
|
||||
nixpkgs follows the [official elixir deprecation schedule](https://hexdocs.pm/elixir/compatibility-and-deprecations.html) and keeps the last 5 released versions of Elixir available.
|
||||
|
||||
## Structure {#beam-structure}
|
||||
|
||||
All BEAM-related expressions are available via the top-level `beam` attribute, which includes:
|
||||
|
||||
- `interpreters`: a set of compilers running on the BEAM, including multiple Erlang/OTP versions (`beam.interpreters.erlangR22`, etc), Elixir (`beam.interpreters.elixir`) and LFE (Lisp Flavoured Erlang) (`beam.interpreters.lfe`).
|
||||
- `interpreters`: a set of compilers running on the BEAM, including multiple Erlang/OTP versions (`beam.interpreters.erlangR19`, etc), Elixir (`beam.interpreters.elixir`) and LFE (Lisp Flavoured Erlang) (`beam.interpreters.lfe`).
|
||||
|
||||
- `packages`: a set of package builders (Mix and rebar3), each compiled with a specific Erlang/OTP version, e.g. `beam.packages.erlang22`.
|
||||
- `packages`: a set of package builders (Mix and rebar3), each compiled with a specific Erlang/OTP version, e.g. `beam.packages.erlangR19`.
|
||||
|
||||
The default Erlang compiler, defined by `beam.interpreters.erlang`, is aliased as `erlang`. The default BEAM package set is defined by `beam.packages.erlang` and aliased at the top level as `beamPackages`.
|
||||
|
||||
@@ -68,107 +62,27 @@ Erlang.mk functions similarly to Rebar3, except we use `buildErlangMk` instead o
|
||||
|
||||
`mixRelease` is used to make a release in the mix sense. Dependencies will need to be fetched with `fetchMixDeps` and passed to it.
|
||||
|
||||
#### mixRelease - Elixir Phoenix example {#mix-release-elixir-phoenix-example}
|
||||
#### mixRelease - Elixir Phoenix example
|
||||
|
||||
there are 3 steps, frontend dependencies (javascript), backend dependencies (elixir) and the final derivation that puts both of those together
|
||||
|
||||
##### mixRelease - Frontend dependencies (javascript) {#mix-release-javascript-deps}
|
||||
|
||||
for phoenix projects, inside of nixpkgs you can either use yarn2nix (mkYarnModule) or node2nix. An example with yarn2nix can be found [here](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/web-apps/plausible/default.nix#L39). An example with node2nix will follow. To package something outside of nixpkgs, you have alternatives like [npmlock2nix](https://github.com/nix-community/npmlock2nix) or [nix-npm-buildpackage](https://github.com/serokell/nix-npm-buildpackage)
|
||||
|
||||
##### mixRelease - backend dependencies (mix) {#mix-release-mix-deps}
|
||||
|
||||
There are 2 ways to package backend dependencies. With mix2nix and with a fixed-output-derivation (FOD).
|
||||
|
||||
###### mix2nix {#mix2nix}
|
||||
|
||||
mix2nix is a cli tool available in nixpkgs. it will generate a nix expression from a mix.lock file. It is quite standard in the 2nix tool series.
|
||||
|
||||
Note that currently mix2nix can't handle git dependencies inside the mix.lock file. If you have git dependencies, you can either add them manually (see [example](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/pleroma/default.nix#L20)) or use the FOD method.
|
||||
|
||||
The advantage of using mix2nix is that nix will know your whole dependency graph. On a dependency update, this won't trigger a full rebuild and download of all the dependencies, where FOD will do so.
|
||||
|
||||
practical steps:
|
||||
|
||||
- run `mix2nix > mix_deps.nix` in the upstream repo.
|
||||
- pass `mixNixDeps = with pkgs; import ./mix_deps.nix { inherit lib beamPackages; };` as an argument to mixRelease.
|
||||
|
||||
If there are git depencencies.
|
||||
|
||||
- You'll need to fix the version artificially in mix.exs and regenerate the mix.lock with fixed version (on upstream). This will enable you to run `mix2nix > mix_deps.nix`.
|
||||
- From the mix_deps.nix file, remove the dependencies that had git versions and pass them as an override to the import function.
|
||||
|
||||
```nix
|
||||
mixNixDeps = import ./mix.nix {
|
||||
inherit beamPackages lib;
|
||||
overrides = (final: prev: {
|
||||
# mix2nix does not support git dependencies yet,
|
||||
# so we need to add them manually
|
||||
prometheus_ex = beamPackages.buildMix rec {
|
||||
name = "prometheus_ex";
|
||||
version = "3.0.5";
|
||||
|
||||
# Change the argument src with the git src that you actually need
|
||||
src = fetchFromGitLab {
|
||||
domain = "git.pleroma.social";
|
||||
group = "pleroma";
|
||||
owner = "elixir-libraries";
|
||||
repo = "prometheus.ex";
|
||||
rev = "a4e9beb3c1c479d14b352fd9d6dd7b1f6d7deee5";
|
||||
sha256 = "1v0q4bi7sb253i8q016l7gwlv5562wk5zy3l2sa446csvsacnpjk";
|
||||
};
|
||||
# you can re-use the same beamDeps argument as generated
|
||||
beamDeps = with final; [ prometheus ];
|
||||
};
|
||||
});
|
||||
};
|
||||
```
|
||||
|
||||
You will need to run the build process once to fix the sha256 to correspond to your new git src.
|
||||
|
||||
###### FOD {#fixed-output-derivation}
|
||||
|
||||
A fixed output derivation will download mix dependencies from the internet. To ensure reproducibility, a hash will be supplied. Note that mix is relatively reproducible. An FOD generating a different hash on each run hasn't been observed (as opposed to npm where the chances are relatively high). See [elixir_ls](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/beam-modules/elixir_ls.nix) for a usage example of FOD.
|
||||
|
||||
Practical steps
|
||||
|
||||
- start with the following argument to mixRelease
|
||||
|
||||
```nix
|
||||
mixFodDeps = fetchMixDeps {
|
||||
pname = "mix-deps-${pname}";
|
||||
inherit src version;
|
||||
sha256 = lib.fakeSha256;
|
||||
};
|
||||
```
|
||||
|
||||
The first build will complain about the sha256 value, you can replace with the suggested value after that.
|
||||
|
||||
Note that if after you've replaced the value, nix suggests another sha256, then mix is not fetching the dependencies reproducibly. An FOD will not work in that case and you will have to use mix2nix.
|
||||
|
||||
##### mixRelease - example {#mix-release-example}
|
||||
|
||||
Here is how your `default.nix` file would look for a phoenix project.
|
||||
Here is how your `default.nix` file would look.
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> { };
|
||||
|
||||
let
|
||||
# beam.interpreters.erlangR23 is available if you need a particular version
|
||||
packages = beam.packagesWith beam.interpreters.erlang;
|
||||
|
||||
pname = "your_project";
|
||||
version = "0.0.1";
|
||||
|
||||
src = builtins.fetchgit {
|
||||
url = "ssh://git@github.com/your_id/your_repo";
|
||||
rev = "replace_with_your_commit";
|
||||
};
|
||||
|
||||
# if using mix2nix you can use the mixNixDeps attribute
|
||||
mixFodDeps = packages.fetchMixDeps {
|
||||
pname = "your_project";
|
||||
version = "0.0.1";
|
||||
mixEnv = "prod";
|
||||
|
||||
mixDeps = packages.fetchMixDeps {
|
||||
pname = "mix-deps-${pname}";
|
||||
inherit src version;
|
||||
inherit src mixEnv version;
|
||||
# nix will complain and tell you the right value to replace this with
|
||||
sha256 = lib.fakeSha256;
|
||||
# if you have build time environment variables add them here
|
||||
@@ -177,19 +91,45 @@ let
|
||||
|
||||
nodeDependencies = (pkgs.callPackage ./assets/default.nix { }).shell.nodeDependencies;
|
||||
|
||||
frontEndFiles = stdenvNoCC.mkDerivation {
|
||||
pname = "frontend-${pname}";
|
||||
|
||||
nativeBuildInputs = [ nodejs ];
|
||||
|
||||
inherit version src;
|
||||
|
||||
buildPhase = ''
|
||||
cp -r ./assets $TEMPDIR
|
||||
|
||||
mkdir -p $TEMPDIR/assets/node_modules/.cache
|
||||
cp -r ${nodeDependencies}/lib/node_modules $TEMPDIR/assets
|
||||
export PATH="${nodeDependencies}/bin:$PATH"
|
||||
|
||||
cd $TEMPDIR/assets
|
||||
webpack --config ./webpack.config.js
|
||||
cd ..
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
cp -r ./priv/static $out/
|
||||
'';
|
||||
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
# nix will complain and tell you the right value to replace this with
|
||||
outputHash = lib.fakeSha256;
|
||||
|
||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
|
||||
};
|
||||
|
||||
|
||||
in packages.mixRelease {
|
||||
inherit src pname version mixFodDeps;
|
||||
inherit src pname version mixEnv mixDeps;
|
||||
# if you have build time environment variables add them here
|
||||
MY_ENV_VAR="my_value";
|
||||
|
||||
postBuild = ''
|
||||
ln -sf ${nodeDependencies}/lib/node_modules assets/node_modules
|
||||
npm run deploy --prefix ./assets
|
||||
|
||||
# for external task you need a workaround for the no deps check flag
|
||||
# https://github.com/phoenixframework/phoenix/issues/2690
|
||||
mix do deps.loadpaths --no-deps-check, phx.digest
|
||||
mix phx.digest --no-deps-check
|
||||
preInstall = ''
|
||||
mkdir -p ./priv/static
|
||||
cp -r ${frontEndFiles} ./priv/static
|
||||
'';
|
||||
}
|
||||
```
|
||||
@@ -202,7 +142,7 @@ Setup will require the following steps:
|
||||
- you can now `nix-build .`
|
||||
- To run the release, set the `RELEASE_TMP` environment variable to a directory that your program has write access to. It will be used to store the BEAM settings.
|
||||
|
||||
#### Example of creating a service for an Elixir - Phoenix project {#example-of-creating-a-service-for-an-elixir---phoenix-project}
|
||||
#### Example of creating a service for an Elixir - Phoenix project
|
||||
|
||||
In order to create a service with your release, you could add a `service.nix`
|
||||
in your project with the following
|
||||
@@ -219,8 +159,6 @@ in
|
||||
systemd.services.${release_name} = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" "postgresql.service" ];
|
||||
# note that if you are connecting to a postgres instance on a different host
|
||||
# postgresql.service should not be included in the requires.
|
||||
requires = [ "network-online.target" "postgresql.service" ];
|
||||
description = "my app";
|
||||
environment = {
|
||||
@@ -257,7 +195,6 @@ in
|
||||
path = [ pkgs.bash ];
|
||||
};
|
||||
|
||||
# in case you have migration scripts or you want to use a remote shell
|
||||
environment.systemPackages = [ release ];
|
||||
}
|
||||
```
|
||||
@@ -269,18 +206,23 @@ in
|
||||
Usually, we need to create a `shell.nix` file and do our development inside of the environment specified therein. Just install your version of Erlang and any other interpreters, and then use your normal build tools. As an example with Elixir:
|
||||
|
||||
```nix
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{ pkgs ? import "<nixpkgs"> {} }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
let
|
||||
elixir = beam.packages.erlangR24.elixir_1_12;
|
||||
|
||||
elixir = beam.packages.erlangR22.elixir_1_9;
|
||||
|
||||
in
|
||||
mkShell {
|
||||
buildInputs = [ elixir ];
|
||||
|
||||
ERL_INCLUDE_PATH="${erlang}/lib/erlang/usr/include";
|
||||
}
|
||||
```
|
||||
|
||||
#### Elixir - Phoenix project {#elixir---phoenix-project}
|
||||
#### Elixir - Phoenix project
|
||||
|
||||
Here is an example `shell.nix`.
|
||||
|
||||
@@ -293,7 +235,7 @@ let
|
||||
git
|
||||
# replace with beam.packages.erlang.elixir_1_11 if you need
|
||||
beam.packages.erlang.elixir
|
||||
nodejs
|
||||
nodejs-15_x
|
||||
postgresql_13
|
||||
# only used for frontend dependencies
|
||||
# you are free to use yarn2nix as well
|
||||
@@ -316,7 +258,6 @@ let
|
||||
# TODO: not sure how to make hex available without installing it afterwards.
|
||||
mix local.hex --if-missing
|
||||
export LANG=en_US.UTF-8
|
||||
# keep your shell history in iex
|
||||
export ERL_AFLAGS="-kernel shell_history enabled"
|
||||
|
||||
# postges related
|
||||
|
||||
@@ -149,7 +149,7 @@ A few notes about [Full example — `default.nix`](#ex-buildBowerComponentsDefau
|
||||
|
||||
## Troubleshooting {#ssec-bower2nix-troubleshooting}
|
||||
|
||||
### ENOCACHE errors from buildBowerComponents {#enocache-errors-from-buildbowercomponents}
|
||||
### ENOCACHE errors from buildBowerComponents
|
||||
|
||||
This means that Bower was looking for a package version which doesn't exist in the generated `bower-packages.nix`.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Coq and coq packages {#sec-language-coq}
|
||||
|
||||
## Coq derivation: `coq` {#coq-derivation-coq}
|
||||
## Coq derivation: `coq`
|
||||
|
||||
The Coq derivation is overridable through the `coq.override overrides`, where overrides is an attribute set which contains the arguments to override. We recommend overriding either of the following
|
||||
|
||||
@@ -8,7 +8,7 @@ The Coq derivation is overridable through the `coq.override overrides`, where ov
|
||||
* `customOCamlPackage` (optional, defaults to `null`, which lets Coq choose a version automatically), which can be set to any of the ocaml packages attribute of `ocaml-ng` (such as `ocaml-ng.ocamlPackages_4_10` which is the default for Coq 8.11 for example).
|
||||
* `coq-version` (optional, defaults to the short version e.g. "8.10"), is a version number of the form "x.y" that indicates which Coq's version build behavior to mimic when using a source which is not a release. E.g. `coq.override { version = "d370a9d1328a4e1cdb9d02ee032f605a9d94ec7a"; coq-version = "8.10"; }`.
|
||||
|
||||
## Coq packages attribute sets: `coqPackages` {#coq-packages-attribute-sets-coqpackages}
|
||||
## Coq packages attribute sets: `coqPackages`
|
||||
|
||||
The recommended way of defining a derivation for a Coq library, is to use the `coqPackages.mkCoqDerivation` function, which is essentially a specialization of `mkDerivation` taking into account most of the specifics of Coq libraries. The following attributes are supported:
|
||||
|
||||
@@ -28,12 +28,11 @@ The recommended way of defining a derivation for a Coq library, is to use the `c
|
||||
* `domain` (optional, defaults to `"github.com"`), domains including the strings `"github"` or `"gitlab"` in their names are automatically supported, otherwise, one must change the `fetcher` argument to support them (cf `pkgs/development/coq-modules/heq/default.nix` for an example),
|
||||
* `releaseRev` (optional, defaults to `(v: v)`), provides a default mapping from release names to revision hashes/branch names/tags,
|
||||
* `displayVersion` (optional), provides a way to alter the computation of `name` from `pname`, by explaining how to display version numbers,
|
||||
* `namePrefix` (optional, defaults to `[ "coq" ]`), provides a way to alter the computation of `name` from `pname`, by explaining which dependencies must occur in `name`,
|
||||
* `namePrefix` (optional), provides a way to alter the computation of `name` from `pname`, by explaining which dependencies must occur in `name`,
|
||||
* `extraBuildInputs` (optional), by default `buildInputs` just contains `coq`, this allows to add more build inputs,
|
||||
* `mlPlugin` (optional, defaults to `false`). Some extensions (plugins) might require OCaml and sometimes other OCaml packages. Standard dependencies can be added by setting the current option to `true`. For a finer grain control, the `coq.ocamlPackages` attribute can be used in `extraBuildInputs` to depend on the same package set Coq was built against.
|
||||
* `useDune2ifVersion` (optional, default to `(x: false)` uses Dune2 to build the package if the provided predicate evaluates to true on the version, e.g. `useDune2if = versions.isGe "1.1"` will use dune if the version of the package is greater or equal to `"1.1"`,
|
||||
* `useDune2` (optional, defaults to `false`) uses Dune2 to build the package if set to true, the presence of this attribute overrides the behavior of the previous one.
|
||||
* `opam-name` (optional, defaults to concatenating with a dash separator the components of `namePrefix` and `pname`), name of the Dune package to build.
|
||||
* `enableParallelBuilding` (optional, defaults to `true`), since it is activated by default, we provide a way to disable it.
|
||||
* `extraInstallFlags` (optional), allows to extend `installFlags` which initializes the variable `COQMF_COQLIB` so as to install in the proper subdirectory. Indeed Coq libraries should be installed in `$(out)/lib/coq/${coq.coq-version}/user-contrib/`. Such directories are automatically added to the `$COQPATH` environment variable by the hook defined in the Coq derivation.
|
||||
* `setCOQBIN` (optional, defaults to `true`), by default, the environment variable `$COQBIN` is set to the current Coq's binary, but one can disable this behavior by setting it to `false`,
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
# Crystal {#crystal}
|
||||
|
||||
## Building a Crystal package {#building-a-crystal-package}
|
||||
## Building a Crystal package
|
||||
|
||||
This section uses [Mint](https://github.com/mint-lang/mint) as an example for how to build a Crystal package.
|
||||
|
||||
If the Crystal project has any dependencies, the first step is to get a `shards.nix` file encoding those. Get a copy of the project and go to its root directory such that its `shard.lock` file is in the current directory. Executable projects should usually commit the `shard.lock` file, but sometimes that's not the case, which means you need to generate it yourself. With an existing `shard.lock` file, `crystal2nix` can be run.
|
||||
If the Crystal project has any dependencies, the first step is to get a `shards.nix` file encoding those. Get a copy of the project and go to its root directory such that its `shard.lock` file is in the current directory, then run `crystal2nix` in it
|
||||
```bash
|
||||
$ git clone https://github.com/mint-lang/mint
|
||||
$ cd mint
|
||||
$ git checkout 0.5.0
|
||||
$ if [ ! -f shard.lock ]; then nix-shell -p shards --run "shards lock"; fi
|
||||
$ nix-shell -p crystal2nix --run crystal2nix
|
||||
```
|
||||
|
||||
This should have generated a `shards.nix` file.
|
||||
|
||||
Next create a Nix file for your derivation and use `pkgs.crystal.buildCrystalPackage` as follows:
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
crystal.buildCrystalPackage rec {
|
||||
|
||||
@@ -50,7 +50,7 @@ expression does not protect the Prelude import with a semantic integrity
|
||||
check, so the first step is to freeze the expression using `dhall freeze`,
|
||||
like this:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ dhall freeze --inplace ./true.dhall
|
||||
```
|
||||
|
||||
@@ -113,7 +113,7 @@ in
|
||||
|
||||
… which we can then build using this command:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ nix build --file ./example.nix dhallPackages.true
|
||||
```
|
||||
|
||||
@@ -121,7 +121,7 @@ $ nix build --file ./example.nix dhallPackages.true
|
||||
|
||||
The above package produces the following directory tree:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ tree -a ./result
|
||||
result
|
||||
├── .cache
|
||||
@@ -135,7 +135,7 @@ result
|
||||
|
||||
* `source.dhall` contains the result of interpreting our Dhall package:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ cat ./result/source.dhall
|
||||
True
|
||||
```
|
||||
@@ -143,7 +143,7 @@ result
|
||||
* The `.cache` subdirectory contains one binary cache product encoding the
|
||||
same result as `source.dhall`:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ dhall decode < ./result/.cache/dhall/122027abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
|
||||
True
|
||||
```
|
||||
@@ -151,7 +151,7 @@ result
|
||||
* `binary.dhall` contains a Dhall expression which handles fetching and decoding
|
||||
the same cache product:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ cat ./result/binary.dhall
|
||||
missing sha256:27abdeddfe8503496adeb623466caa47da5f63abd2bc6fa19f6cfcb73ecfed70
|
||||
$ cp -r ./result/.cache .cache
|
||||
@@ -168,7 +168,7 @@ to conserve disk space when they are used exclusively as dependencies. For
|
||||
example, if we build the Prelude package it will only contain the binary
|
||||
encoding of the expression:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ nix build --file ./example.nix dhallPackages.Prelude
|
||||
|
||||
$ tree -a result
|
||||
@@ -199,7 +199,7 @@ Dhall overlay like this:
|
||||
… and now the Prelude will contain the fully decoded result of interpreting
|
||||
the Prelude:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ nix build --file ./example.nix dhallPackages.Prelude
|
||||
|
||||
$ tree -a result
|
||||
@@ -302,7 +302,7 @@ Additionally, `buildDhallGitHubPackage` accepts the same arguments as
|
||||
You can use the `dhall-to-nixpkgs` command-line utility to automate
|
||||
packaging Dhall code. For example:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ nix-env --install --attr haskellPackages.dhall-nixpkgs
|
||||
|
||||
$ nix-env --install --attr nix-prefetch-git # Used by dhall-to-nixpkgs
|
||||
@@ -329,12 +329,12 @@ The utility takes care of automatically detecting remote imports and converting
|
||||
them to package dependencies. You can also use the utility on local
|
||||
Dhall directories, too:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ dhall-to-nixpkgs directory ~/proj/dhall-semver
|
||||
{ buildDhallDirectoryPackage, Prelude }:
|
||||
buildDhallDirectoryPackage {
|
||||
name = "proj";
|
||||
src = ~/proj/dhall-semver;
|
||||
src = /Users/gabriel/proj/dhall-semver;
|
||||
file = "package.dhall";
|
||||
source = false;
|
||||
document = false;
|
||||
@@ -342,37 +342,6 @@ $ dhall-to-nixpkgs directory ~/proj/dhall-semver
|
||||
}
|
||||
```
|
||||
|
||||
### Remote imports as fixed-output derivations {#ssec-dhall-remote-imports-as-fod}
|
||||
|
||||
`dhall-to-nixpkgs` has the ability to fetch and build remote imports as
|
||||
fixed-output derivations by using their Dhall integrity check. This is
|
||||
sometimes easier than manually packaging all remote imports.
|
||||
|
||||
This can be used like the following:
|
||||
|
||||
```ShellSession
|
||||
$ dhall-to-nixpkgs directory --fixed-output-derivations ~/proj/dhall-semver
|
||||
{ buildDhallDirectoryPackage, buildDhallUrl }:
|
||||
buildDhallDirectoryPackage {
|
||||
name = "proj";
|
||||
src = ~/proj/dhall-semver;
|
||||
file = "package.dhall";
|
||||
source = false;
|
||||
document = false;
|
||||
dependencies = [
|
||||
(buildDhallUrl {
|
||||
url = "https://prelude.dhall-lang.org/v17.0.0/package.dhall";
|
||||
hash = "sha256-ENs8kZwl6QRoM9+Jeo/+JwHcOQ+giT2VjDQwUkvlpD4=";
|
||||
dhallHash = "sha256:10db3c919c25e9046833df897a8ffe2701dc390fa0893d958c3430524be5a43e";
|
||||
})
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
Here, `dhall-semver`'s `Prelude` dependency is fetched and built with the
|
||||
`buildDhallUrl` helper function, instead of being passed in as a function
|
||||
argument.
|
||||
|
||||
## Overriding dependency versions {#ssec-dhall-overriding-dependency-versions}
|
||||
|
||||
Suppose that we change our `true.dhall` example expression to depend on an older
|
||||
@@ -390,7 +359,7 @@ in Prelude.Bool.not False
|
||||
|
||||
If we try to rebuild that expression the build will fail:
|
||||
|
||||
```ShellSession
|
||||
```
|
||||
$ nix build --file ./example.nix dhallPackages.true
|
||||
builder for '/nix/store/0f1hla7ff1wiaqyk1r2ky4wnhnw114fi-true.drv' failed with exit code 1; last 10 log lines:
|
||||
|
||||
@@ -416,7 +385,7 @@ importing the URL.
|
||||
However, we can override the default Prelude version by using `dhall-to-nixpkgs`
|
||||
to create a Dhall package for our desired Prelude:
|
||||
|
||||
```ShellSession
|
||||
```bash
|
||||
$ dhall-to-nixpkgs github https://github.com/dhall-lang/dhall-lang.git \
|
||||
--name Prelude \
|
||||
--directory Prelude \
|
||||
@@ -427,7 +396,7 @@ $ dhall-to-nixpkgs github https://github.com/dhall-lang/dhall-lang.git \
|
||||
… and then referencing that package in our Dhall overlay, by either overriding
|
||||
the Prelude globally for all packages, like this:
|
||||
|
||||
```nix
|
||||
```bash
|
||||
dhallOverrides = self: super: {
|
||||
true = self.callPackage ./true.nix { };
|
||||
|
||||
@@ -438,7 +407,7 @@ the Prelude globally for all packages, like this:
|
||||
… or selectively overriding the Prelude dependency for just the `true` package,
|
||||
like this:
|
||||
|
||||
```nix
|
||||
```bash
|
||||
dhallOverrides = self: super: {
|
||||
true = self.callPackage ./true.nix {
|
||||
Prelude = self.callPackage ./Prelude.nix { };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Dotnet {#dotnet}
|
||||
# Dotnet
|
||||
|
||||
## Local Development Workflow {#local-development-workflow}
|
||||
## Local Development Workflow
|
||||
|
||||
For local development, it's recommended to use nix-shell to create a dotnet environment:
|
||||
|
||||
@@ -16,7 +16,7 @@ mkShell {
|
||||
}
|
||||
```
|
||||
|
||||
### Using many sdks in a workflow {#using-many-sdks-in-a-workflow}
|
||||
### Using many sdks in a workflow
|
||||
|
||||
It's very likely that more than one sdk will be needed on a given project. Dotnet provides several different frameworks (E.g dotnetcore, aspnetcore, etc.) as well as many versions for a given framework. Normally, dotnet is able to fetch a framework and install it relative to the executable. However, this would mean writing to the nix store in nixpkgs, which is read-only. To support the many-sdk use case, one can compose an environment using `dotnetCorePackages.combinePackages`:
|
||||
|
||||
@@ -28,7 +28,8 @@ mkShell {
|
||||
packages = [
|
||||
(with dotnetCorePackages; combinePackages [
|
||||
sdk_3_1
|
||||
sdk_5_0
|
||||
sdk_3_0
|
||||
sdk_2_1
|
||||
])
|
||||
];
|
||||
}
|
||||
@@ -36,7 +37,7 @@ mkShell {
|
||||
|
||||
This will produce a dotnet installation that has the dotnet 3.1, 3.0, and 2.1 sdk. The first sdk listed will have it's cli utility present in the resulting environment. Example info output:
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ dotnet --info
|
||||
.NET Core SDK (reflecting any global.json):
|
||||
Version: 3.1.101
|
||||
@@ -59,54 +60,16 @@ $ dotnet --info
|
||||
Microsoft.NETCore.App 3.1.1 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.NETCore.App]
|
||||
```
|
||||
|
||||
## dotnet-sdk vs dotnetCorePackages.sdk {#dotnet-sdk-vs-dotnetcorepackages.sdk}
|
||||
## dotnet-sdk vs dotnetCorePackages.sdk
|
||||
|
||||
The `dotnetCorePackages.sdk_X_Y` is preferred over the old dotnet-sdk as both major and minor version are very important for a dotnet environment. If a given minor version isn't present (or was changed), then this will likely break your ability to build a project.
|
||||
|
||||
## dotnetCorePackages.sdk vs dotnetCorePackages.runtime vs dotnetCorePackages.aspnetcore {#dotnetcorepackages.sdk-vs-dotnetcorepackages.runtime-vs-dotnetcorepackages.aspnetcore}
|
||||
## dotnetCorePackages.sdk vs dotnetCorePackages.net vs dotnetCorePackages.netcore vs dotnetCorePackages.aspnetcore
|
||||
|
||||
The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given version. The `runtime` and `aspnetcore` packages are meant to serve as minimal runtimes to deploy alongside already built applications.
|
||||
The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given version. The `net`, `netcore` and `aspnetcore` packages are meant to serve as minimal runtimes to deploy alongside already built applications. For runtime versions >= .NET 5 `net` is used while `netcore` is used for older .NET Core runtime version.
|
||||
|
||||
## Packaging a Dotnet Application {#packaging-a-dotnet-application}
|
||||
## Packaging a Dotnet Application
|
||||
|
||||
To package Dotnet applications, you can use `buildDotnetModule`. This has similar arguments to `stdenv.mkDerivation`, with the following additions:
|
||||
Ideally, we would like to build against the sdk, then only have the dotnet runtime available in the runtime closure.
|
||||
|
||||
* `projectFile` has to be used for specifying the dotnet project file relative to the source root. These usually have `.sln` or `.csproj` file extensions.
|
||||
* `nugetDeps` has to be used to specify the NuGet dependency file. Unfortunately, these cannot be deterministically fetched without a lockfile. This file should be generated using `nuget-to-nix` tool, which is available in nixpkgs.
|
||||
* `executables` is used to specify which executables get wrapped to `$out/bin`, relative to `$out/lib/$pname`. If this is unset, all executables generated will get installed. If you do not want to install any, set this to `[]`.
|
||||
* `runtimeDeps` is used to wrap libraries into `LD_LIBRARY_PATH`. This is how dotnet usually handles runtime dependencies.
|
||||
* `buildType` is used to change the type of build. Possible values are `Release`, `Debug`, etc. By default, this is set to `Release`.
|
||||
* `dotnet-sdk` is useful in cases where you need to change what dotnet SDK is being used.
|
||||
* `dotnet-runtime` is useful in cases where you need to change what dotnet runtime is being used. This can be either a regular dotnet runtime, or an aspnetcore.
|
||||
* `dotnet-test-sdk` is useful in cases where unit tests expect a different dotnet SDK. By default, this is set to the `dotnet-sdk` attribute.
|
||||
* `testProjectFile` is useful in cases where the regular project file does not contain the unit tests. By default, this is set to the `projectFile` attribute.
|
||||
* `disabledTests` is used to disable running specific unit tests. This gets passed as: `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all unit test frameworks.
|
||||
* `dotnetRestoreFlags` can be used to pass flags to `dotnet restore`.
|
||||
* `dotnetBuildFlags` can be used to pass flags to `dotnet build`.
|
||||
* `dotnetTestFlags` can be used to pass flags to `dotnet test`.
|
||||
* `dotnetInstallFlags` can be used to pass flags to `dotnet install`.
|
||||
* `dotnetFlags` can be used to pass flags to all of the above phases.
|
||||
|
||||
Here is an example `default.nix`, using some of the previously discussed arguments:
|
||||
```nix
|
||||
{ lib, buildDotnetModule, dotnetCorePackages, ffmpeg }:
|
||||
|
||||
buildDotnetModule rec {
|
||||
pname = "someDotnetApplication";
|
||||
version = "0.1";
|
||||
|
||||
src = ./.;
|
||||
|
||||
projectFile = "src/project.sln";
|
||||
nugetDeps = ./deps.nix; # File generated with `nuget-to-nix path/to/src > deps.nix`.
|
||||
|
||||
dotnet-sdk = dotnetCorePackages.sdk_3_1;
|
||||
dotnet-runtime = dotnetCorePackages.net_5_0;
|
||||
dotnetFlags = [ "--runtime linux-x64" ];
|
||||
|
||||
executables = [ "foo" ]; # This wraps "$out/lib/$pname/foo" to `$out/bin/foo`.
|
||||
executables = []; # Don't install any executables.
|
||||
|
||||
runtimeDeps = [ ffmpeg ]; # This will wrap ffmpeg's library path into `LD_LIBRARY_PATH`.
|
||||
}
|
||||
```
|
||||
TODO: Create closure-friendly way to package dotnet applications
|
||||
|
||||
@@ -27,14 +27,16 @@ Modes of use of `emscripten`:
|
||||
* dev-shell for zlib implementation hacking:
|
||||
* `nix-shell -A emscriptenPackages.zlib`
|
||||
|
||||
## Imperative usage {#imperative-usage}
|
||||
|
||||
## Imperative usage
|
||||
|
||||
A few things to note:
|
||||
|
||||
* `export EMCC_DEBUG=2` is nice for debugging
|
||||
* `~/.emscripten`, the build artifact cache sometimes creates issues and needs to be removed from time to time
|
||||
|
||||
## Declarative usage {#declarative-usage}
|
||||
|
||||
## Declarative usage
|
||||
|
||||
Let's see two different examples from `pkgs/top-level/emscripten-packages.nix`:
|
||||
|
||||
@@ -48,7 +50,7 @@ A special requirement of the `pkgs.buildEmscriptenPackage` is the `doCheck = tru
|
||||
* Use `export EMCC_DEBUG=2` from within a emscriptenPackage's `phase` to get more detailed debug output what is going wrong.
|
||||
* ~/.emscripten cache is requiring us to set `HOME=$TMPDIR` in individual phases. This makes compilation slower but also makes it more deterministic.
|
||||
|
||||
### Usage 1: pkgs.zlib.override {#usage-1-pkgs.zlib.override}
|
||||
### Usage 1: pkgs.zlib.override
|
||||
|
||||
This example uses `zlib` from nixpkgs but instead of compiling **C** to **ELF** it compiles **C** to **JS** since we were using `pkgs.zlib.override` and changed stdenv to `pkgs.emscriptenStdenv`. A few adaptions and hacks were set in place to make it working. One advantage is that when `pkgs.zlib` is updated, it will automatically update this package as well. However, this can also be the downside...
|
||||
|
||||
@@ -108,7 +110,7 @@ See the `zlib` example:
|
||||
'';
|
||||
});
|
||||
|
||||
### Usage 2: pkgs.buildEmscriptenPackage {#usage-2-pkgs.buildemscriptenpackage}
|
||||
### Usage 2: pkgs.buildEmscriptenPackage
|
||||
|
||||
This `xmlmirror` example features a emscriptenPackage which is defined completely from this context and no `pkgs.zlib.override` is used.
|
||||
|
||||
@@ -163,7 +165,7 @@ This `xmlmirror` example features a emscriptenPackage which is defined completel
|
||||
'';
|
||||
};
|
||||
|
||||
### Declarative debugging {#declarative-debugging}
|
||||
### Declarative debugging
|
||||
|
||||
Use `nix-shell -I nixpkgs=/some/dir/nixpkgs -A emscriptenPackages.libz` and from there you can go trough the individual steps. This makes it easy to build a good `unit test` or list the files of the project.
|
||||
|
||||
@@ -175,7 +177,7 @@ Use `nix-shell -I nixpkgs=/some/dir/nixpkgs -A emscriptenPackages.libz` and from
|
||||
6. `buildPhase`
|
||||
7. ... happy hacking...
|
||||
|
||||
## Summary {#summary}
|
||||
## Summary
|
||||
|
||||
Using this toolchain makes it easy to leverage `nix` from NixOS, MacOSX or even Windows (WSL+ubuntu+nix). This toolchain is reproducible, behaves like the rest of the packages from nixpkgs and contains a set of well working examples to learn and adapt from.
|
||||
|
||||
|
||||
@@ -8,30 +8,12 @@ Programs in the GNOME universe are written in various languages but they all use
|
||||
|
||||
[GSettings](https://developer.gnome.org/gio/stable/GSettings.html) API is often used for storing settings. GSettings schemas are required, to know the type and other metadata of the stored values. GLib looks for `glib-2.0/schemas/gschemas.compiled` files inside the directories of `XDG_DATA_DIRS`.
|
||||
|
||||
On Linux, GSettings API is implemented using [dconf](https://wiki.gnome.org/Projects/dconf) backend. You will need to add `dconf` [GIO module](#ssec-gnome-gio-modules) to `GIO_EXTRA_MODULES` variable, otherwise the `memory` backend will be used and the saved settings will not be persistent.
|
||||
On Linux, GSettings API is implemented using [dconf](https://wiki.gnome.org/Projects/dconf) backend. You will need to add `dconf` GIO module to `GIO_EXTRA_MODULES` variable, otherwise the `memory` backend will be used and the saved settings will not be persistent.
|
||||
|
||||
Last you will need the dconf database D-Bus service itself. You can enable it using `programs.dconf.enable`.
|
||||
|
||||
Some applications will also require `gsettings-desktop-schemas` for things like reading proxy configuration or user interface customization. This dependency is often not mentioned by upstream, you should grep for `org.gnome.desktop` and `org.gnome.system` to see if the schemas are needed.
|
||||
|
||||
### GIO modules {#ssec-gnome-gio-modules}
|
||||
|
||||
GLib’s [GIO](https://developer.gnome.org/gio/stable/ch01.html) library supports several [extension points](https://developer.gnome.org/gio/stable/extending-gio.html). Notably, they allow:
|
||||
|
||||
* implementing settings backends (already [mentioned](#ssec-gnome-settings))
|
||||
* adding TLS support
|
||||
* proxy settings
|
||||
* virtual file systems
|
||||
|
||||
The modules are typically installed to `lib/gio/modules/` directory of a package and you need to add them to `GIO_EXTRA_MODULES` if you need any of those features.
|
||||
|
||||
In particular, we recommend:
|
||||
|
||||
* adding `dconf.lib` for any software on Linux that reads [GSettings](#ssec-gnome-settings) (even transitivily through e.g. GTK’s file manager)
|
||||
* adding `glib-networking` for any software that accesses network using GIO or libsoup – glib-networking contains a module that implements TLS support and loads system-wide proxy settings
|
||||
|
||||
To allow software to use various virtual file systems, `gvfs` package can be also added. But that is usually an optional feature so we typically use `gvfs` from the system (e.g. installed globally using NixOS module).
|
||||
|
||||
### GdkPixbuf loaders {#ssec-gnome-gdk-pixbuf-loaders}
|
||||
|
||||
GTK applications typically use [GdkPixbuf](https://developer.gnome.org/gdk-pixbuf/stable/) to load images. But `gdk-pixbuf` package only supports basic bitmap formats like JPEG, PNG or TIFF, requiring to use third-party loader modules for other formats. This is especially painful since GTK itself includes SVG icons, which cannot be rendered without a loader provided by `librsvg`.
|
||||
@@ -102,7 +84,7 @@ For convenience, it also adds `dconf.lib` for a GIO module implementing a GSetti
|
||||
|
||||
- []{#ssec-gnome-hooks-gobject-introspection} `gobject-introspection` setup hook populates `GI_TYPELIB_PATH` variable with `lib/girepository-1.0` directories of dependencies, which is then added to wrapper by `wrapGAppsHook`. It also adds `share` directories of dependencies to `XDG_DATA_DIRS`, which is intended to promote GIR files but it also [pollutes the closures](https://github.com/NixOS/nixpkgs/issues/32790) of packages using `wrapGAppsHook`.
|
||||
|
||||
::: {.warning}
|
||||
::: warning
|
||||
The setup hook [currently](https://github.com/NixOS/nixpkgs/issues/56943) does not work in expressions with `strictDeps` enabled, like Python packages. In those cases, you will need to disable it with `strictDeps = false;`.
|
||||
:::
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ In the following is an example expression using `buildGoModule`, the following a
|
||||
|
||||
- `vendorSha256`: is the hash of the output of the intermediate fetcher derivation. `vendorSha256` can also take `null` as an input. When `null` is used as a value, rather than fetching the dependencies and vendoring them, we use the vendoring included within the source repo. If you'd like to not have to update this field on dependency changes, run `go mod vendor` in your source repo and set `vendorSha256 = null;`
|
||||
- `runVend`: runs the vend command to generate the vendor directory. This is useful if your code depends on c code and go mod tidy does not include the needed sources to build.
|
||||
- `proxyVendor`: Fetches (go mod download) and proxies the vendor directory. This is useful if any dependency has case-insensitive conflicts which will produce platform dependant `vendorSha256` checksums.
|
||||
|
||||
```nix
|
||||
pet = buildGoModule rec {
|
||||
@@ -45,7 +44,7 @@ pet = buildGoModule rec {
|
||||
|
||||
The function `buildGoPackage` builds legacy Go programs, not supporting Go modules.
|
||||
|
||||
### Example for `buildGoPackage` {#example-for-buildgopackage}
|
||||
### Example for `buildGoPackage`
|
||||
|
||||
In the following is an example expression using buildGoPackage, the following arguments are of special significance to the function:
|
||||
|
||||
@@ -113,31 +112,23 @@ done
|
||||
|
||||
Both `buildGoModule` and `buildGoPackage` can be tweaked to behave slightly differently, if the following attributes are used:
|
||||
|
||||
### `ldflags` {#var-go-ldflags}
|
||||
### `buildFlagsArray` and `buildFlags`: {#ex-goBuildFlags-noarray}
|
||||
|
||||
Arguments to pass to the Go linker tool via the `-ldflags` argument of `go build`. The most common use case for this argument is to make the resulting executable aware of its own version. For example:
|
||||
These attributes set build flags supported by `go build`. We recommend using `buildFlagsArray`. The most common use case of these attributes is to make the resulting executable aware of its own version. For example:
|
||||
|
||||
```nix
|
||||
ldflags = [
|
||||
"-s" "-w"
|
||||
"-X main.Version=${version}"
|
||||
"-X main.Commit=${version}"
|
||||
];
|
||||
```
|
||||
|
||||
### `tags` {#var-go-tags}
|
||||
|
||||
Arguments to pass to the Go via the `-tags` argument of `go build`. For example:
|
||||
|
||||
```nix
|
||||
tags = [
|
||||
"production"
|
||||
"sqlite"
|
||||
buildFlagsArray = [
|
||||
# Note: single quotes are not needed.
|
||||
"-ldflags=-X main.Version=${version} -X main.Commit=${version}"
|
||||
];
|
||||
```
|
||||
|
||||
```nix
|
||||
tags = [ "production" ] ++ lib.optionals withSqlite [ "sqlite" ];
|
||||
buildFlagsArray = ''
|
||||
-ldflags=
|
||||
-X main.Version=${version}
|
||||
-X main.Commit=${version}
|
||||
'';
|
||||
```
|
||||
|
||||
### `deleteVendor` {#var-go-deleteVendor}
|
||||
@@ -146,4 +137,4 @@ Removes the pre-existing vendor directory. This should only be used if the depen
|
||||
|
||||
### `subPackages` {#var-go-subPackages}
|
||||
|
||||
Limits the builder from building child packages that have not been listed. If `subPackages` is not specified, all child packages will be built.
|
||||
Limits the builder from building child packages that have not been listed. If <varname>subPackages</varname> is not specified, all child packages will be built.
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
# Hy {#sec-language-hy}
|
||||
|
||||
## Installation {#ssec-hy-installation}
|
||||
|
||||
### Installation without packages {#installation-without-packages}
|
||||
|
||||
You can install `hy` via nix-env or by adding it to `configuration.nix` by reffering to it as a `hy` attribute. This kind of installation adds `hy` to your environment and it succesfully works with `python3`.
|
||||
|
||||
::: {.caution}
|
||||
Packages that are installed with your python derivation, are not accesible by `hy` this way.
|
||||
:::
|
||||
|
||||
### Installation with packages {#installation-with-packages}
|
||||
|
||||
Creating `hy` derivation with custom `python` packages is really simple and similar to the way that python does it. Attribute `hy` provides function `withPackages` that creates custom `hy` derivation with specified packages.
|
||||
|
||||
For example if you want to create shell with `matplotlib` and `numpy`, you can do it like so:
|
||||
|
||||
```ShellSession
|
||||
$ nix-shell -p "hy.withPackages (ps: with ps; [ numpy matplotlib ])"
|
||||
```
|
||||
|
||||
Or if you want to extend your `configuration.nix`:
|
||||
```nix
|
||||
{ # ...
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
(hy.withPackages (py-packages: with py-packages; [ numpy matplotlib ]))
|
||||
];
|
||||
}
|
||||
```
|
||||
@@ -1,10 +1,10 @@
|
||||
# Idris {#idris}
|
||||
|
||||
## Installing Idris {#installing-idris}
|
||||
## Installing Idris
|
||||
|
||||
The easiest way to get a working idris version is to install the `idris` attribute:
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ # On NixOS
|
||||
$ nix-env -i nixos.idris
|
||||
$ # On non-NixOS
|
||||
@@ -21,7 +21,7 @@ self: super: {
|
||||
|
||||
And then:
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ # On NixOS
|
||||
$ nix-env -iA nixos.myIdris
|
||||
$ # On non-NixOS
|
||||
@@ -29,8 +29,7 @@ $ nix-env -iA nixpkgs.myIdris
|
||||
```
|
||||
|
||||
To see all available Idris packages:
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ # On NixOS
|
||||
$ nix-env -qaPA nixos.idrisPackages
|
||||
$ # On non-NixOS
|
||||
@@ -38,23 +37,22 @@ $ nix-env -qaPA nixpkgs.idrisPackages
|
||||
```
|
||||
|
||||
Similarly, entering a `nix-shell`:
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])'
|
||||
```
|
||||
|
||||
## Starting Idris with library support {#starting-idris-with-library-support}
|
||||
## Starting Idris with library support
|
||||
|
||||
To have access to these libraries in idris, call it with an argument `-p <library name>` for each library:
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])'
|
||||
[nix-shell:~]$ idris -p contrib -p pruviloj
|
||||
```
|
||||
|
||||
A listing of all available packages the Idris binary has access to is available via `--listlibs`:
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ idris --listlibs
|
||||
00prelude-idx.ibc
|
||||
pruviloj
|
||||
@@ -66,7 +64,7 @@ prelude
|
||||
00contrib-idx.ibc
|
||||
```
|
||||
|
||||
## Building an Idris project with Nix {#building-an-idris-project-with-nix}
|
||||
## 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`:
|
||||
|
||||
@@ -107,7 +105,7 @@ build-idris-package {
|
||||
|
||||
Assuming this file is saved as `yaml.nix`, it's buildable using
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ nix-build -E '(import <nixpkgs> {}).idrisPackages.callPackage ./yaml.nix {}'
|
||||
```
|
||||
|
||||
@@ -123,11 +121,11 @@ with import <nixpkgs> {};
|
||||
|
||||
in another file (say `default.nix`) to be able to build it with
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ nix-build -A yaml
|
||||
```
|
||||
|
||||
## Passing options to `idris` commands {#passing-options-to-idris-commands}
|
||||
## Passing options to `idris` commands
|
||||
|
||||
The `build-idris-package` function provides also optional input values to set additional options for the used `idris` commands.
|
||||
|
||||
|
||||
@@ -12,21 +12,17 @@
|
||||
<xi:include href="coq.section.xml" />
|
||||
<xi:include href="crystal.section.xml" />
|
||||
<xi:include href="dhall.section.xml" />
|
||||
<xi:include href="dotnet.section.xml" />
|
||||
<xi:include href="emscripten.section.xml" />
|
||||
<xi:include href="gnome.section.xml" />
|
||||
<xi:include href="go.section.xml" />
|
||||
<xi:include href="haskell.section.xml" />
|
||||
<xi:include href="hy.section.xml" />
|
||||
<xi:include href="idris.section.xml" />
|
||||
<xi:include href="ios.section.xml" />
|
||||
<xi:include href="java.section.xml" />
|
||||
<xi:include href="javascript.section.xml" />
|
||||
<xi:include href="lua.section.xml" />
|
||||
<xi:include href="maven.section.xml" />
|
||||
<xi:include href="nim.section.xml" />
|
||||
<xi:include href="node.section.xml" />
|
||||
<xi:include href="ocaml.section.xml" />
|
||||
<xi:include href="octave.section.xml" />
|
||||
<xi:include href="perl.section.xml" />
|
||||
<xi:include href="php.section.xml" />
|
||||
<xi:include href="python.section.xml" />
|
||||
|
||||
@@ -20,8 +20,8 @@ Hydra.
|
||||
|
||||
The Xcode build environment implements a number of features.
|
||||
|
||||
## Deploying a proxy component wrapper exposing Xcode {#deploying-a-proxy-component-wrapper-exposing-xcode}
|
||||
|
||||
Deploying a proxy component wrapper exposing Xcode
|
||||
--------------------------------------------------
|
||||
The first use case is deploying a Nix package that provides symlinks to the Xcode
|
||||
installation on the host system. This package can be used as a build input to
|
||||
any build function implemented in the Nix expression language that requires
|
||||
@@ -55,8 +55,8 @@ lrwxr-xr-x 1 sander staff 61 1 jan 1970 xcodebuild -> /Applications/Xcode.a
|
||||
lrwxr-xr-x 1 sander staff 14 1 jan 1970 xcrun -> /usr/bin/xcrun
|
||||
```
|
||||
|
||||
## Building an iOS application {#building-an-ios-application}
|
||||
|
||||
Building an iOS application
|
||||
---------------------------
|
||||
We can build an iOS app executable for the simulator, or an IPA/xcarchive file
|
||||
for release purposes, e.g. ad-hoc, enterprise or store installations, by
|
||||
executing the `xcodeenv.buildApp {}` function:
|
||||
@@ -99,7 +99,6 @@ xcodeenv.buildApp {
|
||||
```
|
||||
|
||||
The above function takes a variety of parameters:
|
||||
|
||||
* The `name` and `src` parameters are mandatory and specify the name of the app
|
||||
and the location where the source code resides
|
||||
* `sdkVersion` specifies which version of the iOS SDK to use.
|
||||
@@ -152,8 +151,8 @@ the `xcodeenv.composeXcodeWrapper {}` function takes. For example, the
|
||||
`xcodeBaseDir` parameter can be overridden to refer to a different Xcode
|
||||
version.
|
||||
|
||||
## Spawning simulator instances {#spawning-simulator-instances}
|
||||
|
||||
Spawning simulator instances
|
||||
----------------------------
|
||||
In addition to building iOS apps, we can also automatically spawn simulator
|
||||
instances:
|
||||
|
||||
@@ -214,8 +213,8 @@ xcode.simulateApp {
|
||||
By providing the result of an `xcode.buildApp {}` function and configuring the
|
||||
app bundle id, the app gets deployed automatically and started.
|
||||
|
||||
## Troubleshooting {#troubleshooting}
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
In some rare cases, it may happen that after a failure, changes are not picked
|
||||
up. Most likely, this is caused by a derived data cache that Xcode maintains.
|
||||
To wipe it you can run:
|
||||
|
||||
@@ -72,15 +72,6 @@ in
|
||||
...
|
||||
```
|
||||
|
||||
You can also specify what JDK your JRE should be based on, for example
|
||||
selecting a 'headless' build to avoid including a link to GTK+:
|
||||
|
||||
```nix
|
||||
my_jre = pkgs.jre_minimal.override {
|
||||
jdk = jdk11_headless;
|
||||
};
|
||||
```
|
||||
|
||||
Note all JDKs passthru `home`, so if your application requires
|
||||
environment variables like `JAVA_HOME` being set, that can be done in a
|
||||
generic fashion with the `--set` argument of `makeWrapper`:
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
# Javascript {#language-javascript}
|
||||
|
||||
## Introduction {#javascript-introduction}
|
||||
|
||||
This contains instructions on how to package javascript applications.
|
||||
|
||||
The various tools available will be listed in the [tools-overview](#javascript-tools-overview). Some general principles for packaging will follow. Finally some tool specific instructions will be given.
|
||||
|
||||
## Getting unstuck / finding code examples
|
||||
|
||||
If you find you are lacking inspiration for packing javascript applications, the links below might prove useful.
|
||||
Searching online for prior art can be helpful if you are running into solved problems.
|
||||
|
||||
### Github
|
||||
|
||||
- Searching Nix files for `mkYarnPackage`: <https://github.com/search?q=mkYarnPackage+language%3ANix&type=code>
|
||||
|
||||
- Searching just `flake.nix` files for `mkYarnPackage`: <https://github.com/search?q=mkYarnPackage+filename%3Aflake.nix&type=code>
|
||||
|
||||
### Gitlab
|
||||
|
||||
- Searching Nix files for `mkYarnPackage`: <https://gitlab.com/search?scope=blobs&search=mkYarnPackage+extension%3Anix>
|
||||
|
||||
- Searching just `flake.nix` files for `mkYarnPackage`: <https://gitlab.com/search?scope=blobs&search=mkYarnPackage+filename%3Aflake.nix>
|
||||
|
||||
## Tools overview {#javascript-tools-overview}
|
||||
|
||||
## General principles {#javascript-general-principles}
|
||||
|
||||
The following principles are given in order of importance with potential exceptions.
|
||||
|
||||
### Try to use the same node version used upstream {#javascript-upstream-node-version}
|
||||
|
||||
It is often not documented which node version is used upstream, but if it is, try to use the same version when packaging.
|
||||
|
||||
This can be a problem if upstream is using the latest and greatest and you are trying to use an earlier version of node. Some cryptic errors regarding V8 may appear.
|
||||
|
||||
An exception to this:
|
||||
|
||||
### Try to respect the package manager originally used by upstream (and use the upstream lock file) {#javascript-upstream-package-manager}
|
||||
|
||||
A lock file (package-lock.json, yarn.lock...) is supposed to make reproducible installations of node_modules for each tool.
|
||||
|
||||
Guidelines of package managers, recommend to commit those lock files to the repos. If a particular lock file is present, it is a strong indication of which package manager is used upstream.
|
||||
|
||||
It's better to try to use a nix tool that understand the lock file. Using a different tool might give you hard to understand error because different packages have been installed. An example of problems that could arise can be found [here](https://github.com/NixOS/nixpkgs/pull/126629). Upstream uses npm, but this is an attempt to package it with yarn2nix (that uses yarn.lock)
|
||||
|
||||
Using a different tool forces to commit a lock file to the repository. Those files are fairly large, so when packaging for nixpkgs, this approach does not scale well.
|
||||
|
||||
Exceptions to this rule are:
|
||||
|
||||
- when you encounter one of the bugs from a nix tool. In each of the tool specific instructions, known problems will be detailed. If you have a problem with a particular tool, then it's best to try another tool, even if this means you will have to recreate a lock file and commit it to nixpkgs. In general yarn2nix has less known problems and so a simple search in nixpkgs will reveal many yarn.lock files committed
|
||||
- Some lock files contain particular version of a package that has been pulled off npm for some reason. In that case, you can recreate upstream lock (by removing the original and `npm install`, `yarn`, ...) and commit this to nixpkgs.
|
||||
- The only tool that supports workspaces (a feature of npm that helps manage sub-directories with different package.json from a single top level package.json) is yarn2nix. If upstream has workspaces you should try yarn2nix.
|
||||
|
||||
### Try to use upstream package.json {#javascript-upstream-package-json}
|
||||
|
||||
Exceptions to this rule are
|
||||
|
||||
- Sometimes the upstream repo assumes some dependencies be installed globally. In that case you can add them manually to the upstream package.json (`yarn add xxx` or `npm install xxx`, ...). Dependencies that are installed locally can be executed with `npx` for cli tools. (e.g. `npx postcss ...`, this is how you can call those dependencies in the phases).
|
||||
- Sometimes there is a version conflict between some dependency requirements. In that case you can fix a version (by removing the `^`).
|
||||
- Sometimes the script defined in the package.json does not work as is. Some scripts for example use cli tools that might not be available, or cd in directory with a different package.json (for workspaces notably). In that case, it's perfectly fine to look at what the particular script is doing and break this down in the phases. In the build script you can see `build:*` calling in turns several other build scripts like `build:ui` or `build:server`. If one of those fails, you can try to separate those into:
|
||||
|
||||
```Shell
|
||||
yarn build:ui
|
||||
yarn build:server
|
||||
# OR
|
||||
npm run build:ui
|
||||
npm run build:server
|
||||
```
|
||||
|
||||
when you need to override a package.json. It's nice to use the one from the upstream src and do some explicit override. Here is an example.
|
||||
|
||||
```nix
|
||||
patchedPackageJSON = final.runCommand "package.json" { } ''
|
||||
${jq}/bin/jq '.version = "0.4.0" |
|
||||
.devDependencies."@jsdoc/cli" = "^0.2.5"
|
||||
${sonar-src}/package.json > $out
|
||||
'';
|
||||
```
|
||||
|
||||
you will still need to commit the modified version of the lock files, but at least the overrides are explicit for everyone to see.
|
||||
|
||||
### Using node_modules directly {#javascript-using-node_modules}
|
||||
|
||||
each tool has an abstraction to just build the node_modules (dependencies) directory. you can always use the stdenv.mkDerivation with the node_modules to build the package (symlink the node_modules directory and then use the package build command). the node_modules abstraction can be also used to build some web framework frontends. For an example of this see how [plausible](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/web-apps/plausible/default.nix) is built. mkYarnModules to make the derivation containing node_modules. Then when building the frontend you can just symlink the node_modules directory
|
||||
|
||||
## javascript packages inside nixpkgs {#javascript-packages-nixpkgs}
|
||||
|
||||
The `pkgs/development/node-packages` folder contains a generated collection of
|
||||
[NPM packages](https://npmjs.com/) that can be installed with the Nix package
|
||||
manager.
|
||||
|
||||
As a rule of thumb, the package set should only provide _end user_ software
|
||||
packages, such as command-line utilities. Libraries should only be added to the
|
||||
package set if there is a non-NPM package that requires it.
|
||||
|
||||
When it is desired to use NPM libraries in a development project, use the
|
||||
`node2nix` generator directly on the `package.json` configuration file of the
|
||||
project.
|
||||
|
||||
The package set provides support for the official stable Node.js versions.
|
||||
The latest stable LTS release in `nodePackages`, as well as the latest stable
|
||||
Current release in `nodePackages_latest`.
|
||||
|
||||
If your package uses native addons, you need to examine what kind of native
|
||||
build system it uses. Here are some examples:
|
||||
|
||||
- `node-gyp`
|
||||
- `node-gyp-builder`
|
||||
- `node-pre-gyp`
|
||||
|
||||
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`
|
||||
requires `node-gyp-build`, so [we override](https://github.com/NixOS/nixpkgs/blob/32f5e5da4a1b3f0595527f5195ac3a91451e9b56/pkgs/development/node-packages/default.nix#L37-L40) its expression in [`default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/default.nix):
|
||||
|
||||
```nix
|
||||
dat = super.dat.override {
|
||||
buildInputs = [ self.node-gyp-build pkgs.libtool pkgs.autoconf pkgs.automake ];
|
||||
meta.broken = since "12";
|
||||
};
|
||||
```
|
||||
|
||||
To add a package from NPM to nixpkgs:
|
||||
|
||||
1. Modify `pkgs/development/node-packages/node-packages.json` to add, update
|
||||
or remove package entries to have it included in `nodePackages` and
|
||||
`nodePackages_latest`.
|
||||
2. Run the script: `cd pkgs/development/node-packages && ./generate.sh`.
|
||||
3. Build your new package to test your changes:
|
||||
`cd /path/to/nixpkgs && nix-build -A nodePackages.<new-or-updated-package>`.
|
||||
To build against the latest stable Current Node.js version (e.g. 14.x):
|
||||
`nix-build -A nodePackages_latest.<new-or-updated-package>`
|
||||
4. Add and commit all modified and generated files.
|
||||
|
||||
For more information about the generation process, consult the
|
||||
[README.md](https://github.com/svanderburg/node2nix) file of the `node2nix`
|
||||
tool.
|
||||
|
||||
## Tool specific instructions {#javascript-tool-specific}
|
||||
|
||||
### node2nix {#javascript-node2nix}
|
||||
|
||||
#### Preparation {#javascript-node2nix-preparation}
|
||||
|
||||
you will need to generate a nix expression for the dependencies
|
||||
|
||||
- don't forget the `-l package-lock.json` if there is a lock file
|
||||
- Most probably you will need the `--development` to include the `devDependencies`
|
||||
|
||||
so the command will most likely be
|
||||
`node2nix --development -l package-lock.json`
|
||||
|
||||
[link to the doc in the repo](https://github.com/svanderburg/node2nix)
|
||||
|
||||
#### Pitfalls {#javascript-node2nix-pitfalls}
|
||||
|
||||
- if upstream package.json does not have a "version" attribute, node2nix will crash. You will need to add it like shown in [the package.json section](#javascript-upstream-package-json)
|
||||
- node2nix has some [bugs](https://github.com/svanderburg/node2nix/issues/238). related to working with lock files from npm distributed with nodejs-16_x
|
||||
- node2nix does not like missing packages from npm. If you see something like `Cannot resolve version: vue-loader-v16@undefined` then you might want to try another tool. The package might have been pulled off of npm.
|
||||
|
||||
### yarn2nix {#javascript-yarn2nix}
|
||||
|
||||
#### Preparation {#javascript-yarn2nix-preparation}
|
||||
|
||||
you will need at least a yarn.lock and yarn.nix file
|
||||
|
||||
- generate a yarn.lock in upstream if it is not already there
|
||||
- `yarn2nix > yarn.nix` will generate the dependencies in a nix format
|
||||
|
||||
#### mkYarnPackage {#javascript-yarn2nix-mkYarnPackage}
|
||||
|
||||
this will by default try to generate a binary. For package only generating static assets (Svelte, Vue, React...), you will need to explicitly override the build step with your instructions. It's important to use the `--offline` flag. For example if you script is `"build": "something"` in package.json use
|
||||
|
||||
```nix
|
||||
buildPhase = ''
|
||||
yarn build --offline
|
||||
'';
|
||||
```
|
||||
|
||||
The dist phase is also trying to build a binary, the only way to override it is with
|
||||
|
||||
```nix
|
||||
distPhase = "true";
|
||||
```
|
||||
|
||||
the configure phase can sometimes fail because it tries to be too clever.
|
||||
One common override is
|
||||
|
||||
```nix
|
||||
configurePhase = "ln -s $node_modules node_modules";
|
||||
```
|
||||
|
||||
#### mkYarnModules {#javascript-yarn2nix-mkYarnModules}
|
||||
|
||||
this will generate a derivation including the node_modules. If you have to build a derivation for an integrated web framework (rails, phoenix..), this is probably the easiest way. [Plausible](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/web-apps/plausible/default.nix#L39) offers a good example of how to do this.
|
||||
|
||||
#### Overriding dependency behavior
|
||||
|
||||
In the `mkYarnPackage` record the property `pkgConfig` can be used to override packages when you encounter problems building.
|
||||
|
||||
For instance, say your package is throwing errors when trying to invoke node-sass: `ENOENT: no such file or directory, scandir '/build/source/node_modules/node-sass/vendor'`
|
||||
|
||||
To fix this we will specify different versions of build inputs to use, as well as some post install steps to get the software built the way we want:
|
||||
|
||||
```nix
|
||||
mkYarnPackage rec {
|
||||
pkgConfig = {
|
||||
node-sass = {
|
||||
buildInputs = with final;[ python libsass pkg-config ];
|
||||
postInstall = ''
|
||||
LIBSASS_EXT=auto yarn --offline run build
|
||||
rm build/config.gypi
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### Pitfalls {#javascript-yarn2nix-pitfalls}
|
||||
|
||||
- if version is missing from upstream package.json, yarn will silently install nothing. In that case, you will need to override package.json as shown in the [package.json section](#javascript-upstream-package-json)
|
||||
|
||||
- having trouble with node-gyp? Try adding these lines to the `yarnPreBuild` steps:
|
||||
|
||||
```nix
|
||||
yarnPreBuild = ''
|
||||
mkdir -p $HOME/.node-gyp/${nodejs.version}
|
||||
echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion
|
||||
ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version}
|
||||
export npm_config_nodedir=${nodejs}
|
||||
'';
|
||||
```
|
||||
|
||||
- The `echo 9` steps comes from this answer: <https://stackoverflow.com/a/49139496>
|
||||
- Exporting the headers in `npm_config_nodedir` comes from this issue: <https://github.com/nodejs/node-gyp/issues/1191#issuecomment-301243919>
|
||||
|
||||
## Outside of nixpkgs {#javascript-outside-nixpkgs}
|
||||
|
||||
There are some other options available that can't be used inside nixpkgs. Those other options are written in nix. Importing them in nixpkgs will require moving the source code into nixpkgs. Using [Import From Derivation](https://nixos.wiki/wiki/Import_From_Derivation) is not allowed in hydra at present. If you are packaging something outside nixpkgs, those can be considered
|
||||
|
||||
### npmlock2nix {#javascript-npmlock2nix}
|
||||
|
||||
[npmlock2nix](https://github.com/nix-community/npmlock2nix) aims at building node_modules without code generation. It hasn't reached v1 yet, the api might be subject to change.
|
||||
|
||||
#### Pitfalls {#javascript-npmlock2nix-pitfalls}
|
||||
|
||||
- there are some [problems with npm v7](https://github.com/tweag/npmlock2nix/issues/45).
|
||||
|
||||
### nix-npm-buildpackage {#javascript-nix-npm-buildpackage}
|
||||
|
||||
[nix-npm-buildpackage](https://github.com/serokell/nix-npm-buildpackage) aims at building node_modules without code generation. It hasn't reached v1 yet, the api might change. It supports both package-lock.json and yarn.lock.
|
||||
|
||||
#### Pitfalls {#javascript-nix-npm-buildpackage-pitfalls}
|
||||
|
||||
- there are some [problems with npm v7](https://github.com/serokell/nix-npm-buildpackage/issues/33).
|
||||
@@ -1,8 +1,8 @@
|
||||
# User’s Guide to Lua Infrastructure {#users-guide-to-lua-infrastructure}
|
||||
# User's Guide to Lua Infrastructure {#users-guide-to-lua-infrastructure}
|
||||
|
||||
## Using Lua {#using-lua}
|
||||
## Using Lua
|
||||
|
||||
### Overview of Lua {#overview-of-lua}
|
||||
### Overview of Lua
|
||||
|
||||
Several versions of the Lua interpreter are available: luajit, lua 5.1, 5.2, 5.3.
|
||||
The attribute `lua` refers to the default interpreter, it is also possible to refer to specific versions, e.g. `lua5_2` refers to Lua 5.2.
|
||||
@@ -17,31 +17,27 @@ The main package set contains aliases to these package sets, e.g.
|
||||
`luaPackages` refers to `lua5_1.pkgs` and `lua52Packages` to
|
||||
`lua5_2.pkgs`.
|
||||
|
||||
### Installing Lua and packages {#installing-lua-and-packages}
|
||||
### Installing Lua and packages
|
||||
|
||||
#### Lua environment defined in separate `.nix` file {#lua-environment-defined-in-separate-.nix-file}
|
||||
#### Lua environment defined in separate `.nix` file
|
||||
|
||||
Create a file, e.g. `build.nix`, with the following expression
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
|
||||
lua5_2.withPackages (ps: with ps; [ busted luafilesystem ])
|
||||
```
|
||||
|
||||
and install it in your profile with
|
||||
|
||||
```shell
|
||||
nix-env -if build.nix
|
||||
```
|
||||
Now you can use the Lua interpreter, as well as the extra packages (`busted`,
|
||||
`luafilesystem`) that you added to the environment.
|
||||
|
||||
#### Lua environment defined in `~/.config/nixpkgs/config.nix` {#lua-environment-defined-in-.confignixpkgsconfig.nix}
|
||||
#### Lua environment defined in `~/.config/nixpkgs/config.nix`
|
||||
|
||||
If you prefer to, you could also add the environment as a package override to the Nixpkgs set, e.g.
|
||||
using `config.nix`,
|
||||
|
||||
```nix
|
||||
{ # ...
|
||||
|
||||
@@ -50,16 +46,14 @@ using `config.nix`,
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
and install it in your profile with
|
||||
|
||||
```shell
|
||||
nix-env -iA nixpkgs.myLuaEnv
|
||||
```
|
||||
The environment is installed by referring to the attribute, and considering
|
||||
the `nixpkgs` channel was used.
|
||||
|
||||
#### Lua environment defined in `/etc/nixos/configuration.nix` {#lua-environment-defined-in-etcnixosconfiguration.nix}
|
||||
#### Lua environment defined in `/etc/nixos/configuration.nix`
|
||||
|
||||
For the sake of completeness, here's another example how to install the environment system-wide.
|
||||
|
||||
@@ -72,7 +66,7 @@ For the sake of completeness, here's another example how to install the environm
|
||||
}
|
||||
```
|
||||
|
||||
### How to override a Lua package using overlays? {#how-to-override-a-lua-package-using-overlays}
|
||||
### How to override a Lua package using overlays?
|
||||
|
||||
Use the following overlay template:
|
||||
|
||||
@@ -93,22 +87,18 @@ final: prev:
|
||||
}
|
||||
```
|
||||
|
||||
### Temporary Lua environment with `nix-shell` {#temporary-lua-environment-with-nix-shell}
|
||||
### Temporary Lua environment with `nix-shell`
|
||||
|
||||
|
||||
There are two methods for loading a shell with Lua packages. The first and recommended method
|
||||
is to create an environment with `lua.buildEnv` or `lua.withPackages` and load that. E.g.
|
||||
|
||||
```sh
|
||||
$ nix-shell -p 'lua.withPackages(ps: with ps; [ busted luafilesystem ])'
|
||||
```
|
||||
|
||||
opens a shell from which you can launch the interpreter
|
||||
|
||||
```sh
|
||||
[nix-shell:~] lua
|
||||
```
|
||||
|
||||
The other method, which is not recommended, does not create an environment and requires you to list the packages directly,
|
||||
|
||||
```sh
|
||||
@@ -118,7 +108,7 @@ Again, it is possible to launch the interpreter from the shell.
|
||||
The Lua interpreter has the attribute `pkgs` which contains all Lua libraries for that specific interpreter.
|
||||
|
||||
|
||||
## Developing with Lua {#developing-with-lua}
|
||||
## Developing with Lua
|
||||
|
||||
Now that you know how to get a working Lua environment with Nix, it is time
|
||||
to go forward and start actually developing with Lua. There are two ways to
|
||||
@@ -126,7 +116,7 @@ package lua software, either it is on luarocks and most of it can be taken care
|
||||
of by the luarocks2nix converter or the packaging has to be done manually.
|
||||
Let's present the luarocks way first and the manual one in a second time.
|
||||
|
||||
### Packaging a library on luarocks {#packaging-a-library-on-luarocks}
|
||||
### Packaging a library on luarocks
|
||||
|
||||
[Luarocks.org](www.luarocks.org) is the main repository of lua packages.
|
||||
The site proposes two types of packages, the rockspec and the src.rock
|
||||
@@ -139,15 +129,16 @@ the whitelist maintainers/scripts/luarocks-packages.csv and updated by running m
|
||||
[luarocks2nix](https://github.com/nix-community/luarocks) is a tool capable of generating nix derivations from both rockspec and src.rock (and favors the src.rock).
|
||||
The automation only goes so far though and some packages need to be customized.
|
||||
These customizations go in `pkgs/development/lua-modules/overrides.nix`.
|
||||
For instance if the rockspec defines `external_dependencies`, these need to be manually added to the overrides.nix.
|
||||
For instance if the rockspec defines `external_dependencies`, these need to be manually added in its rockspec file then it won't work.
|
||||
|
||||
You can try converting luarocks packages to nix packages with the command `nix-shell -p luarocks-nix` and then `luarocks nix PKG_NAME`.
|
||||
Nix rely on luarocks to install lua packages, basically it runs:
|
||||
`luarocks make --deps-mode=none --tree $out`
|
||||
|
||||
#### Packaging a library manually {#packaging-a-library-manually}
|
||||
#### Packaging a library manually
|
||||
|
||||
You can develop your package as you usually would, just don't forget to wrap it
|
||||
within a `toLuaModule` call, for instance
|
||||
|
||||
```nix
|
||||
mynewlib = toLuaModule ( stdenv.mkDerivation { ... });
|
||||
```
|
||||
@@ -155,15 +146,16 @@ mynewlib = toLuaModule ( stdenv.mkDerivation { ... });
|
||||
There is also the `buildLuaPackage` function that can be used when lua modules
|
||||
are not packaged for luarocks. You can see a few examples at `pkgs/top-level/lua-packages.nix`.
|
||||
|
||||
## Lua Reference {#lua-reference}
|
||||
## Lua Reference
|
||||
|
||||
### Lua interpreters {#lua-interpreters}
|
||||
### Lua interpreters
|
||||
|
||||
Versions 5.1, 5.2, 5.3 and 5.4 of the lua interpreter are available as
|
||||
respectively `lua5_1`, `lua5_2`, `lua5_3` and `lua5_4`. Luajit is available too.
|
||||
Versions 5.1, 5.2 and 5.3 of the lua interpreter are available as
|
||||
respectively `lua5_1`, `lua5_2` and `lua5_3`. Luajit is available too.
|
||||
The Nix expressions for the interpreters can be found in `pkgs/development/interpreters/lua-5`.
|
||||
|
||||
#### Attributes on lua interpreters packages {#attributes-on-lua-interpreters-packages}
|
||||
|
||||
#### Attributes on lua interpreters packages
|
||||
|
||||
Each interpreter has the following attributes:
|
||||
|
||||
@@ -172,7 +164,8 @@ Each interpreter has the following attributes:
|
||||
- `withPackages`. Simpler interface to `buildEnv`.
|
||||
- `pkgs`. Set of Lua packages for that specific interpreter. The package set can be modified by overriding the interpreter and passing `packageOverrides`.
|
||||
|
||||
#### `buildLuarocksPackage` function {#buildluarockspackage-function}
|
||||
|
||||
#### `buildLuarocksPackage` function
|
||||
|
||||
The `buildLuarocksPackage` function is implemented in `pkgs/development/interpreters/lua-5/build-lua-package.nix`
|
||||
The following is an example:
|
||||
@@ -212,17 +205,16 @@ install the package
|
||||
|
||||
By default `meta.platforms` is set to the same value as the interpreter unless overridden otherwise.
|
||||
|
||||
#### `buildLuaApplication` function {#buildluaapplication-function}
|
||||
#### `buildLuaApplication` function
|
||||
|
||||
The `buildLuaApplication` function is practically the same as `buildLuaPackage`.
|
||||
The difference is that `buildLuaPackage` by default prefixes the names of the packages with the version of the interpreter.
|
||||
Because with an application we're not interested in multiple version the prefix is dropped.
|
||||
|
||||
#### lua.withPackages function {#lua.withpackages-function}
|
||||
#### lua.withPackages function
|
||||
|
||||
The `lua.withPackages` takes a function as an argument that is passed the set of lua packages and returns the list of packages to be included in the environment.
|
||||
Using the `withPackages` function, the previous example for the luafilesystem environment can be written like this:
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
|
||||
@@ -231,7 +223,6 @@ lua.withPackages (ps: [ps.luafilesystem])
|
||||
|
||||
`withPackages` passes the correct package set for the specific interpreter version as an argument to the function. In the above example, `ps` equals `luaPackages`.
|
||||
But you can also easily switch to using `lua5_2`:
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
|
||||
@@ -240,12 +231,13 @@ lua5_2.withPackages (ps: [ps.lua])
|
||||
|
||||
Now, `ps` is set to `lua52Packages`, matching the version of the interpreter.
|
||||
|
||||
### Possible Todos {#possible-todos}
|
||||
|
||||
### Possible Todos
|
||||
|
||||
* export/use version specific variables such as `LUA_PATH_5_2`/`LUAROCKS_CONFIG_5_2`
|
||||
* let luarocks check for dependencies via exporting the different rocktrees in temporary config
|
||||
|
||||
### Lua Contributing guidelines {#lua-contributing-guidelines}
|
||||
### Lua Contributing guidelines
|
||||
|
||||
Following rules should be respected:
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ public class Main {
|
||||
|
||||
You find this demo project at https://github.com/fzakaria/nixos-maven-example
|
||||
|
||||
## Solving for dependencies {#solving-for-dependencies}
|
||||
## Solving for dependencies
|
||||
|
||||
### buildMaven with NixOS/mvn2nix-maven-plugin {#buildmaven-with-nixosmvn2nix-maven-plugin}
|
||||
### buildMaven with NixOS/mvn2nix-maven-plugin
|
||||
|
||||
> ⚠️ Although `buildMaven` is the "blessed" way within nixpkgs, as of 2020, it hasn't seen much activity in quite a while.
|
||||
|
||||
@@ -82,7 +82,6 @@ This file is then given to the `buildMaven` function, and it returns 2 attribute
|
||||
A simple derivation that runs through `mvn compile` & `mvn package` to build the JAR. You may use this as inspiration for more complicated derivations.
|
||||
|
||||
Here is an [example](https://github.com/fzakaria/nixos-maven-example/blob/main/build-maven-repository.nix) of building the Maven repository
|
||||
|
||||
```nix
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
with pkgs;
|
||||
@@ -104,8 +103,7 @@ The benefit over the _double invocation_ as we will see below, is that the _/nix
|
||||
│ └── 4.1.3
|
||||
│ ├── avalon-framework-4.1.3.jar -> /nix/store/iv5fp3955w3nq28ff9xfz86wvxbiw6n9-avalon-framework-4.1.3.jar
|
||||
```
|
||||
|
||||
### Double Invocation {#double-invocation}
|
||||
### Double Invocation
|
||||
|
||||
> ⚠️ This pattern is the simplest but may cause unnecessary rebuilds due to the output hash changing.
|
||||
|
||||
@@ -165,7 +163,7 @@ The build will fail, and tell you the expected `outputHash` to place. When you'v
|
||||
|
||||
If your package uses _SNAPSHOT_ dependencies or _version ranges_; there is a strong likelihood that over-time your output hash will change since the resolved dependencies may change. Hence this method is less recommended then using `buildMaven`.
|
||||
|
||||
## Building a JAR {#building-a-jar}
|
||||
## Building a JAR
|
||||
|
||||
Regardless of which strategy is chosen above, the step to build the derivation is the same.
|
||||
|
||||
@@ -203,7 +201,7 @@ in stdenv.mkDerivation rec {
|
||||
2 directories, 1 file
|
||||
```
|
||||
|
||||
## Runnable JAR {#runnable-jar}
|
||||
## Runnable JAR
|
||||
|
||||
The previous example builds a `jar` file but that's not a file one can run.
|
||||
|
||||
@@ -215,7 +213,7 @@ We will use the same repository we built above (either _double invocation_ or _b
|
||||
|
||||
The following two methods are more suited to Nix then building an [UberJar](https://imagej.net/Uber-JAR) which may be the more traditional approach.
|
||||
|
||||
### CLASSPATH {#classpath}
|
||||
### CLASSPATH
|
||||
|
||||
> This is ideal if you are providing a derivation for _nixpkgs_ and don't want to patch the project's `pom.xml`.
|
||||
|
||||
@@ -254,12 +252,11 @@ in stdenv.mkDerivation rec {
|
||||
}
|
||||
```
|
||||
|
||||
### MANIFEST file via Maven Plugin {#manifest-file-via-maven-plugin}
|
||||
### MANIFEST file via Maven Plugin
|
||||
|
||||
> This is ideal if you are the project owner and want to change your `pom.xml` to set the CLASSPATH within it.
|
||||
|
||||
Augment the `pom.xml` to create a JAR with the following manifest:
|
||||
|
||||
```xml
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
# Nim {#nim}
|
||||
|
||||
## Overview {#nim-overview}
|
||||
|
||||
The Nim compiler, a builder function, and some packaged libraries are available
|
||||
in Nixpkgs. Until now each compiler release has been effectively backwards
|
||||
compatible so only the latest version is available.
|
||||
|
||||
## Nim program packages in Nixpkgs {#nim-program-packages-in-nixpkgs}
|
||||
|
||||
Nim programs can be built using `nimPackages.buildNimPackage`. In the
|
||||
case of packages not containing exported library code the attribute
|
||||
`nimBinOnly` should be set to `true`.
|
||||
|
||||
The following example shows a Nim program that depends only on Nim libraries:
|
||||
|
||||
```nix
|
||||
{ lib, nimPackages, fetchurl }:
|
||||
|
||||
nimPackages.buildNimPackage rec {
|
||||
pname = "hottext";
|
||||
version = "1.4";
|
||||
|
||||
nimBinOnly = true;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://git.sr.ht/~ehmry/hottext/archive/v${version}.tar.gz";
|
||||
sha256 = "sha256-hIUofi81zowSMbt1lUsxCnVzfJGN3FEiTtN8CEFpwzY=";
|
||||
};
|
||||
|
||||
buildInputs = with nimPackages; [
|
||||
bumpy
|
||||
chroma
|
||||
flatty
|
||||
nimsimd
|
||||
pixie
|
||||
sdl2
|
||||
typography
|
||||
vmath
|
||||
zippy
|
||||
];
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Nim library packages in Nixpkgs {#nim-library-packages-in-nixpkgs}
|
||||
|
||||
|
||||
Nim libraries can also be built using `nimPackages.buildNimPackage`, but
|
||||
often the product of a fetcher is sufficient to satisfy a dependency.
|
||||
The `fetchgit`, `fetchFromGitHub`, and `fetchNimble` functions yield an
|
||||
output that can be discovered during the `configurePhase` of `buildNimPackage`.
|
||||
|
||||
Nim library packages are listed in
|
||||
[pkgs/top-level/nim-packages.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/nim-packages.nix) and implemented at
|
||||
[pkgs/development/nim-packages](https://github.com/NixOS/nixpkgs/tree/master/pkgs/development/nim-packages).
|
||||
|
||||
The following example shows a Nim library that propagates a dependency on a
|
||||
non-Nim package:
|
||||
```nix
|
||||
{ lib, buildNimPackage, fetchNimble, SDL2 }:
|
||||
|
||||
buildNimPackage rec {
|
||||
pname = "sdl2";
|
||||
version = "2.0.4";
|
||||
src = fetchNimble {
|
||||
inherit pname version;
|
||||
hash = "sha256-Vtcj8goI4zZPQs2TbFoBFlcR5UqDtOldaXSH/+/xULk=";
|
||||
};
|
||||
propagatedBuildInputs = [ SDL2 ];
|
||||
}
|
||||
```
|
||||
|
||||
## `buildNimPackage` parameters {#buildnimpackage-parameters}
|
||||
|
||||
All parameters from `stdenv.mkDerivation` function are still supported. The
|
||||
following are specific to `buildNimPackage`:
|
||||
|
||||
* `nimBinOnly ? false`: If `true` then build only the programs listed in
|
||||
the Nimble file in the packages sources.
|
||||
* `nimbleFile`: Specify the Nimble file location of the package being built
|
||||
rather than discover the file at build-time.
|
||||
* `nimRelease ? true`: Build the package in *release* mode.
|
||||
* `nimDefines ? []`: A list of Nim defines. Key-value tuples are not supported.
|
||||
* `nimFlags ? []`: A list of command line arguments to pass to the Nim compiler.
|
||||
Use this to specify defines with arguments in the form of `-d:${name}=${value}`.
|
||||
* `nimDoc` ? false`: Build and install HTML documentation.
|
||||
|
||||
* `buildInputs` ? []: The packages listed here will be searched for `*.nimble`
|
||||
files which are used to populate the Nim library path. Otherwise the standard
|
||||
behavior is in effect.
|
||||
51
doc/languages-frameworks/node.section.md
Normal file
51
doc/languages-frameworks/node.section.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# Node.js {#node.js}
|
||||
|
||||
The `pkgs/development/node-packages` folder contains a generated collection of
|
||||
[NPM packages](https://npmjs.com/) that can be installed with the Nix package
|
||||
manager.
|
||||
|
||||
As a rule of thumb, the package set should only provide *end user* software
|
||||
packages, such as command-line utilities. Libraries should only be added to the
|
||||
package set if there is a non-NPM package that requires it.
|
||||
|
||||
When it is desired to use NPM libraries in a development project, use the
|
||||
`node2nix` generator directly on the `package.json` configuration file of the
|
||||
project.
|
||||
|
||||
The package set provides support for the official stable Node.js versions.
|
||||
The latest stable LTS release in `nodePackages`, as well as the latest stable
|
||||
Current release in `nodePackages_latest`.
|
||||
|
||||
If your package uses native addons, you need to examine what kind of native
|
||||
build system it uses. Here are some examples:
|
||||
|
||||
* `node-gyp`
|
||||
* `node-gyp-builder`
|
||||
* `node-pre-gyp`
|
||||
|
||||
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`
|
||||
requires `node-gyp-build`, so [we override](https://github.com/NixOS/nixpkgs/blob/32f5e5da4a1b3f0595527f5195ac3a91451e9b56/pkgs/development/node-packages/default.nix#L37-L40) its expression in [`default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/default.nix):
|
||||
|
||||
```nix
|
||||
dat = super.dat.override {
|
||||
buildInputs = [ self.node-gyp-build pkgs.libtool pkgs.autoconf pkgs.automake ];
|
||||
meta.broken = since "12";
|
||||
};
|
||||
```
|
||||
|
||||
To add a package from NPM to nixpkgs:
|
||||
|
||||
1. Modify `pkgs/development/node-packages/node-packages.json` to add, update
|
||||
or remove package entries to have it included in `nodePackages` and
|
||||
`nodePackages_latest`.
|
||||
2. Run the script: `(cd pkgs/development/node-packages && ./generate.sh)`.
|
||||
3. Build your new package to test your changes:
|
||||
`cd /path/to/nixpkgs && nix-build -A nodePackages.<new-or-updated-package>`.
|
||||
To build against the latest stable Current Node.js version (e.g. 14.x):
|
||||
`nix-build -A nodePackages_latest.<new-or-updated-package>`
|
||||
4. Add and commit all modified and generated files.
|
||||
|
||||
For more information about the generation process, consult the
|
||||
[README.md](https://github.com/svanderburg/node2nix) file of the `node2nix`
|
||||
tool.
|
||||
@@ -4,83 +4,60 @@ OCaml libraries should be installed in `$(out)/lib/ocaml/${ocaml.version}/site-l
|
||||
|
||||
Given that most of the OCaml ecosystem is now built with dune, nixpkgs includes a convenience build support function called `buildDunePackage` that will build an OCaml package using dune, OCaml and findlib and any additional dependencies provided as `buildInputs` or `propagatedBuildInputs`.
|
||||
|
||||
Here is a simple package example.
|
||||
|
||||
- It defines an (optional) attribute `minimalOCamlVersion` that will be used to
|
||||
throw a descriptive evaluation error if building with an older OCaml is
|
||||
attempted.
|
||||
|
||||
- It uses the `fetchFromGitHub` fetcher to get its source.
|
||||
|
||||
- `useDune2 = true` ensures that the latest version of Dune is used for the
|
||||
build (this may become the default value in a future release).
|
||||
|
||||
- It sets the optional `doCheck` attribute such that tests will be run with
|
||||
`dune runtest -p angstrom` after the build (`dune build -p angstrom`) is
|
||||
complete, but only if the Ocaml version is at at least `"4.05"`.
|
||||
|
||||
- It uses the package `ocaml-syntax-shims` as a build input, `alcotest` and
|
||||
`ppx_let` as check inputs (because they are needed to run the tests), and
|
||||
`bigstringaf` and `result` as propagated build inputs (thus they will also be
|
||||
available to libraries depending on this library).
|
||||
|
||||
- The library will be installed using the `angstrom.install` file that dune
|
||||
generates.
|
||||
Here is a simple package example. It defines an (optional) attribute `minimumOCamlVersion` that will be used to throw a descriptive evaluation error if building with an older OCaml is attempted. It uses the `fetchFromGitHub` fetcher to get its source. It sets the `doCheck` (optional) attribute to `true` which means that tests will be run with `dune runtest -p angstrom` after the build (`dune build -p angstrom`) is complete. It uses `alcotest` as a build input (because it is needed to run the tests) and `bigstringaf` and `result` as propagated build inputs (thus they will also be available to libraries depending on this library). The library will be installed using the `angstrom.install` file that dune generates.
|
||||
|
||||
```nix
|
||||
{ lib,
|
||||
fetchFromGitHub,
|
||||
buildDunePackage,
|
||||
ocaml,
|
||||
ocaml-syntax-shims,
|
||||
alcotest,
|
||||
result,
|
||||
bigstringaf,
|
||||
ppx_let }:
|
||||
{ lib
|
||||
, fetchFromGitHub
|
||||
, buildDunePackage
|
||||
, alcotest
|
||||
, result
|
||||
, bigstringaf
|
||||
}:
|
||||
|
||||
buildDunePackage rec {
|
||||
pname = "angstrom";
|
||||
version = "0.15.0";
|
||||
useDune2 = true;
|
||||
version = "0.10.0";
|
||||
|
||||
minimalOCamlVersion = "4.04";
|
||||
minimumOCamlVersion = "4.03";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "inhabitedtype";
|
||||
repo = pname;
|
||||
rev = version;
|
||||
sha256 = "1hmrkdcdlkwy7rxhngf3cv3sa61cznnd9p5lmqhx20664gx2ibrh";
|
||||
sha256 = "0lh6024yf9ds0nh9i93r9m6p5psi8nvrqxl5x7jwl13zb0r9xfpw";
|
||||
};
|
||||
|
||||
checkInputs = [ alcotest ppx_let ];
|
||||
buildInputs = [ ocaml-syntax-shims ];
|
||||
buildInputs = [ alcotest ];
|
||||
propagatedBuildInputs = [ bigstringaf result ];
|
||||
doCheck = lib.versionAtLeast ocaml.version "4.05";
|
||||
doCheck = true;
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/inhabitedtype/angstrom";
|
||||
description = "OCaml parser combinators built for speed and memory efficiency";
|
||||
license = lib.licenses.bsd3;
|
||||
maintainers = with lib.maintainers; [ sternenseemann ];
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ sternenseemann ];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Here is a second example, this time using a source archive generated with `dune-release`. It is a good idea to use this archive when it is available as it will usually contain substituted variables such as a `%%VERSION%%` field. This library does not depend on any other OCaml library and no tests are run after building it.
|
||||
|
||||
```nix
|
||||
{ lib, fetchurl, buildDunePackage }:
|
||||
{ lib
|
||||
, fetchurl
|
||||
, buildDunePackage
|
||||
}:
|
||||
|
||||
buildDunePackage rec {
|
||||
pname = "wtf8";
|
||||
version = "1.0.2";
|
||||
version = "1.0.1";
|
||||
|
||||
useDune2 = true;
|
||||
|
||||
minimalOCamlVersion = "4.02";
|
||||
minimumOCamlVersion = "4.01";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/flowtype/ocaml-${pname}/releases/download/v${version}/${pname}-v${version}.tbz";
|
||||
sha256 = "09ygcxxd5warkdzz17rgpidrd0pg14cy2svvnvy1hna080lzg7vp";
|
||||
url = "https://github.com/flowtype/ocaml-${pname}/releases/download/v${version}/${pname}-${version}.tbz";
|
||||
sha256 = "1msg3vycd3k8qqj61sc23qks541cxpb97vrnrvrhjnqxsqnh6ygq";
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
# Octave {#sec-octave}
|
||||
|
||||
## Introduction {#ssec-octave-introduction}
|
||||
|
||||
Octave is a modular scientific programming language and environment.
|
||||
A majority of the packages supported by Octave from their [website](https://octave.sourceforge.io/packages.php) are packaged in nixpkgs.
|
||||
|
||||
## Structure {#ssec-octave-structure}
|
||||
|
||||
All Octave add-on packages are available in two ways:
|
||||
1. Under the top-level `Octave` attribute, `octave.pkgs`.
|
||||
2. As a top-level attribute, `octavePackages`.
|
||||
|
||||
## Packaging Octave Packages {#ssec-octave-packaging}
|
||||
|
||||
Nixpkgs provides a function `buildOctavePackage`, a generic package builder function for any Octave package that complies with the Octave's current packaging format.
|
||||
|
||||
All Octave packages are defined in [pkgs/top-level/octave-packages.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/octave-packages.nix) rather than `pkgs/all-packages.nix`.
|
||||
Each package is defined in their own file in the [pkgs/development/octave-modules](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/octave-modules) directory.
|
||||
Octave packages are made available through `all-packages.nix` through both the attribute `octavePackages` and `octave.pkgs`.
|
||||
You can test building an Octave package as follows:
|
||||
|
||||
```ShellSession
|
||||
$ nix-build -A octavePackages.symbolic
|
||||
```
|
||||
|
||||
When building Octave packages with `nix-build`, the `buildOctavePackage` function adds `octave-octaveVersion` to; the start of the package's name attribute.
|
||||
|
||||
This can be required when installing the package using `nix-env`:
|
||||
|
||||
```ShellSession
|
||||
$ nix-env -i octave-6.2.0-symbolic
|
||||
```
|
||||
|
||||
Although, you can also install it using the attribute name:
|
||||
|
||||
```ShellSession
|
||||
$ nix-env -i -A octavePackages.symbolic
|
||||
```
|
||||
|
||||
You can build Octave with packages by using the `withPackages` passed-through function.
|
||||
|
||||
```ShellSession
|
||||
$ nix-shell -p 'octave.withPackages (ps: with ps; [ symbolic ])'
|
||||
```
|
||||
|
||||
This will also work in a `shell.nix` file.
|
||||
|
||||
```nix
|
||||
{ pkgs ? import <nixpkgs> { }}:
|
||||
|
||||
pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
(octave.withPackages (opkgs: with opkgs; [ symbolic ]))
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
### `buildOctavePackage` Steps {#sssec-buildOctavePackage-steps}
|
||||
|
||||
The `buildOctavePackage` does several things to make sure things work properly.
|
||||
|
||||
1. Sets the environment variable `OCTAVE_HISTFILE` to `/dev/null` during package compilation so that the commands run through the Octave interpreter directly are not logged.
|
||||
2. Skips the configuration step, because the packages are stored as gzipped tarballs, which Octave itself handles directly.
|
||||
3. Change the hierarchy of the tarball so that only a single directory is at the top-most level of the tarball.
|
||||
4. Use Octave itself to run the `pkg build` command, which unzips the tarball, extracts the necessary files written in Octave, and compiles any code written in C++ or Fortran, and places the fully compiled artifact in `$out`.
|
||||
|
||||
`buildOctavePackage` is built on top of `stdenv` in a standard way, allowing most things to be customized.
|
||||
|
||||
### Handling Dependencies {#sssec-octave-handling-dependencies}
|
||||
|
||||
In Octave packages, there are four sets of dependencies that can be specified:
|
||||
|
||||
`nativeBuildInputs`
|
||||
: Just like other packages, `nativeBuildInputs` is intended for architecture-dependent build-time-only dependencies.
|
||||
|
||||
`buildInputs`
|
||||
: Like other packages, `buildInputs` is intended for architecture-independent build-time-only dependencies.
|
||||
|
||||
`propagatedBuildInputs`
|
||||
: Similar to other packages, `propagatedBuildInputs` is intended for packages that are required for both building and running of the package.
|
||||
See [Symbolic](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/octave-modules/symbolic/default.nix) for how this works and why it is needed.
|
||||
|
||||
`requiredOctavePackages`
|
||||
: This is a special dependency that ensures the specified Octave packages are dependent on others, and are made available simultaneously when loading them in Octave.
|
||||
|
||||
### Installing Octave Packages {#sssec-installing-octave-packages}
|
||||
|
||||
By default, the `buildOctavePackage` function does _not_ install the requested package into Octave for use.
|
||||
The function will only build the requested package.
|
||||
This is due to Octave maintaining an text-based database about which packages are installed where.
|
||||
To this end, when all the requested packages have been built, the Octave package and all its add-on packages are put together into an environment, similar to Python.
|
||||
|
||||
1. First, all the Octave binaries are wrapped with the environment variable `OCTAVE_SITE_INITFILE` set to a file in `$out`, which is required for Octave to be able to find the non-standard package database location.
|
||||
2. Because of the way `buildEnv` works, all tarballs that are present (which should be all Octave packages to install) should be removed.
|
||||
3. The path down to the default install location of Octave packages is recreated so that Nix-operated Octave can install the packages.
|
||||
4. Install the packages into the `$out` environment while writing package entries to the database file.
|
||||
This database file is unique for each different (according to Nix) environment invocation.
|
||||
5. Rewrite the Octave-wide startup file to read from the list of packages installed in that particular environment.
|
||||
6. Wrap any programs that are required by the Octave packages so that they work with all the paths defined within the environment.
|
||||
@@ -122,7 +122,7 @@ ImageExifTool = buildPerlPackage {
|
||||
};
|
||||
|
||||
buildInputs = lib.optional stdenv.isDarwin shortenPerlShebang;
|
||||
postInstall = lib.optionalString stdenv.isDarwin ''
|
||||
postInstall = lib.optional stdenv.isDarwin ''
|
||||
shortenPerlShebang $out/bin/exiftool
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# Python {#python}
|
||||
|
||||
## User Guide {#user-guide}
|
||||
## User Guide
|
||||
|
||||
### Using Python {#using-python}
|
||||
### Using Python
|
||||
|
||||
#### Overview {#overview}
|
||||
#### Overview
|
||||
|
||||
Several versions of the Python interpreter are available on Nix, as well as a
|
||||
high amount of packages. The attribute `python3` refers to the default
|
||||
interpreter, which is currently CPython 3.9. The attribute `python` refers to
|
||||
interpreter, which is currently CPython 3.8. The attribute `python` refers to
|
||||
CPython 2.7 for backwards-compatibility. It is also possible to refer to
|
||||
specific versions, e.g. `python38` refers to CPython 3.8, and `pypy` refers to
|
||||
the default PyPy interpreter.
|
||||
@@ -31,7 +31,7 @@ The main package set contains aliases to these package sets, e.g.
|
||||
`pythonPackages` refers to `python.pkgs` and `python38Packages` to
|
||||
`python38.pkgs`.
|
||||
|
||||
#### Installing Python and packages {#installing-python-and-packages}
|
||||
#### Installing Python and packages
|
||||
|
||||
The Nix and NixOS manuals explain how packages are generally installed. In the
|
||||
case of Python and Nix, it is important to make a distinction between whether the
|
||||
@@ -62,7 +62,7 @@ Philosphically, this should be familiar to users who are used to a `venv` style
|
||||
of development: individual projects create their own Python environments without
|
||||
impacting the global environment or each other.
|
||||
|
||||
#### Ad-hoc temporary Python environment with `nix-shell` {#ad-hoc-temporary-python-environment-with-nix-shell}
|
||||
#### Ad-hoc temporary Python environment with `nix-shell`
|
||||
|
||||
The simplest way to start playing with the way nix wraps and sets up Python
|
||||
environments is with `nix-shell` at the cmdline. These environments create a
|
||||
@@ -131,7 +131,7 @@ arbitrary dependencies. This is a good way to get a feel for how the Python
|
||||
interpreter and dependencies work in Nix and NixOS, but to do some actual
|
||||
development, we'll want to make it a bit more persistent.
|
||||
|
||||
##### Running Python scripts and using `nix-shell` as shebang {#running-python-scripts-and-using-nix-shell-as-shebang}
|
||||
##### Running Python scripts and using `nix-shell` as shebang
|
||||
|
||||
Sometimes, we have a script whose header looks like this:
|
||||
|
||||
@@ -146,7 +146,7 @@ print(f"The dot product of {a} and {b} is: {np.dot(a, b)}")
|
||||
Executing this script requires a `python3` that has `numpy`. Using what we learned
|
||||
in the previous section, we could startup a shell and just run it like so:
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ nix-shell -p 'python38.withPackages(ps: with ps; [ numpy ])' --run 'python3 foo.py'
|
||||
The dot product of [1 2] and [3 4] is: 11
|
||||
```
|
||||
@@ -203,7 +203,7 @@ of the package versions.
|
||||
This is also a great way to ensure the script executes identically on different
|
||||
servers.
|
||||
|
||||
##### Load environment from `.nix` expression {#load-environment-from-.nix-expression}
|
||||
##### Load environment from `.nix` expression
|
||||
|
||||
We've now seen how to create an ad-hoc temporary shell session, and how to
|
||||
create a single script with Python dependencies, but in the course of normal
|
||||
@@ -262,7 +262,7 @@ and its Python dependencies, but also tools like `black` or `mypy` and libraries
|
||||
like `libffi` the `openssl` in scope. This is generic and can span any number of
|
||||
tools or languages across the Nixpkgs ecosystem.
|
||||
|
||||
##### Installing environments globally on the system {#installing-environments-globally-on-the-system}
|
||||
##### Installing environments globally on the system
|
||||
|
||||
Up to now, we've been creating environments scoped to an ad-hoc shell session,
|
||||
or a single script, or a single project. This is generally advisable, as it
|
||||
@@ -315,7 +315,7 @@ If you get a conflict or prefer to keep the setup clean, you can have `nix-env`
|
||||
atomically *uninstall* all other imperatively installed packages and replace
|
||||
your profile with just `myEnv` by using the `--replace` flag.
|
||||
|
||||
##### Environment defined in `/etc/nixos/configuration.nix` {#environment-defined-in-etcnixosconfiguration.nix}
|
||||
##### Environment defined in `/etc/nixos/configuration.nix`
|
||||
|
||||
For the sake of completeness, here's how to install the environment system-wide
|
||||
on NixOS.
|
||||
@@ -329,7 +329,7 @@ on NixOS.
|
||||
}
|
||||
```
|
||||
|
||||
### Developing with Python {#developing-with-python}
|
||||
### Developing with Python
|
||||
|
||||
Above, we were mostly just focused on use cases and what to do to get started
|
||||
creating working Python environments in nix.
|
||||
@@ -338,7 +338,7 @@ Now that you know the basics to be up and running, it is time to take a step
|
||||
back and take a deeper look at how Python packages are packaged on Nix. Then,
|
||||
we will look at how you can use development mode with your code.
|
||||
|
||||
#### Python library packages in Nixpkgs {#python-library-packages-in-nixpkgs}
|
||||
#### Python library packages in Nixpkgs
|
||||
|
||||
With Nix all packages are built by functions. The main function in Nix for
|
||||
building Python libraries is `buildPythonPackage`. Let's see how we can build the
|
||||
@@ -425,7 +425,7 @@ of `withPackages` we used a `let` expression. You can see that we used
|
||||
`toolz` from the Nixpkgs package set this time, but instead took our own version
|
||||
that we introduced with the `let` expression.
|
||||
|
||||
#### Handling dependencies {#handling-dependencies}
|
||||
#### Handling dependencies
|
||||
|
||||
Our example, `toolz`, does not have any dependencies on other Python packages or
|
||||
system libraries. According to the manual, `buildPythonPackage` uses the
|
||||
@@ -439,7 +439,7 @@ The following example shows which arguments are given to `buildPythonPackage` in
|
||||
order to build [`datashape`](https://github.com/blaze/datashape).
|
||||
|
||||
```nix
|
||||
{ lib, buildPythonPackage, fetchPypi, numpy, multipledispatch, python-dateutil, pytest }:
|
||||
{ lib, buildPythonPackage, fetchPypi, numpy, multipledispatch, dateutil, pytest }:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "datashape";
|
||||
@@ -451,7 +451,7 @@ buildPythonPackage rec {
|
||||
};
|
||||
|
||||
checkInputs = [ pytest ];
|
||||
propagatedBuildInputs = [ numpy multipledispatch python-dateutil ];
|
||||
propagatedBuildInputs = [ numpy multipledispatch dateutil ];
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/ContinuumIO/datashape";
|
||||
@@ -463,7 +463,7 @@ buildPythonPackage rec {
|
||||
```
|
||||
|
||||
We can see several runtime dependencies, `numpy`, `multipledispatch`, and
|
||||
`python-dateutil`. Furthermore, we have one `checkInputs`, i.e. `pytest`. `pytest` is a
|
||||
`dateutil`. Furthermore, we have one `checkInputs`, i.e. `pytest`. `pytest` is a
|
||||
test runner and is only used during the `checkPhase` and is therefore not added
|
||||
to `propagatedBuildInputs`.
|
||||
|
||||
@@ -537,10 +537,9 @@ buildPythonPackage rec {
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Note also the line `doCheck = false;`, we explicitly disabled running the test-suite.
|
||||
|
||||
#### Testing Python Packages {#testing-python-packages}
|
||||
#### Testing Python Packages
|
||||
|
||||
It is highly encouraged to have testing as part of the package build. This
|
||||
helps to avoid situations where the package was able to build and install,
|
||||
@@ -560,11 +559,10 @@ thus can cause issues when a test suite asserts on that behavior.
|
||||
as many tests should be enabled as possible. Failing tests can still be
|
||||
a good indication that the package is not in a valid state.
|
||||
|
||||
#### Using pytest {#using-pytest}
|
||||
#### Using pytest
|
||||
|
||||
Pytest is the most common test runner for python repositories. A trivial
|
||||
test run would be:
|
||||
|
||||
```
|
||||
checkInputs = [ pytest ];
|
||||
checkPhase = "pytest";
|
||||
@@ -574,7 +572,6 @@ However, many repositories' test suites do not translate well to nix's build
|
||||
sandbox, and will generally need many tests to be disabled.
|
||||
|
||||
To filter tests using pytest, one can do the following:
|
||||
|
||||
```
|
||||
checkInputs = [ pytest ];
|
||||
# avoid tests which need additional data or touch network
|
||||
@@ -590,20 +587,19 @@ easier than having to create a new package.
|
||||
|
||||
`-k` is used to define a predicate for test names. In this example, we are
|
||||
filtering out tests which contain `download` or `update` in their test case name.
|
||||
Only one `-k` argument is allowed, and thus a long predicate should be concatenated
|
||||
with “\\” and wrapped to the next line.
|
||||
Only one `-k` argument is allows, and thus a long predicate should be concatenated
|
||||
with "\" and wrapped to the next line.
|
||||
|
||||
*NOTE:* In pytest==6.0.1, the use of “\\” to continue a line (e.g. `-k 'not download \'`) has
|
||||
*NOTE:* In pytest==6.0.1, the use of "\" to continue a line (e.g. `-k 'not download \'`) has
|
||||
been removed, in this case, it's recommended to use `pytestCheckHook`.
|
||||
|
||||
#### Using pytestCheckHook {#using-pytestcheckhook}
|
||||
#### Using pytestCheckHook
|
||||
|
||||
`pytestCheckHook` is a convenient hook which will substitute the setuptools
|
||||
`test` command for a checkPhase which runs `pytest`. This is also beneficial
|
||||
when a package may need many items disabled to run the test suite.
|
||||
|
||||
Using the example above, the analagous pytestCheckHook usage would be:
|
||||
|
||||
```
|
||||
checkInputs = [ pytestCheckHook ];
|
||||
|
||||
@@ -641,7 +637,7 @@ Trying to concatenate the related strings to disable tests in a regular checkPha
|
||||
would be much harder to read. This also enables us to comment on why specific tests
|
||||
are disabled.
|
||||
|
||||
#### Using pythonImportsCheck {#using-pythonimportscheck}
|
||||
#### Using pythonImportsCheck
|
||||
|
||||
Although unit tests are highly prefered to validate correctness of a package, not
|
||||
all packages have test suites that can be ran easily, and some have none at all.
|
||||
@@ -663,7 +659,7 @@ However, this is done in it's own phase, and not dependent on whether `doCheck =
|
||||
This can also be useful in verifying that the package doesn't assume commonly
|
||||
present packages (e.g. `setuptools`)
|
||||
|
||||
### Develop local package {#develop-local-package}
|
||||
### Develop local package
|
||||
|
||||
As a Python developer you're likely aware of [development mode](http://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode)
|
||||
(`python setup.py develop`); instead of installing the package this command
|
||||
@@ -698,7 +694,7 @@ buildPythonPackage rec {
|
||||
It is important to note that due to how development mode is implemented on Nix
|
||||
it is not possible to have multiple packages simultaneously in development mode.
|
||||
|
||||
### Organising your packages {#organising-your-packages}
|
||||
### Organising your packages
|
||||
|
||||
So far we discussed how you can use Python on Nix, and how you can develop with
|
||||
it. We've looked at how you write expressions to package Python packages, and we
|
||||
@@ -710,7 +706,7 @@ like to be able to use in different projects. In order to minimise unnecessary
|
||||
duplication we now look at how you can maintain a repository with your
|
||||
own packages. The important functions here are `import` and `callPackage`.
|
||||
|
||||
### Including a derivation using `callPackage` {#including-a-derivation-using-callpackage}
|
||||
### Including a derivation using `callPackage`
|
||||
|
||||
Earlier we created a Python environment using `withPackages`, and included the
|
||||
`toolz` package via a `let` expression.
|
||||
@@ -760,12 +756,12 @@ don't explicitly define which `python` derivation should be used. In the above
|
||||
example we use `buildPythonPackage` that is part of the set `python38Packages`,
|
||||
and in this case the `python38` interpreter is automatically used.
|
||||
|
||||
## Reference {#reference}
|
||||
## Reference
|
||||
|
||||
### Interpreters {#interpreters}
|
||||
### Interpreters
|
||||
|
||||
Versions 2.7, 3.6, 3.7, 3.8 and 3.9 of the CPython interpreter are available as
|
||||
respectively `python27`, `python37`, `python38` and `python39`. The
|
||||
respectively `python27`, `python36`, `python37`, `python38` and `python39`. The
|
||||
aliases `python2` and `python3` correspond to respectively `python27` and
|
||||
`python39`. The attribute `python` maps to `python2`. The PyPy interpreters
|
||||
compatible with Python 2.7 and 3 are available as `pypy27` and `pypy3`, with
|
||||
@@ -777,11 +773,11 @@ All packages depending on any Python interpreter get appended
|
||||
`out/{python.sitePackages}` to `$PYTHONPATH` if such directory
|
||||
exists.
|
||||
|
||||
#### Missing `tkinter` module standard library {#missing-tkinter-module-standard-library}
|
||||
#### Missing `tkinter` module standard library
|
||||
|
||||
To reduce closure size the `Tkinter`/`tkinter` is available as a separate package, `pythonPackages.tkinter`.
|
||||
|
||||
#### Attributes on interpreters packages {#attributes-on-interpreters-packages}
|
||||
#### Attributes on interpreters packages
|
||||
|
||||
Each interpreter has the following attributes:
|
||||
|
||||
@@ -793,7 +789,7 @@ Each interpreter has the following attributes:
|
||||
- `executable`. Name of the interpreter executable, e.g. `python3.8`.
|
||||
- `pkgs`. Set of Python packages for that specific interpreter. The package set can be modified by overriding the interpreter and passing `packageOverrides`.
|
||||
|
||||
### Optimizations {#optimizations}
|
||||
### Optimizations
|
||||
|
||||
The Python interpreters are by default not build with optimizations enabled, because
|
||||
the builds are in that case not reproducible. To enable optimizations, override the
|
||||
@@ -810,7 +806,7 @@ let
|
||||
in mypython
|
||||
```
|
||||
|
||||
### Building packages and applications {#building-packages-and-applications}
|
||||
### Building packages and applications
|
||||
|
||||
Python libraries and applications that use `setuptools` or
|
||||
`distutils` are typically built with respectively the `buildPythonPackage` and
|
||||
@@ -830,19 +826,19 @@ attribute set is created for each available Python interpreter. The available
|
||||
sets are
|
||||
|
||||
* `pkgs.python27Packages`
|
||||
* `pkgs.python36Packages`
|
||||
* `pkgs.python37Packages`
|
||||
* `pkgs.python38Packages`
|
||||
* `pkgs.python39Packages`
|
||||
* `pkgs.python310Packages`
|
||||
* `pkgs.pypyPackages`
|
||||
|
||||
and the aliases
|
||||
|
||||
* `pkgs.python2Packages` pointing to `pkgs.python27Packages`
|
||||
* `pkgs.python3Packages` pointing to `pkgs.python39Packages`
|
||||
* `pkgs.python3Packages` pointing to `pkgs.python38Packages`
|
||||
* `pkgs.pythonPackages` pointing to `pkgs.python2Packages`
|
||||
|
||||
#### `buildPythonPackage` function {#buildpythonpackage-function}
|
||||
#### `buildPythonPackage` function
|
||||
|
||||
The `buildPythonPackage` function is implemented in
|
||||
`pkgs/development/interpreters/python/mk-python-derivation`
|
||||
@@ -851,7 +847,7 @@ using setup hooks.
|
||||
The following is an example:
|
||||
|
||||
```nix
|
||||
{ lib, buildPythonPackage, fetchPypi, hypothesis, setuptools-scm, attrs, py, setuptools, six, pluggy }:
|
||||
{ lib, buildPythonPackage, fetchPypi, hypothesis, setuptools_scm, attrs, py, setuptools, six, pluggy }:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "pytest";
|
||||
@@ -868,7 +864,7 @@ buildPythonPackage rec {
|
||||
'';
|
||||
|
||||
checkInputs = [ hypothesis ];
|
||||
nativeBuildInputs = [ setuptools-scm ];
|
||||
nativeBuildInputs = [ setuptools_scm ];
|
||||
propagatedBuildInputs = [ attrs py setuptools six pluggy ];
|
||||
|
||||
meta = with lib; {
|
||||
@@ -894,7 +890,7 @@ e.g. the test runner, should be added to `checkInputs`.
|
||||
By default `meta.platforms` is set to the same value
|
||||
as the interpreter unless overridden otherwise.
|
||||
|
||||
##### `buildPythonPackage` parameters {#buildpythonpackage-parameters}
|
||||
##### `buildPythonPackage` parameters
|
||||
|
||||
All parameters from `stdenv.mkDerivation` function are still supported. The
|
||||
following are specific to `buildPythonPackage`:
|
||||
@@ -950,7 +946,7 @@ because their behaviour is different:
|
||||
`buildPythonPackage` also injects code into and wraps executables with the
|
||||
paths included in this list. Items listed in `install_requires` go here.
|
||||
|
||||
##### Overriding Python packages {#overriding-python-packages}
|
||||
##### Overriding Python packages
|
||||
|
||||
The `buildPythonPackage` function has a `overridePythonAttrs` method that can be
|
||||
used to override the package. In the following example we create an environment
|
||||
@@ -978,7 +974,7 @@ with import <nixpkgs> {};
|
||||
in python.withPackages(ps: [ps.blaze])).env
|
||||
```
|
||||
|
||||
#### `buildPythonApplication` function {#buildpythonapplication-function}
|
||||
#### `buildPythonApplication` function
|
||||
|
||||
The `buildPythonApplication` function is practically the same as
|
||||
`buildPythonPackage`. The main purpose of this function is to build a Python
|
||||
@@ -1023,7 +1019,7 @@ 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}
|
||||
#### `toPythonApplication` function
|
||||
|
||||
A distinction is made between applications and libraries, however, sometimes a
|
||||
package is used as both. In this case the package is added as a library to
|
||||
@@ -1035,12 +1031,11 @@ The Nix expression shall use `buildPythonPackage` and be called from
|
||||
`python-packages.nix`. A reference shall be created from `all-packages.nix` to
|
||||
the attribute in `python-packages.nix`, and the `toPythonApplication` shall be
|
||||
applied to the reference:
|
||||
|
||||
```nix
|
||||
youtube-dl = with pythonPackages; toPythonApplication youtube-dl;
|
||||
```
|
||||
|
||||
#### `toPythonModule` function {#topythonmodule-function}
|
||||
#### `toPythonModule` function
|
||||
|
||||
In some cases, such as bindings, a package is created using
|
||||
`stdenv.mkDerivation` and added as attribute in `all-packages.nix`. The Python
|
||||
@@ -1057,7 +1052,7 @@ opencv = toPythonModule (pkgs.opencv.override {
|
||||
|
||||
Do pay attention to passing in the right Python version!
|
||||
|
||||
#### `python.buildEnv` function {#python.buildenv-function}
|
||||
#### `python.buildEnv` function
|
||||
|
||||
Python environments can be created using the low-level `pkgs.buildEnv` function.
|
||||
This example shows how to create an environment that has the Pyramid Web Framework.
|
||||
@@ -1095,8 +1090,8 @@ with import <nixpkgs> {};
|
||||
will drop you into a shell where Python will have the
|
||||
specified packages in its path.
|
||||
|
||||
##### `python.buildEnv` arguments {#python.buildenv-arguments}
|
||||
|
||||
##### `python.buildEnv` arguments
|
||||
|
||||
* `extraLibs`: List of packages installed inside the environment.
|
||||
* `postBuild`: Shell command executed after the build of environment.
|
||||
@@ -1104,7 +1099,7 @@ specified packages in its path.
|
||||
* `permitUserSite`: Skip setting the `PYTHONNOUSERSITE` environment variable in
|
||||
wrapped binaries in the environment.
|
||||
|
||||
#### `python.withPackages` function {#python.withpackages-function}
|
||||
#### `python.withPackages` function
|
||||
|
||||
The `python.withPackages` function provides a simpler interface to the `python.buildEnv` functionality.
|
||||
It takes a function as an argument that is passed the set of python packages and returns the list
|
||||
@@ -1146,7 +1141,7 @@ need them, you have to use `python.buildEnv`.
|
||||
Python 2 namespace packages may provide `__init__.py` that collide. In that case
|
||||
`python.buildEnv` should be used with `ignoreCollisions = true`.
|
||||
|
||||
#### Setup hooks {#setup-hooks}
|
||||
#### Setup hooks
|
||||
|
||||
The following are setup hooks specifically for Python packages. Most of these
|
||||
are used in `buildPythonPackage`.
|
||||
@@ -1171,7 +1166,7 @@ are used in `buildPythonPackage`.
|
||||
- `wheelUnpackHook` to move a wheel to the correct folder so it can be installed
|
||||
with the `pipInstallHook`.
|
||||
|
||||
### Development mode {#development-mode}
|
||||
### Development mode
|
||||
|
||||
Development or editable mode is supported. To develop Python packages
|
||||
`buildPythonPackage` has additional logic inside `shellPhase` to run `pip
|
||||
@@ -1180,7 +1175,6 @@ install -e . --prefix $TMPDIR/`for the package.
|
||||
Warning: `shellPhase` is executed only if `setup.py` exists.
|
||||
|
||||
Given a `default.nix`:
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
|
||||
@@ -1203,7 +1197,7 @@ nix-shell -p pythonPackages.pyramid zlib libjpeg git
|
||||
|
||||
Note: There is a boolean value `lib.inNixShell` set to `true` if nix-shell is invoked.
|
||||
|
||||
### Tools {#tools}
|
||||
### Tools
|
||||
|
||||
Packages inside nixpkgs are written by hand. However many tools exist in
|
||||
community to help save time. No tool is preferred at the moment.
|
||||
@@ -1215,7 +1209,7 @@ community to help save time. No tool is preferred at the moment.
|
||||
- [nixpkgs-pytools](https://github.com/nix-community/nixpkgs-pytools)
|
||||
- [poetry2nix](https://github.com/nix-community/poetry2nix)
|
||||
|
||||
### Deterministic builds {#deterministic-builds}
|
||||
### Deterministic builds
|
||||
|
||||
The Python interpreters are now built deterministically. Minor modifications had
|
||||
to be made to the interpreters in order to generate deterministic bytecode. This
|
||||
@@ -1227,7 +1221,7 @@ have timestamp 1. The `buildPythonPackage` function sets `DETERMINISTIC_BUILD=1`
|
||||
and [PYTHONHASHSEED=0](https://docs.python.org/3.8/using/cmdline.html#envvar-PYTHONHASHSEED).
|
||||
Both are also exported in `nix-shell`.
|
||||
|
||||
### Automatic tests {#automatic-tests}
|
||||
### Automatic tests
|
||||
|
||||
It is recommended to test packages as part of the build process.
|
||||
Source distributions (`sdist`) often include test files, but not always.
|
||||
@@ -1236,7 +1230,7 @@ By default the command `python setup.py test` is run as part of the
|
||||
`checkPhase`, but often it is necessary to pass a custom `checkPhase`. An
|
||||
example of such a situation is when `py.test` is used.
|
||||
|
||||
#### Common issues {#common-issues}
|
||||
#### Common issues
|
||||
|
||||
* Non-working tests can often be deselected. By default `buildPythonPackage`
|
||||
runs `python setup.py test`. Most Python modules follows the standard test
|
||||
@@ -1253,19 +1247,18 @@ example of such a situation is when `py.test` is used.
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
* Tests that attempt to access `$HOME` can be fixed by using the following
|
||||
work-around before running tests (e.g. `preCheck`): `export HOME=$(mktemp -d)`
|
||||
|
||||
## FAQ {#faq}
|
||||
## FAQ
|
||||
|
||||
### How to solve circular dependencies? {#how-to-solve-circular-dependencies}
|
||||
### How to solve circular dependencies?
|
||||
|
||||
Consider the packages `A` and `B` that depend on each other. When packaging `B`,
|
||||
a solution is to override package `A` not to depend on `B` as an input. The same
|
||||
should also be done when packaging `A`.
|
||||
|
||||
### How to override a Python package? {#how-to-override-a-python-package}
|
||||
### How to override a Python package?
|
||||
|
||||
We can override the interpreter and pass `packageOverrides`. In the following
|
||||
example we rename the `pandas` package and build it.
|
||||
@@ -1323,7 +1316,7 @@ let
|
||||
in newpkgs.inkscape
|
||||
```
|
||||
|
||||
### `python setup.py bdist_wheel` cannot create .whl {#python-setup.py-bdist_wheel-cannot-create-.whl}
|
||||
### `python setup.py bdist_wheel` cannot create .whl
|
||||
|
||||
Executing `python setup.py bdist_wheel` in a `nix-shell `fails with
|
||||
```
|
||||
@@ -1356,7 +1349,7 @@ or unset `SOURCE_DATE_EPOCH`:
|
||||
nix-shell --run "unset SOURCE_DATE_EPOCH; python3 setup.py bdist_wheel"
|
||||
```
|
||||
|
||||
### `install_data` / `data_files` problems {#install_data-data_files-problems}
|
||||
### `install_data` / `data_files` problems
|
||||
|
||||
If you get the following error:
|
||||
|
||||
@@ -1376,7 +1369,7 @@ ${python.interpreter} setup.py install_data --install-dir=$out --root=$out
|
||||
sed -i '/ = data\_files/d' setup.py
|
||||
```
|
||||
|
||||
### Rationale of non-existent global site-packages {#rationale-of-non-existent-global-site-packages}
|
||||
### Rationale of non-existent global site-packages
|
||||
|
||||
On most operating systems a global `site-packages` is maintained. This however
|
||||
becomes problematic if you want to run multiple Python versions or have multiple
|
||||
@@ -1391,7 +1384,7 @@ If you want to create a Python environment for development, then the recommended
|
||||
method is to use `nix-shell`, either with or without the `python.buildEnv`
|
||||
function.
|
||||
|
||||
### How to consume Python modules using pip in a virtual environment like I am used to on other Operating Systems? {#how-to-consume-python-modules-using-pip-in-a-virtual-environment-like-i-am-used-to-on-other-operating-systems}
|
||||
### How to consume Python modules using pip in a virtual environment like I am used to on other Operating Systems?
|
||||
|
||||
While this approach is not very idiomatic from Nix perspective, it can still be
|
||||
useful when dealing with pre-existing projects or in situations where it's not
|
||||
@@ -1504,7 +1497,7 @@ is executed it will attempt to download the Python modules listed in
|
||||
requirements.txt. However these will be cached locally within the `virtualenv`
|
||||
folder and not downloaded again.
|
||||
|
||||
### How to override a Python package from `configuration.nix`? {#how-to-override-a-python-package-from-configuration.nix}
|
||||
### How to override a Python package from `configuration.nix`?
|
||||
|
||||
If you need to change a package's attribute(s) from `configuration.nix` you could do:
|
||||
|
||||
@@ -1513,7 +1506,7 @@ If you need to change a package's attribute(s) from `configuration.nix` you coul
|
||||
python = super.python.override {
|
||||
packageOverrides = python-self: python-super: {
|
||||
twisted = python-super.twisted.overrideAttrs (oldAttrs: {
|
||||
src = super.fetchPypi {
|
||||
src = super.fetchPipy {
|
||||
pname = "twisted";
|
||||
version = "19.10.0";
|
||||
sha256 = "7394ba7f272ae722a74f3d969dcf599bc4ef093bc392038748a490f1724a515d";
|
||||
@@ -1542,7 +1535,7 @@ this snippet:
|
||||
}
|
||||
```
|
||||
|
||||
### How to override a Python package using overlays? {#how-to-override-a-python-package-using-overlays}
|
||||
### How to override a Python package using overlays?
|
||||
|
||||
Use the following overlay template:
|
||||
|
||||
@@ -1563,12 +1556,12 @@ self: super: {
|
||||
}
|
||||
```
|
||||
|
||||
### How to use Intel’s MKL with numpy and scipy? {#how-to-use-intels-mkl-with-numpy-and-scipy}
|
||||
### How to use Intel's MKL with numpy and scipy?
|
||||
|
||||
MKL can be configured using an overlay. See the section "[Using overlays to
|
||||
configure alternatives](#sec-overlays-alternatives-blas-lapack)".
|
||||
|
||||
### What inputs do `setup_requires`, `install_requires` and `tests_require` map to? {#what-inputs-do-setup_requires-install_requires-and-tests_require-map-to}
|
||||
### What inputs do `setup_requires`, `install_requires` and `tests_require` map to?
|
||||
|
||||
In a `setup.py` or `setup.cfg` it is common to declare dependencies:
|
||||
|
||||
@@ -1576,9 +1569,9 @@ In a `setup.py` or `setup.cfg` it is common to declare dependencies:
|
||||
* `install_requires` corresponds to `propagatedBuildInputs`
|
||||
* `tests_require` corresponds to `checkInputs`
|
||||
|
||||
## Contributing {#contributing}
|
||||
## Contributing
|
||||
|
||||
### Contributing guidelines {#contributing-guidelines}
|
||||
### Contributing guidelines
|
||||
|
||||
The following rules are desired to be respected:
|
||||
|
||||
@@ -1602,33 +1595,3 @@ The following rules are desired to be respected:
|
||||
If necessary, `pname` has to be given a different value within `fetchPypi`.
|
||||
* Attribute names in `python-packages.nix` should be sorted alphanumerically to
|
||||
avoid merge conflicts and ease locating attributes.
|
||||
|
||||
## Package set maintenance
|
||||
|
||||
The whole Python package set has a lot of packages that do not see regular
|
||||
updates, because they either are a very fragile component in the Python
|
||||
ecosystem, like for example the `hypothesis` package, or packages that have
|
||||
no maintainer, so maintenance falls back to the package set maintainers.
|
||||
|
||||
### Updating packages in bulk
|
||||
|
||||
There is a tool to update alot of python libraries in bulk, it exists at
|
||||
`maintainers/scripts/update-python-libraries` with this repository.
|
||||
|
||||
It can quickly update minor or major versions for all packages selected
|
||||
and create update commits, and supports the `fetchPypi`, `fetchurl` and
|
||||
`fetchFromGitHub` fetchers. When updating lots of packages that are
|
||||
hosted on GitHub, exporting a `GITHUB_API_TOKEN` is highly recommended.
|
||||
|
||||
Updating packages in bulk leads to lots of breakages, which is why a
|
||||
stabilization period on the `python-unstable` branch is required.
|
||||
|
||||
Once the branch is sufficiently stable it should normally be merged
|
||||
into the `staging` branch.
|
||||
|
||||
An exemplary call to update all python libraries between minor versions
|
||||
would be:
|
||||
|
||||
```ShellSession
|
||||
$ maintainers/scripts/update-python-libraries --target minor --commit --use-pkgs-prefix pkgs/development/python-modules/**/default.nix
|
||||
```
|
||||
|
||||
@@ -90,21 +90,19 @@ stdenv.mkDerivation {
|
||||
}
|
||||
```
|
||||
|
||||
::: {.note}
|
||||
::: note
|
||||
`wrapQtAppsHook` ignores files that are non-ELF executables.
|
||||
This means that scripts won't be automatically wrapped so you'll need to manually wrap them as previously mentioned.
|
||||
An example of when you'd always need to do this is with Python applications that use PyQt.
|
||||
:::
|
||||
|
||||
## Adding a library to Nixpkgs {#adding-a-library-to-nixpkgs}
|
||||
|
||||
## Adding a library to Nixpkgs
|
||||
Add Qt libraries to `qt5-packages.nix` to make them available for every
|
||||
supported Qt version.
|
||||
|
||||
### Example adding a Qt library {#qt-library-all-packages-nix}
|
||||
|
||||
The following represents the contents of `qt5-packages.nix`.
|
||||
|
||||
```nix
|
||||
{
|
||||
# ...
|
||||
@@ -128,15 +126,13 @@ stdenv.mkDerivation {
|
||||
}
|
||||
```
|
||||
|
||||
## Adding an application to Nixpkgs {#adding-an-application-to-nixpkgs}
|
||||
|
||||
## Adding an application to Nixpkgs
|
||||
Add Qt applications to `qt5-packages.nix`. Add an alias to `all-packages.nix`
|
||||
to select the Qt 5 version used for the application.
|
||||
|
||||
### Example adding a Qt application {#qt-application-all-packages-nix}
|
||||
|
||||
The following represents the contents of `qt5-packages.nix`.
|
||||
|
||||
```nix
|
||||
{
|
||||
# ...
|
||||
@@ -148,7 +144,6 @@ The following represents the contents of `qt5-packages.nix`.
|
||||
```
|
||||
|
||||
The following represents the contents of `all-packages.nix`.
|
||||
|
||||
```nix
|
||||
{
|
||||
# ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# R {#r}
|
||||
|
||||
## Installation {#installation}
|
||||
## Installation
|
||||
|
||||
Define an environment for R that contains all the libraries that you'd like to
|
||||
use by adding the following snippet to your $HOME/.config/nixpkgs/config.nix file:
|
||||
@@ -31,7 +31,6 @@ output is the name that has to be passed to rWrapper in the code snipped above.
|
||||
However, if you'd like to add a file to your project source to make the
|
||||
environment available for other contributors, you can create a `default.nix`
|
||||
file like so:
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
{
|
||||
@@ -51,7 +50,7 @@ with import <nixpkgs> {};
|
||||
and then run `nix-shell .` to be dropped into a shell with those packages
|
||||
available.
|
||||
|
||||
## RStudio {#rstudio}
|
||||
## RStudio
|
||||
|
||||
RStudio uses a standard set of packages and ignores any custom R
|
||||
environments or installed packages you may have. To create a custom
|
||||
@@ -94,12 +93,7 @@ Executing `nix-shell` will then drop you into an environment equivalent to the
|
||||
one above. If you need additional packages just add them to the list and
|
||||
re-enter the shell.
|
||||
|
||||
## Updating the package set {#updating-the-package-set}
|
||||
|
||||
There is a script and associated environment for regenerating the package
|
||||
sets and synchronising the rPackages tree to the current CRAN and matching
|
||||
BIOC release. These scripts are found in the `pkgs/development/r-modules`
|
||||
directory and executed as follows:
|
||||
## Updating the package set
|
||||
|
||||
```bash
|
||||
nix-shell generate-shell.nix
|
||||
@@ -117,11 +111,13 @@ Rscript generate-r-packages.R bioc-experiment > bioc-experiment-packages.nix.new
|
||||
mv bioc-experiment-packages.nix.new bioc-experiment-packages.nix
|
||||
```
|
||||
|
||||
`generate-r-packages.R <repo>` reads `<repo>-packages.nix`, therefore
|
||||
the renaming.
|
||||
`generate-r-packages.R <repo>` reads `<repo>-packages.nix`, therefor the renaming.
|
||||
|
||||
Some packages require overrides to specify external dependencies or other
|
||||
patches and special requirements. These overrides are specified in the
|
||||
`pkgs/development/r-modules/default.nix` file. As the `*-packages.nix`
|
||||
contents are automatically generated it should not be edited and broken
|
||||
builds should be addressed using overrides.
|
||||
|
||||
## Testing if the Nix-expression could be evaluated
|
||||
|
||||
```bash
|
||||
nix-build test-evaluation.nix --dry-run
|
||||
```
|
||||
|
||||
If this exits fine, the expression is ok. If not, you have to edit `default.nix`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Ruby {#sec-language-ruby}
|
||||
|
||||
## Using Ruby {#using-ruby}
|
||||
## Using Ruby
|
||||
|
||||
Several versions of Ruby interpreters are available on Nix, as well as over 250 gems and many applications written in Ruby. The attribute `ruby` refers to the default Ruby interpreter, which is currently MRI 2.6. It's also possible to refer to specific versions, e.g. `ruby_2_y`, `jruby`, or `mruby`.
|
||||
|
||||
@@ -8,11 +8,11 @@ In the Nixpkgs tree, Ruby packages can be found throughout, depending on what th
|
||||
|
||||
There are two main approaches for using Ruby with gems. One is to use a specifically locked `Gemfile` for an application that has very strict dependencies. The other is to depend on the common gems, which we'll explain further down, and rely on them being updated regularly.
|
||||
|
||||
The interpreters have common attributes, namely `gems`, and `withPackages`. So you can refer to `ruby.gems.nokogiri`, or `ruby_2_7.gems.nokogiri` to get the Nokogiri gem already compiled and ready to use.
|
||||
The interpreters have common attributes, namely `gems`, and `withPackages`. So you can refer to `ruby.gems.nokogiri`, or `ruby_2_6.gems.nokogiri` to get the Nokogiri gem already compiled and ready to use.
|
||||
|
||||
Since not all gems have executables like `nokogiri`, it's usually more convenient to use the `withPackages` function like this: `ruby.withPackages (p: with p; [ nokogiri ])`. This will also make sure that the Ruby in your environment will be able to find the gem and it can be used in your Ruby code (for example via `ruby` or `irb` executables) via `require "nokogiri"` as usual.
|
||||
|
||||
### Temporary Ruby environment with `nix-shell` {#temporary-ruby-environment-with-nix-shell}
|
||||
### Temporary Ruby environment with `nix-shell`
|
||||
|
||||
Rather than having a single Ruby environment shared by all Ruby development projects on a system, Nix allows you to create separate environments per project. `nix-shell` gives you the possibility to temporarily load another environment akin to a combined `chruby` or `rvm` and `bundle exec`.
|
||||
|
||||
@@ -30,7 +30,7 @@ $ nix-shell -p ruby.gems.nokogiri ruby.gems.pry
|
||||
|
||||
Again, it's possible to launch the interpreter from the shell. The Ruby interpreter has the attribute `gems` which contains all Ruby gems for that specific interpreter.
|
||||
|
||||
#### Load Ruby environment from `.nix` expression {#load-ruby-environment-from-.nix-expression}
|
||||
#### Load Ruby environment from `.nix` expression
|
||||
|
||||
As explained in the Nix manual, `nix-shell` can also load an expression from a `.nix` file. Say we want to have Ruby 2.6, `nokogori`, and `pry`. Consider a `shell.nix` file with:
|
||||
|
||||
@@ -45,7 +45,7 @@ What's happening here?
|
||||
2. Then we create a Ruby environment with the `withPackages` function.
|
||||
3. The `withPackages` function expects us to provide a function as an argument that takes the set of all ruby gems and returns a list of packages to include in the environment. Here, we select the packages `nokogiri` and `pry` from the package set.
|
||||
|
||||
#### Execute command with `--run` {#execute-command-with---run}
|
||||
#### Execute command with `--run`
|
||||
|
||||
A convenient flag for `nix-shell` is `--run`. It executes a command in the `nix-shell`. We can e.g. directly open a `pry` REPL:
|
||||
|
||||
@@ -65,7 +65,7 @@ Or run a script using this environment:
|
||||
$ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --run "ruby example.rb"
|
||||
```
|
||||
|
||||
#### Using `nix-shell` as shebang {#using-nix-shell-as-shebang}
|
||||
#### Using `nix-shell` as shebang
|
||||
|
||||
In fact, for the last case, there is a more convenient method. You can add a [shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>) to your script specifying which dependencies `nix-shell` needs. With the following shebang, you can just execute `./example.rb`, and it will run with all dependencies.
|
||||
|
||||
@@ -80,9 +80,9 @@ body = RestClient.get('http://example.com').body
|
||||
puts Nokogiri::HTML(body).at('h1').text
|
||||
```
|
||||
|
||||
## Developing with Ruby {#developing-with-ruby}
|
||||
## Developing with Ruby
|
||||
|
||||
### Using an existing Gemfile {#using-an-existing-gemfile}
|
||||
### Using an existing Gemfile
|
||||
|
||||
In most cases, you'll already have a `Gemfile.lock` listing all your dependencies. This can be used to generate a `gemset.nix` which is used to fetch the gems and combine them into a single environment. The reason why you need to have a separate file for this, is that Nix requires you to have a checksum for each input to your build. Since the `Gemfile.lock` that `bundler` generates doesn't provide us with checksums, we have to first download each gem, calculate its SHA256, and store it in this separate file.
|
||||
|
||||
@@ -120,7 +120,7 @@ One common issue that you might have is that you have Ruby 2.6, but also `bundle
|
||||
mkShell { buildInputs = [ gems (lowPrio gems.wrappedRuby) ]; }
|
||||
```
|
||||
|
||||
### Gem-specific configurations and workarounds {#gem-specific-configurations-and-workarounds}
|
||||
### Gem-specific configurations and workarounds
|
||||
|
||||
In some cases, especially if the gem has native extensions, you might need to modify the way the gem is built.
|
||||
|
||||
@@ -201,7 +201,7 @@ $ nix-shell --run 'ruby -rpg -e "puts PG.library_version"'
|
||||
|
||||
Of course for this use-case one could also use overlays since the configuration for `pg` depends on the `postgresql` alias, but for demonstration purposes this has to suffice.
|
||||
|
||||
### Adding a gem to the default gemset {#adding-a-gem-to-the-default-gemset}
|
||||
### Adding a gem to the default gemset
|
||||
|
||||
Now that you know how to get a working Ruby environment with Nix, it's time to go forward and start actually developing with Ruby. We will first have a look at how Ruby gems are packaged on Nix. Then, we will look at how you can use development mode with your code.
|
||||
|
||||
@@ -215,7 +215,7 @@ To test that it works, you can then try using the gem with:
|
||||
NIX_PATH=nixpkgs=$PWD nix-shell -p "ruby.withPackages (ps: with ps; [ name-of-your-gem ])"
|
||||
```
|
||||
|
||||
### Packaging applications {#packaging-applications}
|
||||
### Packaging applications
|
||||
|
||||
A common task is to add a ruby executable to nixpkgs, popular examples would be `chef`, `jekyll`, or `sass`. A good way to do that is to use the `bundlerApp` function, that allows you to make a package that only exposes the listed executables, otherwise the package may cause conflicts through common paths like `bin/rake` or `bin/bundler` that aren't meant to be used.
|
||||
|
||||
@@ -243,7 +243,7 @@ bundlerApp {
|
||||
|
||||
All that's left to do is to generate the corresponding `Gemfile.lock` and `gemset.nix` as described above in the `Using an existing Gemfile` section.
|
||||
|
||||
#### Packaging executables that require wrapping {#packaging-executables-that-require-wrapping}
|
||||
#### Packaging executables that require wrapping
|
||||
|
||||
Sometimes your app will depend on other executables at runtime, and tries to find it through the `PATH` environment variable.
|
||||
|
||||
|
||||
@@ -13,14 +13,14 @@ into your `configuration.nix` or bring them into scope with `nix-shell -p rustc
|
||||
|
||||
For other versions such as daily builds (beta and nightly),
|
||||
use either `rustup` from nixpkgs (which will manage the rust installation in your home directory),
|
||||
or use a community maintained [Rust overlay](#using-community-rust-overlays).
|
||||
or use Mozilla's [Rust nightlies overlay](#using-the-rust-nightlies-overlay).
|
||||
|
||||
## Compiling Rust applications with Cargo {#compiling-rust-applications-with-cargo}
|
||||
## Compiling Rust applications with Cargo
|
||||
|
||||
Rust applications are packaged by using the `buildRustPackage` helper from `rustPlatform`:
|
||||
|
||||
```nix
|
||||
{ lib, fetchFromGitHub, rustPlatform }:
|
||||
{ lib, rustPlatform }:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "ripgrep";
|
||||
@@ -107,113 +107,8 @@ rustPlatform.buildRustPackage rec {
|
||||
}
|
||||
```
|
||||
|
||||
### Importing a `Cargo.lock` file {#importing-a-cargo.lock-file}
|
||||
|
||||
Using `cargoSha256` or `cargoHash` is tedious when using
|
||||
`buildRustPackage` within a project, since it requires that the hash
|
||||
is updated after every change to `Cargo.lock`. Therefore,
|
||||
`buildRustPackage` also supports vendoring dependencies directly from
|
||||
a `Cargo.lock` file using the `cargoLock` argument. For example:
|
||||
|
||||
```nix
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "myproject";
|
||||
version = "1.0.0";
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
|
||||
# ...
|
||||
}
|
||||
```
|
||||
|
||||
This will retrieve the dependencies using fixed-output derivations from
|
||||
the specified lockfile.
|
||||
|
||||
One caveat is that `Cargo.lock` cannot be patched in the `patchPhase`
|
||||
because it runs after the dependencies have already been fetched. If
|
||||
you need to patch or generate the lockfile you can alternatively set
|
||||
`cargoLock.lockFileContents` to a string of its contents:
|
||||
|
||||
```nix
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "myproject";
|
||||
version = "1.0.0";
|
||||
|
||||
cargoLock = let
|
||||
fixupLockFile = path: f (builtins.readFile path);
|
||||
in {
|
||||
lockFileContents = fixupLockFile ./Cargo.lock;
|
||||
};
|
||||
|
||||
# ...
|
||||
}
|
||||
```
|
||||
|
||||
Note that setting `cargoLock.lockFile` or `cargoLock.lockFileContents`
|
||||
doesn't add a `Cargo.lock` to your `src`, and a `Cargo.lock` is still
|
||||
required to build a rust package. A simple fix is to use:
|
||||
|
||||
```nix
|
||||
postPatch = ''
|
||||
cp ${./Cargo.lock} Cargo.lock
|
||||
'';
|
||||
```
|
||||
|
||||
The output hash of each dependency that uses a git source must be
|
||||
specified in the `outputHashes` attribute. For example:
|
||||
|
||||
```nix
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "myproject";
|
||||
version = "1.0.0";
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"finalfusion-0.14.0" = "17f4bsdzpcshwh74w5z119xjy2if6l2wgyjy56v621skr2r8y904";
|
||||
};
|
||||
};
|
||||
|
||||
# ...
|
||||
}
|
||||
```
|
||||
|
||||
If you do not specify an output hash for a git dependency, building
|
||||
the package will fail and inform you of which crate needs to be
|
||||
added. To find the correct hash, you can first use `lib.fakeSha256` or
|
||||
`lib.fakeHash` as a stub hash. Building the package (and thus the
|
||||
vendored dependencies) will then inform you of the correct hash.
|
||||
|
||||
### Cargo features {#cargo-features}
|
||||
|
||||
You can disable default features using `buildNoDefaultFeatures`, and
|
||||
extra features can be added with `buildFeatures`.
|
||||
|
||||
If you want to use different features for check phase, you can use
|
||||
`checkNoDefaultFeatures` and `checkFeatures`. They are only passed to
|
||||
`cargo test` and not `cargo build`. If left unset, they default to
|
||||
`buildNoDefaultFeatures` and `buildFeatures`.
|
||||
|
||||
For example:
|
||||
|
||||
```nix
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "myproject";
|
||||
version = "1.0.0";
|
||||
|
||||
buildNoDefaultFeatures = true;
|
||||
buildFeatures = [ "color" "net" ];
|
||||
|
||||
# disable network features in tests
|
||||
checkFeatures = [ "color" ];
|
||||
|
||||
# ...
|
||||
}
|
||||
```
|
||||
|
||||
### Cross compilation {#cross-compilation}
|
||||
### Cross compilation
|
||||
|
||||
By default, Rust packages are compiled for the host platform, just like any
|
||||
other package is. The `--target` passed to rust tools is computed from this.
|
||||
@@ -225,7 +120,6 @@ where they are known to differ. But there are ways to customize the argument:
|
||||
name will be used instead.
|
||||
|
||||
For example:
|
||||
|
||||
```nix
|
||||
import <nixpkgs> {
|
||||
crossSystem = (import <nixpkgs/lib>).systems.examples.armhf-embedded // {
|
||||
@@ -233,9 +127,7 @@ where they are known to differ. But there are ways to customize the argument:
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
will result in:
|
||||
|
||||
```shell
|
||||
--target thumbv7em-none-eabi
|
||||
```
|
||||
@@ -248,7 +140,6 @@ where they are known to differ. But there are ways to customize the argument:
|
||||
will be used instead.
|
||||
|
||||
For example:
|
||||
|
||||
```nix
|
||||
import <nixpkgs> {
|
||||
crossSystem = (import <nixpkgs/lib>).systems.examples.armhf-embedded // {
|
||||
@@ -257,17 +148,31 @@ where they are known to differ. But there are ways to customize the argument:
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
will result in:
|
||||
|
||||
```shell
|
||||
--target /nix/store/asdfasdfsadf-thumb-crazy.json # contains {"foo":"","bar":""}
|
||||
```
|
||||
|
||||
Finally, as an ad-hoc escape hatch, a computed target (string or JSON file
|
||||
path) can be passed directly to `buildRustPackage`:
|
||||
|
||||
```nix
|
||||
pkgs.rustPlatform.buildRustPackage {
|
||||
/* ... */
|
||||
target = "x86_64-fortanix-unknown-sgx";
|
||||
}
|
||||
```
|
||||
|
||||
This is useful to avoid rebuilding Rust tools, since they are actually target
|
||||
agnostic and don't need to be rebuilt. But in the future, we should always
|
||||
build the Rust tools and standard library crates separately so there is no
|
||||
reason not to take the `stdenv.hostPlatform.rustc`-modifying approach, and the
|
||||
ad-hoc escape hatch to `buildRustPackage` can be removed.
|
||||
|
||||
Note that currently custom targets aren't compiled with `std`, so `cargo test`
|
||||
will fail. This can be ignored by adding `doCheck = false;` to your derivation.
|
||||
|
||||
### Running package tests {#running-package-tests}
|
||||
### Running package tests
|
||||
|
||||
When using `buildRustPackage`, the `checkPhase` is enabled by default and runs
|
||||
`cargo test` on the package to build. To make sure that we don't compile the
|
||||
@@ -288,14 +193,14 @@ rustPlatform.buildRustPackage {
|
||||
Please note that the code will be compiled twice here: once in `release` mode
|
||||
for the `buildPhase`, and again in `debug` mode for the `checkPhase`.
|
||||
|
||||
Test flags, e.g., `--package foo`, can be passed to `cargo test` via the
|
||||
Test flags, e.g., `--features xxx/yyy`, can be passed to `cargo test` via the
|
||||
`cargoTestFlags` attribute.
|
||||
|
||||
Another attribute, called `checkFlags`, is used to pass arguments to the test
|
||||
binary itself, as stated
|
||||
(here)[https://doc.rust-lang.org/cargo/commands/cargo-test.html].
|
||||
|
||||
#### Tests relying on the structure of the `target/` directory {#tests-relying-on-the-structure-of-the-target-directory}
|
||||
#### Tests relying on the structure of the `target/` directory
|
||||
|
||||
Some tests may rely on the structure of the `target/` directory. Those tests
|
||||
are likely to fail because we use `cargo --target` during the build. This means that
|
||||
@@ -305,7 +210,7 @@ rather than in `target/release/`.
|
||||
|
||||
This can only be worked around by patching the affected tests accordingly.
|
||||
|
||||
#### Disabling package-tests {#disabling-package-tests}
|
||||
#### Disabling package-tests
|
||||
|
||||
In some instances, it may be necessary to disable testing altogether (with `doCheck = false;`):
|
||||
|
||||
@@ -319,7 +224,7 @@ The above are just guidelines, and exceptions may be granted on a case-by-case b
|
||||
However, please check if it's possible to disable a problematic subset of the
|
||||
test suite and leave a comment explaining your reasoning.
|
||||
|
||||
#### Setting `test-threads` {#setting-test-threads}
|
||||
#### Setting `test-threads`
|
||||
|
||||
`buildRustPackage` will use parallel test threads by default,
|
||||
sometimes it may be necessary to disable this so the tests run consecutively.
|
||||
@@ -331,7 +236,7 @@ rustPlatform.buildRustPackage {
|
||||
}
|
||||
```
|
||||
|
||||
### Building a package in `debug` mode {#building-a-package-in-debug-mode}
|
||||
### Building a package in `debug` mode
|
||||
|
||||
By default, `buildRustPackage` will use `release` mode for builds. If a package
|
||||
should be built in `debug` mode, it can be configured like so:
|
||||
@@ -345,14 +250,14 @@ rustPlatform.buildRustPackage {
|
||||
|
||||
In this scenario, the `checkPhase` will be ran in `debug` mode as well.
|
||||
|
||||
### Custom `build`/`install`-procedures {#custom-buildinstall-procedures}
|
||||
### Custom `build`/`install`-procedures
|
||||
|
||||
Some packages may use custom scripts for building/installing, e.g. with a `Makefile`.
|
||||
In these cases, it's recommended to override the `buildPhase`/`installPhase`/`checkPhase`.
|
||||
|
||||
Otherwise, some steps may fail because of the modified directory structure of `target/`.
|
||||
|
||||
### Building a crate with an absent or out-of-date Cargo.lock file {#building-a-crate-with-an-absent-or-out-of-date-cargo.lock-file}
|
||||
### Building a crate with an absent or out-of-date Cargo.lock file
|
||||
|
||||
`buildRustPackage` needs a `Cargo.lock` file to get all dependencies in the
|
||||
source code in a reproducible way. If it is missing or out-of-date one can use
|
||||
@@ -368,13 +273,13 @@ rustPlatform.buildRustPackage rec {
|
||||
}
|
||||
```
|
||||
|
||||
## Compiling non-Rust packages that include Rust code {#compiling-non-rust-packages-that-include-rust-code}
|
||||
## Compiling non-Rust packages that include Rust code
|
||||
|
||||
Several non-Rust packages incorporate Rust code for performance- or
|
||||
security-sensitive parts. `rustPlatform` exposes several functions and
|
||||
hooks that can be used to integrate Cargo in non-Rust packages.
|
||||
|
||||
### Vendoring of dependencies {#vendoring-of-dependencies}
|
||||
### Vendoring of dependencies
|
||||
|
||||
Since network access is not allowed in sandboxed builds, Rust crate
|
||||
dependencies need to be retrieved using a fetcher. `rustPlatform`
|
||||
@@ -403,42 +308,11 @@ attributes can also be used:
|
||||
the `Cargo.lock`/`Cargo.toml` files need to be patched before
|
||||
vendoring.
|
||||
|
||||
If a `Cargo.lock` file is available, you can alternatively use the
|
||||
`importCargoLock` function. In contrast to `fetchCargoTarball`, this
|
||||
function does not require a hash (unless git dependencies are used)
|
||||
and fetches every dependency as a separate fixed-output derivation.
|
||||
`importCargoLock` can be used as follows:
|
||||
|
||||
```
|
||||
cargoDeps = rustPlatform.importCargoLock {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
```
|
||||
|
||||
If the `Cargo.lock` file includes git dependencies, then their output
|
||||
hashes need to be specified since they are not available through the
|
||||
lock file. For example:
|
||||
|
||||
```
|
||||
cargoDeps = rustPlatform.importCargoLock {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"rand-0.8.3" = "0ya2hia3cn31qa8894s3av2s8j5bjwb6yq92k0jsnlx7jid0jwqa";
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
If you do not specify an output hash for a git dependency, building
|
||||
`cargoDeps` will fail and inform you of which crate needs to be
|
||||
added. To find the correct hash, you can first use `lib.fakeSha256` or
|
||||
`lib.fakeHash` as a stub hash. Building `cargoDeps` will then inform
|
||||
you of the correct hash.
|
||||
|
||||
### Hooks {#hooks}
|
||||
### Hooks
|
||||
|
||||
`rustPlatform` provides the following hooks to automate Cargo builds:
|
||||
|
||||
* `cargoSetupHook`: configure Cargo to use dependencies vendored
|
||||
* `cargoSetupHook`: configure Cargo to use depenencies vendored
|
||||
through `fetchCargoTarball`. This hook uses the `cargoDeps`
|
||||
environment variable to find the vendored dependencies. If a project
|
||||
already vendors its dependencies, the variable `cargoVendorDir` can
|
||||
@@ -448,26 +322,24 @@ you of the correct hash.
|
||||
* `cargoBuildHook`: use Cargo to build a crate. If the crate to be
|
||||
built is a crate in e.g. a Cargo workspace, the relative path to the
|
||||
crate to build can be set through the optional `buildAndTestSubdir`
|
||||
environment variable. Features can be specified with
|
||||
`cargoBuildNoDefaultFeatures` and `cargoBuildFeatures`. Additional
|
||||
Cargo build flags can be passed through `cargoBuildFlags`.
|
||||
environment variable. Additional Cargo build flags can be passed
|
||||
through `cargoBuildFlags`.
|
||||
* `maturinBuildHook`: use [Maturin](https://github.com/PyO3/maturin)
|
||||
to build a Python wheel. Similar to `cargoBuildHook`, the optional
|
||||
variable `buildAndTestSubdir` can be used to build a crate in a
|
||||
Cargo workspace. Additional Maturin flags can be passed through
|
||||
Cargo workspace. Additional maturin flags can be passed through
|
||||
`maturinBuildFlags`.
|
||||
* `cargoCheckHook`: run tests using Cargo. The build type for checks
|
||||
can be set using `cargoCheckType`. Features can be specified with
|
||||
`cargoCheckNoDefaultFeaatures` and `cargoCheckFeatures`. Additional
|
||||
flags can be passed to the tests using `checkFlags` and
|
||||
`checkFlagsArray`. By default, tests are run in parallel. This can
|
||||
be disabled by setting `dontUseCargoParallelTests`.
|
||||
can be set using `cargoCheckType`. Additional flags can be passed to
|
||||
the tests using `checkFlags` and `checkFlagsArray`. By default,
|
||||
tests are run in parallel. This can be disabled by setting
|
||||
`dontUseCargoParallelTests`.
|
||||
* `cargoInstallHook`: install binaries and static/shared libraries
|
||||
that were built using `cargoBuildHook`.
|
||||
|
||||
### Examples {#examples}
|
||||
### Examples
|
||||
|
||||
#### Python package using `setuptools-rust` {#python-package-using-setuptools-rust}
|
||||
#### Python package using `setuptools-rust`
|
||||
|
||||
For Python packages using `setuptools-rust`, you can use
|
||||
`fetchCargoTarball` and `cargoSetupHook` to retrieve and set up Cargo
|
||||
@@ -476,7 +348,7 @@ dependencies. The build itself is then performed by
|
||||
|
||||
The following example outlines how the `tokenizers` Python package is
|
||||
built. Since the Python package is in the `source/bindings/python`
|
||||
directory of the `tokenizers` project's source archive, we use
|
||||
directory of the *tokenizers* project's source archive, we use
|
||||
`sourceRoot` to point the tooling to this directory:
|
||||
|
||||
```nix
|
||||
@@ -553,7 +425,7 @@ buildPythonPackage rec {
|
||||
}
|
||||
```
|
||||
|
||||
#### Python package using `maturin` {#python-package-using-maturin}
|
||||
#### Python package using `maturin`
|
||||
|
||||
Python packages that use [Maturin](https://github.com/PyO3/maturin)
|
||||
can be built with `fetchCargoTarball`, `cargoSetupHook`, and
|
||||
@@ -594,9 +466,9 @@ buildPythonPackage rec {
|
||||
}
|
||||
```
|
||||
|
||||
## Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo}
|
||||
## Compiling Rust crates using Nix instead of Cargo
|
||||
|
||||
### Simple operation {#simple-operation}
|
||||
### Simple operation
|
||||
|
||||
When run, `cargo build` produces a file called `Cargo.lock`,
|
||||
containing pinned versions of all dependencies. Nixpkgs contains a
|
||||
@@ -607,15 +479,14 @@ That Nix expression calls `rustc` directly (hence bypassing Cargo),
|
||||
and can be used to compile a crate and all its dependencies. Here is
|
||||
an example for a minimal `hello` crate:
|
||||
|
||||
```ShellSession
|
||||
$ cargo new hello
|
||||
$ cd hello
|
||||
$ cargo build
|
||||
|
||||
$ cargo new hello
|
||||
$ cd hello
|
||||
$ cargo build
|
||||
Compiling hello v0.1.0 (file:///tmp/hello)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.20 secs
|
||||
$ carnix -o hello.nix --src ./. Cargo.lock --standalone
|
||||
$ nix-build hello.nix -A hello_0_1_0
|
||||
```
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.20 secs
|
||||
$ carnix -o hello.nix --src ./. Cargo.lock --standalone
|
||||
$ nix-build hello.nix -A hello_0_1_0
|
||||
|
||||
Now, the file produced by the call to `carnix`, called `hello.nix`, looks like:
|
||||
|
||||
@@ -694,14 +565,14 @@ Here, the `libc` crate has no `src` attribute, so `buildRustCrate`
|
||||
will fetch it from [crates.io](https://crates.io). A `sha256`
|
||||
attribute is still needed for Nix purity.
|
||||
|
||||
### Handling external dependencies {#handling-external-dependencies}
|
||||
### Handling external dependencies
|
||||
|
||||
Some crates require external libraries. For crates from
|
||||
[crates.io](https://crates.io), such libraries can be specified in
|
||||
`defaultCrateOverrides` package in nixpkgs itself.
|
||||
|
||||
Starting from that file, one can add more overrides, to add features
|
||||
or build inputs by overriding the hello crate in a separate file.
|
||||
or build inputs by overriding the hello crate in a seperate file.
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
@@ -753,12 +624,12 @@ with import <nixpkgs> {};
|
||||
}
|
||||
```
|
||||
|
||||
### Options and phases configuration {#options-and-phases-configuration}
|
||||
### Options and phases configuration
|
||||
|
||||
Actually, the overrides introduced in the previous section are more
|
||||
general. A number of other parameters can be overridden:
|
||||
|
||||
- The version of `rustc` used to compile the crate:
|
||||
- The version of rustc used to compile the crate:
|
||||
|
||||
```nix
|
||||
(hello {}).override { rust = pkgs.rust; };
|
||||
@@ -771,7 +642,7 @@ general. A number of other parameters can be overridden:
|
||||
(hello {}).override { release = false; };
|
||||
```
|
||||
|
||||
- Whether to print the commands sent to `rustc` when building
|
||||
- Whether to print the commands sent to rustc when building
|
||||
(equivalent to `--verbose` in cargo:
|
||||
|
||||
```nix
|
||||
@@ -800,7 +671,7 @@ general. A number of other parameters can be overridden:
|
||||
};
|
||||
```
|
||||
|
||||
### Features {#features}
|
||||
### Features
|
||||
|
||||
One can also supply features switches. For example, if we want to
|
||||
compile `diesel_cli` only with the `postgres` feature, and no default
|
||||
@@ -815,15 +686,14 @@ features, we would write:
|
||||
|
||||
Where `diesel.nix` is the file generated by Carnix, as explained above.
|
||||
|
||||
## Setting Up `nix-shell` {#setting-up-nix-shell}
|
||||
|
||||
## Setting Up `nix-shell`
|
||||
Oftentimes you want to develop code from within `nix-shell`. Unfortunately
|
||||
`buildRustCrate` does not support common `nix-shell` operations directly
|
||||
(see [this issue](https://github.com/NixOS/nixpkgs/issues/37945))
|
||||
so we will use `stdenv.mkDerivation` instead.
|
||||
|
||||
Using the example `hello` project above, we want to do the following:
|
||||
|
||||
- Have access to `cargo` and `rustc`
|
||||
- Have the `openssl` library available to a crate through it's _normal_
|
||||
compilation mechanism (`pkg-config`).
|
||||
@@ -852,15 +722,13 @@ stdenv.mkDerivation {
|
||||
```
|
||||
|
||||
You should now be able to run the following:
|
||||
|
||||
```ShellSession
|
||||
```ShellSesssion
|
||||
$ nix-shell --pure
|
||||
$ cargo build
|
||||
$ cargo test
|
||||
```
|
||||
|
||||
### Controlling Rust Version Inside `nix-shell` {#controlling-rust-version-inside-nix-shell}
|
||||
|
||||
### Controlling Rust Version Inside `nix-shell`
|
||||
To control your rust version (i.e. use nightly) from within `shell.nix` (or
|
||||
other nix expressions) you can use the following `shell.nix`
|
||||
|
||||
@@ -892,7 +760,6 @@ stdenv.mkDerivation {
|
||||
```
|
||||
|
||||
Now run:
|
||||
|
||||
```ShellSession
|
||||
$ rustc --version
|
||||
rustc 1.26.0-nightly (188e693b3 2018-03-26)
|
||||
@@ -900,103 +767,38 @@ rustc 1.26.0-nightly (188e693b3 2018-03-26)
|
||||
|
||||
To see that you are using nightly.
|
||||
|
||||
## Using community Rust overlays {#using-community-rust-overlays}
|
||||
|
||||
There are two community maintained approaches to Rust toolchain management:
|
||||
- [oxalica's Rust overlay](https://github.com/oxalica/rust-overlay)
|
||||
- [fenix](https://github.com/nix-community/fenix)
|
||||
## Using the Rust nightlies overlay
|
||||
|
||||
Oxalica's overlay allows you to select a particular Rust version and components.
|
||||
See [their documentation](https://github.com/oxalica/rust-overlay#rust-overlay) for more
|
||||
detailed usage.
|
||||
Mozilla provides an overlay for nixpkgs to bring a nightly version of Rust into scope.
|
||||
This overlay can _also_ be used to install recent unstable or stable versions
|
||||
of Rust, if desired.
|
||||
|
||||
Fenix is an alternative to `rustup` and can also be used as an overlay.
|
||||
|
||||
Both oxalica's overlay and fenix better integrate with nix and cache optimizations.
|
||||
Because of this and ergonomics, either of those community projects
|
||||
should be preferred to the Mozilla's Rust overlay (`nixpkgs-mozilla`).
|
||||
|
||||
### How to select a specific `rustc` and toolchain version {#how-to-select-a-specific-rustc-and-toolchain-version}
|
||||
|
||||
You can consume the oxalica overlay and use it to grab a specific Rust toolchain version.
|
||||
Here is an example `shell.nix` showing how to grab the current stable toolchain:
|
||||
```nix
|
||||
{ pkgs ? import <nixpkgs> {
|
||||
overlays = [
|
||||
(import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
|
||||
];
|
||||
}
|
||||
}:
|
||||
pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
rust-bin.stable.latest.minimal
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
You can try this out by:
|
||||
1. Saving that to `shell.nix`
|
||||
2. Executing `nix-shell --pure --command 'rustc --version'`
|
||||
|
||||
As of writing, this prints out `rustc 1.56.0 (09c42c458 2021-10-18)`.
|
||||
|
||||
### How to use an overlay toolchain in a derivation {#how-to-use-an-overlay-toolchain-in-a-derivation}
|
||||
|
||||
You can also use an overlay's Rust toolchain with `buildRustPackage`.
|
||||
The below snippet demonstrates invoking `buildRustPackage` with an oxalica overlay selected Rust toolchain:
|
||||
```nix
|
||||
with import <nixpkgs> {
|
||||
overlays = [
|
||||
(import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
|
||||
];
|
||||
};
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "ripgrep";
|
||||
version = "12.1.1";
|
||||
nativeBuildInputs = [
|
||||
rust-bin.stable.latest.minimal
|
||||
];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "BurntSushi";
|
||||
repo = "ripgrep";
|
||||
rev = version;
|
||||
sha256 = "1hqps7l5qrjh9f914r5i6kmcz6f1yb951nv4lby0cjnp5l253kps";
|
||||
};
|
||||
|
||||
cargoSha256 = "03wf9r2csi6jpa7v5sw5lpxkrk4wfzwmzx7k3991q3bdjzcwnnwp";
|
||||
|
||||
meta = with lib; {
|
||||
description = "A fast line-oriented regex search tool, similar to ag and ack";
|
||||
homepage = "https://github.com/BurntSushi/ripgrep";
|
||||
license = licenses.unlicense;
|
||||
maintainers = [ maintainers.tailhook ];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Follow the below steps to try that snippet.
|
||||
1. create a new directory
|
||||
1. save the above snippet as `default.nix` in that directory
|
||||
1. cd into that directory and run `nix-build`
|
||||
|
||||
### Rust overlay installation {#rust-overlay-installation}
|
||||
### Rust overlay installation
|
||||
|
||||
You can use this overlay by either changing your local nixpkgs configuration,
|
||||
or by adding the overlay declaratively in a nix expression, e.g. in `configuration.nix`.
|
||||
For more information see [the manual on installing overlays](#sec-overlays-install).
|
||||
For more information see [#sec-overlays-install](the manual on installing overlays).
|
||||
|
||||
### Declarative Rust overlay installation {#declarative-rust-overlay-installation}
|
||||
#### Imperative rust overlay installation
|
||||
|
||||
Clone [nixpkgs-mozilla](https://github.com/mozilla/nixpkgs-mozilla),
|
||||
and create a symbolic link to the file
|
||||
[rust-overlay.nix](https://github.com/mozilla/nixpkgs-mozilla/blob/master/rust-overlay.nix)
|
||||
in the `~/.config/nixpkgs/overlays` directory.
|
||||
|
||||
$ git clone https://github.com/mozilla/nixpkgs-mozilla.git
|
||||
$ mkdir -p ~/.config/nixpkgs/overlays
|
||||
$ ln -s $(pwd)/nixpkgs-mozilla/rust-overlay.nix ~/.config/nixpkgs/overlays/rust-overlay.nix
|
||||
|
||||
### Declarative rust overlay installation
|
||||
|
||||
This snippet shows how to use oxalica's Rust overlay.
|
||||
Add the following to your `configuration.nix`, `home-configuration.nix`, `shell.nix`, or similar:
|
||||
|
||||
```nix
|
||||
{ pkgs ? import <nixpkgs> {
|
||||
overlays = [
|
||||
(import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
|
||||
(import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz))
|
||||
# Further overlays go here
|
||||
];
|
||||
};
|
||||
@@ -1004,3 +806,32 @@ Add the following to your `configuration.nix`, `home-configuration.nix`, `shell.
|
||||
```
|
||||
|
||||
Note that this will fetch the latest overlay version when rebuilding your system.
|
||||
|
||||
### Rust overlay usage
|
||||
|
||||
The overlay contains attribute sets corresponding to different versions of the rust toolchain, such as:
|
||||
|
||||
* `latest.rustChannels.stable`
|
||||
* `latest.rustChannels.nightly`
|
||||
* a function `rustChannelOf`, called as `(rustChannelOf { date = "2018-04-11"; channel = "nightly"; })`, or...
|
||||
* `(nixpkgs.rustChannelOf { rustToolchain = ./rust-toolchain; })` if you have a local `rust-toolchain` file (see https://github.com/mozilla/nixpkgs-mozilla#using-in-nix-expressions for an example)
|
||||
|
||||
Each of these contain packages such as `rust`, which contains your usual rust development tools with the respective toolchain chosen.
|
||||
For example, you might want to add `latest.rustChannels.stable.rust` to the list of packages in your configuration.
|
||||
|
||||
Imperatively, the latest stable version can be installed with the following command:
|
||||
|
||||
$ nix-env -Ai nixpkgs.latest.rustChannels.stable.rust
|
||||
|
||||
Or using the attribute with nix-shell:
|
||||
|
||||
$ nix-shell -p nixpkgs.latest.rustChannels.stable.rust
|
||||
|
||||
Substitute the `nixpkgs` prefix with `nixos` on NixOS.
|
||||
To install the beta or nightly channel, "stable" should be substituted by
|
||||
"nightly" or "beta", or
|
||||
use the function provided by this overlay to pull a version based on a
|
||||
build date.
|
||||
|
||||
The overlay automatically updates itself as it uses the same source as
|
||||
[rustup](https://www.rustup.rs/).
|
||||
|
||||
@@ -5,7 +5,6 @@ Since release 15.09 there is a new TeX Live packaging that lives entirely under
|
||||
## User's guide {#sec-language-texlive-user-guide}
|
||||
|
||||
- For basic usage just pull `texlive.combined.scheme-basic` for an environment with basic LaTeX support.
|
||||
|
||||
- It typically won't work to use separately installed packages together. Instead, you can build a custom set of packages like this:
|
||||
|
||||
```nix
|
||||
@@ -15,7 +14,6 @@ Since release 15.09 there is a new TeX Live packaging that lives entirely under
|
||||
```
|
||||
|
||||
- There are all the schemes, collections and a few thousand packages, as defined upstream (perhaps with tiny differences).
|
||||
|
||||
- By default you only get executables and files needed during runtime, and a little documentation for the core packages. To change that, you need to add `pkgFilter` function to `combine`.
|
||||
|
||||
```nix
|
||||
|
||||
@@ -9,8 +9,8 @@ applications for Android and iOS devices from source code.
|
||||
Not all Titanium features supported -- currently, it can only be used to build
|
||||
Android and iOS apps.
|
||||
|
||||
## Building a Titanium app {#building-a-titanium-app}
|
||||
|
||||
Building a Titanium app
|
||||
-----------------------
|
||||
We can build a Titanium app from source for Android or iOS and for debugging or
|
||||
release purposes by invoking the `titaniumenv.buildApp {}` function:
|
||||
|
||||
@@ -103,8 +103,8 @@ When `enableWirelessDistribution` has been enabled, you must also provide the
|
||||
path of the PHP script (`installURL`) (that is included with the iOS build
|
||||
environment) to enable wireless ad-hoc installations.
|
||||
|
||||
## Emulating or simulating the app {#emulating-or-simulating-the-app}
|
||||
|
||||
Emulating or simulating the app
|
||||
-------------------------------
|
||||
It is also possible to simulate the correspond iOS simulator build by using
|
||||
`xcodeenv.simulateApp {}` and emulate an Android APK by using
|
||||
`androidenv.emulateApp {}`.
|
||||
|
||||
@@ -12,7 +12,7 @@ At the moment we support three different methods for managing plugins:
|
||||
- Pathogen
|
||||
- vim-plug
|
||||
|
||||
## Custom configuration {#custom-configuration}
|
||||
## Custom configuration
|
||||
|
||||
Adding custom .vimrc lines can be done using the following code:
|
||||
|
||||
@@ -56,7 +56,7 @@ neovim-qt.override {
|
||||
}
|
||||
```
|
||||
|
||||
## Managing plugins with Vim packages {#managing-plugins-with-vim-packages}
|
||||
## Managing plugins with Vim packages
|
||||
|
||||
To store you plugins in Vim packages (the native Vim plugin manager, see `:help packages`) the following example can be used:
|
||||
|
||||
@@ -116,11 +116,11 @@ The resulting package can be added to `packageOverrides` in `~/.nixpkgs/config.n
|
||||
|
||||
After that you can install your special grafted `myVim` or `myNeovim` packages.
|
||||
|
||||
### What if your favourite Vim plugin isn’t already packaged? {#what-if-your-favourite-vim-plugin-isnt-already-packaged}
|
||||
### What if your favourite Vim plugin isn't already packaged?
|
||||
|
||||
If one of your favourite plugins isn't packaged, you can package it yourself:
|
||||
|
||||
```nix
|
||||
```
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
@@ -154,34 +154,7 @@ in
|
||||
}
|
||||
```
|
||||
|
||||
### Specificities for some plugins
|
||||
#### Tree sitter
|
||||
|
||||
By default `nvim-treesitter` encourages you to download, compile and install
|
||||
the required tree-sitter grammars at run time with `:TSInstall`. This works
|
||||
poorly on NixOS. Instead, to install the `nvim-treesitter` plugins with a set
|
||||
of precompiled grammars, you can use `nvim-treesitter.withPlugins` function:
|
||||
|
||||
```nix
|
||||
(pkgs.neovim.override {
|
||||
configure = {
|
||||
packages.myPlugins = with pkgs.vimPlugins; {
|
||||
start = [
|
||||
(nvim-treesitter.withPlugins (
|
||||
plugins: with plugins; [
|
||||
tree-sitter-nix
|
||||
tree-sitter-python
|
||||
]
|
||||
))
|
||||
];
|
||||
};
|
||||
};
|
||||
})
|
||||
```
|
||||
|
||||
To enable all grammars packaged in nixpkgs, use `(pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: pkgs.tree-sitter.allGrammars))`.
|
||||
|
||||
## Managing plugins with vim-plug {#managing-plugins-with-vim-plug}
|
||||
## 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:
|
||||
@@ -210,14 +183,14 @@ neovim.override {
|
||||
}
|
||||
```
|
||||
|
||||
## Managing plugins with VAM {#managing-plugins-with-vam}
|
||||
## Managing plugins with VAM
|
||||
|
||||
### Handling dependencies of Vim plugins {#handling-dependencies-of-vim-plugins}
|
||||
### Handling dependencies of Vim plugins
|
||||
|
||||
VAM introduced .json files supporting dependencies without versioning
|
||||
assuming that "using latest version" is ok most of the time.
|
||||
|
||||
### Example {#example}
|
||||
### Example
|
||||
|
||||
First create a vim-scripts file having one plugin name per line. Example:
|
||||
|
||||
@@ -307,9 +280,9 @@ Sample output2:
|
||||
]
|
||||
```
|
||||
|
||||
## Adding new plugins to nixpkgs {#adding-new-plugins-to-nixpkgs}
|
||||
## Adding new plugins to nixpkgs
|
||||
|
||||
Nix expressions for Vim plugins are stored in [pkgs/misc/vim-plugins](/pkgs/misc/vim-plugins). For the vast majority of plugins, Nix expressions are automatically generated by running [`./update.py`](/pkgs/misc/vim-plugins/update.py). This creates a [generated.nix](/pkgs/misc/vim-plugins/generated.nix) file based on the plugins listed in [vim-plugin-names](/pkgs/misc/vim-plugins/vim-plugin-names). Plugins are listed in alphabetical order in `vim-plugin-names` using the format `[github username]/[repository]@[gitref]`. For example https://github.com/scrooloose/nerdtree becomes `scrooloose/nerdtree`.
|
||||
Nix expressions for Vim plugins are stored in [pkgs/misc/vim-plugins](/pkgs/misc/vim-plugins). For the vast majority of plugins, Nix expressions are automatically generated by running [`./update.py`](/pkgs/misc/vim-plugins/update.py). This creates a [generated.nix](/pkgs/misc/vim-plugins/generated.nix) file based on the plugins listed in [vim-plugin-names](/pkgs/misc/vim-plugins/vim-plugin-names). Plugins are listed in alphabetical order in `vim-plugin-names` using the format `[github username]/[repository]`. For example https://github.com/scrooloose/nerdtree becomes `scrooloose/nerdtree`.
|
||||
|
||||
Some plugins require overrides in order to function properly. Overrides are placed in [overrides.nix](/pkgs/misc/vim-plugins/overrides.nix). Overrides are most often required when a plugin requires some dependencies, or extra steps are required during the build process. For example `deoplete-fish` requires both `deoplete-nvim` and `vim-fish`, and so the following override was added:
|
||||
|
||||
@@ -325,7 +298,7 @@ To add a new plugin, run `./update.py --add "[owner]/[name]"`. **NOTE**: This sc
|
||||
|
||||
Finally, there are some plugins that are also packaged in nodePackages because they have Javascript-related build steps, such as running webpack. Those plugins are not listed in `vim-plugin-names` or managed by `update.py` at all, and are included separately in `overrides.nix`. Currently, all these plugins are related to the `coc.nvim` ecosystem of Language Server Protocol integration with vim/neovim.
|
||||
|
||||
## Updating plugins in nixpkgs {#updating-plugins-in-nixpkgs}
|
||||
## Updating plugins in nixpkgs
|
||||
|
||||
Run the update script with a GitHub API token that has at least `public_repo` access. Running the script without the token is likely to result in rate-limiting (429 errors). For steps on creating an API token, please refer to [GitHub's token documentation](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token).
|
||||
|
||||
@@ -339,7 +312,7 @@ Alternatively, set the number of processes to a lower count to avoid rate-limiti
|
||||
./pkgs/misc/vim-plugins/update.py --proc 1
|
||||
```
|
||||
|
||||
## Important repositories {#important-repositories}
|
||||
## Important repositories
|
||||
|
||||
- [vim-pi](https://bitbucket.org/vimcommunity/vim-pi) is a plugin repository
|
||||
from VAM plugin manager meant to be used by others as well used by
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
<xi:include href="preface.chapter.xml" />
|
||||
<part>
|
||||
<title>Using Nixpkgs</title>
|
||||
<xi:include href="using/configuration.chapter.xml" />
|
||||
<xi:include href="using/overlays.chapter.xml" />
|
||||
<xi:include href="using/overrides.chapter.xml" />
|
||||
<xi:include href="using/configuration.xml" />
|
||||
<xi:include href="using/overlays.xml" />
|
||||
<xi:include href="using/overrides.xml" />
|
||||
<xi:include href="functions.xml" />
|
||||
</part>
|
||||
<part>
|
||||
|
||||
@@ -12,7 +12,7 @@ Nixpkgs. If you like to learn more about the Nix package manager and the Nix
|
||||
expression language, then you are kindly referred to the [Nix manual](https://nixos.org/nix/manual/).
|
||||
The NixOS distribution is documented in the [NixOS manual](https://nixos.org/nixos/manual/).
|
||||
|
||||
## Overview of Nixpkgs {#overview-of-nixpkgs}
|
||||
## Overview of Nixpkgs
|
||||
|
||||
Nix expressions describe how to build packages from source and are collected in
|
||||
the [nixpkgs repository](https://github.com/NixOS/nixpkgs). Also included in the
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
This chapter will be organized in three parts. First, it will describe the basics of how to package software in a way that supports cross-compilation. Second, it will describe how to use Nixpkgs when cross-compiling. Third, it will describe the internal infrastructure supporting cross-compilation.
|
||||
|
||||
|
||||
## Packaging in a cross-friendly manner {#sec-cross-packaging}
|
||||
|
||||
### Platform parameters {#ssec-cross-platform-parameters}
|
||||
@@ -64,8 +65,8 @@ The exact schema these fields follow is a bit ill-defined due to a long and conv
|
||||
|
||||
### Theory of dependency categorization {#ssec-cross-dependency-categorization}
|
||||
|
||||
::: {.note}
|
||||
This is a rather philosophical description that isn't very Nixpkgs-specific. For an overview of all the relevant attributes given to `mkDerivation`, see [](#ssec-stdenv-dependencies). For a description of how everything is implemented, see [](#ssec-cross-dependency-implementation).
|
||||
::: note
|
||||
This is a rather philosophical description that isn't very Nixpkgs-specific. For an overview of all the relevant attributes given to `mkDerivation`, see <xref linkend="ssec-stdenv-dependencies"/>. For a description of how everything is implemented, see <xref linkend="ssec-cross-dependency-implementation"/>.
|
||||
:::
|
||||
|
||||
In this section we explore the relationship between both runtime and build-time dependencies and the 3 Autoconf platforms.
|
||||
@@ -80,10 +81,10 @@ Finally, if the depending package is a compiler or other machine-code-producing
|
||||
|
||||
Putting this all together, that means we have dependencies in the form "host → target", in at most the following six combinations:
|
||||
|
||||
#### Possible dependency types {#possible-dependency-types}
|
||||
|
||||
| Dependency’s host platform | Dependency’s target platform |
|
||||
|----------------------------|------------------------------|
|
||||
#### Possible dependency types
|
||||
| Dependency's host platform | Dependency's target platform |
|
||||
| -- | -- |
|
||||
| build | build |
|
||||
| build | host |
|
||||
| build | target |
|
||||
@@ -112,18 +113,15 @@ On less powerful machines, it can be inconvenient to cross-compile a package onl
|
||||
$ nix-build '<nixpkgs>' -A pkgsCross.raspberryPi.hello
|
||||
```
|
||||
|
||||
#### What if my package’s build system needs to build a C program to be run under the build environment? {#cross-qa-build-c-program-in-build-environment}
|
||||
|
||||
#### What if my package's build system needs to build a C program to be run under the build environment? {#cross-qa-build-c-program-in-build-environment}
|
||||
Add the following to your `mkDerivation` invocation.
|
||||
|
||||
```nix
|
||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
||||
```
|
||||
|
||||
#### My package’s testsuite needs to run host platform code. {#cross-testsuite-runs-host-code}
|
||||
#### My package's testsuite needs to run host platform code. {#cross-testsuite-runs-host-code}
|
||||
|
||||
Add the following to your `mkDerivation` invocation.
|
||||
|
||||
```nix
|
||||
doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
|
||||
```
|
||||
@@ -136,7 +134,7 @@ Nixpkgs can be instantiated with `localSystem` alone, in which case there is no
|
||||
$ nix-build '<nixpkgs>' --arg crossSystem '(import <nixpkgs/lib>).systems.examples.fooBarBaz' -A whatever
|
||||
```
|
||||
|
||||
::: {.note}
|
||||
::: note
|
||||
Eventually we would like to make these platform examples an unnecessary convenience so that
|
||||
|
||||
```ShellSession
|
||||
@@ -148,7 +146,7 @@ works in the vast majority of cases. The problem today is dependencies on other
|
||||
|
||||
While one is free to pass both parameters in full, there's a lot of logic to fill in missing fields. As discussed in the previous section, only one of `system`, `config`, and `parsed` is needed to infer the other two. Additionally, `libc` will be inferred from `parse`. Finally, `localSystem.system` is also _impurely_ inferred based on the platform evaluation occurs. This means it is often not necessary to pass `localSystem` at all, as in the command-line example in the previous paragraph.
|
||||
|
||||
::: {.note}
|
||||
::: note
|
||||
Many sources (manual, wiki, etc) probably mention passing `system`, `platform`, along with the optional `crossSystem` to Nixpkgs: `import <nixpkgs> { system = ..; platform = ..; crossSystem = ..; }`. Passing those two instead of `localSystem` is still supported for compatibility, but is discouraged. Indeed, much of the inference we do for these parameters is motivated by compatibility as much as convenience.
|
||||
:::
|
||||
|
||||
@@ -158,9 +156,9 @@ One would think that `localSystem` and `crossSystem` overlap horribly with the t
|
||||
|
||||
### Implementation of dependencies {#ssec-cross-dependency-implementation}
|
||||
|
||||
The categories of dependencies developed in [](#ssec-cross-dependency-categorization) are specified as lists of derivations given to `mkDerivation`, as documented in [](#ssec-stdenv-dependencies). In short, each list of dependencies for "host → target" is called `deps<host><target>` (where `host`, and `target` values are either `build`, `host`, or `target`), with exceptions for backwards compatibility that `depsBuildHost` is instead called `nativeBuildInputs` and `depsHostTarget` is instead called `buildInputs`. Nixpkgs is now structured so that each `deps<host><target>` is automatically taken from `pkgs<host><target>`. (These `pkgs<host><target>`s are quite new, so there is no special case for `nativeBuildInputs` and `buildInputs`.) For example, `pkgsBuildHost.gcc` should be used at build-time, while `pkgsHostTarget.gcc` should be used at run-time.
|
||||
The categories of dependencies developed in <xref linkend="ssec-cross-dependency-categorization"/> are specified as lists of derivations given to `mkDerivation`, as documented in <xref linkend="ssec-stdenv-dependencies"/>. In short, each list of dependencies for "host → target" of "foo → bar" is called `depsFooBar`, with exceptions for backwards compatibility that `depsBuildHost` is instead called `nativeBuildInputs` and `depsHostTarget` is instead called `buildInputs`. Nixpkgs is now structured so that each `depsFooBar` is automatically taken from `pkgsFooBar`. (These `pkgsFooBar`s are quite new, so there is no special case for `nativeBuildInputs` and `buildInputs`.) For example, `pkgsBuildHost.gcc` should be used at build-time, while `pkgsHostTarget.gcc` should be used at run-time.
|
||||
|
||||
Now, for most of Nixpkgs's history, there were no `pkgs<host><target>` attributes, and most packages have not been refactored to use it explicitly. Prior to those, there were just `buildPackages`, `pkgs`, and `targetPackages`. Those are now redefined as aliases to `pkgsBuildHost`, `pkgsHostTarget`, and `pkgsTargetTarget`. It is acceptable, even recommended, to use them for libraries to show that the host platform is irrelevant.
|
||||
Now, for most of Nixpkgs's history, there were no `pkgsFooBar` attributes, and most packages have not been refactored to use it explicitly. Prior to those, there were just `buildPackages`, `pkgs`, and `targetPackages`. Those are now redefined as aliases to `pkgsBuildHost`, `pkgsHostTarget`, and `pkgsTargetTarget`. It is acceptable, even recommended, to use them for libraries to show that the host platform is irrelevant.
|
||||
|
||||
But before that, there was just `pkgs`, even though both `buildInputs` and `nativeBuildInputs` existed. \[Cross barely worked, and those were implemented with some hacks on `mkDerivation` to override dependencies.\] What this means is the vast majority of packages do not use any explicit package set to populate their dependencies, just using whatever `callPackage` gives them even if they do correctly sort their dependencies into the multiple lists described above. And indeed, asking that users both sort their dependencies, _and_ take them from the right attribute set, is both too onerous and redundant, so the recommended approach (for now) is to continue just categorizing by list and not using an explicit package set.
|
||||
|
||||
@@ -180,7 +178,7 @@ While there are many package sets, and thus many edges, the stages can also be a
|
||||
|
||||
In each stage, `pkgsBuildHost` refers to the previous stage, `pkgsBuildBuild` refers to the one before that, and `pkgsHostTarget` refers to the current one, and `pkgsTargetTarget` refers to the next one. When there is no previous or next stage, they instead refer to the current stage. Note how all the invariants regarding the mapping between dependency and depending packages' build host and target platforms are preserved. `pkgsBuildTarget` and `pkgsHostHost` are more complex in that the stage fitting the requirements isn't always a fixed chain of "prevs" and "nexts" away (modulo the "saturating" self-references at the ends). We just special case each instead. All the primary edges are implemented is in `pkgs/stdenv/booter.nix`, and secondarily aliases in `pkgs/top-level/stage.nix`.
|
||||
|
||||
::: {.note}
|
||||
::: note
|
||||
The native stages are bootstrapped in legacy ways that predate the current cross implementation. This is why the bootstrapping stages leading up to the final stages are ignored in the previous paragraph.
|
||||
:::
|
||||
|
||||
@@ -188,7 +186,6 @@ If one looks at the 3 platform triples, one can see that they overlap such that
|
||||
```
|
||||
(native, native, native, foreign, foreign)
|
||||
```
|
||||
|
||||
If one imagines the saturating self references at the end being replaced with infinite stages, and then overlays those platform triples, one ends up with the infinite tuple:
|
||||
```
|
||||
(native..., native, native, native, foreign, foreign, foreign...)
|
||||
@@ -196,8 +193,8 @@ If one imagines the saturating self references at the end being replaced with in
|
||||
One can then imagine any sequence of platforms such that there are bootstrap stages with their 3 platforms determined by "sliding a window" that is the 3 tuple through the sequence. This was the original model for bootstrapping. Without a target platform (assume a better world where all compilers are multi-target and all standard libraries are built in their own derivation), this is sufficient. Conversely if one wishes to cross compile "faster", with a "Canadian Cross" bootstrapping stage where `build != host != target`, more bootstrapping stages are needed since no sliding window provides the pesky `pkgsBuildTarget` package set since it skips the Canadian cross stage's "host".
|
||||
|
||||
|
||||
::: {.note}
|
||||
It is much better to refer to `buildPackages` than `targetPackages`, or more broadly package sets that do not mention “target”. There are three reasons for this.
|
||||
::: note
|
||||
It is much better to refer to `buildPackages` than `targetPackages`, or more broadly package sets that do not mention "target". There are three reasons for this.
|
||||
|
||||
First, it is because bootstrapping stages do not have a unique `targetPackages`. For example a `(x86-linux, x86-linux, arm-linux)` and `(x86-linux, x86-linux, x86-windows)` package set both have a `(x86-linux, x86-linux, x86-linux)` package set. Because there is no canonical `targetPackages` for such a native (`build == host == target`) package set, we set their `targetPackages`
|
||||
|
||||
@@ -206,6 +203,6 @@ Second, it is because this is a frequent source of hard-to-follow "infinite recu
|
||||
Thirdly, it is because everything target-mentioning only exists to accommodate compilers with lousy build systems that insist on the compiler itself and standard library being built together. Of course that is bad because bigger derivations means longer rebuilds. It is also problematic because it tends to make the standard libraries less like other libraries than they could be, complicating code and build systems alike. Because of the other problems, and because of these innate disadvantages, compilers ought to be packaged another way where possible.
|
||||
:::
|
||||
|
||||
::: {.note}
|
||||
If one explores Nixpkgs, they will see derivations with names like `gccCross`. Such `*Cross` derivations is a holdover from before we properly distinguished between the host and target platforms—the derivation with “Cross” in the name covered the `build = host != target` case, while the other covered the `host = target`, with build platform the same or not based on whether one was using its `.nativeDrv` or `.crossDrv`. This ugliness will disappear soon.
|
||||
::: note
|
||||
If one explores Nixpkgs, they will see derivations with names like `gccCross`. Such `*Cross` derivations is a holdover from before we properly distinguished between the host and target platforms—the derivation with "Cross" in the name covered the `build = host != target` case, while the other covered the `host = target`, with build platform the same or not based on whether one was using its `.nativeDrv` or `.crossDrv`. This ugliness will disappear soon.
|
||||
:::
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user