mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 19:00:19 +08:00
Compare commits
1 Commits
haskell-up
...
system
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8e8e8c720 |
@@ -95,13 +95,3 @@ trim_trailing_whitespace = unset
|
||||
|
||||
[pkgs/tools/misc/timidity/timidity.cfg]
|
||||
trim_trailing_whitespace = unset
|
||||
|
||||
[pkgs/tools/virtualization/ovftool/*.ova]
|
||||
end_of_line = unset
|
||||
insert_final_newline = unset
|
||||
trim_trailing_whitespace = unset
|
||||
charset = unset
|
||||
|
||||
[lib/tests/*.plist]
|
||||
indent_style = tab
|
||||
insert_final_newline = unset
|
||||
|
||||
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,6 +1,5 @@
|
||||
**/deps.nix linguist-generated
|
||||
**/deps.json linguist-generated
|
||||
**/deps.toml lingust-generated
|
||||
**/node-packages.nix linguist-generated
|
||||
|
||||
pkgs/applications/editors/emacs-modes/*-generated.nix linguist-generated
|
||||
|
||||
54
.github/CODEOWNERS
vendored
54
.github/CODEOWNERS
vendored
@@ -22,19 +22,19 @@
|
||||
/.editorconfig @Mic92 @zowoq
|
||||
|
||||
# Libraries
|
||||
/lib @edolstra @infinisil
|
||||
/lib/systems @alyssais @ericson2314 @matthewbauer
|
||||
/lib/generators.nix @edolstra @Profpatsch
|
||||
/lib/cli.nix @edolstra @Profpatsch
|
||||
/lib/debug.nix @edolstra @Profpatsch
|
||||
/lib/asserts.nix @edolstra @Profpatsch
|
||||
/lib @edolstra @nbp @infinisil
|
||||
/lib/systems @alyssais @nbp @ericson2314 @matthewbauer
|
||||
/lib/generators.nix @edolstra @nbp @Profpatsch
|
||||
/lib/cli.nix @edolstra @nbp @Profpatsch
|
||||
/lib/debug.nix @edolstra @nbp @Profpatsch
|
||||
/lib/asserts.nix @edolstra @nbp @Profpatsch
|
||||
/lib/path.* @infinisil @fricklerhandwerk
|
||||
|
||||
# Nixpkgs Internals
|
||||
/default.nix @Ericson2314
|
||||
/pkgs/top-level/default.nix @Ericson2314
|
||||
/pkgs/top-level/impure.nix @Ericson2314
|
||||
/pkgs/top-level/stage.nix @Ericson2314 @matthewbauer
|
||||
/default.nix @nbp
|
||||
/pkgs/top-level/default.nix @nbp @Ericson2314
|
||||
/pkgs/top-level/impure.nix @nbp @Ericson2314
|
||||
/pkgs/top-level/stage.nix @nbp @Ericson2314 @matthewbauer
|
||||
/pkgs/top-level/splice.nix @Ericson2314 @matthewbauer
|
||||
/pkgs/top-level/release-cross.nix @Ericson2314 @matthewbauer
|
||||
/pkgs/stdenv/generic @Ericson2314 @matthewbauer
|
||||
@@ -45,7 +45,6 @@
|
||||
/pkgs/build-support/setup-hooks @Ericson2314
|
||||
/pkgs/build-support/setup-hooks/auto-patchelf.sh @layus
|
||||
/pkgs/build-support/setup-hooks/auto-patchelf.py @layus
|
||||
/pkgs/pkgs-lib @infinisil
|
||||
|
||||
# Nixpkgs build-support
|
||||
/pkgs/build-support/writers @lassulus @Profpatsch
|
||||
@@ -67,9 +66,22 @@
|
||||
/doc/using @fricklerhandwerk
|
||||
|
||||
# NixOS Internals
|
||||
/nixos/default.nix @infinisil
|
||||
/nixos/lib/from-env.nix @infinisil
|
||||
/nixos/lib/eval-config.nix @infinisil
|
||||
/nixos/default.nix @nbp @infinisil
|
||||
/nixos/lib/from-env.nix @nbp @infinisil
|
||||
/nixos/lib/eval-config.nix @nbp @infinisil
|
||||
/nixos/doc/manual/configuration/abstractions.xml @nbp
|
||||
/nixos/doc/manual/configuration/config-file.xml @nbp
|
||||
/nixos/doc/manual/configuration/config-syntax.xml @nbp
|
||||
/nixos/doc/manual/configuration/modularity.xml @nbp
|
||||
/nixos/doc/manual/development/assertions.xml @nbp
|
||||
/nixos/doc/manual/development/meta-attributes.xml @nbp
|
||||
/nixos/doc/manual/development/option-declarations.xml @nbp
|
||||
/nixos/doc/manual/development/option-def.xml @nbp
|
||||
/nixos/doc/manual/development/option-types.xml @nbp
|
||||
/nixos/doc/manual/development/replace-modules.xml @nbp
|
||||
/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/modules/system/activation/bootspec.nix @grahamc @cole-h @raitobezarius
|
||||
/nixos/modules/system/activation/bootspec.cue @grahamc @cole-h @raitobezarius
|
||||
@@ -77,9 +89,6 @@
|
||||
# NixOS integration test driver
|
||||
/nixos/lib/test-driver @tfc
|
||||
|
||||
# NixOS QEMU virtualisation
|
||||
/nixos/virtualisation/qemu-vm.nix @raitobezarius
|
||||
|
||||
# Systemd
|
||||
/nixos/modules/system/boot/systemd.nix @NixOS/systemd
|
||||
/nixos/modules/system/boot/systemd @NixOS/systemd
|
||||
@@ -95,7 +104,9 @@
|
||||
|
||||
# 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 @mweinelt
|
||||
/pkgs/development/tools/poetry2nix @adisbladis
|
||||
/pkgs/development/interpreters/python/hooks @FRidh @jonringer
|
||||
@@ -123,13 +134,13 @@
|
||||
/pkgs/development/ruby-modules @marsam
|
||||
|
||||
# Rust
|
||||
/pkgs/development/compilers/rust @Mic92 @zowoq @winterqt @figsoda
|
||||
/pkgs/development/compilers/rust @Mic92 @LnL7 @zowoq @winterqt @figsoda
|
||||
/pkgs/build-support/rust @zowoq @winterqt @figsoda
|
||||
/doc/languages-frameworks/rust.section.md @zowoq @winterqt @figsoda
|
||||
|
||||
# C compilers
|
||||
/pkgs/development/compilers/gcc @matthewbauer
|
||||
/pkgs/development/compilers/llvm @matthewbauer @RaitoBezarius
|
||||
/pkgs/development/compilers/llvm @matthewbauer
|
||||
|
||||
# Compatibility stuff
|
||||
/pkgs/top-level/unix-tools.nix @matthewbauer
|
||||
@@ -300,8 +311,3 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
|
||||
/pkgs/build-support/node/build-npm-package @winterqt
|
||||
/pkgs/build-support/node/fetch-npm-deps @winterqt
|
||||
/doc/languages-frameworks/javascript.section.md @winterqt
|
||||
|
||||
# OCaml
|
||||
/pkgs/build-support/ocaml @romildo @ulrikstrid
|
||||
/pkgs/development/compilers/ocaml @romildo @ulrikstrid
|
||||
/pkgs/development/ocaml-modules @romildo @ulrikstrid
|
||||
|
||||
3
.github/workflows/backport.yml
vendored
3
.github/workflows/backport.yml
vendored
@@ -24,10 +24,9 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Create backport PRs
|
||||
uses: korthout/backport-action@v1.2.0
|
||||
uses: korthout/backport-action@v1.1.0
|
||||
with:
|
||||
# Config README: https://github.com/korthout/backport-action#backport-action
|
||||
copy_labels_pattern: 'severity:\ssecurity'
|
||||
pull_description: |-
|
||||
Bot-based backport to `${target_branch}`, triggered by a label in #${pull_number}.
|
||||
|
||||
|
||||
2
.github/workflows/basic-eval.yml
vendored
2
.github/workflows/basic-eval.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
# we don't limit this action to only NixOS repo since the checks are cheap and useful developer feedback
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v20
|
||||
- uses: cachix/install-nix-action@v18
|
||||
- uses: cachix/cachix-action@v12
|
||||
with:
|
||||
# This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere.
|
||||
|
||||
24
.github/workflows/check-maintainers-sorted.yaml
vendored
24
.github/workflows/check-maintainers-sorted.yaml
vendored
@@ -1,24 +0,0 @@
|
||||
name: "Check that maintainer list is sorted"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
paths:
|
||||
- 'maintainers/maintainer-list.nix'
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
nixos:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
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@v20
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
- name: Check that maintainer-list.nix is sorted
|
||||
run: nix-instantiate --eval maintainers/scripts/check-maintainers-sorted.nix
|
||||
6
.github/workflows/editorconfig.yml
vendored
6
.github/workflows/editorconfig.yml
vendored
@@ -28,14 +28,16 @@ jobs:
|
||||
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@v20
|
||||
- uses: cachix/install-nix-action@v18
|
||||
with:
|
||||
# nixpkgs commit is pinned so that it doesn't break
|
||||
# editorconfig-checker 2.4.0
|
||||
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/c473cc8714710179df205b153f4e9fa007107ff9.tar.gz
|
||||
- name: install editorconfig-checker
|
||||
run: nix-env -iA editorconfig-checker -f '<nixpkgs>'
|
||||
- name: Checking EditorConfig
|
||||
run: |
|
||||
cat "$HOME/changed_files" | nix-shell -p editorconfig-checker --run 'xargs -r editorconfig-checker -disable-indent-size'
|
||||
cat "$HOME/changed_files" | xargs -r editorconfig-checker -disable-indent-size
|
||||
- if: ${{ failure() }}
|
||||
run: |
|
||||
echo "::error :: Hey! It looks like your changes don't follow our editorconfig settings. Read https://editorconfig.org/#download to configure your editor so you never see this error again."
|
||||
|
||||
2
.github/workflows/manual-nixos.yml
vendored
2
.github/workflows/manual-nixos.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
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@v20
|
||||
- uses: cachix/install-nix-action@v18
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
|
||||
3
.github/workflows/manual-nixpkgs.yml
vendored
3
.github/workflows/manual-nixpkgs.yml
vendored
@@ -8,7 +8,6 @@ on:
|
||||
- master
|
||||
paths:
|
||||
- 'doc/**'
|
||||
- 'lib/**'
|
||||
|
||||
jobs:
|
||||
nixpkgs:
|
||||
@@ -19,7 +18,7 @@ jobs:
|
||||
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@v20
|
||||
- uses: cachix/install-nix-action@v18
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
|
||||
4
.github/workflows/manual-rendering.yml
vendored
4
.github/workflows/manual-rendering.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v20
|
||||
- uses: cachix/install-nix-action@v18
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
@@ -54,7 +54,7 @@ jobs:
|
||||
# less noisy until all nixpkgs pull requests have stopped using
|
||||
# docbook for option docs.
|
||||
- name: Comment on failure
|
||||
uses: peter-evans/create-or-update-comment@v3
|
||||
uses: peter-evans/create-or-update-comment@v2
|
||||
if: ${{ failure() && steps.check.conclusion == 'failure' }}
|
||||
with:
|
||||
issue-number: 189318
|
||||
|
||||
2
.github/workflows/periodic-merge-24h.yml
vendored
2
.github/workflows/periodic-merge-24h.yml
vendored
@@ -51,7 +51,7 @@ jobs:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Comment on failure
|
||||
uses: peter-evans/create-or-update-comment@v3
|
||||
uses: peter-evans/create-or-update-comment@v2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
issue-number: 105153
|
||||
|
||||
2
.github/workflows/periodic-merge-6h.yml
vendored
2
.github/workflows/periodic-merge-6h.yml
vendored
@@ -49,7 +49,7 @@ jobs:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Comment on failure
|
||||
uses: peter-evans/create-or-update-comment@v3
|
||||
uses: peter-evans/create-or-update-comment@v2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
issue-number: 105153
|
||||
|
||||
18
.github/workflows/update-terraform-providers.yml
vendored
18
.github/workflows/update-terraform-providers.yml
vendored
@@ -12,12 +12,12 @@ jobs:
|
||||
tf-providers:
|
||||
permissions:
|
||||
contents: write # for peter-evans/create-pull-request to create branch
|
||||
pull-requests: write # for peter-evans/create-pull-request to create a PR
|
||||
pull-requests: write # for peter-evans/create-pull-request to create a PR, for peter-evans/create-or-update-comment to create or update comment
|
||||
if: github.repository_owner == 'NixOS' && github.ref == 'refs/heads/master' # ensure workflow_dispatch only runs on master
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v20
|
||||
- uses: cachix/install-nix-action@v18
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixpkgs-unstable
|
||||
- name: setup
|
||||
@@ -36,33 +36,21 @@ jobs:
|
||||
--argstr keep-going true \
|
||||
--argstr max-workers 2 \
|
||||
--argstr path terraform-providers
|
||||
- name: get failed updates
|
||||
run: |
|
||||
echo 'FAILED<<EOF' >> $GITHUB_ENV
|
||||
git ls-files --others >> $GITHUB_ENV
|
||||
echo 'EOF' >> $GITHUB_ENV
|
||||
# cleanup logs of failed updates so they aren't included in the PR
|
||||
- name: clean repo
|
||||
run: |
|
||||
git clean -f
|
||||
- name: create PR
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
body: |
|
||||
Automatic update by [update-terraform-providers](https://github.com/NixOS/nixpkgs/blob/master/.github/workflows/update-terraform-providers.yml) action.
|
||||
|
||||
https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}
|
||||
|
||||
These providers failed to update:
|
||||
```
|
||||
${{ env.FAILED }}
|
||||
```
|
||||
|
||||
Check that all providers build with:
|
||||
```
|
||||
@ofborg build terraform.full
|
||||
```
|
||||
If there is more than ten commits in the PR `ofborg` won't build it automatically and you will need to use the above command.
|
||||
branch: terraform-providers-update
|
||||
delete-branch: false
|
||||
title: ${{ steps.setup.outputs.title }}
|
||||
|
||||
@@ -43,7 +43,6 @@ Below is a short excerpt of some points in there:
|
||||
* Not start with the package name.
|
||||
* More generally, it should not refer to the package name.
|
||||
* Not end with a period (or any punctuation for that matter).
|
||||
* Aim to inform while avoiding subjective language.
|
||||
* `meta.license` must be set and fit the upstream license.
|
||||
* If there is no upstream license, `meta.license` should default to `lib.licenses.unfree`.
|
||||
* If in doubt, try to contact the upstream developers for clarification.
|
||||
|
||||
3
doc/.gitignore
vendored
3
doc/.gitignore
vendored
@@ -6,6 +6,3 @@ functions/library/locations.xml
|
||||
highlightjs
|
||||
manual-full.xml
|
||||
out
|
||||
result
|
||||
result-*
|
||||
media
|
||||
|
||||
@@ -19,9 +19,6 @@ pandoc_flags = --extract-media=$(pandoc_media_dir) \
|
||||
.PHONY: all
|
||||
all: validate format out/html/index.html out/epub/manual.epub
|
||||
|
||||
.PHONY: render-md
|
||||
render-md: ${MD_TARGETS}
|
||||
|
||||
.PHONY: debug
|
||||
debug:
|
||||
nix-shell --run "xmloscopy --docbook5 ./manual.xml ./manual-full.xml"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{ pkgs ? import ../../.. {} }:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
manpageURLs = lib.importJSON (pkgs.path + "/doc/manpage-urls.json");
|
||||
manpageURLs = builtins.fromJSON (builtins.readFile (pkgs.path + "/doc/manpage-urls.json"));
|
||||
in pkgs.writeText "link-manpages.lua" ''
|
||||
--[[
|
||||
Adds links to known man pages that aren't already in a link.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Building software with Nix often requires downloading source code and other files from the internet.
|
||||
`nixpkgs` provides *fetchers* for different protocols and services. Fetchers are functions that simplify downloading files.
|
||||
|
||||
## Caveats {#chap-pkgs-fetchers-caveats}
|
||||
## Caveats
|
||||
|
||||
Fetchers create [fixed output derivations](https://nixos.org/manual/nix/stable/#fixed-output-drvs) from downloaded files.
|
||||
Nix can reuse the downloaded files via the hash of the resulting derivation.
|
||||
@@ -71,7 +71,6 @@ The main difference between `fetchurl` and `fetchzip` is in how they store the c
|
||||
|
||||
- `relative`: Similar to using `git-diff`'s `--relative` flag, only keep changes inside the specified directory, making paths relative to it.
|
||||
- `stripLen`: Remove the first `stripLen` components of pathnames in the patch.
|
||||
- `decode`: Pipe the downloaded data through this command before processing it as a patch.
|
||||
- `extraPrefix`: Prefix pathnames by this string.
|
||||
- `excludes`: Exclude files matching these patterns (applies after the above arguments).
|
||||
- `includes`: Include only files matching these patterns (applies after the above arguments).
|
||||
|
||||
@@ -6,7 +6,7 @@ Nix packages are most commonly shared between machines using [HTTP, SSH, or S3](
|
||||
|
||||
Note that this function is meant for advanced use-cases. The more idiomatic way to work with flat-file binary caches is via the [nix-copy-closure](https://nixos.org/manual/nix/stable/command-ref/nix-copy-closure.html) command. You may also want to consider [dockerTools](#sec-pkgs-dockerTools) for your containerization needs.
|
||||
|
||||
## Example {#sec-pkgs-binary-cache-example}
|
||||
## Example
|
||||
|
||||
The following derivation will construct a flat-file binary cache containing the closure of `hello`.
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@ If the derivation is fully buildable (i.e. `nix-build` can be used on it), runni
|
||||
The behavior doesn't match `nix-shell` or `nix-build` exactly and this function is known not to work correctly for e.g. fixed-output derivations, content-addressed derivations, impure derivations and other special types of derivations.
|
||||
:::
|
||||
|
||||
### Arguments {#ssec-pkgs-dockerTools-buildNixShellImage-arguments}
|
||||
### Arguments
|
||||
|
||||
`drv`
|
||||
|
||||
@@ -473,7 +473,7 @@ The behavior doesn't match `nix-shell` or `nix-build` exactly and this function
|
||||
|
||||
*Default:* (none)
|
||||
|
||||
### Example {#ssec-pkgs-dockerTools-buildNixShellImage-example}
|
||||
### Example
|
||||
|
||||
The following shows how to build the `pkgs.hello` package inside a Docker container built with `buildNixShellImage`.
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ Whereas for many web servers, applications, it is possible to work with a Nix st
|
||||
|
||||
NixOS tests also use this function when preparing the VM. The `cptofs` method is used when `virtualisation.useBootLoader` is false (the default). Otherwise the second method is used.
|
||||
|
||||
## Features {#sec-make-disk-image-features}
|
||||
## Features
|
||||
|
||||
For reference, read the function signature source code for documentation on arguments: <https://github.com/NixOS/nixpkgs/blob/master/nixos/lib/make-disk-image.nix>.
|
||||
Features are separated in various sections depending on if you opt for a Nix-store only image or a full NixOS image.
|
||||
|
||||
### Common {#sec-make-disk-image-features-common}
|
||||
### Common
|
||||
|
||||
- arbitrary NixOS configuration
|
||||
- automatic or bound disk size: `diskSize` parameter, `additionalSpace` can be set when `diskSize` is `auto` to add a constant of disk space
|
||||
@@ -29,7 +29,7 @@ Features are separated in various sections depending on if you opt for a Nix-sto
|
||||
- the current nixpkgs can be realized as a channel in the disk image, which will change the hash of the image when the sources are updated
|
||||
- additional store paths can be provided through `additionalPaths`
|
||||
|
||||
### Full NixOS image {#sec-make-disk-image-features-full-image}
|
||||
### Full NixOS image
|
||||
|
||||
- arbitrary contents with permissions can be placed in the target filesystem using `contents`
|
||||
- a `/etc/nixpkgs/nixos/configuration.nix` can be provided through `configFile`
|
||||
@@ -37,7 +37,7 @@ Features are separated in various sections depending on if you opt for a Nix-sto
|
||||
- EFI variables can be mutated during image production and the result is exposed in `$out`
|
||||
- boot partition size when partition table is `efi` or `hybrid`
|
||||
|
||||
### On bit-to-bit reproducibility {#sec-make-disk-image-features-reproducibility}
|
||||
### On bit-to-bit reproducibility
|
||||
|
||||
Images are **NOT** deterministic, please do not hesitate to try to fix this, source of determinisms are (not exhaustive) :
|
||||
|
||||
@@ -47,7 +47,7 @@ Images are **NOT** deterministic, please do not hesitate to try to fix this, sou
|
||||
|
||||
A `deterministic` flag is available for best efforts determinism.
|
||||
|
||||
## Usage {#sec-make-disk-image-usage}
|
||||
## Usage
|
||||
|
||||
To produce a Nix-store only image:
|
||||
```nix
|
||||
@@ -101,7 +101,6 @@ in
|
||||
diskSize = "auto";
|
||||
additionalSpace = "0M"; # Defaults to 512M.
|
||||
copyChannel = false;
|
||||
memSize = 2048; # Qemu VM memory size in megabytes. Defaults to 1024M.
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
This chapter describes several special builders.
|
||||
</para>
|
||||
<xi:include href="special/fhs-environments.section.xml" />
|
||||
<xi:include href="special/makesetuphook.section.xml" />
|
||||
<xi:include href="special/mkshell.section.xml" />
|
||||
<xi:include href="special/darwin-builder.section.xml" />
|
||||
<xi:include href="special/vm-tools.section.xml" />
|
||||
</chapter>
|
||||
|
||||
@@ -61,89 +61,3 @@ builders-use-substitutes = true
|
||||
```ShellSession
|
||||
$ sudo launchctl kickstart -k system/org.nixos.nix-daemon
|
||||
```
|
||||
|
||||
## Example flake usage
|
||||
|
||||
```
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-22.11-darwin";
|
||||
darwin.url = "github:lnl7/nix-darwin/master";
|
||||
darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, darwin, nixpkgs, ... }@inputs:
|
||||
let
|
||||
|
||||
inherit (darwin.lib) darwinSystem;
|
||||
system = "aarch64-darwin";
|
||||
pkgs = nixpkgs.legacyPackages."${system}";
|
||||
linuxSystem = builtins.replaceStrings [ "darwin" ] [ "linux" ] system;
|
||||
|
||||
darwin-builder = nixpkgs.lib.nixosSystem {
|
||||
system = linuxSystem;
|
||||
modules = [
|
||||
"${nixpkgs}/nixos/modules/profiles/macos-builder.nix"
|
||||
{ virtualisation.host.pkgs = pkgs; }
|
||||
];
|
||||
};
|
||||
in {
|
||||
|
||||
darwinConfigurations = {
|
||||
machine1 = darwinSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
{
|
||||
nix.distributedBuilds = true;
|
||||
nix.buildMachines = [{
|
||||
hostName = "ssh://builder@localhost";
|
||||
system = linuxSystem;
|
||||
maxJobs = 4;
|
||||
supportedFeatures = [ "kvm" "benchmark" "big-parallel" ];
|
||||
}];
|
||||
|
||||
launchd.daemons.darwin-builder = {
|
||||
command = "${darwin-builder.config.system.build.macos-builder-installer}/bin/create-builder";
|
||||
serviceConfig = {
|
||||
KeepAlive = true;
|
||||
RunAtLoad = true;
|
||||
StandardOutPath = "/var/log/darwin-builder.log";
|
||||
StandardErrorPath = "/var/log/darwin-builder.log";
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Reconfiguring the builder
|
||||
|
||||
Initially you should not change the builder configuration else you will not be
|
||||
able to use the binary cache. However, after you have the builder running locally
|
||||
you may use it to build a modified builder with additional storage or memory.
|
||||
|
||||
To do this, you just need to set the `virtualisation.darwin-builder.*` parameters as
|
||||
in the example below and rebuild.
|
||||
|
||||
```
|
||||
darwin-builder = nixpkgs.lib.nixosSystem {
|
||||
system = linuxSystem;
|
||||
modules = [
|
||||
"${nixpkgs}/nixos/modules/profiles/macos-builder.nix"
|
||||
{
|
||||
virtualisation.host.pkgs = pkgs;
|
||||
virtualisation.darwin-builder.diskSize = 5120;
|
||||
virtualisation.darwin-builder.memorySize = 1024;
|
||||
virtualisation.darwin-builder.hostPort = 33022;
|
||||
virtualisation.darwin-builder.workingDirectory = "/var/lib/darwin-builder";
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
You may make any other changes to your VM in this attribute set. For example,
|
||||
you could enable Docker or X11 forwarding to your Darwin host.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# buildFHSEnv {#sec-fhs-environments}
|
||||
# buildFHSUserEnv {#sec-fhs-environments}
|
||||
|
||||
`buildFHSEnv` provides a way to build and run FHS-compatible lightweight sandboxes. It creates an isolated root with bound `/nix/store`, so its footprint in terms of disk space needed is quite small. This allows one to run software which is hard or unfeasible to patch for NixOS -- 3rd-party source trees with FHS assumptions, games distributed as tarballs, software with integrity checking and/or external self-updated binaries. It uses Linux namespaces feature to create temporary lightweight environments which are destroyed after all child processes exit, without root user rights requirement. Accepted arguments are:
|
||||
`buildFHSUserEnv` provides a way to build and run FHS-compatible lightweight sandboxes. It creates an isolated root with bound `/nix/store`, so its footprint in terms of disk space needed is quite small. This allows one to run software which is hard or unfeasible to patch for NixOS -- 3rd-party source trees with FHS assumptions, games distributed as tarballs, software with integrity checking and/or external self-updated binaries. It uses Linux namespaces feature to create temporary lightweight environments which are destroyed after all child processes exit, without root user rights requirement. Accepted arguments are:
|
||||
|
||||
- `name`
|
||||
Environment name.
|
||||
@@ -26,7 +26,7 @@ One can create a simple environment using a `shell.nix` like that:
|
||||
```nix
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
(pkgs.buildFHSEnv {
|
||||
(pkgs.buildFHSUserEnv {
|
||||
name = "simple-x11-env";
|
||||
targetPkgs = pkgs: (with pkgs;
|
||||
[ udev
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# pkgs.makeSetupHook {#sec-pkgs.makeSetupHook}
|
||||
|
||||
`pkgs.makeSetupHook` is a builder that produces hooks that go in to `nativeBuildInputs`
|
||||
|
||||
## Usage {#sec-pkgs.makeSetupHook-usage}
|
||||
|
||||
```nix
|
||||
pkgs.makeSetupHook {
|
||||
name = "something-hook";
|
||||
propagatedBuildInputs = [ pkgs.commandsomething ];
|
||||
depsTargetTargetPropagated = [ pkgs.libsomething ];
|
||||
} ./script.sh
|
||||
```
|
||||
|
||||
#### setup hook that depends on the hello package and runs hello and @shell@ is substituted with path to bash {#sec-pkgs.makeSetupHook-usage-example}
|
||||
|
||||
```nix
|
||||
pkgs.makeSetupHook {
|
||||
name = "run-hello-hook";
|
||||
propagatedBuildInputs = [ pkgs.hello ];
|
||||
substitutions = { shell = "${pkgs.bash}/bin/bash"; };
|
||||
passthru.tests.greeting = callPackage ./test { };
|
||||
meta.platforms = lib.platforms.linux;
|
||||
} (writeScript "run-hello-hook.sh" ''
|
||||
#!@shell@
|
||||
hello
|
||||
'')
|
||||
```
|
||||
|
||||
## Attributes {#sec-pkgs.makeSetupHook-attributes}
|
||||
|
||||
* `name` Set the name of the hook.
|
||||
* `propagatedBuildInputs` Runtime dependencies (such as binaries) of the hook.
|
||||
* `depsTargetTargetPropagated` Non-binary dependencies.
|
||||
* `meta`
|
||||
* `passthru`
|
||||
* `substitutions` Variables for `substituteAll`
|
||||
@@ -20,7 +20,7 @@ pkgs.mkShell {
|
||||
}
|
||||
```
|
||||
|
||||
## Attributes {#sec-pkgs-mkShell-attributes}
|
||||
## Attributes
|
||||
|
||||
* `name` (default: `nix-shell`). Set the name of the derivation.
|
||||
* `packages` (default: `[]`). Add executable packages to the `nix-shell` environment.
|
||||
@@ -29,7 +29,7 @@ pkgs.mkShell {
|
||||
|
||||
... all the attributes of `stdenv.mkDerivation`.
|
||||
|
||||
## Building the shell {#sec-pkgs-mkShell-building}
|
||||
## Building the shell
|
||||
|
||||
This derivation output will contain a text file that contains a reference to
|
||||
all the build inputs. This is useful in CI where we want to make sure that
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
# vmTools {#sec-vm-tools}
|
||||
|
||||
A set of VM related utilities, that help in building some packages in more advanced scenarios.
|
||||
|
||||
## `vmTools.createEmptyImage` {#vm-tools-createEmptyImage}
|
||||
|
||||
A bash script fragment that produces a disk image at `destination`.
|
||||
|
||||
### Attributes
|
||||
|
||||
* `size`. The disk size, in MiB.
|
||||
* `fullName`. Name that will be written to `${destination}/nix-support/full-name`.
|
||||
* `destination` (optional, default `$out`). Where to write the image files.
|
||||
|
||||
## `vmTools.runInLinuxVM` {#vm-tools-runInLinuxVM}
|
||||
|
||||
Run a derivation in a Linux virtual machine (using Qemu/KVM).
|
||||
By default, there is no disk image; the root filesystem is a `tmpfs`, and the Nix store is shared with the host (via the [9P protocol](https://wiki.qemu.org/Documentation/9p#9p_Protocol)).
|
||||
Thus, any pure Nix derivation should run unmodified.
|
||||
|
||||
If the build fails and Nix is run with the `-K/--keep-failed` option, a script `run-vm` will be left behind in the temporary build directory that allows you to boot into the VM and debug it interactively.
|
||||
|
||||
### Attributes
|
||||
|
||||
* `preVM` (optional). Shell command to be evaluated *before* the VM is started (i.e., on the host).
|
||||
* `memSize` (optional, default `512`). The memory size of the VM in MiB.
|
||||
* `diskImage` (optional). A file system image to be attached to `/dev/sda`.
|
||||
Note that currently we expect the image to contain a filesystem, not a full disk image with a partition table etc.
|
||||
|
||||
### Examples
|
||||
|
||||
Build the derivation hello inside a VM:
|
||||
```nix
|
||||
{ pkgs }: with pkgs; with vmTools;
|
||||
runInLinuxVM hello
|
||||
```
|
||||
|
||||
Build inside a VM with extra memory:
|
||||
```nix
|
||||
{ pkgs }: with pkgs; with vmTools;
|
||||
runInLinuxVM (hello.overrideAttrs (_: { memSize = 1024; }))
|
||||
```
|
||||
|
||||
Use VM with a disk image (implicitly sets `diskImage`, see [`vmTools.createEmptyImage`](#vm-tools-createEmptyImage)):
|
||||
```nix
|
||||
{ pkgs }: with pkgs; with vmTools;
|
||||
runInLinuxVM (hello.overrideAttrs (_: {
|
||||
preVM = createEmptyImage {
|
||||
size = 1024;
|
||||
fullName = "vm-image";
|
||||
};
|
||||
}))
|
||||
```
|
||||
|
||||
## `vmTools.extractFs` {#vm-tools-extractFs}
|
||||
|
||||
Takes a file, such as an ISO, and extracts its contents into the store.
|
||||
|
||||
### Attributes
|
||||
|
||||
* `file`. Path to the file to be extracted.
|
||||
Note that currently we expect the image to contain a filesystem, not a full disk image with a partition table etc.
|
||||
* `fs` (optional). Filesystem of the contents of the file.
|
||||
|
||||
### Examples
|
||||
|
||||
Extract the contents of an ISO file:
|
||||
```nix
|
||||
{ pkgs }: with pkgs; with vmTools;
|
||||
extractFs { file = ./image.iso; }
|
||||
```
|
||||
|
||||
## `vmTools.extractMTDfs` {#vm-tools-extractMTDfs}
|
||||
|
||||
Like [](#vm-tools-extractFs), but it makes use of a [Memory Technology Device (MTD)](https://en.wikipedia.org/wiki/Memory_Technology_Device).
|
||||
|
||||
## `vmTools.runInLinuxImage` {#vm-tools-runInLinuxImage}
|
||||
|
||||
Like [](#vm-tools-runInLinuxVM), but instead of using `stdenv` from the Nix store, run the build using the tools provided by `/bin`, `/usr/bin`, etc. from the specified filesystem image, which typically is a filesystem containing a [FHS](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard)-based Linux distribution.
|
||||
|
||||
## `vmTools.makeImageTestScript` {#vm-tools-makeImageTestScript}
|
||||
|
||||
Generate a script that can be used to run an interactive session in the given image.
|
||||
|
||||
### Examples
|
||||
|
||||
Create a script for running a Fedora 27 VM:
|
||||
```nix
|
||||
{ pkgs }: with pkgs; with vmTools;
|
||||
makeImageTestScript diskImages.fedora27x86_64
|
||||
```
|
||||
|
||||
Create a script for running an Ubuntu 20.04 VM:
|
||||
```nix
|
||||
{ pkgs }: with pkgs; with vmTools;
|
||||
makeImageTestScript diskImages.ubuntu2004x86_64
|
||||
```
|
||||
|
||||
## `vmTools.diskImageFuns` {#vm-tools-diskImageFuns}
|
||||
|
||||
A set of functions that build a predefined set of minimal Linux distributions images.
|
||||
|
||||
### Images
|
||||
|
||||
* Fedora
|
||||
* `fedora26x86_64`
|
||||
* `fedora27x86_64`
|
||||
* CentOS
|
||||
* `centos6i386`
|
||||
* `centos6x86_64`
|
||||
* `centos7x86_64`
|
||||
* Ubuntu
|
||||
* `ubuntu1404i386`
|
||||
* `ubuntu1404x86_64`
|
||||
* `ubuntu1604i386`
|
||||
* `ubuntu1604x86_64`
|
||||
* `ubuntu1804i386`
|
||||
* `ubuntu1804x86_64`
|
||||
* `ubuntu2004i386`
|
||||
* `ubuntu2004x86_64`
|
||||
* `ubuntu2204i386`
|
||||
* `ubuntu2204x86_64`
|
||||
* Debian
|
||||
* `debian10i386`
|
||||
* `debian10x86_64`
|
||||
* `debian11i386`
|
||||
* `debian11x86_64`
|
||||
|
||||
### Attributes
|
||||
|
||||
* `size` (optional, defaults to `4096`). The size of the image, in MiB.
|
||||
* `extraPackages` (optional). A list names of additional packages from the distribution that should be included in the image.
|
||||
|
||||
### Examples
|
||||
|
||||
8GiB image containing Firefox in addition to the default packages:
|
||||
```nix
|
||||
{ pkgs }: with pkgs; with vmTools;
|
||||
diskImageFuns.ubuntu2004x86_64 { extraPackages = [ "firefox" ]; size = 8192; }
|
||||
```
|
||||
|
||||
## `vmTools.diskImageExtraFuns` {#vm-tools-diskImageExtraFuns}
|
||||
|
||||
Shorthand for `vmTools.diskImageFuns.<attr> { extraPackages = ... }`.
|
||||
|
||||
## `vmTools.diskImages` {#vm-tools-diskImages}
|
||||
|
||||
Shorthand for `vmTools.diskImageFuns.<attr> { }`.
|
||||
@@ -164,26 +164,6 @@ tests.fetchgit = testers.invalidateFetcherByDrvHash fetchgit {
|
||||
};
|
||||
```
|
||||
|
||||
## `runNixOSTest` {#tester-runNixOSTest}
|
||||
|
||||
A helper function that behaves exactly like the NixOS `runTest`, except it also assigns this Nixpkgs package set as the `pkgs` of the test and makes the `nixpkgs.*` options read-only.
|
||||
|
||||
If your test is part of the Nixpkgs repository, or if you need a more general entrypoint, see ["Calling a test" in the NixOS manual](https://nixos.org/manual/nixos/stable/index.html#sec-calling-nixos-tests).
|
||||
|
||||
Example:
|
||||
|
||||
```nix
|
||||
pkgs.testers.runNixOSTest ({ lib, ... }: {
|
||||
name = "hello";
|
||||
nodes.machine = { pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.hello ];
|
||||
};
|
||||
testScript = ''
|
||||
machine.succeed("hello")
|
||||
'';
|
||||
})
|
||||
```
|
||||
|
||||
## `nixosTest` {#tester-nixosTest}
|
||||
|
||||
Run a NixOS VM network test using this evaluation of Nixpkgs.
|
||||
@@ -198,7 +178,7 @@ letting NixOS invoke Nixpkgs anew.
|
||||
If a test machine needs to set NixOS options under `nixpkgs`, it must set only the
|
||||
`nixpkgs.pkgs` option.
|
||||
|
||||
### Parameter {#tester-nixosTest-parameter}
|
||||
### Parameter
|
||||
|
||||
A [NixOS VM test network](https://nixos.org/nixos/manual/index.html#sec-nixos-tests), or path to it. Example:
|
||||
|
||||
@@ -220,7 +200,7 @@ A [NixOS VM test network](https://nixos.org/nixos/manual/index.html#sec-nixos-te
|
||||
}
|
||||
```
|
||||
|
||||
### Result {#tester-nixosTest-result}
|
||||
### Result
|
||||
|
||||
A derivation that runs the VM test.
|
||||
|
||||
|
||||
@@ -454,7 +454,7 @@ In the file `pkgs/top-level/all-packages.nix` you can find fetch helpers, these
|
||||
owner = "NixOS";
|
||||
repo = "nix";
|
||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae";
|
||||
hash = "ha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=";
|
||||
hash = "ha256-7D4m+saJjbSFP5hOwpQq2FGR2rr+psQMTcyb1ZvtXsQ=;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ Other examples of reasons are:
|
||||
- The previous download links were all broken
|
||||
- Crash when starting on some X11 systems
|
||||
|
||||
#### Acceptable backport criteria {#acceptable-backport-criteria}
|
||||
#### 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.
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@ in pkgs.stdenv.mkDerivation {
|
||||
ln -s ${doc-support} ./doc-support/result
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
make -j$NIX_BUILD_CORES render-md
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
dest="$out/share/doc/nixpkgs"
|
||||
mkdir -p "$(dirname "$dest")"
|
||||
|
||||
@@ -45,10 +45,7 @@ let
|
||||
# NB: This file describes the Nixpkgs manual, which happens to use module
|
||||
# docs infra originally developed for NixOS.
|
||||
optionsDoc = pkgs.nixosOptionsDoc {
|
||||
inherit (pkgs.lib.evalModules {
|
||||
modules = [ ../../pkgs/top-level/config.nix ];
|
||||
class = "nixpkgsConfig";
|
||||
}) options;
|
||||
inherit (pkgs.lib.evalModules { modules = [ ../../pkgs/top-level/config.nix ]; }) options;
|
||||
documentType = "none";
|
||||
transformOptions = opt:
|
||||
opt // {
|
||||
@@ -78,7 +75,7 @@ in pkgs.runCommand "doc-support" {}
|
||||
ln -s ${epub-xsl} ./epub.xsl
|
||||
ln -s ${xhtml-xsl} ./xhtml.xsl
|
||||
|
||||
ln -s ${./xmlformat.conf} ./xmlformat.conf
|
||||
ln -s ${../../nixos/doc/xmlformat.conf} ./xmlformat.conf
|
||||
ln -s ${pkgs.documentation-highlighter} ./highlightjs
|
||||
|
||||
echo -n "${version}" > ./version
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{ pkgs, nixpkgs ? { }, libsets }:
|
||||
let
|
||||
revision = pkgs.lib.trivial.revisionWithDefault (nixpkgs.rev or "master");
|
||||
revision = pkgs.lib.trivial.revisionWithDefault (nixpkgs.revision or "master");
|
||||
|
||||
libDefPos = prefix: set:
|
||||
builtins.concatMap
|
||||
|
||||
@@ -216,7 +216,7 @@ you can test whether it builds correctly by writing in a comment:
|
||||
@ofborg build agdaPackages.iowa-stdlib
|
||||
```
|
||||
|
||||
### Maintaining Agda packages {#agda-maintaining-packages}
|
||||
### 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:
|
||||
|
||||
@@ -14,7 +14,7 @@ nixpkgs follows the [official elixir deprecation schedule](https://hexdocs.pm/el
|
||||
|
||||
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.erlang_22`, 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.erlangR22`, 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`.
|
||||
|
||||
@@ -22,7 +22,7 @@ The default Erlang compiler, defined by `beam.interpreters.erlang`, is aliased a
|
||||
|
||||
To create a package builder built with a custom Erlang version, use the lambda, `beam.packagesWith`, which accepts an Erlang/OTP derivation and produces a package builder similar to `beam.packages.erlang`.
|
||||
|
||||
Many Erlang/OTP distributions available in `beam.interpreters` have versions with ODBC and/or Java enabled or without wx (no observer support). For example, there's `beam.interpreters.erlang_22_odbc_javac`, which corresponds to `beam.interpreters.erlang_22` and `beam.interpreters.erlang_22_nox`, which corresponds to `beam.interpreters.erlang_22`.
|
||||
Many Erlang/OTP distributions available in `beam.interpreters` have versions with ODBC and/or Java enabled or without wx (no observer support). For example, there's `beam.interpreters.erlangR22_odbc_javac`, which corresponds to `beam.interpreters.erlangR22` and `beam.interpreters.erlangR22_nox`, which corresponds to `beam.interpreters.erlangR22`.
|
||||
|
||||
## Build Tools {#build-tools}
|
||||
|
||||
@@ -128,7 +128,7 @@ You will need to run the build process once to fix the hash to correspond to you
|
||||
|
||||
###### 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/default.nix) for a usage example of FOD.
|
||||
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/default.nix) for a usage example of FOD.
|
||||
|
||||
Practical steps
|
||||
|
||||
@@ -154,7 +154,7 @@ Here is how your `default.nix` file would look for a phoenix project.
|
||||
with import <nixpkgs> { };
|
||||
|
||||
let
|
||||
# beam.interpreters.erlang_23 is available if you need a particular version
|
||||
# beam.interpreters.erlangR23 is available if you need a particular version
|
||||
packages = beam.packagesWith beam.interpreters.erlang;
|
||||
|
||||
pname = "your_project";
|
||||
@@ -171,7 +171,6 @@ let
|
||||
inherit src version;
|
||||
# nix will complain and tell you the right value to replace this with
|
||||
hash = lib.fakeHash;
|
||||
mixEnv = ""; # default is "prod", when empty includes all dependencies, such as "dev", "test".
|
||||
# if you have build time environment variables add them here
|
||||
MY_ENV_VAR="my_value";
|
||||
};
|
||||
@@ -274,18 +273,18 @@ Usually, we need to create a `shell.nix` file and do our development inside of t
|
||||
|
||||
with pkgs;
|
||||
let
|
||||
elixir = beam.packages.erlang_24.elixir_1_12;
|
||||
elixir = beam.packages.erlangR24.elixir_1_12;
|
||||
in
|
||||
mkShell {
|
||||
buildInputs = [ elixir ];
|
||||
}
|
||||
```
|
||||
|
||||
### Using an overlay {#beam-using-overlays}
|
||||
### Using an overlay
|
||||
|
||||
If you need to use an overlay to change some attributes of a derivation, e.g. if you need a bugfix from a version that is not yet available in nixpkgs, you can override attributes such as `version` (and the corresponding `hash`) and then use this overlay in your development environment:
|
||||
|
||||
#### `shell.nix` {#beam-using-overlays-shell.nix}
|
||||
#### `shell.nix`
|
||||
|
||||
```nix
|
||||
let
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
[R⁵RS](https://schemers.org/Documents/Standards/R5RS/HTML/)-compliant Scheme
|
||||
compiler. It includes an interactive mode and a custom package format, "eggs".
|
||||
|
||||
## Using Eggs {#sec-chicken-using}
|
||||
## Using Eggs
|
||||
|
||||
Eggs described in nixpkgs are available inside the
|
||||
`chickenPackages.chickenEggs` attrset. Including an egg as a build input is
|
||||
@@ -22,7 +22,7 @@ might write:
|
||||
Both `chicken` and its eggs have a setup hook which configures the environment
|
||||
variables `CHICKEN_INCLUDE_PATH` and `CHICKEN_REPOSITORY_PATH`.
|
||||
|
||||
## Updating Eggs {#sec-chicken-updating-eggs}
|
||||
## Updating Eggs
|
||||
|
||||
nixpkgs only knows about a subset of all published eggs. It uses
|
||||
[egg2nix](https://github.com/the-kenny/egg2nix) to generate a
|
||||
@@ -36,7 +36,7 @@ $ cd pkgs/development/compilers/chicken/5/
|
||||
$ egg2nix eggs.scm > eggs.nix
|
||||
```
|
||||
|
||||
## Adding Eggs {#sec-chicken-adding-eggs}
|
||||
## Adding Eggs
|
||||
|
||||
When we run `egg2nix`, we obtain one collection of eggs with
|
||||
mutually-compatible versions. This means that when we add new eggs, we may
|
||||
|
||||
@@ -37,7 +37,7 @@ The recommended way of defining a derivation for a Coq library, is to use the `c
|
||||
* `buildInputs` (optional), is a list of libraries and dependencies that are required to build and run the current derivation, in addition to the default one `[ coq ]`,
|
||||
* `extraBuildInputs` (optional, deprecated), an additional list of derivation to add to `buildInputs`,
|
||||
* `overrideBuildInputs` (optional) replaces the default list of derivation to which `buildInputs` and `extraBuildInputs` adds extras elements,
|
||||
* `propagatedBuildInputs` (optional) is passed as is to `mkDerivation`, we recommend to use this for Coq libraries and Coq plugin dependencies, as this makes sure the paths of the compiled libraries and plugins will always be added to the build environments of subsequent derivation, which is necessary for Coq packages to work correctly,
|
||||
* `propagatedBuildInputs` (optional) is passed as is to `mkDerivation`, we recommend to use this for Coq libraries and Coq plugin dependencies, as this makes sure the paths of the compiled libraries and plugins will always be added to the build environements of subsequent derivation, which is necessary for Coq packages to work correctly,
|
||||
* `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 `nativeBuildInputs`, `buildInputs`, and `propagatedBuildInputs` to depend on the same package set Coq was built against.
|
||||
* `useDuneifVersion` (optional, default to `(x: false)` uses Dune to build the package if the provided predicate evaluates to true on the version, e.g. `useDuneifVersion = versions.isGe "1.1"` will use dune if the version of the package is greater or equal to `"1.1"`,
|
||||
* `useDune` (optional, defaults to `false`) uses Dune to build the package if set to true, the presence of this attribute overrides the behavior of the previous one.
|
||||
|
||||
@@ -27,7 +27,7 @@ package set to make it the default. This guarantees you get a consistent package
|
||||
set.
|
||||
```nix
|
||||
mypkg = let
|
||||
cudaPackages = cudaPackages_11_5.overrideScope' (final: prev: {
|
||||
cudaPackages = cudaPackages_11_5.overrideScope' (final: prev {
|
||||
cudnn = prev.cudnn_8_3_2;
|
||||
}});
|
||||
in callPackage { inherit cudaPackages; };
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
- do configuration akin to [Dhall Lang](https://dhall-lang.org/)
|
||||
- perform data validation
|
||||
|
||||
## Cuelang schema quick start {#cuelang-quickstart}
|
||||
## Cuelang schema quick start
|
||||
|
||||
Cuelang schemas are similar to JSON, here is a quick cheatsheet:
|
||||
|
||||
@@ -21,7 +21,7 @@ Cuelang schemas are similar to JSON, here is a quick cheatsheet:
|
||||
- Read <https://cuelang.org/docs/concepts/logic/> to learn more about the semantics.
|
||||
- Read <https://cuelang.org/docs/references/spec/> to learn about the language specification.
|
||||
|
||||
## `writeCueValidator` {#cuelang-writeCueValidator}
|
||||
## `writeCueValidator`
|
||||
|
||||
Nixpkgs provides a `pkgs.writeCueValidator` helper, which will write a validation script based on the provided Cuelang schema.
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
# Dart {#sec-language-dart}
|
||||
|
||||
## Dart applications {#ssec-dart-applications}
|
||||
|
||||
The function `buildDartApplication` builds Dart applications managed with pub.
|
||||
|
||||
It fetches its Dart dependencies automatically through `fetchDartDeps`, and (through a series of hooks) builds and installs the executables specified in the pubspec file. The hooks can be used in other derivations, if needed. The phases can also be overridden to do something different from installing binaries.
|
||||
|
||||
If you are packaging a Flutter desktop application, use [`buildFlutterApplication`](#ssec-dart-flutter) instead.
|
||||
|
||||
`vendorHash`: is the hash of the output of the dependency fetcher derivation. To obtain it, simply set it to `lib.fakeHash` (or omit it) and run the build ([more details here](#sec-source-hashes)).
|
||||
|
||||
If the upstream source is missing a `pubspec.lock` file, you'll have to vendor one and specify it using `pubspecLockFile`. If it is needed, one will be generated for you and printed when attempting to build the derivation.
|
||||
|
||||
The `dart` commands run can be overridden through `pubGetScript` and `dartCompileCommand`, you can also add flags using `dartCompileFlags` or `dartJitFlags`.
|
||||
|
||||
Dart supports multiple [outputs types](https://dart.dev/tools/dart-compile#types-of-output), you can choose between them using `dartOutputType` (defaults to `exe`). If you want to override the binaries path or the source path they come from, you can use `dartEntryPoints`. Outputs that require a runtime will automatically be wrapped with the relevant runtime (`dartaotruntime` for `aot-snapshot`, `dart run` for `jit-snapshot` and `kernel`, `node` for `js`), this can be overridden through `dartRuntimeCommand`.
|
||||
|
||||
```nix
|
||||
{ buildDartApplication, fetchFromGitHub }:
|
||||
|
||||
buildDartApplication rec {
|
||||
pname = "dart-sass";
|
||||
version = "1.62.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "sass";
|
||||
repo = pname;
|
||||
rev = version;
|
||||
hash = "sha256-U6enz8yJcc4Wf8m54eYIAnVg/jsGi247Wy8lp1r1wg4=";
|
||||
};
|
||||
|
||||
pubspecLockFile = ./pubspec.lock;
|
||||
vendorHash = "sha256-Atm7zfnDambN/BmmUf4BG0yUz/y6xWzf0reDw3Ad41s=";
|
||||
}
|
||||
```
|
||||
|
||||
## Flutter applications {#ssec-dart-flutter}
|
||||
|
||||
The function `buildFlutterApplication` builds Flutter applications.
|
||||
|
||||
The deps.json file must always be provided when packaging in Nixpkgs. It will be generated and printed if the derivation is attempted to be built without one. Alternatively, `autoDepsList` may be set to `true` when outside of Nixpkgs, as it relies on import-from-derivation.
|
||||
|
||||
A `pubspec.lock` file must be available. See the [Dart documentation](#ssec-dart-applications) for more details.
|
||||
|
||||
```nix
|
||||
{ flutter, fetchFromGitHub }:
|
||||
|
||||
flutter.buildFlutterApplication {
|
||||
pname = "firmware-updater";
|
||||
version = "unstable-2023-04-30";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "canonical";
|
||||
repo = "firmware-updater";
|
||||
rev = "6e7dbdb64e344633ea62874b54ff3990bd3b8440";
|
||||
sha256 = "sha256-s5mwtr5MSPqLMN+k851+pFIFFPa0N1hqz97ys050tFA=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
pubspecLockFile = ./pubspec.lock;
|
||||
depsListFile = ./deps.json;
|
||||
vendorHash = "sha256-cdMO+tr6kYiN5xKXa+uTMAcFf2C75F3wVPrn21G4QPQ=";
|
||||
}
|
||||
```
|
||||
@@ -11,7 +11,7 @@ with import <nixpkgs> {};
|
||||
mkShell {
|
||||
name = "dotnet-env";
|
||||
packages = [
|
||||
dotnet-sdk
|
||||
dotnet-sdk_3
|
||||
];
|
||||
}
|
||||
```
|
||||
@@ -27,57 +27,36 @@ mkShell {
|
||||
name = "dotnet-env";
|
||||
packages = [
|
||||
(with dotnetCorePackages; combinePackages [
|
||||
sdk_3_1
|
||||
sdk_6_0
|
||||
sdk_7_0
|
||||
])
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
This will produce a dotnet installation that has the dotnet 6.0 7.0 sdk. The first sdk listed will have it's cli utility present in the resulting environment. Example info output:
|
||||
This will produce a dotnet installation that has the dotnet 3.1 6.0 sdk. The first sdk listed will have it's cli utility present in the resulting environment. Example info output:
|
||||
|
||||
```ShellSession
|
||||
$ dotnet --info
|
||||
.NET SDK:
|
||||
Version: 7.0.202
|
||||
Commit: 6c74320bc3
|
||||
.NET Core SDK (reflecting any global.json):
|
||||
Version: 3.1.101
|
||||
Commit: b377529961
|
||||
|
||||
Środowisko uruchomieniowe:
|
||||
OS Name: nixos
|
||||
OS Version: 23.05
|
||||
OS Platform: Linux
|
||||
RID: linux-x64
|
||||
Base Path: /nix/store/n2pm44xq20hz7ybsasgmd7p3yh31gnh4-dotnet-sdk-7.0.202/sdk/7.0.202/
|
||||
...
|
||||
|
||||
Host:
|
||||
Version: 7.0.4
|
||||
Architecture: x64
|
||||
Commit: 0a396acafe
|
||||
.NET Core SDKs installed:
|
||||
2.1.803 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/sdk]
|
||||
3.0.102 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/sdk]
|
||||
3.1.101 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/sdk]
|
||||
|
||||
.NET SDKs installed:
|
||||
6.0.407 [/nix/store/3b19303vwrhv0xxz1hg355c7f2hgxxgd-dotnet-core-combined/sdk]
|
||||
7.0.202 [/nix/store/3b19303vwrhv0xxz1hg355c7f2hgxxgd-dotnet-core-combined/sdk]
|
||||
|
||||
.NET runtimes installed:
|
||||
Microsoft.AspNetCore.App 6.0.15 [/nix/store/3b19303vwrhv0xxz1hg355c7f2hgxxgd-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
|
||||
Microsoft.AspNetCore.App 7.0.4 [/nix/store/3b19303vwrhv0xxz1hg355c7f2hgxxgd-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
|
||||
Microsoft.NETCore.App 6.0.15 [/nix/store/3b19303vwrhv0xxz1hg355c7f2hgxxgd-dotnet-core-combined/shared/Microsoft.NETCore.App]
|
||||
Microsoft.NETCore.App 7.0.4 [/nix/store/3b19303vwrhv0xxz1hg355c7f2hgxxgd-dotnet-core-combined/shared/Microsoft.NETCore.App]
|
||||
|
||||
Other architectures found:
|
||||
None
|
||||
|
||||
Environment variables:
|
||||
Not set
|
||||
|
||||
global.json file:
|
||||
Not found
|
||||
|
||||
Learn more:
|
||||
https://aka.ms/dotnet/info
|
||||
|
||||
Download .NET:
|
||||
https://aka.ms/dotnet/download
|
||||
.NET Core runtimes installed:
|
||||
Microsoft.AspNetCore.All 2.1.15 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.AspNetCore.All]
|
||||
Microsoft.AspNetCore.App 2.1.15 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
|
||||
Microsoft.AspNetCore.App 3.0.2 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
|
||||
Microsoft.AspNetCore.App 3.1.1 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
|
||||
Microsoft.NETCore.App 2.1.15 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.NETCore.App]
|
||||
Microsoft.NETCore.App 3.0.2 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.NETCore.App]
|
||||
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}
|
||||
@@ -109,7 +88,7 @@ To package Dotnet applications, you can use `buildDotnetModule`. This has simila
|
||||
* `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`.
|
||||
* `selfContainedBuild` allows to enable the [self-contained](https://docs.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained) build flag. By default, it is set to false and generated applications have a dependency on the selected dotnet runtime. If enabled, the dotnet runtime is bundled into the executable and the built app has no dependency on Dotnet.
|
||||
* `dotnet-sdk` is useful in cases where you need to change what dotnet SDK is being used. You can also set this to the result of `dotnetSdkPackages.combinePackages`, if the project uses multiple SDKs to build.
|
||||
* `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. It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this.
|
||||
@@ -140,8 +119,8 @@ in buildDotnetModule rec {
|
||||
|
||||
projectReferences = [ referencedProject ]; # `referencedProject` must contain `nupkg` in the folder structure.
|
||||
|
||||
dotnet-sdk = dotnetCorePackages.sdk_6.0;
|
||||
dotnet-runtime = dotnetCorePackages.runtime_6_0;
|
||||
dotnet-sdk = dotnetCorePackages.sdk_3_1;
|
||||
dotnet-runtime = dotnetCorePackages.net_6_0;
|
||||
|
||||
executables = [ "foo" ]; # This wraps "$out/lib/$pname/foo" to `$out/bin/foo`.
|
||||
executables = []; # Don't install any executables.
|
||||
|
||||
@@ -56,11 +56,11 @@ See the `zlib` example:
|
||||
|
||||
zlib = (pkgs.zlib.override {
|
||||
stdenv = pkgs.emscriptenStdenv;
|
||||
}).overrideAttrs
|
||||
}).overrideDerivation
|
||||
(old: rec {
|
||||
buildInputs = old.buildInputs ++ [ pkg-config ];
|
||||
# we need to reset this setting!
|
||||
env = (old.env or { }) // { NIX_CFLAGS_COMPILE = ""; };
|
||||
NIX_CFLAGS_COMPILE="";
|
||||
configurePhase = ''
|
||||
# FIXME: Some tests require writing at $HOME
|
||||
HOME=$TMPDIR
|
||||
|
||||
@@ -116,6 +116,10 @@ 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}
|
||||
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;`.
|
||||
:::
|
||||
|
||||
- []{#ssec-gnome-hooks-gst-grl-plugins} Setup hooks of `gst_all_1.gstreamer` and `grilo` will populate the `GST_PLUGIN_SYSTEM_PATH_1_0` and `GRL_PLUGIN_PATH` variables, respectively, which will then be added to the wrapper by `wrapGAppsHook`.
|
||||
|
||||
You can also pass additional arguments to `makeWrapper` using `gappsWrapperArgs` in `preFixup` hook:
|
||||
|
||||
@@ -20,7 +20,6 @@ In the following is an example expression using `buildGoModule`, the following a
|
||||
|
||||
To obtain the actual hash, set `vendorHash = lib.fakeSha256;` and run the build ([more details here](#sec-source-hashes)).
|
||||
- `proxyVendor`: Fetches (go mod download) and proxies 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 or if any dependency has case-insensitive conflicts which will produce platform dependant `vendorHash` checksums.
|
||||
- `modPostBuild`: Shell commands to run after the build of the go-modules executes `go mod vendor`, and before calculating fixed output derivation's `vendorHash` (or `vendorSha256`). Note that if you change this attribute, you need to update `vendorHash` (or `vendorSha256`) attribute.
|
||||
|
||||
```nix
|
||||
pet = buildGoModule rec {
|
||||
@@ -115,16 +114,7 @@ done
|
||||
|
||||
## Attributes used by the builders {#ssec-go-common-attributes}
|
||||
|
||||
Many attributes [controlling the build phase](#variables-controlling-the-build-phase) are respected by both `buildGoModule` and `buildGoPackage`. Note that `buildGoModule` reads the following attributes also when building the `vendor/` go-modules fixed output derivation as well:
|
||||
|
||||
- [`sourceRoot`](#var-stdenv-sourceRoot)
|
||||
- [`prePatch`](#var-stdenv-prePatch)
|
||||
- [`patches`](#var-stdenv-patches)
|
||||
- [`patchFlags`](#var-stdenv-patchFlags)
|
||||
- [`postPatch`](#var-stdenv-postPatch)
|
||||
- [`preBuild`](#var-stdenv-preBuild)
|
||||
|
||||
In addition to the above attributes, and the many more variables respected also by `stdenv.mkDerivation`, both `buildGoModule` and `buildGoPackage` respect Go-specific attributes that tweak them to behave slightly differently:
|
||||
Both `buildGoModule` and `buildGoPackage` can be tweaked to behave slightly differently, if the following attributes are used:
|
||||
|
||||
### `ldflags` {#var-go-ldflags}
|
||||
|
||||
|
||||
@@ -71,10 +71,8 @@ $ nix-env -f '<nixpkgs>' -qaP -A haskell.compiler
|
||||
haskell.compiler.ghc810 ghc-8.10.7
|
||||
haskell.compiler.ghc88 ghc-8.8.4
|
||||
haskell.compiler.ghc90 ghc-9.0.2
|
||||
haskell.compiler.ghc924 ghc-9.2.4
|
||||
haskell.compiler.ghc92 ghc-9.2.4
|
||||
haskell.compiler.ghc925 ghc-9.2.5
|
||||
haskell.compiler.ghc926 ghc-9.2.6
|
||||
haskell.compiler.ghc92 ghc-9.2.7
|
||||
haskell.compiler.ghc942 ghc-9.4.2
|
||||
haskell.compiler.ghc943 ghc-9.4.3
|
||||
haskell.compiler.ghc94 ghc-9.4.4
|
||||
@@ -88,15 +86,13 @@ haskell.compiler.ghc924Binary ghc-binary-9.2.4
|
||||
haskell.compiler.ghc924BinaryMinimal ghc-binary-9.2.4
|
||||
haskell.compiler.integer-simple.ghc810 ghc-integer-simple-8.10.7
|
||||
haskell.compiler.integer-simple.ghc8107 ghc-integer-simple-8.10.7
|
||||
haskell.compiler.integer-simple.ghc88 ghc-integer-simple-8.8.4
|
||||
haskell.compiler.integer-simple.ghc884 ghc-integer-simple-8.8.4
|
||||
haskell.compiler.integer-simple.ghc88 ghc-integer-simple-8.8.4
|
||||
haskell.compiler.native-bignum.ghc90 ghc-native-bignum-9.0.2
|
||||
haskell.compiler.native-bignum.ghc902 ghc-native-bignum-9.0.2
|
||||
haskell.compiler.native-bignum.ghc92 ghc-native-bignum-9.2.4
|
||||
haskell.compiler.native-bignum.ghc924 ghc-native-bignum-9.2.4
|
||||
haskell.compiler.native-bignum.ghc925 ghc-native-bignum-9.2.5
|
||||
haskell.compiler.native-bignum.ghc926 ghc-native-bignum-9.2.6
|
||||
haskell.compiler.native-bignum.ghc92 ghc-native-bignum-9.2.7
|
||||
haskell.compiler.native-bignum.ghc927 ghc-native-bignum-9.2.7
|
||||
haskell.compiler.native-bignum.ghc942 ghc-native-bignum-9.4.2
|
||||
haskell.compiler.native-bignum.ghc943 ghc-native-bignum-9.4.3
|
||||
haskell.compiler.native-bignum.ghc94 ghc-native-bignum-9.4.4
|
||||
@@ -108,16 +104,16 @@ haskell.compiler.ghcjs ghcjs-8.10.7
|
||||
Each of those compiler versions has a corresponding attribute set built using
|
||||
it. However, the non-standard package sets are not tested regularly and, as a
|
||||
result, contain fewer working packages. The corresponding package set for GHC
|
||||
9.4.5 is `haskell.packages.ghc945`. In fact `haskellPackages` is just an alias
|
||||
for `haskell.packages.ghc927`:
|
||||
9.4.4 is `haskell.packages.ghc944`. In fact `haskellPackages` is just an alias
|
||||
for `haskell.packages.ghc924`:
|
||||
|
||||
```console
|
||||
$ nix-env -f '<nixpkgs>' -qaP -A haskell.packages.ghc927
|
||||
haskell.packages.ghc927.a50 a50-0.5
|
||||
haskell.packages.ghc927.AAI AAI-0.2.0.1
|
||||
haskell.packages.ghc927.aasam aasam-0.2.0.0
|
||||
haskell.packages.ghc927.abacate abacate-0.0.0.0
|
||||
haskell.packages.ghc927.abc-puzzle abc-puzzle-0.2.1
|
||||
$ nix-env -f '<nixpkgs>' -qaP -A haskell.packages.ghc924
|
||||
haskell.packages.ghc924.a50 a50-0.5
|
||||
haskell.packages.ghc924.AAI AAI-0.2.0.1
|
||||
haskell.packages.ghc924.aasam aasam-0.2.0.0
|
||||
haskell.packages.ghc924.abacate abacate-0.0.0.0
|
||||
haskell.packages.ghc924.abc-puzzle abc-puzzle-0.2.1
|
||||
…
|
||||
```
|
||||
|
||||
@@ -141,12 +137,7 @@ set the default version to a version older than the newest on Hackage. We do
|
||||
this to get them or their reverse dependencies to compile in our package set.
|
||||
4. For all packages, for which the newest Hackage version is not the default
|
||||
version, there will also be a `haskellPackages.foo_x_y_z` package with the
|
||||
newest version. The `x_y_z` part encodes the version with dots replaced by
|
||||
underscores. When the newest version changes by a new release to Hackage the
|
||||
old package will disappear under that name and be replaced by a newer one under
|
||||
the name with the new version. The package name including the version will
|
||||
also disappear when the default version e.g. from Stackage catches up with the
|
||||
newest version from Hackage.
|
||||
newest version.
|
||||
5. For some packages, we also manually add other `haskellPackages.foo_x_y_z`
|
||||
versions, if they are required for a certain build.
|
||||
|
||||
@@ -160,7 +151,7 @@ All `haskell.packages.*` package sets use the same package descriptions and the
|
||||
of versions by default. There are however GHC version specific override `.nix`
|
||||
files to loosen this a bit.
|
||||
|
||||
### Dependency resolution {#haskell-dependency-resolution}
|
||||
### Dependency resolution
|
||||
|
||||
Normally when you build Haskell packages with `cabal-install`, `cabal-install`
|
||||
does dependency resolution. It will look at all Haskell package versions known
|
||||
@@ -170,14 +161,12 @@ given in the `.cabal` file of your package and all its dependencies.
|
||||
|
||||
The [Haskell builder in nixpkgs](#haskell-mkderivation) does no such thing.
|
||||
It will simply take as input packages with names off the desired dependencies
|
||||
and just check whether they fulfill the version bounds and fail if they don’t
|
||||
(by default, see `jailbreak` to circumvent this).
|
||||
and just check whether they fulfill the version bounds and (by default, see
|
||||
`jailbreak`) fail if they don’t.
|
||||
|
||||
The `haskellPackages.callPackage` function does the package resolution.
|
||||
It will, e.g., use `haskellPackages.aeson`which has the default version as
|
||||
described above for a package input of name `aeson`. (More general:
|
||||
`<packages>.callPackage f` will call `f` with named inputs provided from the
|
||||
package set `<packages>`.)
|
||||
The package resolution is done by the `haskellPackages.callPackage` function
|
||||
which will, e.g., use `haskellPackages.aeson` for a package input of name
|
||||
`aeson`.
|
||||
While this is the default behavior, it is possible to override the dependencies
|
||||
for a specific package, see
|
||||
[`override` and `overrideScope`](#haskell-overriding-haskell-packages).
|
||||
@@ -230,7 +219,7 @@ specification, test suites, benchmarks etc. by compiling and invoking the
|
||||
package's `Setup.hs`. It does *not* use or invoke the `cabal-install` binary,
|
||||
but uses the underlying `Cabal` library instead.
|
||||
|
||||
### General arguments {#haskell-derivation-args}
|
||||
### General arguments
|
||||
|
||||
`pname`
|
||||
: Package name, assumed to be the same as on Hackage (if applicable)
|
||||
@@ -479,7 +468,7 @@ are especially useful when writing [overrides](#haskell-overriding-haskell-packa
|
||||
when you want to make sure that they are definitely included. However, it is
|
||||
recommended to use the more accurate ones listed above when possible.
|
||||
|
||||
### Meta attributes {#haskell-derivation-meta}
|
||||
### Meta attributes
|
||||
|
||||
`haskellPackages.mkDerivation` accepts the following attributes as direct
|
||||
arguments which are transparently set in `meta` of the resulting derivation. See
|
||||
@@ -714,7 +703,7 @@ editor plugin to achieve this.
|
||||
|
||||
## Overriding Haskell packages {#haskell-overriding-haskell-packages}
|
||||
|
||||
### Overriding a single package {#haskell-overriding-a-single-package}
|
||||
### Overriding a single package
|
||||
|
||||
<!-- TODO(@sternenseemann): we should document /somewhere/ that base == null etc. -->
|
||||
|
||||
@@ -803,7 +792,7 @@ lib.pipe my-haskell-package [
|
||||
]
|
||||
```
|
||||
|
||||
#### `haskell.lib.compose` {#haskell-haskell.lib.compose}
|
||||
#### `haskell.lib.compose`
|
||||
|
||||
The base interface for all overriding is the following function:
|
||||
|
||||
@@ -826,7 +815,7 @@ following overview. Refer to the
|
||||
[documentation of `haskellPackages.mkDerivation`](#haskell-mkderivation)
|
||||
for a more detailed description of the effects of the respective arguments.
|
||||
|
||||
##### Packaging Helpers {#haskell-packaging-helpers}
|
||||
##### Packaging Helpers
|
||||
|
||||
`overrideSrc { src, version } drv`
|
||||
: Replace the source used for building `drv` with the path or derivation given
|
||||
@@ -875,7 +864,7 @@ sometimes necessary when working with versioned packages in
|
||||
altogether. Useful if it fails to evaluate cleanly and is causing
|
||||
noise in the evaluation errors tab on Hydra.
|
||||
|
||||
##### Development Helpers {#haskell-development-helpers}
|
||||
##### Development Helpers
|
||||
|
||||
`sdistTarball drv`
|
||||
: Create a source distribution tarball like those found on Hackage
|
||||
@@ -913,7 +902,7 @@ for debugging with e.g. `gdb`.
|
||||
|
||||
<!-- TODO(@sternenseemann): shellAware -->
|
||||
|
||||
##### Trivial Helpers {#haskell-trivial-helpers}
|
||||
##### Trivial Helpers
|
||||
|
||||
`doJailbreak drv`
|
||||
: Sets the `jailbreak` argument to `true` for `drv`.
|
||||
@@ -998,7 +987,7 @@ benchmark component.
|
||||
`dontCoverage drv`
|
||||
: Sets the `doCoverage` argument to `false` for `drv`.
|
||||
|
||||
#### Library functions in the Haskell package sets {#haskell-package-set-lib-functions}
|
||||
#### Library functions in the Haskell package sets
|
||||
|
||||
Some library functions depend on packages from the Haskell package sets. Thus they are
|
||||
exposed from those instead of from `haskell.lib.compose` which can only access what is
|
||||
@@ -1062,7 +1051,7 @@ it does for the unstable branches.
|
||||
|
||||
## F.A.Q. {#haskell-faq}
|
||||
|
||||
### Why is topic X not covered in this section? Why is section Y missing? {#haskell-why-not-covered}
|
||||
### Why is topic X not covered in this section? Why is section Y missing?
|
||||
|
||||
We have been working on [moving the nixpkgs Haskell documentation back into the
|
||||
nixpkgs manual](https://github.com/NixOS/nixpkgs/issues/121403). Since this
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<xi:include href="crystal.section.xml" />
|
||||
<xi:include href="cuda.section.xml" />
|
||||
<xi:include href="cuelang.section.xml" />
|
||||
<xi:include href="dart.section.xml" />
|
||||
<xi:include href="dhall.section.xml" />
|
||||
<xi:include href="dotnet.section.xml" />
|
||||
<xi:include href="emscripten.section.xml" />
|
||||
@@ -26,7 +25,6 @@
|
||||
<xi:include href="ios.section.xml" />
|
||||
<xi:include href="java.section.xml" />
|
||||
<xi:include href="javascript.section.xml" />
|
||||
<xi:include href="lisp.section.xml" />
|
||||
<xi:include href="lua.section.xml" />
|
||||
<xi:include href="maven.section.xml" />
|
||||
<xi:include href="nim.section.xml" />
|
||||
|
||||
@@ -6,16 +6,16 @@ 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 {#javascript-finding-examples}
|
||||
## 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 {#javascript-finding-examples-github}
|
||||
### 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 {#javascript-finding-examples-gitlab}
|
||||
### 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>
|
||||
@@ -105,7 +105,7 @@ After you have identified the correct system, you need to override your package
|
||||
});
|
||||
```
|
||||
|
||||
### Adding and Updating Javascript packages in nixpkgs {#javascript-adding-or-updating-packages}
|
||||
### Adding and Updating Javascript packages in nixpkgs
|
||||
|
||||
To add a package from NPM to nixpkgs:
|
||||
|
||||
@@ -140,7 +140,7 @@ To update NPM packages in nixpkgs, run the same `generate.sh` script:
|
||||
./pkgs/development/node-packages/generate.sh
|
||||
```
|
||||
|
||||
#### Git protocol error {#javascript-git-error}
|
||||
#### Git protocol error
|
||||
|
||||
Some packages may have Git dependencies from GitHub specified with `git://`.
|
||||
GitHub has [disabled unecrypted Git connections](https://github.blog/2021-09-01-improving-git-protocol-security-github/#no-more-unauthenticated-git), so you may see the following error when running the generate script:
|
||||
@@ -229,7 +229,7 @@ See `node2nix` [docs](https://github.com/svanderburg/node2nix) for more info.
|
||||
#### 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`.
|
||||
- `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}
|
||||
@@ -288,7 +288,7 @@ configurePhase = ''
|
||||
This will generate a derivation including the `node_modules` directory.
|
||||
If you have to build a derivation for an integrated web framework (rails, phoenix..), this is probably the easiest way.
|
||||
|
||||
#### Overriding dependency behavior {#javascript-mkYarnPackage-overriding-dependencies}
|
||||
#### Overriding dependency behavior
|
||||
|
||||
In the `mkYarnPackage` record the property `pkgConfig` can be used to override packages when you encounter problems building.
|
||||
|
||||
|
||||
@@ -1,304 +0,0 @@
|
||||
# lisp-modules {#lisp}
|
||||
|
||||
This document describes the Nixpkgs infrastructure for building Common Lisp
|
||||
libraries that use ASDF (Another System Definition Facility). It lives in
|
||||
`pkgs/development/lisp-modules`.
|
||||
|
||||
## Overview {#lisp-overview}
|
||||
|
||||
The main entry point of the API are the Common Lisp implementation packages
|
||||
(e.g. `abcl`, `ccl`, `clasp-common-lisp`, `clisp` `ecl`, `sbcl`)
|
||||
themselves. They have the `pkgs` and `withPackages` attributes, which can be
|
||||
used to discover available packages and to build wrappers, respectively.
|
||||
|
||||
The `pkgs` attribute set contains packages that were automatically imported from
|
||||
Quicklisp, and any other manually defined ones. Not every package works for all
|
||||
the CL implementations (e.g. `nyxt` only makes sense for `sbcl`).
|
||||
|
||||
The `withPackages` function is of primary utility. It is used to build runnable
|
||||
wrappers, with a pinned and pre-built ASDF FASL available in the `ASDF`
|
||||
environment variable, and `CL_SOURCE_REGISTRY`/`ASDF_OUTPUT_TRANSLATIONS`
|
||||
configured to find the desired systems on runtime.
|
||||
|
||||
With a few exceptions, the primary thing that the infrastructure does is to run
|
||||
`asdf:load-system` for each system specified in the `systems` argument to
|
||||
`build-asdf-system`, and save the FASLs to the Nix store. Then, it makes these
|
||||
FASLs available to wrappers. Any other use-cases, such as producing SBCL
|
||||
executables with `sb-ext:save-lisp-and-die`, are achieved via overriding the
|
||||
`buildPhase` etc.
|
||||
|
||||
In addition, Lisps have the `withOverrides` function, which can be used to
|
||||
substitute any package in the scope of their `pkgs`. This will be useful
|
||||
together with `overrideLispAttrs` when dealing with slashy ASDF systems, because
|
||||
they should stay in the main package and be build by specifying the `systems`
|
||||
argument to `build-asdf-system`.
|
||||
|
||||
## The 90% use case example {#lisp-use-case-example}
|
||||
|
||||
The most common way to use the library is to run ad-hoc wrappers like this:
|
||||
|
||||
`nix-shell -p 'sbcl.withPackages (ps: with ps; [ alexandria ])'`
|
||||
|
||||
Then, in a shell:
|
||||
|
||||
```
|
||||
$ result/bin/sbcl
|
||||
* (load (sb-ext:posix-getenv "ASDF"))
|
||||
* (asdf:load-system 'alexandria)
|
||||
```
|
||||
|
||||
Also one can create a `pkgs.mkShell` environment in `shell.nix`/`flake.nix`:
|
||||
|
||||
```
|
||||
let
|
||||
sbcl' = sbcl.withPackages (ps: [ ps.alexandria ]);
|
||||
in mkShell {
|
||||
buildInputs = [ sbcl' ];
|
||||
}
|
||||
```
|
||||
|
||||
Such a Lisp can be now used e.g. to compile your sources:
|
||||
|
||||
```
|
||||
buildPhase = ''
|
||||
${sbcl'}/bin/sbcl --load my-build-file.lisp
|
||||
''
|
||||
```
|
||||
|
||||
## Importing packages from Quicklisp {#lisp-importing-packages-from-quicklisp}
|
||||
|
||||
The library is able to very quickly import all the packages distributed by
|
||||
Quicklisp by parsing its `releases.txt` and `systems.txt` files. These files are
|
||||
available from [http://beta.quicklisp.org/dist/quicklisp.txt].
|
||||
|
||||
The import process is implemented in the `import` directory as Common Lisp
|
||||
functions in the `org.lispbuilds.nix` ASDF system. To run the script, one can
|
||||
execute `ql-import.lisp`:
|
||||
|
||||
```
|
||||
nix-shell --run 'sbcl --script ql-import.lisp'
|
||||
```
|
||||
|
||||
The script will:
|
||||
|
||||
1. Download the latest Quicklisp `systems.txt` and `releases.txt` files
|
||||
2. Generate an SQLite database of all QL systems in `packages.sqlite`
|
||||
3. Generate an `imported.nix` file from the database
|
||||
|
||||
The maintainer's job there is to:
|
||||
|
||||
1. Re-run the `ql-import.lisp` script
|
||||
2. Add missing native dependencies in `ql.nix`
|
||||
3. For packages that still don't build, package them manually in `packages.nix`
|
||||
|
||||
Also, the `imported.nix` file **must not be edited manually**! It should only be
|
||||
generated as described in this section.
|
||||
|
||||
### Adding native dependencies {#lisp-quicklisp-adding-native-dependencies}
|
||||
|
||||
The Quicklisp files contain ASDF dependency data, but don't include native
|
||||
library (CFFI) dependencies, and, in the case of ABCL, Java dependencies.
|
||||
|
||||
The `ql.nix` file contains a long list of overrides, where these dependencies
|
||||
can be added.
|
||||
|
||||
Packages defined in `packages.nix` contain these dependencies naturally.
|
||||
|
||||
### Trusting `systems.txt` and `releases.txt` {#lisp-quicklisp-trusting}
|
||||
|
||||
The previous implementation of `lisp-modules` didn't fully trust the Quicklisp
|
||||
data, because there were times where the dependencies specified were not
|
||||
complete, and caused broken builds. It instead used a `nix-shell` environment to
|
||||
discover real dependencies by using the ASDF APIs.
|
||||
|
||||
The current implementation has chosen to trust this data, because it's faster to
|
||||
parse a text file than to build each system to generate its Nix file, and
|
||||
because that way packages can be mass-imported. Because of that, there may come
|
||||
a day where some packages will break, due to bugs in Quicklisp. In that case,
|
||||
the fix could be a manual override in `packages.nix` and `ql.nix`.
|
||||
|
||||
A known fact is that Quicklisp doesn't include dependencies on slashy systems in
|
||||
its data. This is an example of a situation where such fixes were used, e.g. to
|
||||
replace the `systems` attribute of the affected packages. (See the definition of
|
||||
`iolib`).
|
||||
|
||||
### Quirks {#lisp-quicklisp-quirks}
|
||||
|
||||
During Quicklisp import:
|
||||
|
||||
- `+` in names are converted to `_plus{_,}`: `cl+ssl`->`cl_plus_ssl`, `alexandria+`->`alexandria_plus`
|
||||
- `.` to `_dot_`: `iolib.base`->`iolib_dot_base`
|
||||
- names starting with a number have a `_` prepended (`3d-vectors`->`_3d-vectors`)
|
||||
- `_` in names is converted to `__` for reversibility
|
||||
|
||||
|
||||
## Defining packages manually inside Nixpkgs {#lisp-defining-packages-inside}
|
||||
|
||||
New packages, that for some reason are not in Quicklisp, and so cannot be
|
||||
auto-imported, can be written in the `packages.nix` file.
|
||||
|
||||
In that file, use the `build-asdf-system` function, which is a wrapper around
|
||||
`mkDerivation` for building ASDF systems. Various other hacks are present, such
|
||||
as `build-with-compile-into-pwd` for systems which create files during
|
||||
compilation.
|
||||
|
||||
The `build-asdf-system` function is documented with comments in
|
||||
`nix-cl.nix`. Also, `packages.nix` is full of examples of how to use it.
|
||||
|
||||
## Defining packages manually outside Nixpkgs {#lisp-defining-packages-outside}
|
||||
|
||||
Lisp derivations (`abcl`, `sbcl` etc.) also export the `buildASDFSystem`
|
||||
function, which is the same as `build-asdf-system`, except for the `lisp`
|
||||
argument which is set to the given CL implementation.
|
||||
|
||||
It can be used to define packages outside Nixpkgs, and, for example, add them
|
||||
into the package scope with `withOverrides` which will be discussed later on.
|
||||
|
||||
### Including an external package in scope {#lisp-including-external-pkg-in-scope}
|
||||
|
||||
A package defined outside Nixpkgs using `buildASDFSystem` can be woven into the
|
||||
Nixpkgs-provided scope like this:
|
||||
|
||||
```
|
||||
let
|
||||
alexandria = sbcl.buildASDFSystem rec {
|
||||
pname = "alexandria";
|
||||
version = "1.4";
|
||||
src = fetchFromGitLab {
|
||||
domain = "gitlab.common-lisp.net";
|
||||
owner = "alexandria";
|
||||
repo = "alexandria";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-1Hzxt65dZvgOFIljjjlSGgKYkj+YBLwJCACi5DZsKmQ=";
|
||||
};
|
||||
};
|
||||
sbcl' = sbcl.withOverrides (self: super: {
|
||||
inherit alexandria;
|
||||
});
|
||||
in sbcl'.pkgs.alexandria
|
||||
```
|
||||
|
||||
## Overriding package attributes {#lisp-overriding-package-attributes}
|
||||
|
||||
Packages export the `overrideLispAttrs` function, which can be used to build a
|
||||
new package with different parameters.
|
||||
|
||||
Example of overriding `alexandria`:
|
||||
|
||||
```
|
||||
sbcl.pkgs.alexandria.overrideLispAttrs (oldAttrs: rec {
|
||||
version = "1.4";
|
||||
src = fetchFromGitLab {
|
||||
domain = "gitlab.common-lisp.net";
|
||||
owner = "alexandria";
|
||||
repo = "alexandria";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-1Hzxt65dZvgOFIljjjlSGgKYkj+YBLwJCACi5DZsKmQ=";
|
||||
};
|
||||
})
|
||||
```
|
||||
|
||||
## Overriding packages in scope {#lisp-overriding-packages-in-scope}
|
||||
|
||||
Packages can be woven into a new scope by using `withOverrides`:
|
||||
|
||||
```
|
||||
let
|
||||
sbcl' = sbcl.withOverrides (self: super: {
|
||||
alexandria = super.alexandria.overrideLispAttrs (oldAttrs: rec {
|
||||
pname = "alexandria";
|
||||
version = "1.4";
|
||||
src = fetchFromGitLab {
|
||||
domain = "gitlab.common-lisp.net";
|
||||
owner = "alexandria";
|
||||
repo = "alexandria";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-1Hzxt65dZvgOFIljjjlSGgKYkj+YBLwJCACi5DZsKmQ=";
|
||||
};
|
||||
});
|
||||
});
|
||||
in builtins.elemAt sbcl'.pkgs.bordeaux-threads.lispLibs 0
|
||||
```
|
||||
|
||||
### Dealing with slashy systems {#lisp-dealing-with-slashy-systems}
|
||||
|
||||
Slashy (secondary) systems should not exist in their own packages! Instead, they
|
||||
should be included in the parent package as an extra entry in the `systems`
|
||||
argument to the `build-asdf-system`/`buildASDFSystem` functions.
|
||||
|
||||
The reason is that ASDF searches for a secondary system in the `.asd` of the
|
||||
parent package. Thus, having them separate would cause either one of them not to
|
||||
load cleanly, because one will contains FASLs of itself but not the other, and
|
||||
vice versa.
|
||||
|
||||
To package slashy systems, use `overrideLispAttrs`, like so:
|
||||
|
||||
```
|
||||
ecl.pkgs.alexandria.overrideLispAttrs (oldAttrs: {
|
||||
systems = oldAttrs.systems ++ [ "alexandria/tests" ];
|
||||
lispLibs = oldAttrs.lispLibs ++ [ ecl.pkgs.rt ];
|
||||
})
|
||||
```
|
||||
|
||||
See the respective section on using `withOverrides` for how to weave it back
|
||||
into `ecl.pkgs`.
|
||||
|
||||
Note that sometimes the slashy systems might not only have more dependencies
|
||||
than the main one, but create a circular dependency between `.asd`
|
||||
files. Unfortunately, in this case an adhoc solution becomes necessary.
|
||||
|
||||
## Building Wrappers {#lisp-building-wrappers}
|
||||
|
||||
Wrappers can be built using the `withPackages` function of Common Lisp
|
||||
implementations (`abcl`, `ecl`, `sbcl` etc.):
|
||||
|
||||
```
|
||||
sbcl.withPackages (ps: [ ps.alexandria ps.bordeaux-threads ])
|
||||
```
|
||||
|
||||
Such a wrapper can then be executed like this:
|
||||
|
||||
```
|
||||
result/bin/sbcl
|
||||
```
|
||||
|
||||
### Loading ASDF {#lisp-loading-asdf}
|
||||
|
||||
For best results, avoid calling `(require 'asdf)` When using the
|
||||
library-generated wrappers.
|
||||
|
||||
Use `(load (ext:getenv "ASDF"))` instead, supplying your implementation's way of
|
||||
getting an environment variable for `ext:getenv`. This will load the
|
||||
(pre-compiled to FASL) Nixpkgs-provided version of ASDF.
|
||||
|
||||
### Loading systems {#lisp-loading-systems}
|
||||
|
||||
There, you can simply use `asdf:load-system`. This works by setting the right
|
||||
values for the `CL_SOURCE_REGISTRY`/`ASDF_OUTPUT_TRANSLATIONS` environment
|
||||
variables, so that systems are found in the Nix store and pre-compiled FASLs are
|
||||
loaded.
|
||||
|
||||
## Adding a new Lisp {#lisp-adding-a-new-lisp}
|
||||
|
||||
The function `wrapLisp` is used to wrap Common Lisp implementations. It adds the
|
||||
`pkgs`, `withPackages`, `withOverrides` and `buildASDFSystem` attributes to the
|
||||
derivation.
|
||||
|
||||
`wrapLisp` takes these arguments:
|
||||
|
||||
- `pkg`: the Lisp package
|
||||
- `faslExt`: Implementation-specific extension for FASL files
|
||||
- `program`: The name of executable file in `${pkg}/bin/` (Default: `pkg.pname`)
|
||||
- `flags`: A list of flags to always pass to `program` (Default: `[]`)
|
||||
- `asdf`: The ASDF version to use (Default: `pkgs.asdf_3_3`)
|
||||
- `packageOverrides`: Package overrides config (Default: `(self: super: {})`)
|
||||
|
||||
This example wraps CLISP:
|
||||
|
||||
```
|
||||
wrapLisp {
|
||||
pkg = clisp;
|
||||
faslExt = "fas";
|
||||
flags = ["-E" "UTF8"];
|
||||
}
|
||||
```
|
||||
@@ -129,21 +129,16 @@ 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}
|
||||
|
||||
[Luarocks.org](https://luarocks.org/) is the main repository of lua packages.
|
||||
The site proposes two types of packages, the `rockspec` and the `src.rock`
|
||||
The site proposes two types of packages, the rockspec and the src.rock
|
||||
(equivalent of a [rockspec](https://github.com/luarocks/luarocks/wiki/Rockspec-format) but with the source).
|
||||
These packages can have different build types such as `cmake`, `builtin` etc .
|
||||
|
||||
Luarocks-based packages are generated in [pkgs/development/lua-modules/generated-packages.nix](https://github.com/NixOS/nixpkgs/tree/master/pkgs/development/lua-modules/generated-packages.nix) from
|
||||
the whitelist maintainers/scripts/luarocks-packages.csv and updated by running
|
||||
the script
|
||||
[maintainers/scripts/update-luarocks-packages](https://github.com/NixOS/nixpkgs/tree/master/maintainers/scripts/update-luarocks-packages):
|
||||
|
||||
```sh
|
||||
./maintainers/scripts/update-luarocks-packages update
|
||||
```
|
||||
Luarocks-based packages are generated in pkgs/development/lua-modules/generated-packages.nix from
|
||||
the whitelist maintainers/scripts/luarocks-packages.csv and updated by running maintainers/scripts/update-luarocks-packages.
|
||||
|
||||
[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](https://github.com/NixOS/nixpkgs/tree/master/pkgs/development/lua-modules/overrides.nix).
|
||||
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.
|
||||
|
||||
You can try converting luarocks packages to nix packages with the command `nix-shell -p luarocks-nix` and then `luarocks nix PKG_NAME`.
|
||||
|
||||
@@ -38,12 +38,12 @@ Here is a simple package example.
|
||||
|
||||
- It uses the `fetchFromGitHub` fetcher to get its source.
|
||||
|
||||
- It also accept `duneVersion` parameter (valid value are `"1"`, `"2"`, and
|
||||
`"3"`). The recommended practice it to set only if you don't want the default
|
||||
value and/or it depends on something else like package version. You might see
|
||||
a not-supported argument `useDune2`. The behavior was `useDune2 = true;` =>
|
||||
`duneVersion = "2";` and `useDune2 = false;` => `duneVersion = "1";`. It was
|
||||
used at the time when dune3 didn't existed.
|
||||
- `duneVersion = "2"` ensures that Dune version 2 is used for the
|
||||
build (this is the default; valid values are `"1"`, `"2"`, and `"3"`);
|
||||
note that there is also a legacy `useDune2` boolean attribute:
|
||||
set to `false` it corresponds to `duneVersion = "1"`; set to `true` it
|
||||
corresponds to `duneVersion = "2"`. If both arguments (`duneVersion` and
|
||||
`useDune2`) are given, the second one (`useDune2`) is silently ignored.
|
||||
|
||||
- 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
|
||||
@@ -71,6 +71,7 @@ Here is a simple package example.
|
||||
buildDunePackage rec {
|
||||
pname = "angstrom";
|
||||
version = "0.15.0";
|
||||
duneVersion = "2";
|
||||
|
||||
minimalOCamlVersion = "4.04";
|
||||
|
||||
@@ -103,6 +104,8 @@ buildDunePackage rec {
|
||||
pname = "wtf8";
|
||||
version = "1.0.2";
|
||||
|
||||
useDune2 = true;
|
||||
|
||||
minimalOCamlVersion = "4.02";
|
||||
|
||||
src = fetchurl {
|
||||
|
||||
@@ -118,7 +118,7 @@ ImageExifTool = buildPerlPackage {
|
||||
hash = "sha256-vOhB/FwQMC8PPvdnjDvxRpU6jAZcC6GMQfc0AH4uwKg=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = lib.optional stdenv.isDarwin shortenPerlShebang;
|
||||
buildInputs = lib.optional stdenv.isDarwin shortenPerlShebang;
|
||||
postInstall = lib.optionalString stdenv.isDarwin ''
|
||||
shortenPerlShebang $out/bin/exiftool
|
||||
'';
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
Nixpkgs provides a couple of facilities for working with this tool.
|
||||
|
||||
## Writing packages providing pkg-config modules {#pkg-config-writing-packages}
|
||||
## Writing packages providing pkg-config modules
|
||||
|
||||
Packages should set `meta.pkgConfigModules` with the list of package config modules they provide.
|
||||
Packages should set `meta.pkgConfigProvides` with the list of package config modules they provide.
|
||||
They should also use `testers.testMetaPkgConfig` to check that the final built package matches that list.
|
||||
Additionally, the [`validatePkgConfig` setup hook](https://nixos.org/manual/nixpkgs/stable/#validatepkgconfig), will do extra checks on to-be-installed pkg-config modules.
|
||||
|
||||
@@ -29,9 +29,9 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
})
|
||||
```
|
||||
|
||||
## Accessing packages via pkg-config module name {#sec-pkg-config-usage}
|
||||
## Accessing packages via pkg-config module name
|
||||
|
||||
### Within Nixpkgs {#sec-pkg-config-usage-internal}
|
||||
### Within Nixpkgs
|
||||
|
||||
A [setup hook](#setup-hook-pkg-config) is bundled in the `pkg-config` package to bring a derivation's declared build inputs into the environment.
|
||||
This will populate environment variables like `PKG_CONFIG_PATH`, `PKG_CONFIG_PATH_FOR_BUILD`, and `PKG_CONFIG_PATH_HOST` based on:
|
||||
@@ -44,7 +44,7 @@ For more details see the section on [specifying dependencies in general](#ssec-s
|
||||
|
||||
Normal pkg-config commands to look up dependencies by name will then work with those environment variables defined by the hook.
|
||||
|
||||
### Externally {#sec-pkg-config-usage-external}
|
||||
### Externally
|
||||
|
||||
The `defaultPkgConfigPackages` package set is a set of aliases, named after the modules they provide.
|
||||
This is meant to be used by language-to-nix integrations.
|
||||
|
||||
@@ -1019,7 +1019,7 @@ buildPythonPackage rec {
|
||||
|
||||
The `buildPythonPackage` mainly does four things:
|
||||
|
||||
* In the `buildPhase`, it calls `${python.pythonForBuild.interpreter} setup.py bdist_wheel` to
|
||||
* In the `buildPhase`, it calls `${python.interpreter} setup.py bdist_wheel` to
|
||||
build a wheel binary zipfile.
|
||||
* In the `installPhase`, it installs the wheel file using `pip install *.whl`.
|
||||
* In the `postFixup` phase, the `wrapPythonPrograms` bash function is called to
|
||||
@@ -1117,7 +1117,7 @@ with import <nixpkgs> {};
|
||||
in python.withPackages(ps: [ps.blaze])).env
|
||||
```
|
||||
|
||||
#### Optional extra dependencies {#python-optional-dependencies}
|
||||
#### Optional extra dependencies
|
||||
|
||||
Some packages define optional dependencies for additional features. With
|
||||
`setuptools` this is called `extras_require` and `flit` calls it
|
||||
@@ -1546,7 +1546,7 @@ of such package using the feature is `pkgs/tools/X11/xpra/default.nix`.
|
||||
As workaround install it as an extra `preInstall` step:
|
||||
|
||||
```shell
|
||||
${python.pythonForBuild.interpreter} setup.py install_data --install-dir=$out --root=$out
|
||||
${python.interpreter} setup.py install_data --install-dir=$out --root=$out
|
||||
sed -i '/ = data\_files/d' setup.py
|
||||
```
|
||||
|
||||
@@ -1801,14 +1801,14 @@ The following rules are desired to be respected:
|
||||
* Attribute names in `python-packages.nix` should be sorted alphanumerically to
|
||||
avoid merge conflicts and ease locating attributes.
|
||||
|
||||
## Package set maintenance {#python-package-set-maintenance}
|
||||
## 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 {#python-package-bulk-updates}
|
||||
### 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.
|
||||
@@ -1821,11 +1821,6 @@ 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.
|
||||
|
||||
If a package is fragile and often breaks during these bulks updates, it
|
||||
may be reasonable to set `passthru.skipBulkUpdate = true` in the
|
||||
derivation. This decision should not be made on a whim and should
|
||||
always be supported by a qualifying comment.
|
||||
|
||||
Once the branch is sufficiently stable it should normally be merged
|
||||
into the `staging` branch.
|
||||
|
||||
@@ -1836,7 +1831,7 @@ would be:
|
||||
$ maintainers/scripts/update-python-libraries --target minor --commit --use-pkgs-prefix pkgs/development/python-modules/**/default.nix
|
||||
```
|
||||
|
||||
## CPython Update Schedule {#python-cpython-update-schedule}
|
||||
## CPython Update Schedule
|
||||
|
||||
With [PEP 602](https://www.python.org/dev/peps/pep-0602/), CPython now
|
||||
follows a yearly release cadence. In nixpkgs, all supported interpreters
|
||||
|
||||
@@ -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.
|
||||
|
||||
### Platform-specific gems {#ruby-platform-specif-gems}
|
||||
### Platform-specific gems
|
||||
|
||||
Right now, bundix has some issues with pre-built, platform-specific gems: [bundix PR #68](https://github.com/nix-community/bundix/pull/68).
|
||||
Until this is solved, you can tell bundler to not use platform-specific gems and instead build them from source each time:
|
||||
|
||||
@@ -13,7 +13,7 @@ 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 [community maintained Rust toolchains](#using-community-maintained-rust-toolchains).
|
||||
or use a community maintained [Rust overlay](#using-community-rust-overlays).
|
||||
|
||||
## `buildRustPackage`: Compiling Rust applications with Cargo {#compiling-rust-applications-with-cargo}
|
||||
|
||||
@@ -50,11 +50,6 @@ package. `cargoHash256` is used for traditional Nix SHA-256 hashes,
|
||||
such as the one in the example above. `cargoHash` should instead be
|
||||
used for [SRI](https://www.w3.org/TR/SRI/) hashes. For example:
|
||||
|
||||
Exception: If the application has cargo `git` dependencies, the `cargoHash`/`cargoSha256`
|
||||
approach will not work, and you will need to copy the `Cargo.lock` file of the application
|
||||
to nixpkgs and continue with the next section for specifying the options of the`cargoLock`
|
||||
section.
|
||||
|
||||
```nix
|
||||
cargoHash = "sha256-l1vL2ZdtDRxSGvP0X/l3nMw8+6WF67KPutJEzUROjg8=";
|
||||
```
|
||||
@@ -162,7 +157,7 @@ required to build a rust package. A simple fix is to use:
|
||||
|
||||
```nix
|
||||
postPatch = ''
|
||||
ln -s ${./Cargo.lock} Cargo.lock
|
||||
cp ${./Cargo.lock} Cargo.lock
|
||||
'';
|
||||
```
|
||||
|
||||
@@ -416,13 +411,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 {#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 {#vendoring-of-dependencies}
|
||||
|
||||
Since network access is not allowed in sandboxed builds, Rust crate
|
||||
dependencies need to be retrieved using a fetcher. `rustPlatform`
|
||||
@@ -482,7 +477,7 @@ 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 {#hooks}
|
||||
|
||||
`rustPlatform` provides the following hooks to automate Cargo builds:
|
||||
|
||||
@@ -518,7 +513,7 @@ you of the correct hash.
|
||||
* `bindgenHook`: for crates which use `bindgen` as a build dependency, lets
|
||||
`bindgen` find `libclang` and `libclang` find the libraries in `buildInputs`.
|
||||
|
||||
#### Examples {#examples}
|
||||
### Examples {#examples}
|
||||
|
||||
#### Python package using `setuptools-rust` {#python-package-using-setuptools-rust}
|
||||
|
||||
@@ -535,9 +530,7 @@ directory of the `tokenizers` project's source archive, we use
|
||||
```nix
|
||||
{ fetchFromGitHub
|
||||
, buildPythonPackage
|
||||
, cargo
|
||||
, rustPlatform
|
||||
, rustc
|
||||
, setuptools-rust
|
||||
}:
|
||||
|
||||
@@ -560,12 +553,11 @@ buildPythonPackage rec {
|
||||
|
||||
sourceRoot = "source/bindings/python";
|
||||
|
||||
nativeBuildInputs = [
|
||||
cargo
|
||||
rustPlatform.cargoSetupHook
|
||||
rustc
|
||||
setuptools-rust
|
||||
];
|
||||
nativeBuildInputs = [ setuptools-rust ] ++ (with rustPlatform; [
|
||||
cargoSetupHook
|
||||
rust.cargo
|
||||
rust.rustc
|
||||
]);
|
||||
|
||||
# ...
|
||||
}
|
||||
@@ -650,127 +642,7 @@ buildPythonPackage rec {
|
||||
}
|
||||
```
|
||||
|
||||
## `buildRustCrate`: Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo}
|
||||
|
||||
### Simple operation {#simple-operation}
|
||||
|
||||
When run, `cargo build` produces a file called `Cargo.lock`,
|
||||
containing pinned versions of all dependencies. Nixpkgs contains a
|
||||
tool called `crate2Nix` (`nix-shell -p crate2nix`), which can be
|
||||
used to turn a `Cargo.lock` into a Nix expression. That Nix
|
||||
expression calls `rustc` directly (hence bypassing Cargo), and can
|
||||
be used to compile a crate and all its dependencies.
|
||||
|
||||
See [`crate2nix`'s documentation](https://github.com/kolloch/crate2nix#known-restrictions)
|
||||
for instructions on how to use it.
|
||||
|
||||
### 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.
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
((import ./hello.nix).hello {}).override {
|
||||
crateOverrides = defaultCrateOverrides // {
|
||||
hello = attrs: { buildInputs = [ openssl ]; };
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Here, `crateOverrides` is expected to be a attribute set, where the
|
||||
key is the crate name without version number and the value a function.
|
||||
The function gets all attributes passed to `buildRustCrate` as first
|
||||
argument and returns a set that contains all attribute that should be
|
||||
overwritten.
|
||||
|
||||
For more complicated cases, such as when parts of the crate's
|
||||
derivation depend on the crate's version, the `attrs` argument of
|
||||
the override above can be read, as in the following example, which
|
||||
patches the derivation:
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
((import ./hello.nix).hello {}).override {
|
||||
crateOverrides = defaultCrateOverrides // {
|
||||
hello = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
|
||||
postPatch = ''
|
||||
substituteInPlace lib/zoneinfo.rs \
|
||||
--replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Another situation is when we want to override a nested
|
||||
dependency. This actually works in the exact same way, since the
|
||||
`crateOverrides` parameter is forwarded to the crate's
|
||||
dependencies. For instance, to override the build inputs for crate
|
||||
`libc` in the example above, where `libc` is a dependency of the main
|
||||
crate, we could do:
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
((import hello.nix).hello {}).override {
|
||||
crateOverrides = defaultCrateOverrides // {
|
||||
libc = attrs: { buildInputs = []; };
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### 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:
|
||||
|
||||
```nix
|
||||
(hello {}).override { rust = pkgs.rust; };
|
||||
```
|
||||
|
||||
- Whether to build in release mode or debug mode (release mode by
|
||||
default):
|
||||
|
||||
```nix
|
||||
(hello {}).override { release = false; };
|
||||
```
|
||||
|
||||
- Whether to print the commands sent to `rustc` when building
|
||||
(equivalent to `--verbose` in cargo:
|
||||
|
||||
```nix
|
||||
(hello {}).override { verbose = false; };
|
||||
```
|
||||
|
||||
- Extra arguments to be passed to `rustc`:
|
||||
|
||||
```nix
|
||||
(hello {}).override { extraRustcOpts = "-Z debuginfo=2"; };
|
||||
```
|
||||
|
||||
- Phases, just like in any other derivation, can be specified using
|
||||
the following attributes: `preUnpack`, `postUnpack`, `prePatch`,
|
||||
`patches`, `postPatch`, `preConfigure` (in the case of a Rust crate,
|
||||
this is run before calling the "build" script), `postConfigure`
|
||||
(after the "build" script),`preBuild`, `postBuild`, `preInstall` and
|
||||
`postInstall`. As an example, here is how to create a new module
|
||||
before running the build script:
|
||||
|
||||
```nix
|
||||
(hello {}).override {
|
||||
preConfigure = ''
|
||||
echo "pub const PATH=\"${hi.out}\";" >> src/path.rs"
|
||||
'';
|
||||
};
|
||||
```
|
||||
|
||||
### Setting Up `nix-shell` {#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
|
||||
@@ -814,61 +686,31 @@ $ cargo build
|
||||
$ cargo test
|
||||
```
|
||||
|
||||
## Using community maintained Rust toolchains {#using-community-maintained-rust-toolchains}
|
||||
### Controlling Rust Version Inside `nix-shell` {#controlling-rust-version-inside-nix-shell}
|
||||
|
||||
::: {.note}
|
||||
Note: The following projects cannot be used within nixpkgs since [IFD](#ssec-import-from-derivation) is disallowed.
|
||||
To package things that require Rust nightly, `RUSTC_BOOTSTRAP = true;` can sometimes be used as a hack.
|
||||
:::
|
||||
|
||||
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)
|
||||
|
||||
Despite their names, both projects provides a similar set of packages and overlays under different APIs.
|
||||
|
||||
Oxalica's overlay allows you to select a particular Rust version without you providing a hash or a flake input,
|
||||
but comes with a larger git repository than fenix.
|
||||
|
||||
Fenix also provides rust-analyzer nightly in addition to the Rust toolchains.
|
||||
|
||||
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](https://github.com/mozilla/nixpkgs-mozilla)).
|
||||
|
||||
The following documentation demonstrates examples using fenix and oxalica's Rust overlay
|
||||
with `nix-shell` and building derivations. More advanced usages like flake usage
|
||||
are documented in their own repositories.
|
||||
|
||||
### Using Rust nightly with `nix-shell` {#using-rust-nightly-with-nix-shell}
|
||||
|
||||
Here is a simple `shell.nix` that provides Rust nightly (default profile) using fenix:
|
||||
To control your rust version (i.e. use nightly) from within `shell.nix` (or
|
||||
other nix expressions) you can use the following `shell.nix`
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> { };
|
||||
let
|
||||
fenix = callPackage
|
||||
(fetchFromGitHub {
|
||||
owner = "nix-community";
|
||||
repo = "fenix";
|
||||
# commit from: 2023-03-03
|
||||
rev = "e2ea04982b892263c4d939f1cc3bf60a9c4deaa1";
|
||||
hash = "sha256-AsOim1A8KKtMWIxG+lXh5Q4P2bhOZjoUhFWJ1EuZNNk=";
|
||||
})
|
||||
{ };
|
||||
# Latest Nightly
|
||||
with import <nixpkgs> {};
|
||||
let src = fetchFromGitHub {
|
||||
owner = "mozilla";
|
||||
repo = "nixpkgs-mozilla";
|
||||
# commit from: 2019-05-15
|
||||
rev = "9f35c4b09fd44a77227e79ff0c1b4b6a69dff533";
|
||||
hash = "sha256-18h0nvh55b5an4gmlgfbvwbyqj91bklf1zymis6lbdh75571qaz0=";
|
||||
};
|
||||
in
|
||||
mkShell {
|
||||
with import "${src.out}/rust-overlay.nix" pkgs pkgs;
|
||||
stdenv.mkDerivation {
|
||||
name = "rust-env";
|
||||
nativeBuildInputs = [
|
||||
# Note: to use stable, just replace `default` with `stable`
|
||||
fenix.default.toolchain
|
||||
|
||||
# Example Build-time Additional Dependencies
|
||||
pkg-config
|
||||
];
|
||||
buildInputs = [
|
||||
# Example Run-time Additional Dependencies
|
||||
openssl
|
||||
# Note: to use stable, just replace `nightly` with `stable`
|
||||
latest.rustChannels.nightly.rust
|
||||
|
||||
# Add some extra dependencies from `pkgs`
|
||||
pkg-config openssl
|
||||
];
|
||||
|
||||
# Set Environment Variables
|
||||
@@ -876,66 +718,116 @@ mkShell {
|
||||
}
|
||||
```
|
||||
|
||||
Save this to `shell.nix`, then run:
|
||||
Now run:
|
||||
|
||||
```ShellSession
|
||||
$ rustc --version
|
||||
rustc 1.69.0-nightly (13471d3b2 2023-03-02)
|
||||
rustc 1.26.0-nightly (188e693b3 2018-03-26)
|
||||
```
|
||||
|
||||
To see that you are using nightly.
|
||||
|
||||
Oxalica's Rust overlay has more complete examples of `shell.nix` (and cross compilation) under its
|
||||
[`examples` directory](https://github.com/oxalica/rust-overlay/tree/e53e8853aa7b0688bc270e9e6a681d22e01cf299/examples).
|
||||
## Using community Rust overlays {#using-community-rust-overlays}
|
||||
|
||||
### Using Rust nightly in a derivation with `buildRustPackage` {#using-rust-nightly-in-a-derivation-with-buildrustpackage}
|
||||
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)
|
||||
|
||||
You can also use Rust nightly to build rust packages using `makeRustPlatform`.
|
||||
The below snippet demonstrates invoking `buildRustPackage` with a Rust toolchain from oxalica's 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.
|
||||
|
||||
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
|
||||
with import <nixpkgs>
|
||||
{
|
||||
{ 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"))
|
||||
];
|
||||
};
|
||||
let
|
||||
rustPlatform = makeRustPlatform {
|
||||
cargo = rust-bin.stable.latest.minimal;
|
||||
rustc = rust-bin.stable.latest.minimal;
|
||||
};
|
||||
in
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "ripgrep";
|
||||
version = "12.1.1";
|
||||
nativeBuildInputs = [
|
||||
rust-bin.stable.latest.minimal
|
||||
];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "BurntSushi";
|
||||
repo = "ripgrep";
|
||||
rev = version;
|
||||
hash = "sha256-+s5RBC3XSgb8omTbUNLywZnP6jSxZBKSS1BmXOjRF8M=";
|
||||
hash = "sha256-1hqps7l5qrjh9f914r5i6kmcz6f1yb951nv4lby0cjnp5l253kps=";
|
||||
};
|
||||
|
||||
cargoHash = "sha256-l1vL2ZdtDRxSGvP0X/l3nMw8+6WF67KPutJEzUROjg8=";
|
||||
|
||||
doCheck = false;
|
||||
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 = with licenses; [ mit unlicense ];
|
||||
maintainers = with maintainers; [ tailhook ];
|
||||
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
|
||||
2. cd into that directory and run `nix-build`
|
||||
1. cd into that directory and run `nix-build`
|
||||
|
||||
Fenix also has examples with `buildRustPackage`,
|
||||
[crane](https://github.com/ipetkov/crane),
|
||||
[naersk](https://github.com/nix-community/naersk),
|
||||
and cross compilation in its [Examples](https://github.com/nix-community/fenix#examples) section.
|
||||
### 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).
|
||||
|
||||
### Declarative Rust overlay installation {#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"))
|
||||
# Further overlays go here
|
||||
];
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
Note that this will fetch the latest overlay version when rebuilding your system.
|
||||
|
||||
@@ -40,24 +40,17 @@ Since release 15.09 there is a new TeX Live packaging that lives entirely under
|
||||
|
||||
## Custom packages {#sec-language-texlive-custom-packages}
|
||||
|
||||
You may find that you need to use an external TeX package. A derivation for such package has to provide the contents of the "texmf" directory in its output and provide the appropriate `tlType` attribute (one of `"run"`, `"bin"`, `"doc"`, `"source"`). Dependencies on other TeX packages can be listed in the attribute `tlDeps`.
|
||||
|
||||
Such derivation must then be listed in the attribute `pkgs` of an attribute set passed to `texlive.combine`, for instance by passing `extraPkgs = { pkgs = [ custom_package ]; };`. Within Nixpkgs, `pkgs` should be part of the derivation itself, allowing users to call `texlive.combine { inherit (texlive) scheme-small; inherit some_tex_package; }`.
|
||||
|
||||
Here is a (very verbose) example where the attribute `pkgs` is attached to the derivation itself, which requires creating a fixed point. See also the packages `auctex`, `eukleides`, `mftrace` for more examples.
|
||||
You may find that you need to use an external TeX package. A derivation for such package has to provide contents of the "texmf" directory in its output and provide the `tlType` attribute. Here is a (very verbose) example:
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
|
||||
let
|
||||
foiltex = stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
foiltex_run = stdenvNoCC.mkDerivation {
|
||||
pname = "latex-foiltex";
|
||||
version = "2.1.4b";
|
||||
passthru = {
|
||||
pkgs = [ finalAttrs.finalPackage ];
|
||||
tlDeps = with texlive; [ latex ];
|
||||
tlType = "run";
|
||||
};
|
||||
passthru.tlType = "run";
|
||||
|
||||
srcs = [
|
||||
(fetchurl {
|
||||
@@ -109,7 +102,8 @@ let
|
||||
maintainers = with maintainers; [ veprbl ];
|
||||
platforms = platforms.all;
|
||||
};
|
||||
});
|
||||
};
|
||||
foiltex = { pkgs = [ foiltex_run ]; };
|
||||
|
||||
latex_with_foiltex = texlive.combine {
|
||||
inherit (texlive) scheme-small;
|
||||
|
||||
@@ -166,8 +166,8 @@ in
|
||||
|
||||
If your package requires building specific parts, use instead `pkgs.vimUtils.buildVimPlugin`.
|
||||
|
||||
### Specificities for some plugins {#vim-plugin-specificities}
|
||||
#### Treesitter {#vim-plugin-treesitter}
|
||||
### Specificities for some plugins
|
||||
#### Treesitter
|
||||
|
||||
By default `nvim-treesitter` encourages you to download, compile and install
|
||||
the required Treesitter grammars at run time with `:TSInstall`. This works
|
||||
@@ -212,7 +212,7 @@ Note: this is not possible anymore for Neovim.
|
||||
|
||||
## Adding new plugins to nixpkgs {#adding-new-plugins-to-nixpkgs}
|
||||
|
||||
Nix expressions for Vim plugins are stored in [pkgs/applications/editors/vim/plugins](https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/editors/vim/plugins). For the vast majority of plugins, Nix expressions are automatically generated by running [`./update.py`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/update.py). This creates a [generated.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/generated.nix) file based on the plugins listed in [vim-plugin-names](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/vim-plugin-names).
|
||||
Nix expressions for Vim plugins are stored in [pkgs/applications/editors/vim/plugins](https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/editors/vim/plugins). For the vast majority of plugins, Nix expressions are automatically generated by running [`./update.py`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/update.py). This creates a [generated.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/generated.nix) file based on the plugins listed in [vim-plugin-names](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/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`.
|
||||
|
||||
After running `./update.py`, if nvim-treesitter received an update, also run [`nvim-treesitter/update.py`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/update.py) to update the tree sitter grammars for `nvim-treesitter`.
|
||||
|
||||
@@ -226,7 +226,7 @@ deoplete-fish = super.deoplete-fish.overrideAttrs(old: {
|
||||
|
||||
Sometimes plugins require an override that must be changed when the plugin is updated. This can cause issues when Vim plugins are auto-updated but the associated override isn't updated. For these plugins, the override should be written so that it specifies all information required to install the plugin, and running `./update.py` doesn't change the derivation for the plugin. Manually updating the override is required to update these types of plugins. An example of such a plugin is `LanguageClient-neovim`.
|
||||
|
||||
To add a new plugin, run `./update.py add "[owner]/[name]"`. **NOTE**: This script automatically commits to your git repository. Be sure to check out a fresh branch before running.
|
||||
To add a new plugin, run `./update.py --add "[owner]/[name]"`. **NOTE**: This script automatically commits to your git repository. Be sure to check out a fresh branch before running.
|
||||
|
||||
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 the Language Server Protocol integration with Vim/Neovim.
|
||||
|
||||
@@ -244,7 +244,7 @@ Alternatively, set the number of processes to a lower count to avoid rate-limiti
|
||||
./pkgs/applications/editors/vim/plugins/update.py --proc 1
|
||||
```
|
||||
|
||||
## How to maintain an out-of-tree overlay of vim plugins ? {#vim-out-of-tree-overlays}
|
||||
## How to maintain an out-of-tree overlay of vim plugins ?
|
||||
|
||||
You can use the updater script to generate basic packages out of a custom vim
|
||||
plugin list:
|
||||
|
||||
@@ -1,24 +1,19 @@
|
||||
<book xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
xml:id="nixpkgs-manual">
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<info>
|
||||
<title>Nixpkgs Manual</title>
|
||||
<subtitle>Version <xi:include href=".version" parse="text" />
|
||||
</subtitle>
|
||||
</info>
|
||||
<xi:include href="preface.chapter.xml" />
|
||||
<part xml:id="part-using">
|
||||
<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="functions.xml" />
|
||||
</part>
|
||||
<part>
|
||||
<title>Nixpkgs <code>lib</code></title>
|
||||
<xi:include href="functions.xml" />
|
||||
<xi:include href="module-system/module-system.chapter.xml" />
|
||||
</part>
|
||||
<part xml:id="part-stdenv">
|
||||
<title>Standard environment</title>
|
||||
<xi:include href="stdenv/stdenv.chapter.xml" />
|
||||
<xi:include href="stdenv/meta.chapter.xml" />
|
||||
@@ -26,7 +21,7 @@
|
||||
<xi:include href="stdenv/cross-compilation.chapter.xml" />
|
||||
<xi:include href="stdenv/platform-notes.chapter.xml" />
|
||||
</part>
|
||||
<part xml:id="part-builders">
|
||||
<part>
|
||||
<title>Builders</title>
|
||||
<xi:include href="builders/fetchers.chapter.xml" />
|
||||
<xi:include href="builders/trivial-builders.chapter.xml" />
|
||||
@@ -37,7 +32,7 @@
|
||||
<xi:include href="languages-frameworks/index.xml" />
|
||||
<xi:include href="builders/packages/index.xml" />
|
||||
</part>
|
||||
<part xml:id="part-contributing">
|
||||
<part>
|
||||
<title>Contributing to Nixpkgs</title>
|
||||
<xi:include href="contributing/quick-start.chapter.xml" />
|
||||
<xi:include href="contributing/coding-conventions.chapter.xml" />
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
# Module System {#module-system}
|
||||
|
||||
## Introduction {#module-system-introduction}
|
||||
|
||||
The module system is a language for handling configuration, implemented as a Nix library.
|
||||
|
||||
Compared to plain Nix, it adds documentation, type checking and composition or extensibility.
|
||||
|
||||
::: {.note}
|
||||
This chapter is new and not complete yet. For a gentle introduction to the module system, in the context of NixOS, see [Writing NixOS Modules](https://nixos.org/manual/nixos/unstable/index.html#sec-writing-modules) in the NixOS manual.
|
||||
:::
|
||||
|
||||
|
||||
## `lib.evalModules` {#module-system-lib-evalModules}
|
||||
|
||||
Evaluate a set of modules. This function is typically only used once per application (e.g. once in NixOS, once in Home Manager, ...).
|
||||
|
||||
### Parameters {#module-system-lib-evalModules-parameters}
|
||||
|
||||
#### `modules` {#module-system-lib-evalModules-param-modules}
|
||||
|
||||
A list of modules. These are merged together to form the final configuration.
|
||||
<!-- TODO link to section about merging, TBD -->
|
||||
|
||||
#### `specialArgs` {#module-system-lib-evalModules-param-specialArgs}
|
||||
|
||||
An attribute set of module arguments that can be used in `imports`.
|
||||
|
||||
This is in contrast to `config._module.args`, which is only available after all `imports` have been resolved.
|
||||
|
||||
#### `class` {#module-system-lib-evalModules-param-class}
|
||||
|
||||
If the `class` attribute is set and non-`null`, the module system will reject `imports` with a different `_class` declaration.
|
||||
|
||||
The `class` value should be a string in lower [camel case](https://en.wikipedia.org/wiki/Camel_case).
|
||||
|
||||
If applicable, the `class` should match the "prefix" of the attributes used in (experimental) [flakes](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#description). Some examples are:
|
||||
|
||||
- `nixos` as in `flake.nixosModules`
|
||||
- `nixosTest`: modules that constitute a [NixOS VM test](https://nixos.org/manual/nixos/stable/index.html#sec-nixos-tests)
|
||||
<!-- We've only just started with `class`. You're invited to add a few more. -->
|
||||
|
||||
#### `prefix` {#module-system-lib-evalModules-param-prefix}
|
||||
|
||||
A list of strings representing the location at or below which all options are evaluated. This is used by `types.submodule` to improve error reporting and find the implicit `name` module argument.
|
||||
|
||||
### Return value {#module-system-lib-evalModules-return-value}
|
||||
|
||||
The result is an attribute set with the following attributes:
|
||||
|
||||
#### `options` {#module-system-lib-evalModules-return-value-options}
|
||||
|
||||
The nested attribute set of all option declarations.
|
||||
|
||||
#### `config` {#module-system-lib-evalModules-return-value-config}
|
||||
|
||||
The nested attribute set of all option values.
|
||||
|
||||
#### `type` {#module-system-lib-evalModules-return-value-type}
|
||||
|
||||
A module system type. This type is an instance of `types.submoduleWith` containing the current [`modules`](#module-system-lib-evalModules-param-modules).
|
||||
|
||||
The option definitions that are typed with this type will extend the current set of modules, like [`extendModules`](#module-system-lib-evalModules-return-value-extendModules).
|
||||
|
||||
However, the value returned from the type is just the [`config`](#module-system-lib-evalModules-return-value-config), like any submodule.
|
||||
|
||||
If you're familiar with prototype inheritance, you can think of this `evalModules` invocation as the prototype, and usages of this type as the instances.
|
||||
|
||||
This type is also available to the [`modules`](#module-system-lib-evalModules-param-modules) as the module argument `moduleType`.
|
||||
<!-- TODO: document the module arguments. Using moduleType is like saying: suppose this configuration was extended. -->
|
||||
|
||||
#### `extendModules` {#module-system-lib-evalModules-return-value-extendModules}
|
||||
|
||||
A function similar to `evalModules` but building on top of the already passed [`modules`](#module-system-lib-evalModules-param-modules). Its arguments, `modules` and `specialArgs` are added to the existing values.
|
||||
|
||||
If you're familiar with prototype inheritance, you can think of the current, actual `evalModules` invocation as the prototype, and the return value of `extendModules` as the instance.
|
||||
|
||||
This functionality is also available to modules as the `extendModules` module argument.
|
||||
|
||||
::: {.note}
|
||||
|
||||
**Evaluation Performance**
|
||||
|
||||
`extendModules` returns a configuration that shares very little with the original `evalModules` invocation, because the module arguments may be different.
|
||||
|
||||
So if you have a configuration that has been (or will be) largely evaluated, almost none of the computation is shared with the configuration returned by `extendModules`.
|
||||
|
||||
The real work of module evaluation happens while computing the values in `config` and `options`, so multiple invocations of `extendModules` have a particularly small cost, as long as only the final `config` and `options` are evaluated.
|
||||
|
||||
If you do reference multiple `config` (or `options`) from before and after `extendModules`, evaluation performance is the same as with multiple `evalModules` invocations, because the new modules' ability to override existing configuration fundamentally requires constructing a new `config` and `options` fixpoint.
|
||||
:::
|
||||
|
||||
#### `_module` {#module-system-lib-evalModules-return-value-_module}
|
||||
|
||||
A portion of the configuration tree which is elided from `config`.
|
||||
|
||||
<!-- TODO: when markdown migration is complete, make _module docs visible again and reference _module docs. Maybe move those docs into this chapter? -->
|
||||
|
||||
#### `_type` {#module-system-lib-evalModules-return-value-_type}
|
||||
|
||||
A nominal type marker, always `"configuration"`.
|
||||
|
||||
#### `class` {#module-system-lib-evalModules-return-value-_configurationClass}
|
||||
|
||||
The [`class` argument](#module-system-lib-evalModules-param-class).
|
||||
@@ -86,23 +86,6 @@ meta.platforms = lib.platforms.linux;
|
||||
|
||||
Attribute Set `lib.platforms` defines [various common lists](https://github.com/NixOS/nixpkgs/blob/master/lib/systems/doubles.nix) of platforms types.
|
||||
|
||||
### `badPlatforms` {#var-meta-badPlatforms}
|
||||
|
||||
The list of Nix [platform types](https://github.com/NixOS/nixpkgs/blob/b03ac42b0734da3e7be9bf8d94433a5195734b19/lib/meta.nix#L75-L81) on which the package is known not to be buildable.
|
||||
Hydra will never create prebuilt binaries for these platform types, even if they are in [`meta.platforms`](#var-meta-platforms).
|
||||
In general it is preferable to set `meta.platforms = lib.platforms.all` and then exclude any platforms on which the package is known not to build.
|
||||
For example, a package which requires dynamic linking and cannot be linked statically could use this:
|
||||
|
||||
```nix
|
||||
meta.platforms = lib.platforms.all;
|
||||
meta.badPlatforms = [ lib.systems.inspect.patterns.isStatic ];
|
||||
```
|
||||
|
||||
The [`lib.meta.availableOn`](https://github.com/NixOS/nixpkgs/blob/b03ac42b0734da3e7be9bf8d94433a5195734b19/lib/meta.nix#L95-L106) function can be used to test whether or not a package is available (i.e. buildable) on a given platform.
|
||||
Some packages use this to automatically detect the maximum set of features with which they can be built.
|
||||
For example, `systemd` [requires dynamic linking](https://github.com/systemd/systemd/issues/20600#issuecomment-912338965), and [has a `meta.badPlatforms` setting](https://github.com/NixOS/nixpkgs/blob/b03ac42b0734da3e7be9bf8d94433a5195734b19/pkgs/os-specific/linux/systemd/default.nix#L752) similar to the one above.
|
||||
Packages which can be built with or without `systemd` support will use `lib.meta.availableOn` to detect whether or not `systemd` is available on the [`hostPlatform`](#ssec-cross-platform-parameters) for which they are being built; if it is not available (e.g. due to a statically-linked host platform like `pkgsStatic`) this support will be disabled by default.
|
||||
|
||||
### `tests` {#var-meta-tests}
|
||||
|
||||
::: {.warning}
|
||||
@@ -118,7 +101,7 @@ $ cd path/to/nixpkgs
|
||||
$ nix-build -A your-package.tests
|
||||
```
|
||||
|
||||
#### Package tests {#var-meta-tests-packages}
|
||||
#### Package tests
|
||||
|
||||
Tests that are part of the source package are often executed in the `installCheckPhase`.
|
||||
|
||||
@@ -130,7 +113,7 @@ Prefer `passthru.tests` for tests that are introduced in nixpkgs because:
|
||||
|
||||
For more on how to write and run package tests, see <xref linkend="sec-package-tests"/>.
|
||||
|
||||
#### NixOS tests {#var-meta-tests-nixos}
|
||||
#### NixOS tests
|
||||
|
||||
The NixOS tests are available as `nixosTests` in parameters of derivations. For instance, the OpenSMTPD derivation includes lines similar to:
|
||||
|
||||
@@ -190,7 +173,7 @@ To be effective, it must be presented directly to an evaluation process that han
|
||||
|
||||
### `hydraPlatforms` {#var-meta-hydraPlatforms}
|
||||
|
||||
The list of Nix platform types for which the [Hydra](https://github.com/nixos/hydra) [instance at `hydra.nixos.org`](https://nixos.org/hydra) will build the package. (Hydra is the Nix-based continuous build system.) It defaults to the value of `meta.platforms`. Thus, the only reason to set `meta.hydraPlatforms` is if you want `hydra.nixos.org` to build the package on a subset of `meta.platforms`, or not at all, e.g.
|
||||
The list of Nix platform types for which the Hydra instance at `hydra.nixos.org` will build the package. (Hydra is the Nix-based continuous build system.) It defaults to the value of `meta.platforms`. Thus, the only reason to set `meta.hydraPlatforms` is if you want `hydra.nixos.org` to build the package on a subset of `meta.platforms`, or not at all, e.g.
|
||||
|
||||
```nix
|
||||
meta.platforms = lib.platforms.linux;
|
||||
@@ -199,26 +182,7 @@ meta.hydraPlatforms = [];
|
||||
|
||||
### `broken` {#var-meta-broken}
|
||||
|
||||
If set to `true`, the package is marked as "broken", meaning that it won’t show up in [search.nixos.org](https://search.nixos.org/packages), and cannot be built or installed unless the environment variable [`NIXPKGS_ALLOW_BROKEN`](#opt-allowBroken) is set.
|
||||
Such unconditionally-broken packages should be removed from Nixpkgs eventually unless they are fixed.
|
||||
|
||||
The value of this attribute can depend on a package's arguments, including `stdenv`.
|
||||
This means that `broken` can be used to express constraints, for example:
|
||||
|
||||
- Does not cross compile
|
||||
|
||||
```nix
|
||||
meta.broken = !(stdenv.buildPlatform.canExecute stdenv.hostPlatform)
|
||||
```
|
||||
|
||||
- Broken if all of a certain set of its dependencies are broken
|
||||
|
||||
```nix
|
||||
meta.broken = lib.all (map (p: p.meta.broken) [ glibc musl ])
|
||||
```
|
||||
|
||||
This makes `broken` strictly more powerful than `meta.badPlatforms`.
|
||||
However `meta.availableOn` currently examines only `meta.platforms` and `meta.badPlatforms`, so `meta.broken` does not influence the default values for optional dependencies.
|
||||
If set to `true`, the package is marked as "broken", meaning that it won’t show up in `nix-env -qa`, and cannot be built or installed. Such packages should be removed from Nixpkgs eventually unless they are fixed.
|
||||
|
||||
## Licenses {#sec-meta-license}
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ stdenv.mkDerivation {
|
||||
}
|
||||
```
|
||||
|
||||
(`stdenv` needs to be in scope, so if you write this in a separate Nix expression from `pkgs/all-packages.nix`, you need to pass it as a function argument.) Specifying a `name` and a `src` is the absolute minimum Nix requires. For convenience, you can also use `pname` and `version` attributes and `mkDerivation` will automatically set `name` to `"${pname}-${version}"` by default.
|
||||
**Since [RFC 0035](https://github.com/NixOS/rfcs/pull/35), this is preferred for packages in Nixpkgs**, as it allows us to reuse the version easily:
|
||||
(`stdenv` needs to be in scope, so if you write this in a separate Nix expression from `pkgs/all-packages.nix`, you need to pass it as a function argument.) Specifying a `name` and a `src` is the absolute minimum Nix requires. For convenience, you can also use `pname` and `version` attributes and `mkDerivation` will automatically set `name` to `"${pname}-${version}"` by default. Since [RFC 0035](https://github.com/NixOS/rfcs/pull/35), this is preferred for packages in Nixpkgs, as it allows us to reuse the version easily:
|
||||
|
||||
```nix
|
||||
stdenv.mkDerivation rec {
|
||||
@@ -34,8 +33,7 @@ Many packages have dependencies that are not provided in the standard environmen
|
||||
|
||||
```nix
|
||||
stdenv.mkDerivation {
|
||||
pname = "libfoo";
|
||||
version = "1.2.3";
|
||||
name = "libfoo-1.2.3";
|
||||
...
|
||||
buildInputs = [libbar perl ncurses];
|
||||
}
|
||||
@@ -47,8 +45,7 @@ Often it is necessary to override or modify some aspect of the build. To make th
|
||||
|
||||
```nix
|
||||
stdenv.mkDerivation {
|
||||
pname = "fnord";
|
||||
version = "4.5";
|
||||
name = "fnord-4.5";
|
||||
...
|
||||
buildPhase = ''
|
||||
gcc foo.c -o foo
|
||||
@@ -68,8 +65,7 @@ While the standard environment provides a generic builder, you can still supply
|
||||
|
||||
```nix
|
||||
stdenv.mkDerivation {
|
||||
pname = "libfoo";
|
||||
version = "1.2.3";
|
||||
name = "libfoo-1.2.3";
|
||||
...
|
||||
builder = ./builder.sh;
|
||||
}
|
||||
@@ -99,27 +95,6 @@ installPhase() {
|
||||
genericBuild
|
||||
```
|
||||
|
||||
### Building a `stdenv` package in `nix-shell` {#sec-building-stdenv-package-in-nix-shell}
|
||||
|
||||
To build a `stdenv` package in a [`nix-shell`](https://nixos.org/manual/nix/unstable/command-ref/nix-shell.html), use
|
||||
|
||||
```bash
|
||||
nix-shell '<nixpkgs>' -A some_package
|
||||
eval "${unpackPhase:-unpackPhase}"
|
||||
cd $sourceRoot
|
||||
eval "${patchPhase:-patchPhase}"
|
||||
eval "${configurePhase:-configurePhase}"
|
||||
eval "${buildPhase:-buildPhase}"
|
||||
```
|
||||
|
||||
To modify a [phase](#sec-stdenv-phases), first print it with
|
||||
|
||||
```bash
|
||||
type buildPhase
|
||||
```
|
||||
|
||||
then change it in a text editor, and paste it back to the terminal.
|
||||
|
||||
## Tools provided by `stdenv` {#sec-tools-of-stdenv}
|
||||
|
||||
The standard environment provides the following packages:
|
||||
@@ -384,107 +359,39 @@ Values inside it are not passed to the builder, so you can change them without t
|
||||
|
||||
#### `passthru.updateScript` {#var-passthru-updateScript}
|
||||
|
||||
A script to be run by `maintainers/scripts/update.nix` when the package is matched. The attribute can contain one of the following:
|
||||
A script to be run by `maintainers/scripts/update.nix` when the package is matched. It needs to be an executable file, either on the file system:
|
||||
|
||||
- []{#var-passthru-updateScript-command} an executable file, either on the file system:
|
||||
```nix
|
||||
passthru.updateScript = ./update.sh;
|
||||
```
|
||||
|
||||
```nix
|
||||
passthru.updateScript = ./update.sh;
|
||||
```
|
||||
or inside the expression itself:
|
||||
|
||||
or inside the expression itself:
|
||||
```nix
|
||||
passthru.updateScript = writeScript "update-zoom-us" ''
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl pcre common-updater-scripts
|
||||
|
||||
```nix
|
||||
passthru.updateScript = writeScript "update-zoom-us" ''
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl pcre common-updater-scripts
|
||||
set -eu -o pipefail
|
||||
|
||||
set -eu -o pipefail
|
||||
version="$(curl -sI https://zoom.us/client/latest/zoom_x86_64.tar.xz | grep -Fi 'Location:' | pcregrep -o1 '/(([0-9]\.?)+)/')"
|
||||
update-source-version zoom-us "$version"
|
||||
'';
|
||||
```
|
||||
|
||||
version="$(curl -sI https://zoom.us/client/latest/zoom_x86_64.tar.xz | grep -Fi 'Location:' | pcregrep -o1 '/(([0-9]\.?)+)/')"
|
||||
update-source-version zoom-us "$version"
|
||||
'';
|
||||
```
|
||||
The attribute can also contain a list, a script followed by arguments to be passed to it:
|
||||
|
||||
- a list, a script followed by arguments to be passed to it:
|
||||
```nix
|
||||
passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ];
|
||||
```
|
||||
|
||||
```nix
|
||||
passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ];
|
||||
```
|
||||
|
||||
- an attribute set containing:
|
||||
- [`command`]{#var-passthru-updateScript-set-command} – a string or list in the [format expected by `passthru.updateScript`](#var-passthru-updateScript-command).
|
||||
- [`attrPath`]{#var-passthru-updateScript-set-attrPath} (optional) – a string containing the canonical attribute path for the package. If present, it will be passed to the update script instead of the attribute path on which the package was discovered during Nixpkgs traversal.
|
||||
- [`supportedFeatures`]{#var-passthru-updateScript-set-supportedFeatures} (optional) – a list of the [extra features](#var-passthru-updateScript-supported-features) the script supports.
|
||||
|
||||
```nix
|
||||
passthru.updateScript = {
|
||||
command = [ ../../update.sh pname ];
|
||||
attrPath = pname;
|
||||
supportedFeatures = [ … ];
|
||||
};
|
||||
```
|
||||
|
||||
##### How update scripts are executed? {#var-passthru-updateScript-execution}
|
||||
|
||||
Update scripts are to be invoked by `maintainers/scripts/update.nix` script. You can run `nix-shell maintainers/scripts/update.nix` in the root of Nixpkgs repository for information on how to use it. `update.nix` offers several modes for selecting packages to update (e.g. select by attribute path, traverse Nixpkgs and filter by maintainer, etc.), and it will execute update scripts for all matched packages that have an `updateScript` attribute.
|
||||
|
||||
Each update script will be passed the following environment variables:
|
||||
|
||||
- [`UPDATE_NIX_NAME`]{#var-passthru-updateScript-env-UPDATE_NIX_NAME} – content of the `name` attribute of the updated package.
|
||||
- [`UPDATE_NIX_PNAME`]{#var-passthru-updateScript-env-UPDATE_NIX_PNAME} – content of the `pname` attribute of the updated package.
|
||||
- [`UPDATE_NIX_OLD_VERSION`]{#var-passthru-updateScript-env-UPDATE_NIX_OLD_VERSION} – content of the `version` attribute of the updated package.
|
||||
- [`UPDATE_NIX_ATTR_PATH`]{#var-passthru-updateScript-env-UPDATE_NIX_ATTR_PATH} – attribute path the `update.nix` discovered the package on (or the [canonical `attrPath`](#var-passthru-updateScript-set-attrPath) when available). Example: `pantheon.elementary-terminal`
|
||||
The script will be run with the `UPDATE_NIX_NAME`, `UPDATE_NIX_PNAME`, `UPDATE_NIX_OLD_VERSION` and `UPDATE_NIX_ATTR_PATH` environment variables set respectively to the name, pname, old version and attribute path of the package it is supposed to update.
|
||||
|
||||
::: {.note}
|
||||
An update script will be usually run from the root of the Nixpkgs repository but you should not rely on that. Also note that `update.nix` executes update scripts in parallel by default so you should avoid running `git commit` or any other commands that cannot handle that.
|
||||
The script will be usually run from the root of the Nixpkgs repository but you should not rely on that. Also note that the update scripts will be run in parallel by default; you should avoid running `git commit` or any other commands that cannot handle that.
|
||||
:::
|
||||
|
||||
::: {.tip}
|
||||
While update scripts should not create commits themselves, `maintainers/scripts/update.nix` supports automatically creating commits when running it with `--argstr commit true`. If you need to customize commit message, you can have the update script implement [`commit`](#var-passthru-updateScript-commit) feature.
|
||||
:::
|
||||
|
||||
##### Supported features {#var-passthru-updateScript-supported-features}
|
||||
###### `commit` {#var-passthru-updateScript-commit}
|
||||
|
||||
This feature allows update scripts to *ask* `update.nix` to create Git commits.
|
||||
|
||||
When support of this feature is declared, whenever the update script exits with `0` return status, it is expected to print a JSON list containing an object described below for each updated attribute to standard output.
|
||||
|
||||
When `update.nix` is run with `--argstr commit true` arguments, it will create a separate commit for each of the objects. An empty list can be returned when the script did not update any files, for example, when the package is already at the latest version.
|
||||
|
||||
The commit object contains the following values:
|
||||
|
||||
- [`attrPath`]{#var-passthru-updateScript-commit-attrPath} – a string containing attribute path.
|
||||
- [`oldVersion`]{#var-passthru-updateScript-commit-oldVersion} – a string containing old version.
|
||||
- [`newVersion`]{#var-passthru-updateScript-commit-newVersion} – a string containing new version.
|
||||
- [`files`]{#var-passthru-updateScript-commit-files} – a non-empty list of file paths (as strings) to add to the commit.
|
||||
- [`commitBody`]{#var-passthru-updateScript-commit-commitBody} (optional) – a string with extra content to be appended to the default commit message (useful for adding changelog links).
|
||||
- [`commitMessage`]{#var-passthru-updateScript-commit-commitMessage} (optional) – a string to use instead of the default commit message.
|
||||
|
||||
If the returned array contains exactly one object (e.g. `[{}]`), all values are optional and will be determined automatically.
|
||||
|
||||
```{=docbook}
|
||||
<example>
|
||||
<title>Standard output of an update script using commit feature</title>
|
||||
```
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"attrPath": "volume_key",
|
||||
"oldVersion": "0.3.11",
|
||||
"newVersion": "0.3.12",
|
||||
"files": [
|
||||
"/path/to/nixpkgs/pkgs/development/libraries/volume-key/default.nix"
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
```{=docbook}
|
||||
</example>
|
||||
```
|
||||
For information about how to run the updates, execute `nix-shell maintainers/scripts/update.nix`.
|
||||
|
||||
### Recursive attributes in `mkDerivation` {#mkderivation-recursive-attributes}
|
||||
|
||||
@@ -707,7 +614,7 @@ The prefix under which the package must be installed, passed via the `--prefix`
|
||||
|
||||
The key to use when specifying the prefix. By default, this is set to `--prefix=` as that is used by the majority of packages.
|
||||
|
||||
##### `dontAddStaticConfigureFlags` {#var-stdenv-dontAddStaticConfigureFlags}
|
||||
##### `dontAddStaticConfigureFlags`
|
||||
|
||||
By default, when building statically, stdenv will try to add build system appropriate configure flags to try to enable static builds.
|
||||
|
||||
@@ -1099,15 +1006,15 @@ postInstall = ''
|
||||
|
||||
Performs string substitution on the contents of \<infile\>, writing the result to \<outfile\>. The substitutions in \<subs\> are of the following form:
|
||||
|
||||
#### `--replace` \<s1\> \<s2\> {#fun-substitute-replace}
|
||||
#### `--replace` \<s1\> \<s2\>
|
||||
|
||||
Replace every occurrence of the string \<s1\> by \<s2\>.
|
||||
|
||||
#### `--subst-var` \<varName\> {#fun-substitute-subst-var}
|
||||
#### `--subst-var` \<varName\>
|
||||
|
||||
Replace every occurrence of `@varName@` by the contents of the environment variable \<varName\>. This is useful for generating files from templates, using `@...@` in the template as placeholders.
|
||||
|
||||
#### `--subst-var-by` \<varName\> \<s\> {#fun-substitute-subst-var-by}
|
||||
#### `--subst-var-by` \<varName\> \<s\>
|
||||
|
||||
Replace every occurrence of `@varName@` by the string \<s\>.
|
||||
|
||||
@@ -1248,7 +1155,7 @@ Multiple paths can be specified.
|
||||
patchShebangs [--build | --host] PATH...
|
||||
```
|
||||
|
||||
##### Flags {#patch-shebangs.sh-invocation-flags}
|
||||
##### Flags
|
||||
|
||||
`--build`
|
||||
: Look up commands available at build time
|
||||
@@ -1256,7 +1163,7 @@ patchShebangs [--build | --host] PATH...
|
||||
`--host`
|
||||
: Look up commands available at run time
|
||||
|
||||
##### Examples {#patch-shebangs.sh-invocation-examples}
|
||||
##### Examples
|
||||
|
||||
```sh
|
||||
patchShebangs --host /nix/store/<hash>-hello-1.0/bin
|
||||
@@ -1343,7 +1250,7 @@ Similarly, the CC Wrapper follows the Bintools Wrapper in defining standard envi
|
||||
|
||||
Here are some more packages that provide a setup hook. Since the list of hooks is extensible, this is not an exhaustive list. The mechanism is only to be used as a last resort, so it might cover most uses.
|
||||
|
||||
### Other hooks {#stdenv-other-hooks}
|
||||
### Other hooks
|
||||
|
||||
Many other packages provide hooks, that are not part of `stdenv`. You can find
|
||||
these in the [Hooks Reference](#chap-hooks).
|
||||
@@ -1401,7 +1308,7 @@ bin/blib.a(bios_console.o): In function `bios_handle_cup':
|
||||
|
||||
Adds the `-O2 -D_FORTIFY_SOURCE=2` compiler options. During code generation the compiler knows a great deal of information about buffer sizes (where possible), and attempts to replace insecure unlimited length buffer function calls with length-limited ones. This is especially useful for old, crufty code. Additionally, format strings in writable memory that contain `%n` are blocked. If an application depends on such a format string, it will need to be worked around.
|
||||
|
||||
Additionally, some warnings are enabled which might trigger build failures if compiler warnings are treated as errors in the package build. In this case, set `env.NIX_CFLAGS_COMPILE` to `-Wno-error=warning-type`.
|
||||
Additionally, some warnings are enabled which might trigger build failures if compiler warnings are treated as errors in the package build. In this case, set `NIX_CFLAGS_COMPILE` to `-Wno-error=warning-type`.
|
||||
|
||||
This needs to be turned off or fixed for errors similar to:
|
||||
|
||||
|
||||
13
flake.nix
13
flake.nix
@@ -57,19 +57,6 @@
|
||||
|
||||
nixosModules = {
|
||||
notDetected = ./nixos/modules/installer/scan/not-detected.nix;
|
||||
|
||||
/*
|
||||
Make the `nixpkgs.*` configuration read-only. Guarantees that `pkgs`
|
||||
is the way you initialize it.
|
||||
|
||||
Example:
|
||||
|
||||
{
|
||||
imports = [ nixpkgs.nixosModules.readOnlyPkgs ];
|
||||
nixpkgs.pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
}
|
||||
*/
|
||||
readOnlyPkgs = ./nixos/modules/misc/nixpkgs/read-only.nix;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
{ "\t" = 9;
|
||||
"\n" = 10;
|
||||
"\r" = 13;
|
||||
" " = 32;
|
||||
{ " " = 32;
|
||||
"!" = 33;
|
||||
"\"" = 34;
|
||||
"#" = 35;
|
||||
|
||||
@@ -9,7 +9,7 @@ let
|
||||
in
|
||||
|
||||
rec {
|
||||
inherit (builtins) attrNames listToAttrs hasAttr isAttrs getAttr removeAttrs;
|
||||
inherit (builtins) attrNames listToAttrs hasAttr isAttrs getAttr;
|
||||
|
||||
|
||||
/* Return an attribute from nested attribute sets.
|
||||
@@ -333,66 +333,6 @@ rec {
|
||||
) (attrNames set)
|
||||
);
|
||||
|
||||
/*
|
||||
Like builtins.foldl' but for attribute sets.
|
||||
Iterates over every name-value pair in the given attribute set.
|
||||
The result of the callback function is often called `acc` for accumulator. It is passed between callbacks from left to right and the final `acc` is the return value of `foldlAttrs`.
|
||||
|
||||
Attention:
|
||||
There is a completely different function
|
||||
`lib.foldAttrs`
|
||||
which has nothing to do with this function, despite the similar name.
|
||||
|
||||
Example:
|
||||
foldlAttrs
|
||||
(acc: name: value: {
|
||||
sum = acc.sum + value;
|
||||
names = acc.names ++ [name];
|
||||
})
|
||||
{ sum = 0; names = []; }
|
||||
{
|
||||
foo = 1;
|
||||
bar = 10;
|
||||
}
|
||||
->
|
||||
{
|
||||
sum = 11;
|
||||
names = ["bar" "foo"];
|
||||
}
|
||||
|
||||
foldlAttrs
|
||||
(throw "function not needed")
|
||||
123
|
||||
{};
|
||||
->
|
||||
123
|
||||
|
||||
foldlAttrs
|
||||
(_: _: v: v)
|
||||
(throw "initial accumulator not needed")
|
||||
{ z = 3; a = 2; };
|
||||
->
|
||||
3
|
||||
|
||||
The accumulator doesn't have to be an attrset.
|
||||
It can be as simple as a number or string.
|
||||
|
||||
foldlAttrs
|
||||
(acc: _: v: acc * 10 + v)
|
||||
1
|
||||
{ z = 1; a = 2; };
|
||||
->
|
||||
121
|
||||
|
||||
Type:
|
||||
foldlAttrs :: ( a -> String -> b -> a ) -> a -> { ... :: b } -> a
|
||||
*/
|
||||
foldlAttrs = f: init: set:
|
||||
foldl'
|
||||
(acc: name: f acc name set.${name})
|
||||
init
|
||||
(attrNames set);
|
||||
|
||||
/* Apply fold functions to values grouped by key.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -176,7 +176,7 @@ rec {
|
||||
# Only show the error for the first missing argument
|
||||
error = errorForArg (lib.head missingArgs);
|
||||
|
||||
in if missingArgs == [] then makeOverridable f allArgs else abort error;
|
||||
in if missingArgs == [] then makeOverridable f allArgs else throw error;
|
||||
|
||||
|
||||
/* Like callPackage, but for a function that returns an attribute
|
||||
@@ -213,14 +213,7 @@ rec {
|
||||
outputSpecified = true;
|
||||
drvPath = assert condition; drv.${outputName}.drvPath;
|
||||
outPath = assert condition; drv.${outputName}.outPath;
|
||||
} //
|
||||
# TODO: give the derivation control over the outputs.
|
||||
# `overrideAttrs` may not be the only attribute that needs
|
||||
# updating when switching outputs.
|
||||
lib.optionalAttrs (passthru?overrideAttrs) {
|
||||
# TODO: also add overrideAttrs when overrideAttrs is not custom, e.g. when not splicing.
|
||||
overrideAttrs = f: (passthru.overrideAttrs f).${outputName};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
outputsList = map outputToAttrListElement outputs;
|
||||
|
||||
150
lib/debug.nix
150
lib/debug.nix
@@ -109,8 +109,6 @@ rec {
|
||||
traceSeqN 2 { a.b.c = 3; } null
|
||||
trace: { a = { b = {…}; }; }
|
||||
=> null
|
||||
|
||||
Type: traceSeqN :: Int -> a -> b -> b
|
||||
*/
|
||||
traceSeqN = depth: x: y:
|
||||
let snip = v: if isList v then noQuotes "[…]" v
|
||||
@@ -175,63 +173,17 @@ rec {
|
||||
|
||||
# -- TESTING --
|
||||
|
||||
/* Evaluates a set of tests.
|
||||
|
||||
A test is an attribute set `{expr, expected}`,
|
||||
denoting an expression and its expected result.
|
||||
|
||||
The result is a `list` of __failed tests__, each represented as
|
||||
`{name, expected, result}`,
|
||||
|
||||
- expected
|
||||
- What was passed as `expected`
|
||||
- result
|
||||
- The actual `result` of the test
|
||||
/* Evaluate a set of tests. A test is an attribute set `{expr,
|
||||
expected}`, denoting an expression and its expected result. The
|
||||
result is a list of failed tests, each represented as `{name,
|
||||
expected, actual}`, denoting the attribute name of the failing
|
||||
test and its expected and actual results.
|
||||
|
||||
Used for regression testing of the functions in lib; see
|
||||
tests.nix for more examples.
|
||||
tests.nix for an example. Only tests having names starting with
|
||||
"test" are run.
|
||||
|
||||
Important: Only attributes that start with `test` are executed.
|
||||
|
||||
- If you want to run only a subset of the tests add the attribute `tests = ["testName"];`
|
||||
|
||||
Example:
|
||||
|
||||
runTests {
|
||||
testAndOk = {
|
||||
expr = lib.and true false;
|
||||
expected = false;
|
||||
};
|
||||
testAndFail = {
|
||||
expr = lib.and true false;
|
||||
expected = true;
|
||||
};
|
||||
}
|
||||
->
|
||||
[
|
||||
{
|
||||
name = "testAndFail";
|
||||
expected = true;
|
||||
result = false;
|
||||
}
|
||||
]
|
||||
|
||||
Type:
|
||||
runTests :: {
|
||||
tests = [ String ];
|
||||
${testName} :: {
|
||||
expr :: a;
|
||||
expected :: a;
|
||||
};
|
||||
}
|
||||
->
|
||||
[
|
||||
{
|
||||
name :: String;
|
||||
expected :: a;
|
||||
result :: a;
|
||||
}
|
||||
]
|
||||
Add attr { tests = ["testName"]; } to run these tests only.
|
||||
*/
|
||||
runTests =
|
||||
# Tests to run
|
||||
@@ -250,4 +202,90 @@ rec {
|
||||
{ testX = allTrue [ true ]; }
|
||||
*/
|
||||
testAllTrue = expr: { inherit expr; expected = map (x: true) expr; };
|
||||
|
||||
|
||||
# -- DEPRECATED --
|
||||
|
||||
traceShowVal = x: trace (showVal x) x;
|
||||
traceShowValMarked = str: x: trace (str + showVal x) x;
|
||||
|
||||
attrNamesToStr = a:
|
||||
trace ( "Warning: `attrNamesToStr` is deprecated "
|
||||
+ "and will be removed in the next release. "
|
||||
+ "Please use more specific concatenation "
|
||||
+ "for your uses (`lib.concat(Map)StringsSep`)." )
|
||||
(concatStringsSep "; " (map (x: "${x}=") (attrNames a)));
|
||||
|
||||
showVal =
|
||||
trace ( "Warning: `showVal` is deprecated "
|
||||
+ "and will be removed in the next release, "
|
||||
+ "please use `traceSeqN`" )
|
||||
(let
|
||||
modify = v:
|
||||
let pr = f: { __pretty = f; val = v; };
|
||||
in if isDerivation v then pr
|
||||
(drv: "<δ:${drv.name}:${concatStringsSep ","
|
||||
(attrNames drv)}>")
|
||||
else if [] == v then pr (const "[]")
|
||||
else if isList v then pr (l: "[ ${go (head l)}, … ]")
|
||||
else if isAttrs v then pr
|
||||
(a: "{ ${ concatStringsSep ", " (attrNames a)} }")
|
||||
else v;
|
||||
go = x: generators.toPretty
|
||||
{ allowPrettyValues = true; }
|
||||
(modify x);
|
||||
in go);
|
||||
|
||||
traceXMLVal = x:
|
||||
trace ( "Warning: `traceXMLVal` is deprecated "
|
||||
+ "and will be removed in the next release. "
|
||||
+ "Please use `traceValFn builtins.toXML`." )
|
||||
(trace (builtins.toXML x) x);
|
||||
traceXMLValMarked = str: x:
|
||||
trace ( "Warning: `traceXMLValMarked` is deprecated "
|
||||
+ "and will be removed in the next release. "
|
||||
+ "Please use `traceValFn (x: str + builtins.toXML x)`." )
|
||||
(trace (str + builtins.toXML x) x);
|
||||
|
||||
# trace the arguments passed to function and its result
|
||||
# maybe rewrite these functions in a traceCallXml like style. Then one function is enough
|
||||
traceCall = n: f: a: let t = n2: x: traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a));
|
||||
traceCall2 = n: f: a: b: let t = n2: x: traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b));
|
||||
traceCall3 = n: f: a: b: c: let t = n2: x: traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b) (t "arg 3" c));
|
||||
|
||||
traceValIfNot = c: x:
|
||||
trace ( "Warning: `traceValIfNot` is deprecated "
|
||||
+ "and will be removed in the next release. "
|
||||
+ "Please use `if/then/else` and `traceValSeq 1`.")
|
||||
(if c x then true else traceSeq (showVal x) false);
|
||||
|
||||
|
||||
addErrorContextToAttrs = attrs:
|
||||
trace ( "Warning: `addErrorContextToAttrs` is deprecated "
|
||||
+ "and will be removed in the next release. "
|
||||
+ "Please use `builtins.addErrorContext` directly." )
|
||||
(mapAttrs (a: v: addErrorContext "while evaluating ${a}" v) attrs);
|
||||
|
||||
# example: (traceCallXml "myfun" id 3) will output something like
|
||||
# calling myfun arg 1: 3 result: 3
|
||||
# this forces deep evaluation of all arguments and the result!
|
||||
# note: if result doesn't evaluate you'll get no trace at all (FIXME)
|
||||
# args should be printed in any case
|
||||
traceCallXml = a:
|
||||
trace ( "Warning: `traceCallXml` is deprecated "
|
||||
+ "and will be removed in the next release. "
|
||||
+ "Please complain if you use the function regularly." )
|
||||
(if !isInt a then
|
||||
traceCallXml 1 "calling ${a}\n"
|
||||
else
|
||||
let nr = a;
|
||||
in (str: expr:
|
||||
if isFunction expr then
|
||||
(arg:
|
||||
traceCallXml (builtins.add 1 nr) "${str}\n arg ${builtins.toString nr} is \n ${builtins.toXML (builtins.seq arg arg)}" (expr arg)
|
||||
)
|
||||
else
|
||||
let r = builtins.seq expr expr;
|
||||
in trace "${str}\n result:\n${builtins.toXML r}" r
|
||||
));
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ let
|
||||
composeManyExtensions makeExtensible makeExtensibleWithCustomName;
|
||||
inherit (self.attrsets) attrByPath hasAttrByPath setAttrByPath
|
||||
getAttrFromPath attrVals attrValues getAttrs catAttrs filterAttrs
|
||||
filterAttrsRecursive foldlAttrs foldAttrs collect nameValuePair mapAttrs
|
||||
filterAttrsRecursive foldAttrs collect nameValuePair mapAttrs
|
||||
mapAttrs' mapAttrsToList concatMapAttrs mapAttrsRecursive mapAttrsRecursiveCond
|
||||
genAttrs isDerivation toDerivation optionalAttrs
|
||||
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
||||
@@ -100,7 +100,7 @@ let
|
||||
escapeShellArg escapeShellArgs
|
||||
isStorePath isStringLike
|
||||
isValidPosixName toShellVar toShellVars
|
||||
escapeRegex escapeURL escapeXML replaceChars lowerChars
|
||||
escapeRegex escapeXML replaceChars lowerChars
|
||||
upperChars toLower toUpper addContextFrom splitString
|
||||
removePrefix removeSuffix versionOlder versionAtLeast
|
||||
getName getVersion
|
||||
@@ -145,10 +145,11 @@ let
|
||||
isOptionType mkOptionType;
|
||||
inherit (self.asserts)
|
||||
assertMsg assertOneOf;
|
||||
inherit (self.debug) traceIf traceVal traceValFn
|
||||
traceSeq traceSeqN traceValSeq
|
||||
traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN
|
||||
runTests testAllTrue;
|
||||
inherit (self.debug) addErrorContextToAttrs traceIf traceVal traceValFn
|
||||
traceXMLVal traceXMLValMarked traceSeq traceSeqN traceValSeq
|
||||
traceValSeqFn traceValSeqN traceValSeqNFn traceFnSeqN traceShowVal
|
||||
traceShowValMarked showVal traceCall traceCall2 traceCall3
|
||||
traceValIfNot runTests testAllTrue traceCallXml attrNamesToStr;
|
||||
inherit (self.misc) maybeEnv defaultMergeArg defaultMerge foldArgs
|
||||
maybeAttrNullable maybeAttr ifEnable checkFlag getValue
|
||||
checkReqs uniqList uniqListExt condConcat lazyGenericClosure
|
||||
|
||||
@@ -355,7 +355,6 @@ rec {
|
||||
# PLIST handling
|
||||
toPlist = {}: v: let
|
||||
isFloat = builtins.isFloat or (x: false);
|
||||
isPath = x: builtins.typeOf x == "path";
|
||||
expr = ind: x: with builtins;
|
||||
if x == null then "" else
|
||||
if isBool x then bool ind x else
|
||||
@@ -363,7 +362,6 @@ rec {
|
||||
if isString x then str ind x else
|
||||
if isList x then list ind x else
|
||||
if isAttrs x then attrs ind x else
|
||||
if isPath x then str ind (toString x) else
|
||||
if isFloat x then float ind x else
|
||||
abort "generators.toPlist: should never happen (v = ${v})";
|
||||
|
||||
@@ -424,103 +422,8 @@ ${expr "" v}
|
||||
(if v then "True" else "False")
|
||||
else if isFunction v then
|
||||
abort "generators.toDhall: cannot convert a function to Dhall"
|
||||
else if v == null then
|
||||
else if isNull v then
|
||||
abort "generators.toDhall: cannot convert a null to Dhall"
|
||||
else
|
||||
builtins.toJSON v;
|
||||
|
||||
/*
|
||||
Translate a simple Nix expression to Lua representation with occasional
|
||||
Lua-inlines that can be construted by mkLuaInline function.
|
||||
|
||||
Configuration:
|
||||
* multiline - by default is true which results in indented block-like view.
|
||||
* indent - initial indent.
|
||||
* asBindings - by default generate single value, but with this use attrset to set global vars.
|
||||
|
||||
Attention:
|
||||
Regardless of multiline parameter there is no trailing newline.
|
||||
|
||||
Example:
|
||||
generators.toLua {}
|
||||
{
|
||||
cmd = [ "typescript-language-server" "--stdio" ];
|
||||
settings.workspace.library = mkLuaInline ''vim.api.nvim_get_runtime_file("", true)'';
|
||||
}
|
||||
->
|
||||
{
|
||||
["cmd"] = {
|
||||
"typescript-language-server",
|
||||
"--stdio"
|
||||
},
|
||||
["settings"] = {
|
||||
["workspace"] = {
|
||||
["library"] = (vim.api.nvim_get_runtime_file("", true))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Type:
|
||||
toLua :: AttrSet -> Any -> String
|
||||
*/
|
||||
toLua = {
|
||||
/* If this option is true, the output is indented with newlines for attribute sets and lists */
|
||||
multiline ? true,
|
||||
/* Initial indentation level */
|
||||
indent ? "",
|
||||
/* Interpret as variable bindings */
|
||||
asBindings ? false,
|
||||
}@args: v:
|
||||
with builtins;
|
||||
let
|
||||
innerIndent = "${indent} ";
|
||||
introSpace = if multiline then "\n${innerIndent}" else " ";
|
||||
outroSpace = if multiline then "\n${indent}" else " ";
|
||||
innerArgs = args // {
|
||||
indent = if asBindings then indent else innerIndent;
|
||||
asBindings = false;
|
||||
};
|
||||
concatItems = concatStringsSep ",${introSpace}";
|
||||
isLuaInline = { _type ? null, ... }: _type == "lua-inline";
|
||||
|
||||
generatedBindings =
|
||||
assert lib.assertMsg (badVarNames == []) "Bad Lua var names: ${toPretty {} badVarNames}";
|
||||
libStr.concatStrings (
|
||||
lib.attrsets.mapAttrsToList (key: value: "${indent}${key} = ${toLua innerArgs value}\n") v
|
||||
);
|
||||
|
||||
# https://en.wikibooks.org/wiki/Lua_Programming/variable#Variable_names
|
||||
matchVarName = match "[[:alpha:]_][[:alnum:]_]*(\\.[[:alpha:]_][[:alnum:]_]*)*";
|
||||
badVarNames = filter (name: matchVarName name == null) (attrNames v);
|
||||
in
|
||||
if asBindings then
|
||||
generatedBindings
|
||||
else if v == null then
|
||||
"nil"
|
||||
else if isInt v || isFloat v || isString v || isBool v then
|
||||
builtins.toJSON v
|
||||
else if isList v then
|
||||
(if v == [ ] then "{}" else
|
||||
"{${introSpace}${concatItems (map (value: "${toLua innerArgs value}") v)}${outroSpace}}")
|
||||
else if isAttrs v then
|
||||
(
|
||||
if isLuaInline v then
|
||||
"(${v.expr})"
|
||||
else if v == { } then
|
||||
"{}"
|
||||
else
|
||||
"{${introSpace}${concatItems (
|
||||
lib.attrsets.mapAttrsToList (key: value: "[${builtins.toJSON key}] = ${toLua innerArgs value}") v
|
||||
)}${outroSpace}}"
|
||||
)
|
||||
else
|
||||
abort "generators.toLua: type ${typeOf v} is unsupported";
|
||||
|
||||
/*
|
||||
Mark string as Lua expression to be inlined when processed by toLua.
|
||||
|
||||
Type:
|
||||
mkLuaInline :: String -> AttrSet
|
||||
*/
|
||||
mkLuaInline = expr: { _type = "lua-inline"; inherit expr; };
|
||||
}
|
||||
|
||||
@@ -8,10 +8,9 @@ with lib;
|
||||
option = x:
|
||||
x // { optional = true; };
|
||||
|
||||
yes = { tristate = "y"; optional = false; };
|
||||
no = { tristate = "n"; optional = false; };
|
||||
module = { tristate = "m"; optional = false; };
|
||||
unset = { tristate = null; optional = false; };
|
||||
yes = { tristate = "y"; optional = false; };
|
||||
no = { tristate = "n"; optional = false; };
|
||||
module = { tristate = "m"; optional = false; };
|
||||
freeform = x: { freeform = x; optional = false; };
|
||||
|
||||
/*
|
||||
|
||||
@@ -81,6 +81,7 @@ in mkLicense lset) ({
|
||||
apsl10 = {
|
||||
spdxId = "APSL-1.0";
|
||||
fullName = "Apple Public Source License 1.0";
|
||||
url = "https://web.archive.org/web/20040701000000*/http://www.opensource.apple.com/apsl/1.0.txt";
|
||||
};
|
||||
|
||||
apsl20 = {
|
||||
@@ -108,11 +109,6 @@ in mkLicense lset) ({
|
||||
fullName = "Apache License 2.0";
|
||||
};
|
||||
|
||||
asl20-llvm = {
|
||||
spdxId = "Apache-2.0 WITH LLVM-exception";
|
||||
fullName = "Apache License 2.0 with LLVM Exceptions";
|
||||
};
|
||||
|
||||
bitstreamVera = {
|
||||
spdxId = "Bitstream-Vera";
|
||||
fullName = "Bitstream Vera Font License";
|
||||
@@ -204,11 +200,6 @@ in mkLicense lset) ({
|
||||
free = false;
|
||||
};
|
||||
|
||||
caossl = {
|
||||
fullName = "Computer Associates Open Source Licence Version 1.0";
|
||||
url = "http://jxplorer.org/licence.html";
|
||||
};
|
||||
|
||||
cal10 = {
|
||||
fullName = "Cryptographic Autonomy License version 1.0 (CAL-1.0)";
|
||||
url = "https://opensource.org/licenses/CAL-1.0";
|
||||
@@ -229,18 +220,6 @@ in mkLicense lset) ({
|
||||
fullName = "Creative Commons Zero v1.0 Universal";
|
||||
};
|
||||
|
||||
cc-by-nc-nd-30 = {
|
||||
spdxId = "CC-BY-NC-ND-3.0";
|
||||
fullName = "Creative Commons Attribution Non Commercial No Derivative Works 3.0 Unported";
|
||||
free = false;
|
||||
};
|
||||
|
||||
cc-by-nc-nd-40 = {
|
||||
spdxId = "CC-BY-NC-ND-4.0";
|
||||
fullName = "Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International";
|
||||
free = false;
|
||||
};
|
||||
|
||||
cc-by-nc-sa-20 = {
|
||||
spdxId = "CC-BY-NC-SA-2.0";
|
||||
fullName = "Creative Commons Attribution Non Commercial Share Alike 2.0";
|
||||
@@ -678,6 +657,11 @@ in mkLicense lset) ({
|
||||
url = "https://opensource.franz.com/preamble.html";
|
||||
};
|
||||
|
||||
llvm-exception = {
|
||||
spdxId = "LLVM-exception";
|
||||
fullName = "LLVM Exception"; # LLVM exceptions to the Apache 2.0 License
|
||||
};
|
||||
|
||||
lppl12 = {
|
||||
spdxId = "LPPL-1.2";
|
||||
fullName = "LaTeX Project Public License v1.2";
|
||||
@@ -920,13 +904,6 @@ in mkLicense lset) ({
|
||||
url = "https://github.com/thestk/stk/blob/master/LICENSE";
|
||||
};
|
||||
|
||||
tsl = {
|
||||
shortName = "TSL";
|
||||
fullName = "Timescale License Agreegment";
|
||||
url = "https://github.com/timescale/timescaledb/blob/main/tsl/LICENSE-TIMESCALE";
|
||||
unfree = true;
|
||||
};
|
||||
|
||||
tcltk = {
|
||||
spdxId = "TCL";
|
||||
fullName = "TCL/TK License";
|
||||
|
||||
206
lib/modules.nix
206
lib/modules.nix
@@ -21,7 +21,6 @@ let
|
||||
isBool
|
||||
isFunction
|
||||
isList
|
||||
isPath
|
||||
isString
|
||||
length
|
||||
mapAttrs
|
||||
@@ -46,9 +45,6 @@ let
|
||||
showOption
|
||||
unknownModule
|
||||
;
|
||||
inherit (lib.strings)
|
||||
isConvertibleWithToString
|
||||
;
|
||||
|
||||
showDeclPrefix = loc: decl: prefix:
|
||||
" - option(s) with prefix `${showOption (loc ++ [prefix])}' in module `${decl._file}'";
|
||||
@@ -63,8 +59,39 @@ let
|
||||
decls
|
||||
));
|
||||
|
||||
/* See https://nixos.org/manual/nixpkgs/unstable/#module-system-lib-evalModules
|
||||
or file://./../doc/module-system/module-system.chapter.md
|
||||
in
|
||||
|
||||
rec {
|
||||
|
||||
/*
|
||||
Evaluate a set of modules. The result is a set with the attributes:
|
||||
|
||||
‘options’: The nested set of all option declarations,
|
||||
|
||||
‘config’: The nested set of all option values.
|
||||
|
||||
‘type’: A module system type representing the module set as a submodule,
|
||||
to be extended by configuration from the containing module set.
|
||||
|
||||
This is also available as the module argument ‘moduleType’.
|
||||
|
||||
‘extendModules’: A function similar to ‘evalModules’ but building on top
|
||||
of the module set. Its arguments, ‘modules’ and ‘specialArgs’ are
|
||||
added to the existing values.
|
||||
|
||||
Using ‘extendModules’ a few times has no performance impact as long
|
||||
as you only reference the final ‘options’ and ‘config’.
|
||||
If you do reference multiple ‘config’ (or ‘options’) from before and
|
||||
after ‘extendModules’, performance is the same as with multiple
|
||||
‘evalModules’ invocations, because the new modules' ability to
|
||||
override existing configuration fundamentally requires a new
|
||||
fixpoint to be constructed.
|
||||
|
||||
This is also available as a module argument.
|
||||
|
||||
‘_module’: A portion of the configuration tree which is elided from
|
||||
‘config’. It contains some values that are mostly internal to the
|
||||
module system implementation.
|
||||
|
||||
!!! Please think twice before adding to this argument list! The more
|
||||
that is specified here instead of in the modules themselves the harder
|
||||
@@ -79,12 +106,8 @@ let
|
||||
# there's _module.args. If specialArgs.modulesPath is defined it will be
|
||||
# used as the base path for disabledModules.
|
||||
specialArgs ? {}
|
||||
, # `class`:
|
||||
# A nominal type for modules. When set and non-null, this adds a check to
|
||||
# make sure that only compatible modules are imported.
|
||||
# This would be remove in the future, Prefer _module.args option instead.
|
||||
class ? null
|
||||
, args ? {}
|
||||
, # This would be remove in the future, Prefer _module.args option instead.
|
||||
args ? {}
|
||||
, # This would be remove in the future, Prefer _module.check option instead.
|
||||
check ? true
|
||||
}:
|
||||
@@ -233,7 +256,6 @@ let
|
||||
|
||||
merged =
|
||||
let collected = collectModules
|
||||
class
|
||||
(specialArgs.modulesPath or "")
|
||||
(regularModules ++ [ internalModule ])
|
||||
({ inherit lib options config specialArgs; } // specialArgs);
|
||||
@@ -310,64 +332,38 @@ let
|
||||
prefix ? [],
|
||||
}:
|
||||
evalModules (evalModulesArgs // {
|
||||
inherit class;
|
||||
modules = regularModules ++ modules;
|
||||
specialArgs = evalModulesArgs.specialArgs or {} // specialArgs;
|
||||
prefix = extendArgs.prefix or evalModulesArgs.prefix or [];
|
||||
});
|
||||
|
||||
type = lib.types.submoduleWith {
|
||||
inherit modules specialArgs class;
|
||||
inherit modules specialArgs;
|
||||
};
|
||||
|
||||
result = withWarnings {
|
||||
_type = "configuration";
|
||||
options = checked options;
|
||||
config = checked (removeAttrs config [ "_module" ]);
|
||||
_module = checked (config._module);
|
||||
inherit extendModules type;
|
||||
class = class;
|
||||
};
|
||||
in result;
|
||||
|
||||
# collectModules :: (class: String) -> (modulesPath: String) -> (modules: [ Module ]) -> (args: Attrs) -> [ Module ]
|
||||
# collectModules :: (modulesPath: String) -> (modules: [ Module ]) -> (args: Attrs) -> [ Module ]
|
||||
#
|
||||
# Collects all modules recursively through `import` statements, filtering out
|
||||
# all modules in disabledModules.
|
||||
collectModules = class: let
|
||||
collectModules = let
|
||||
|
||||
# Like unifyModuleSyntax, but also imports paths and calls functions if necessary
|
||||
loadModule = args: fallbackFile: fallbackKey: m:
|
||||
if isFunction m then
|
||||
unifyModuleSyntax fallbackFile fallbackKey (applyModuleArgs fallbackKey m args)
|
||||
else if isAttrs m then
|
||||
if m._type or "module" == "module" then
|
||||
unifyModuleSyntax fallbackFile fallbackKey m
|
||||
else if m._type == "if" || m._type == "override" then
|
||||
loadModule args fallbackFile fallbackKey { config = m; }
|
||||
else
|
||||
throw (
|
||||
"Could not load a value as a module, because it is of type ${lib.strings.escapeNixString m._type}"
|
||||
+ lib.optionalString (fallbackFile != unknownModule) ", in file ${toString fallbackFile}."
|
||||
+ lib.optionalString (m._type == "configuration") " If you do intend to import this configuration, please only import the modules that make up the configuration. You may have to create a `let` binding, file or attribute to give yourself access to the relevant modules.\nWhile loading a configuration into the module system is a very sensible idea, it can not be done cleanly in practice."
|
||||
# Extended explanation: That's because a finalized configuration is more than just a set of modules. For instance, it has its own `specialArgs` that, by the nature of `specialArgs` can't be loaded through `imports` or the the `modules` argument. So instead, we have to ask you to extract the relevant modules and use those instead. This way, we keep the module system comparatively simple, and hopefully avoid a bad surprise down the line.
|
||||
)
|
||||
if isFunction m || isAttrs m then
|
||||
unifyModuleSyntax fallbackFile fallbackKey (applyModuleArgsIfFunction fallbackKey m args)
|
||||
else if isList m then
|
||||
let defs = [{ file = fallbackFile; value = m; }]; in
|
||||
throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
|
||||
else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
|
||||
|
||||
checkModule =
|
||||
if class != null
|
||||
then
|
||||
m:
|
||||
if m._class != null -> m._class == class
|
||||
then m
|
||||
else
|
||||
throw "The module ${m._file or m.key} was imported into ${class} instead of ${m._class}."
|
||||
else
|
||||
m: m;
|
||||
|
||||
/*
|
||||
Collects all modules recursively into the form
|
||||
|
||||
@@ -401,13 +397,13 @@ let
|
||||
};
|
||||
in parentFile: parentKey: initialModules: args: collectResults (imap1 (n: x:
|
||||
let
|
||||
module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
|
||||
module = loadModule args parentFile "${parentKey}:anon-${toString n}" x;
|
||||
collectedImports = collectStructuredModules module._file module.key module.imports args;
|
||||
in {
|
||||
key = module.key;
|
||||
module = module;
|
||||
modules = collectedImports.modules;
|
||||
disabled = (if module.disabledModules != [] then [{ file = module._file; disabled = module.disabledModules; }] else []) ++ collectedImports.disabled;
|
||||
disabled = module.disabledModules ++ collectedImports.disabled;
|
||||
}) initialModules);
|
||||
|
||||
# filterModules :: String -> { disabled, modules } -> [ Module ]
|
||||
@@ -416,30 +412,10 @@ let
|
||||
# modules recursively. It returns the final list of unique-by-key modules
|
||||
filterModules = modulesPath: { disabled, modules }:
|
||||
let
|
||||
moduleKey = file: m:
|
||||
if isString m
|
||||
then
|
||||
if builtins.substring 0 1 m == "/"
|
||||
then m
|
||||
else toString modulesPath + "/" + m
|
||||
|
||||
else if isConvertibleWithToString m
|
||||
then
|
||||
if m?key && m.key != toString m
|
||||
then
|
||||
throw "Module `${file}` contains a disabledModules item that is an attribute set that can be converted to a string (${toString m}) but also has a `.key` attribute (${m.key}) with a different value. This makes it ambiguous which module should be disabled."
|
||||
else
|
||||
toString m
|
||||
|
||||
else if m?key
|
||||
then
|
||||
m.key
|
||||
|
||||
else if isAttrs m
|
||||
then throw "Module `${file}` contains a disabledModules item that is an attribute set, presumably a module, that does not have a `key` attribute. This means that the module system doesn't have any means to identify the module that should be disabled. Make sure that you've put the correct value in disabledModules: a string path relative to modulesPath, a path value, or an attribute set with a `key` attribute."
|
||||
else throw "Each disabledModules item must be a path, string, or a attribute set with a key attribute, or a value supported by toString. However, one of the disabledModules items in `${toString file}` is none of that, but is of type ${builtins.typeOf m}.";
|
||||
|
||||
disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
|
||||
moduleKey = m: if isString m && (builtins.substring 0 1 m != "/")
|
||||
then toString modulesPath + "/" + m
|
||||
else toString m;
|
||||
disabledKeys = map moduleKey disabled;
|
||||
keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
|
||||
in map (attrs: attrs.module) (builtins.genericClosure {
|
||||
startSet = keyFilter modules;
|
||||
@@ -465,12 +441,11 @@ let
|
||||
else config;
|
||||
in
|
||||
if m ? config || m ? options then
|
||||
let badAttrs = removeAttrs m ["_class" "_file" "key" "disabledModules" "imports" "options" "config" "meta" "freeformType"]; in
|
||||
let badAttrs = removeAttrs m ["_file" "key" "disabledModules" "imports" "options" "config" "meta" "freeformType"]; in
|
||||
if badAttrs != {} then
|
||||
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: ${toString (attrNames badAttrs)}) into the explicit `config' attribute."
|
||||
else
|
||||
{ _file = toString m._file or file;
|
||||
_class = m._class or null;
|
||||
key = toString m.key or key;
|
||||
disabledModules = m.disabledModules or [];
|
||||
imports = m.imports or [];
|
||||
@@ -481,18 +456,14 @@ let
|
||||
# shorthand syntax
|
||||
lib.throwIfNot (isAttrs m) "module ${file} (${key}) does not look like a module."
|
||||
{ _file = toString m._file or file;
|
||||
_class = m._class or null;
|
||||
key = toString m.key or key;
|
||||
disabledModules = m.disabledModules or [];
|
||||
imports = m.require or [] ++ m.imports or [];
|
||||
options = {};
|
||||
config = addFreeformType (removeAttrs m ["_class" "_file" "key" "disabledModules" "require" "imports" "freeformType"]);
|
||||
config = addFreeformType (removeAttrs m ["_file" "key" "disabledModules" "require" "imports" "freeformType"]);
|
||||
};
|
||||
|
||||
applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }:
|
||||
if isFunction f then applyModuleArgs key f args else f;
|
||||
|
||||
applyModuleArgs = key: f: args@{ config, options, lib, ... }:
|
||||
applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then
|
||||
let
|
||||
# Module arguments are resolved in a strict manner when attribute set
|
||||
# deconstruction is used. As the arguments are now defined with the
|
||||
@@ -516,7 +487,9 @@ let
|
||||
# context on the explicit arguments of "args" too. This update
|
||||
# operator is used to make the "args@{ ... }: with args.lib;" notation
|
||||
# works.
|
||||
in f (args // extraArgs);
|
||||
in f (args // extraArgs)
|
||||
else
|
||||
f;
|
||||
|
||||
/* Merge a list of modules. This will recurse over the option
|
||||
declarations in all modules, combining them into a single set.
|
||||
@@ -570,19 +543,15 @@ let
|
||||
zipAttrsWith (n: concatLists)
|
||||
(map (module: let subtree = module.${attr}; in
|
||||
if !(builtins.isAttrs subtree) then
|
||||
throw (if attr == "config" then ''
|
||||
You're trying to define a value of type `${builtins.typeOf subtree}'
|
||||
rather than an attribute set for the option
|
||||
throw ''
|
||||
You're trying to declare a value of type `${builtins.typeOf subtree}'
|
||||
rather than an attribute-set for the option
|
||||
`${builtins.concatStringsSep "." prefix}'!
|
||||
|
||||
This usually happens if `${builtins.concatStringsSep "." prefix}' has option
|
||||
definitions inside that are not matched. Please check how to properly define
|
||||
this option by e.g. referring to `man 5 configuration.nix'!
|
||||
'' else ''
|
||||
An option declaration for `${builtins.concatStringsSep "." prefix}' has type
|
||||
`${builtins.typeOf subtree}' rather than an attribute set.
|
||||
Did you mean to define this outside of `options'?
|
||||
'')
|
||||
''
|
||||
else
|
||||
mapAttrs (n: f module) subtree
|
||||
) modules);
|
||||
@@ -1221,67 +1190,4 @@ let
|
||||
_file = file;
|
||||
config = lib.importTOML file;
|
||||
};
|
||||
|
||||
private = lib.mapAttrs
|
||||
(k: lib.warn "External use of `lib.modules.${k}` is deprecated. If your use case isn't covered by non-deprecated functions, we'd like to know more and perhaps support your use case well, instead of providing access to these low level functions. In this case please open an issue in https://github.com/nixos/nixpkgs/issues/.")
|
||||
{
|
||||
inherit
|
||||
applyModuleArgsIfFunction
|
||||
dischargeProperties
|
||||
evalOptionValue
|
||||
mergeModules
|
||||
mergeModules'
|
||||
pushDownProperties
|
||||
unifyModuleSyntax
|
||||
;
|
||||
collectModules = collectModules null;
|
||||
};
|
||||
|
||||
in
|
||||
private //
|
||||
{
|
||||
# NOTE: not all of these functions are necessarily public interfaces; some
|
||||
# are just needed by types.nix, but are not meant to be consumed
|
||||
# externally.
|
||||
inherit
|
||||
defaultOrderPriority
|
||||
defaultOverridePriority
|
||||
defaultPriority
|
||||
doRename
|
||||
evalModules
|
||||
filterOverrides
|
||||
filterOverrides'
|
||||
fixMergeModules
|
||||
fixupOptionType # should be private?
|
||||
importJSON
|
||||
importTOML
|
||||
mergeDefinitions
|
||||
mergeOptionDecls # should be private?
|
||||
mkAfter
|
||||
mkAliasAndWrapDefinitions
|
||||
mkAliasAndWrapDefsWithPriority
|
||||
mkAliasDefinitions
|
||||
mkAliasIfDef
|
||||
mkAliasOptionModule
|
||||
mkAliasOptionModuleMD
|
||||
mkAssert
|
||||
mkBefore
|
||||
mkChangedOptionModule
|
||||
mkDefault
|
||||
mkDerivedConfig
|
||||
mkFixStrictness
|
||||
mkForce
|
||||
mkIf
|
||||
mkImageMediaOverride
|
||||
mkMerge
|
||||
mkMergedOptionModule
|
||||
mkOptionDefault
|
||||
mkOrder
|
||||
mkOverride
|
||||
mkRemovedOptionModule
|
||||
mkRenamedOptionModule
|
||||
mkRenamedOptionModuleWith
|
||||
mkVMOverride
|
||||
setDefaultModuleLocation
|
||||
sortProperties;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,6 @@ let
|
||||
inherit (lib.types)
|
||||
mkOptionType
|
||||
;
|
||||
inherit (lib.lists)
|
||||
last
|
||||
;
|
||||
prioritySuggestion = ''
|
||||
Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.
|
||||
'';
|
||||
@@ -110,26 +107,17 @@ rec {
|
||||
/* Creates an Option attribute set for an option that specifies the
|
||||
package a module should use for some purpose.
|
||||
|
||||
The package is specified in the third argument under `default` as a list of strings
|
||||
representing its attribute path in nixpkgs (or another package set).
|
||||
Because of this, you need to pass nixpkgs itself (or a subset) as the first argument.
|
||||
The package is specified as a list of strings representing its attribute path in nixpkgs.
|
||||
|
||||
The second argument may be either a string or a list of strings.
|
||||
It provides the display name of the package in the description of the generated option
|
||||
(using only the last element if the passed value is a list)
|
||||
and serves as the fallback value for the `default` argument.
|
||||
Because of this, you need to pass nixpkgs itself as the first argument.
|
||||
|
||||
To include extra information in the description, pass `extraDescription` to
|
||||
append arbitrary text to the generated description.
|
||||
You can also pass an `example` value, either a literal string or an attribute path.
|
||||
The second argument is the name of the option, used in the description "The <name> package to use.".
|
||||
|
||||
The default argument can be omitted if the provided name is
|
||||
an attribute of pkgs (if name is a string) or a
|
||||
valid attribute path in pkgs (if name is a list).
|
||||
You can also pass an example value, either a literal string or a package's attribute path.
|
||||
|
||||
If you wish to explicitly provide no default, pass `null` as `default`.
|
||||
You can omit the default path if the name of the option is also attribute path in nixpkgs.
|
||||
|
||||
Type: mkPackageOption :: pkgs -> (string|[string]) -> { default? :: [string], example? :: null|string|[string], extraDescription? :: string } -> option
|
||||
Type: mkPackageOption :: pkgs -> string -> { default :: [string]; example :: null | string | [string]; } -> option
|
||||
|
||||
Example:
|
||||
mkPackageOption pkgs "hello" { }
|
||||
@@ -141,46 +129,27 @@ rec {
|
||||
example = "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])";
|
||||
}
|
||||
=> { _type = "option"; default = «derivation /nix/store/jxx55cxsjrf8kyh3fp2ya17q99w7541r-ghc-8.10.7.drv»; defaultText = { ... }; description = "The GHC package to use."; example = { ... }; type = { ... }; }
|
||||
|
||||
Example:
|
||||
mkPackageOption pkgs [ "python39Packages" "pytorch" ] {
|
||||
extraDescription = "This is an example and doesn't actually do anything.";
|
||||
}
|
||||
=> { _type = "option"; default = «derivation /nix/store/gvqgsnc4fif9whvwd9ppa568yxbkmvk8-python3.9-pytorch-1.10.2.drv»; defaultText = { ... }; description = "The pytorch package to use. This is an example and doesn't actually do anything."; type = { ... }; }
|
||||
|
||||
*/
|
||||
mkPackageOption =
|
||||
# Package set (a specific version of nixpkgs or a subset)
|
||||
# Package set (a specific version of nixpkgs)
|
||||
pkgs:
|
||||
# Name for the package, shown in option description
|
||||
name:
|
||||
{
|
||||
# The attribute path where the default package is located (may be omitted)
|
||||
default ? name,
|
||||
# A string or an attribute path to use as an example (may be omitted)
|
||||
example ? null,
|
||||
# Additional text to include in the option description (may be omitted)
|
||||
extraDescription ? "",
|
||||
}:
|
||||
let
|
||||
name' = if isList name then last name else name;
|
||||
default' = if isList default then default else [ default ];
|
||||
defaultPath = concatStringsSep "." default';
|
||||
defaultValue = attrByPath default'
|
||||
(throw "${defaultPath} cannot be found in pkgs") pkgs;
|
||||
{ default ? [ name ], example ? null }:
|
||||
let default' = if !isList default then [ default ] else default;
|
||||
in mkOption {
|
||||
defaultText = literalExpression ("pkgs." + defaultPath);
|
||||
type = lib.types.package;
|
||||
description = "The ${name'} package to use."
|
||||
+ (if extraDescription == "" then "" else " ") + extraDescription;
|
||||
${if default != null then "default" else null} = defaultValue;
|
||||
description = "The ${name} package to use.";
|
||||
default = attrByPath default'
|
||||
(throw "${concatStringsSep "." default'} cannot be found in pkgs") pkgs;
|
||||
defaultText = literalExpression ("pkgs." + concatStringsSep "." default');
|
||||
${if example != null then "example" else null} = literalExpression
|
||||
(if isList example then "pkgs." + concatStringsSep "." example else example);
|
||||
};
|
||||
|
||||
/* Like mkPackageOption, but emit an mdDoc description instead of DocBook. */
|
||||
mkPackageOptionMD = pkgs: name: extra:
|
||||
let option = mkPackageOption pkgs name extra;
|
||||
mkPackageOptionMD = args: name: extra:
|
||||
let option = mkPackageOption args name extra;
|
||||
in option // { description = lib.mdDoc option.description; };
|
||||
|
||||
/* This option accepts anything, but it does not produce any result.
|
||||
@@ -261,7 +230,7 @@ rec {
|
||||
concatMap (opt:
|
||||
let
|
||||
name = showOption opt.loc;
|
||||
docOption = {
|
||||
docOption = rec {
|
||||
loc = opt.loc;
|
||||
inherit name;
|
||||
description = opt.description or null;
|
||||
@@ -280,9 +249,9 @@ rec {
|
||||
renderOptionValue opt.example
|
||||
);
|
||||
}
|
||||
// optionalAttrs (opt ? defaultText || opt ? default) {
|
||||
// optionalAttrs (opt ? default) {
|
||||
default =
|
||||
builtins.addErrorContext "while evaluating the ${if opt?defaultText then "defaultText" else "default value"} of option `${name}`" (
|
||||
builtins.addErrorContext "while evaluating the default value of option `${name}`" (
|
||||
renderOptionValue (opt.defaultText or opt.default)
|
||||
);
|
||||
}
|
||||
@@ -368,17 +337,19 @@ rec {
|
||||
|
||||
# Helper functions.
|
||||
|
||||
/* Convert an option, described as a list of the option parts to a
|
||||
human-readable version.
|
||||
/* Convert an option, described as a list of the option parts in to a
|
||||
safe, human readable version.
|
||||
|
||||
Example:
|
||||
(showOption ["foo" "bar" "baz"]) == "foo.bar.baz"
|
||||
(showOption ["foo" "bar.baz" "tux"]) == "foo.\"bar.baz\".tux"
|
||||
(showOption ["windowManager" "2bwm" "enable"]) == "windowManager.\"2bwm\".enable"
|
||||
(showOption ["foo" "bar.baz" "tux"]) == "foo.bar.baz.tux"
|
||||
|
||||
Placeholders will not be quoted as they are not actual values:
|
||||
(showOption ["foo" "*" "bar"]) == "foo.*.bar"
|
||||
(showOption ["foo" "<name>" "bar"]) == "foo.<name>.bar"
|
||||
|
||||
Unlike attributes, options can also start with numbers:
|
||||
(showOption ["windowManager" "2bwm" "enable"]) == "windowManager.2bwm.enable"
|
||||
*/
|
||||
showOption = parts: let
|
||||
escapeOptionPart = part:
|
||||
|
||||
@@ -15,9 +15,6 @@ let
|
||||
last
|
||||
genList
|
||||
elemAt
|
||||
all
|
||||
concatMap
|
||||
foldl'
|
||||
;
|
||||
|
||||
inherit (lib.strings)
|
||||
@@ -193,80 +190,6 @@ in /* No rec! Add dependencies on this file at the top. */ {
|
||||
subpathInvalidReason value == null;
|
||||
|
||||
|
||||
/* Join subpath strings together using `/`, returning a normalised subpath string.
|
||||
|
||||
Like `concatStringsSep "/"` but safer, specifically:
|
||||
|
||||
- All elements must be valid subpath strings, see `lib.path.subpath.isValid`
|
||||
|
||||
- The result gets normalised, see `lib.path.subpath.normalise`
|
||||
|
||||
- The edge case of an empty list gets properly handled by returning the neutral subpath `"./."`
|
||||
|
||||
Laws:
|
||||
|
||||
- Associativity:
|
||||
|
||||
subpath.join [ x (subpath.join [ y z ]) ] == subpath.join [ (subpath.join [ x y ]) z ]
|
||||
|
||||
- Identity - `"./."` is the neutral element for normalised paths:
|
||||
|
||||
subpath.join [ ] == "./."
|
||||
subpath.join [ (subpath.normalise p) "./." ] == subpath.normalise p
|
||||
subpath.join [ "./." (subpath.normalise p) ] == subpath.normalise p
|
||||
|
||||
- Normalisation - the result is normalised according to `lib.path.subpath.normalise`:
|
||||
|
||||
subpath.join ps == subpath.normalise (subpath.join ps)
|
||||
|
||||
- For non-empty lists, the implementation is equivalent to normalising the result of `concatStringsSep "/"`.
|
||||
Note that the above laws can be derived from this one.
|
||||
|
||||
ps != [] -> subpath.join ps == subpath.normalise (concatStringsSep "/" ps)
|
||||
|
||||
Type:
|
||||
subpath.join :: [ String ] -> String
|
||||
|
||||
Example:
|
||||
subpath.join [ "foo" "bar/baz" ]
|
||||
=> "./foo/bar/baz"
|
||||
|
||||
# normalise the result
|
||||
subpath.join [ "./foo" "." "bar//./baz/" ]
|
||||
=> "./foo/bar/baz"
|
||||
|
||||
# passing an empty list results in the current directory
|
||||
subpath.join [ ]
|
||||
=> "./."
|
||||
|
||||
# elements must be valid subpath strings
|
||||
subpath.join [ /foo ]
|
||||
=> <error>
|
||||
subpath.join [ "" ]
|
||||
=> <error>
|
||||
subpath.join [ "/foo" ]
|
||||
=> <error>
|
||||
subpath.join [ "../foo" ]
|
||||
=> <error>
|
||||
*/
|
||||
subpath.join =
|
||||
# The list of subpaths to join together
|
||||
subpaths:
|
||||
# Fast in case all paths are valid
|
||||
if all isValid subpaths
|
||||
then joinRelPath (concatMap splitRelPath subpaths)
|
||||
else
|
||||
# Otherwise we take our time to gather more info for a better error message
|
||||
# Strictly go through each path, throwing on the first invalid one
|
||||
# Tracks the list index in the fold accumulator
|
||||
foldl' (i: path:
|
||||
if isValid path
|
||||
then i + 1
|
||||
else throw ''
|
||||
lib.path.subpath.join: Element at index ${toString i} is not a valid subpath string:
|
||||
${subpathInvalidReason path}''
|
||||
) 0 subpaths;
|
||||
|
||||
/* Normalise a subpath. Throw an error if the subpath isn't valid, see
|
||||
`lib.path.subpath.isValid`
|
||||
|
||||
|
||||
@@ -107,36 +107,6 @@ let
|
||||
expected = true;
|
||||
};
|
||||
|
||||
# Test examples from the lib.path.subpath.join documentation
|
||||
testSubpathJoinExample1 = {
|
||||
expr = subpath.join [ "foo" "bar/baz" ];
|
||||
expected = "./foo/bar/baz";
|
||||
};
|
||||
testSubpathJoinExample2 = {
|
||||
expr = subpath.join [ "./foo" "." "bar//./baz/" ];
|
||||
expected = "./foo/bar/baz";
|
||||
};
|
||||
testSubpathJoinExample3 = {
|
||||
expr = subpath.join [ ];
|
||||
expected = "./.";
|
||||
};
|
||||
testSubpathJoinExample4 = {
|
||||
expr = (builtins.tryEval (subpath.join [ /foo ])).success;
|
||||
expected = false;
|
||||
};
|
||||
testSubpathJoinExample5 = {
|
||||
expr = (builtins.tryEval (subpath.join [ "" ])).success;
|
||||
expected = false;
|
||||
};
|
||||
testSubpathJoinExample6 = {
|
||||
expr = (builtins.tryEval (subpath.join [ "/foo" ])).success;
|
||||
expected = false;
|
||||
};
|
||||
testSubpathJoinExample7 = {
|
||||
expr = (builtins.tryEval (subpath.join [ "../foo" ])).success;
|
||||
expected = false;
|
||||
};
|
||||
|
||||
# Test examples from the lib.path.subpath.normalise documentation
|
||||
testSubpathNormaliseExample1 = {
|
||||
expr = subpath.normalise "foo//bar";
|
||||
|
||||
107
lib/strings.nix
107
lib/strings.nix
@@ -2,11 +2,7 @@
|
||||
{ lib }:
|
||||
let
|
||||
|
||||
inherit (builtins) length;
|
||||
|
||||
inherit (lib.trivial) warnIf;
|
||||
|
||||
asciiTable = import ./ascii-table.nix;
|
||||
inherit (builtins) length;
|
||||
|
||||
in
|
||||
|
||||
@@ -209,20 +205,7 @@ rec {
|
||||
normalizePath "/a//b///c/"
|
||||
=> "/a/b/c/"
|
||||
*/
|
||||
normalizePath = s:
|
||||
warnIf
|
||||
(isPath s)
|
||||
''
|
||||
lib.strings.normalizePath: The argument (${toString s}) is a path value, but only strings are supported.
|
||||
Path values are always normalised in Nix, so there's no need to call this function on them.
|
||||
This function also copies the path to the Nix store and returns the store path, the same as "''${path}" will, which may not be what you want.
|
||||
This behavior is deprecated and will throw an error in the future.''
|
||||
(
|
||||
builtins.foldl'
|
||||
(x: y: if y == "/" && hasSuffix "/" x then x else x+y)
|
||||
""
|
||||
(stringToCharacters s)
|
||||
);
|
||||
normalizePath = s: (builtins.foldl' (x: y: if y == "/" && hasSuffix "/" x then x else x+y) "" (stringToCharacters s));
|
||||
|
||||
/* Depending on the boolean `cond', return either the given string
|
||||
or the empty string. Useful to concatenate against a bigger string.
|
||||
@@ -255,17 +238,7 @@ rec {
|
||||
# Prefix to check for
|
||||
pref:
|
||||
# Input string
|
||||
str:
|
||||
# Before 23.05, paths would be copied to the store before converting them
|
||||
# to strings and comparing. This was surprising and confusing.
|
||||
warnIf
|
||||
(isPath pref)
|
||||
''
|
||||
lib.strings.hasPrefix: The first argument (${toString pref}) is a path value, but only strings are supported.
|
||||
There is almost certainly a bug in the calling code, since this function always returns `false` in such a case.
|
||||
This function also copies the path to the Nix store, which may not be what you want.
|
||||
This behavior is deprecated and will throw an error in the future.''
|
||||
(substring 0 (stringLength pref) str == pref);
|
||||
str: substring 0 (stringLength pref) str == pref;
|
||||
|
||||
/* Determine whether a string has given suffix.
|
||||
|
||||
@@ -285,20 +258,8 @@ rec {
|
||||
let
|
||||
lenContent = stringLength content;
|
||||
lenSuffix = stringLength suffix;
|
||||
in
|
||||
# Before 23.05, paths would be copied to the store before converting them
|
||||
# to strings and comparing. This was surprising and confusing.
|
||||
warnIf
|
||||
(isPath suffix)
|
||||
''
|
||||
lib.strings.hasSuffix: The first argument (${toString suffix}) is a path value, but only strings are supported.
|
||||
There is almost certainly a bug in the calling code, since this function always returns `false` in such a case.
|
||||
This function also copies the path to the Nix store, which may not be what you want.
|
||||
This behavior is deprecated and will throw an error in the future.''
|
||||
(
|
||||
lenContent >= lenSuffix
|
||||
&& substring (lenContent - lenSuffix) lenContent content == suffix
|
||||
);
|
||||
in lenContent >= lenSuffix &&
|
||||
substring (lenContent - lenSuffix) lenContent content == suffix;
|
||||
|
||||
/* Determine whether a string contains the given infix
|
||||
|
||||
@@ -315,16 +276,7 @@ rec {
|
||||
=> false
|
||||
*/
|
||||
hasInfix = infix: content:
|
||||
# Before 23.05, paths would be copied to the store before converting them
|
||||
# to strings and comparing. This was surprising and confusing.
|
||||
warnIf
|
||||
(isPath infix)
|
||||
''
|
||||
lib.strings.hasInfix: The first argument (${toString infix}) is a path value, but only strings are supported.
|
||||
There is almost certainly a bug in the calling code, since this function always returns `false` in such a case.
|
||||
This function also copies the path to the Nix store, which may not be what you want.
|
||||
This behavior is deprecated and will throw an error in the future.''
|
||||
(builtins.match ".*${escapeRegex infix}.*" "${content}" != null);
|
||||
builtins.match ".*${escapeRegex infix}.*" "${content}" != null;
|
||||
|
||||
/* Convert a string to a list of characters (i.e. singleton strings).
|
||||
This allows you to, e.g., map a function over each character. However,
|
||||
@@ -375,7 +327,9 @@ rec {
|
||||
=> 40
|
||||
|
||||
*/
|
||||
charToInt = c: builtins.getAttr c asciiTable;
|
||||
charToInt = let
|
||||
table = import ./ascii-table.nix;
|
||||
in c: builtins.getAttr c table;
|
||||
|
||||
/* Escape occurrence of the elements of `list` in `string` by
|
||||
prefixing it with a backslash.
|
||||
@@ -401,21 +355,6 @@ rec {
|
||||
*/
|
||||
escapeC = list: replaceStrings list (map (c: "\\x${ toLower (lib.toHexString (charToInt c))}") list);
|
||||
|
||||
/* Escape the string so it can be safely placed inside a URL
|
||||
query.
|
||||
|
||||
Type: escapeURL :: string -> string
|
||||
|
||||
Example:
|
||||
escapeURL "foo/bar baz"
|
||||
=> "foo%2Fbar%20baz"
|
||||
*/
|
||||
escapeURL = let
|
||||
unreserved = [ "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "-" "_" "." "~" ];
|
||||
toEscape = builtins.removeAttrs asciiTable unreserved;
|
||||
in
|
||||
replaceStrings (builtins.attrNames toEscape) (lib.mapAttrsToList (_: c: "%${fixedWidthString 2 "0" (lib.toHexString c)}") toEscape);
|
||||
|
||||
/* Quote string to be used safely within the Bourne shell.
|
||||
|
||||
Type: escapeShellArg :: string -> string
|
||||
@@ -616,23 +555,14 @@ rec {
|
||||
prefix:
|
||||
# Input string
|
||||
str:
|
||||
# Before 23.05, paths would be copied to the store before converting them
|
||||
# to strings and comparing. This was surprising and confusing.
|
||||
warnIf
|
||||
(isPath prefix)
|
||||
''
|
||||
lib.strings.removePrefix: The first argument (${toString prefix}) is a path value, but only strings are supported.
|
||||
There is almost certainly a bug in the calling code, since this function never removes any prefix in such a case.
|
||||
This function also copies the path to the Nix store, which may not be what you want.
|
||||
This behavior is deprecated and will throw an error in the future.''
|
||||
(let
|
||||
let
|
||||
preLen = stringLength prefix;
|
||||
sLen = stringLength str;
|
||||
in
|
||||
if substring 0 preLen str == prefix then
|
||||
if hasPrefix prefix str then
|
||||
substring preLen (sLen - preLen) str
|
||||
else
|
||||
str);
|
||||
str;
|
||||
|
||||
/* Return a string without the specified suffix, if the suffix matches.
|
||||
|
||||
@@ -649,23 +579,14 @@ rec {
|
||||
suffix:
|
||||
# Input string
|
||||
str:
|
||||
# Before 23.05, paths would be copied to the store before converting them
|
||||
# to strings and comparing. This was surprising and confusing.
|
||||
warnIf
|
||||
(isPath suffix)
|
||||
''
|
||||
lib.strings.removeSuffix: The first argument (${toString suffix}) is a path value, but only strings are supported.
|
||||
There is almost certainly a bug in the calling code, since this function never removes any suffix in such a case.
|
||||
This function also copies the path to the Nix store, which may not be what you want.
|
||||
This behavior is deprecated and will throw an error in the future.''
|
||||
(let
|
||||
let
|
||||
sufLen = stringLength suffix;
|
||||
sLen = stringLength str;
|
||||
in
|
||||
if sufLen <= sLen && suffix == substring (sLen - sufLen) sufLen str then
|
||||
substring 0 (sLen - sufLen) str
|
||||
else
|
||||
str);
|
||||
str;
|
||||
|
||||
/* Return true if string v1 denotes a version older than v2.
|
||||
|
||||
|
||||
@@ -40,21 +40,14 @@ rec {
|
||||
# a superior CPU has all the features of an inferior and is able to build and test code for it
|
||||
inferiors = {
|
||||
# x86_64 Intel
|
||||
# https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
|
||||
default = [ ];
|
||||
westmere = [ ];
|
||||
sandybridge = [ "westmere" ] ++ inferiors.westmere;
|
||||
ivybridge = [ "sandybridge" ] ++ inferiors.sandybridge;
|
||||
haswell = [ "ivybridge" ] ++ inferiors.ivybridge;
|
||||
broadwell = [ "haswell" ] ++ inferiors.haswell;
|
||||
skylake = [ "broadwell" ] ++ inferiors.broadwell;
|
||||
skylake-avx512 = [ "skylake" ] ++ inferiors.skylake;
|
||||
cannonlake = [ "skylake-avx512" ] ++ inferiors.skylake-avx512;
|
||||
icelake-client = [ "cannonlake" ] ++ inferiors.cannonlake;
|
||||
icelake-server = [ "icelake-client" ] ++ inferiors.icelake-client;
|
||||
cascadelake = [ "skylake-avx512" ] ++ inferiors.cannonlake;
|
||||
cooperlake = [ "cascadelake" ] ++ inferiors.cascadelake;
|
||||
tigerlake = [ "icelake-server" ] ++ inferiors.icelake-server;
|
||||
sandybridge = [ "westmere" ] ++ inferiors.westmere;
|
||||
ivybridge = [ "sandybridge" ] ++ inferiors.sandybridge;
|
||||
haswell = [ "ivybridge" ] ++ inferiors.ivybridge;
|
||||
broadwell = [ "haswell" ] ++ inferiors.haswell;
|
||||
skylake = [ "broadwell" ] ++ inferiors.broadwell;
|
||||
skylake-avx512 = [ "skylake" ] ++ inferiors.skylake;
|
||||
|
||||
# x86_64 AMD
|
||||
# TODO: fill this (need testing)
|
||||
|
||||
@@ -50,7 +50,6 @@ rec {
|
||||
else if final.isFreeBSD then "fblibc"
|
||||
else if final.isNetBSD then "nblibc"
|
||||
else if final.isAvr then "avrlibc"
|
||||
else if final.isGhcjs then null
|
||||
else if final.isNone then "newlib"
|
||||
# TODO(@Ericson2314) think more about other operating systems
|
||||
else "native/impure";
|
||||
@@ -121,7 +120,7 @@ rec {
|
||||
({
|
||||
linux-kernel = args.linux-kernel or {};
|
||||
gcc = args.gcc or {};
|
||||
rustc = args.rustc or {};
|
||||
rustc = args.rust or {};
|
||||
} // platforms.select final)
|
||||
linux-kernel gcc rustc;
|
||||
|
||||
@@ -137,15 +136,12 @@ rec {
|
||||
else if final.isPower then "powerpc"
|
||||
else if final.isRiscV then "riscv"
|
||||
else if final.isS390 then "s390"
|
||||
else if final.isLoongArch64 then "loongarch"
|
||||
else final.parsed.cpu.name;
|
||||
|
||||
qemuArch =
|
||||
if final.isAarch32 then "arm"
|
||||
else if final.isS390 && !final.isS390x then null
|
||||
else if final.isx86_64 then "x86_64"
|
||||
else if final.isx86 then "i386"
|
||||
else if final.isMips64 then "mips64${lib.optionalString final.isLittleEndian "el"}"
|
||||
else final.uname.processor;
|
||||
|
||||
# Name used by UEFI for architectures.
|
||||
@@ -188,7 +184,6 @@ rec {
|
||||
pulseSupport = false;
|
||||
smbdSupport = false;
|
||||
seccompSupport = false;
|
||||
enableDocs = false;
|
||||
hostCpuTargets = [ "${final.qemuArch}-linux-user" ];
|
||||
};
|
||||
wine = (pkgs.winePackagesFor "wine${toString final.parsed.cpu.bits}").minimal;
|
||||
@@ -198,7 +193,7 @@ rec {
|
||||
then "${pkgs.runtimeShell} -c '\"$@\"' --"
|
||||
else if final.isWindows
|
||||
then "${wine}/bin/wine${lib.optionalString (final.parsed.cpu.bits == 64) "64"}"
|
||||
else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux && final.qemuArch != null
|
||||
else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux
|
||||
then "${qemu-user}/bin/qemu-${final.qemuArch}"
|
||||
else if final.isWasi
|
||||
then "${pkgs.wasmtime}/bin/wasmtime"
|
||||
|
||||
@@ -22,11 +22,11 @@ let
|
||||
"x86_64-solaris"
|
||||
|
||||
# JS
|
||||
"javascript-ghcjs"
|
||||
"js-ghcjs"
|
||||
|
||||
# Linux
|
||||
"aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux"
|
||||
"armv7l-linux" "i686-linux" "loongarch64-linux" "m68k-linux" "microblaze-linux"
|
||||
"armv7l-linux" "i686-linux" "m68k-linux" "microblaze-linux"
|
||||
"microblazeel-linux" "mipsel-linux" "mips64el-linux" "powerpc64-linux"
|
||||
"powerpc64le-linux" "riscv32-linux" "riscv64-linux" "s390-linux"
|
||||
"s390x-linux" "x86_64-linux"
|
||||
@@ -86,7 +86,6 @@ in {
|
||||
m68k = filterDoubles predicates.isM68k;
|
||||
s390 = filterDoubles predicates.isS390;
|
||||
s390x = filterDoubles predicates.isS390x;
|
||||
loongarch64 = filterDoubles predicates.isLoongArch64;
|
||||
js = filterDoubles predicates.isJavaScript;
|
||||
|
||||
bigEndian = filterDoubles predicates.isBigEndian;
|
||||
|
||||
@@ -135,10 +135,6 @@ rec {
|
||||
libc = "newlib";
|
||||
};
|
||||
|
||||
loongarch64-linux = {
|
||||
config = "loongarch64-unknown-linux-gnu";
|
||||
};
|
||||
|
||||
mmix = {
|
||||
config = "mmix-unknown-mmixware";
|
||||
libc = "newlib";
|
||||
@@ -333,9 +329,6 @@ rec {
|
||||
|
||||
# Ghcjs
|
||||
ghcjs = {
|
||||
# This triple is special to GHC/Cabal/GHCJS and not recognized by autotools
|
||||
# See: https://gitlab.haskell.org/ghc/ghc/-/commit/6636b670233522f01d002c9b97827d00289dbf5c
|
||||
# https://github.com/ghcjs/ghcjs/issues/53
|
||||
config = "javascript-unknown-ghcjs";
|
||||
config = "js-unknown-ghcjs";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,14 +9,6 @@ let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis
|
||||
rec {
|
||||
# these patterns are to be matched against {host,build,target}Platform.parsed
|
||||
patterns = rec {
|
||||
# The patterns below are lists in sum-of-products form.
|
||||
#
|
||||
# Each attribute is list of product conditions; non-list values are treated
|
||||
# as a singleton list. If *any* product condition in the list matches then
|
||||
# the predicate matches. Each product condition is tested by
|
||||
# `lib.attrsets.matchAttrs`, which requires a match on *all* attributes of
|
||||
# the product.
|
||||
|
||||
isi686 = { cpu = cpuTypes.i686; };
|
||||
isx86_32 = { cpu = { family = "x86"; bits = 32; }; };
|
||||
isx86_64 = { cpu = { family = "x86"; bits = 64; }; };
|
||||
@@ -57,8 +49,7 @@ rec {
|
||||
isM68k = { cpu = { family = "m68k"; }; };
|
||||
isS390 = { cpu = { family = "s390"; }; };
|
||||
isS390x = { cpu = { family = "s390"; bits = 64; }; };
|
||||
isLoongArch64 = { cpu = { family = "loongarch"; bits = 64; }; };
|
||||
isJavaScript = { cpu = cpuTypes.javascript; };
|
||||
isJavaScript = { cpu = cpuTypes.js; };
|
||||
|
||||
is32bit = { cpu = { bits = 32; }; };
|
||||
is64bit = { cpu = { bits = 64; }; };
|
||||
|
||||
@@ -131,9 +131,7 @@ rec {
|
||||
|
||||
or1k = { bits = 32; significantByte = bigEndian; family = "or1k"; };
|
||||
|
||||
loongarch64 = { bits = 64; significantByte = littleEndian; family = "loongarch"; };
|
||||
|
||||
javascript = { bits = 32; significantByte = littleEndian; family = "javascript"; };
|
||||
js = { bits = 32; significantByte = littleEndian; family = "js"; };
|
||||
};
|
||||
|
||||
# GNU build systems assume that older NetBSD architectures are using a.out.
|
||||
@@ -184,13 +182,24 @@ rec {
|
||||
(b == armv7l && isCompatible a armv7a)
|
||||
(b == armv7l && isCompatible a armv7r)
|
||||
(b == armv7l && isCompatible a armv7m)
|
||||
(b == armv7a && isCompatible a armv8a)
|
||||
(b == armv7r && isCompatible a armv8a)
|
||||
(b == armv7m && isCompatible a armv8a)
|
||||
(b == armv7a && isCompatible a armv8r)
|
||||
(b == armv7r && isCompatible a armv8r)
|
||||
(b == armv7m && isCompatible a armv8r)
|
||||
(b == armv7a && isCompatible a armv8m)
|
||||
(b == armv7r && isCompatible a armv8m)
|
||||
(b == armv7m && isCompatible a armv8m)
|
||||
|
||||
# ARMv8
|
||||
(b == aarch64 && a == armv8a)
|
||||
(b == armv8a && isCompatible a aarch64)
|
||||
(b == armv8r && isCompatible a armv8a)
|
||||
(b == armv8m && isCompatible a armv8a)
|
||||
|
||||
# XXX: not always true! Some arm64 cpus don’t support arm32 mode.
|
||||
(b == aarch64 && a == armv8a)
|
||||
(b == armv8a && isCompatible a aarch64)
|
||||
|
||||
# PowerPC
|
||||
(b == powerpc && isCompatible a powerpc64)
|
||||
(b == powerpcle && isCompatible a powerpc64le)
|
||||
|
||||
@@ -4,11 +4,6 @@
|
||||
with import ../default.nix;
|
||||
|
||||
let
|
||||
testingThrow = expr: {
|
||||
expr = (builtins.tryEval (builtins.seq expr "didn't throw"));
|
||||
expected = { success = false; value = false; };
|
||||
};
|
||||
testingDeepThrow = expr: testingThrow (builtins.deepSeq expr expr);
|
||||
|
||||
testSanitizeDerivationName = { name, expected }:
|
||||
let
|
||||
@@ -352,15 +347,6 @@ runTests {
|
||||
expected = "Hello\\x20World";
|
||||
};
|
||||
|
||||
testEscapeURL = testAllTrue [
|
||||
("" == strings.escapeURL "")
|
||||
("Hello" == strings.escapeURL "Hello")
|
||||
("Hello%20World" == strings.escapeURL "Hello World")
|
||||
("Hello%2FWorld" == strings.escapeURL "Hello/World")
|
||||
("42%25" == strings.escapeURL "42%")
|
||||
("%20%3F%26%3D%23%2B%25%21%3C%3E%23%22%7B%7D%7C%5C%5E%5B%5D%60%09%3A%2F%40%24%27%28%29%2A%2C%3B" == strings.escapeURL " ?&=#+%!<>#\"{}|\\^[]`\t:/@$'()*,;")
|
||||
];
|
||||
|
||||
testToInt = testAllTrue [
|
||||
# Naive
|
||||
(123 == toInt "123")
|
||||
@@ -538,37 +524,6 @@ runTests {
|
||||
};
|
||||
};
|
||||
|
||||
# code from example
|
||||
testFoldlAttrs = {
|
||||
expr = {
|
||||
example = foldlAttrs
|
||||
(acc: name: value: {
|
||||
sum = acc.sum + value;
|
||||
names = acc.names ++ [ name ];
|
||||
})
|
||||
{ sum = 0; names = [ ]; }
|
||||
{
|
||||
foo = 1;
|
||||
bar = 10;
|
||||
};
|
||||
# should just return the initial value
|
||||
emptySet = foldlAttrs (throw "function not needed") 123 { };
|
||||
# should just evaluate to the last value
|
||||
accNotNeeded = foldlAttrs (_acc: _name: v: v) (throw "accumulator not needed") { z = 3; a = 2; };
|
||||
# the accumulator doesnt have to be an attrset it can be as trivial as being just a number or string
|
||||
trivialAcc = foldlAttrs (acc: _name: v: acc * 10 + v) 1 { z = 1; a = 2; };
|
||||
};
|
||||
expected = {
|
||||
example = {
|
||||
sum = 11;
|
||||
names = [ "bar" "foo" ];
|
||||
};
|
||||
emptySet = 123;
|
||||
accNotNeeded = 3;
|
||||
trivialAcc = 121;
|
||||
};
|
||||
};
|
||||
|
||||
# code from the example
|
||||
testRecursiveUpdateUntil = {
|
||||
expr = recursiveUpdateUntil (path: l: r: path == ["foo"]) {
|
||||
@@ -919,131 +874,6 @@ runTests {
|
||||
expected = "«foo»";
|
||||
};
|
||||
|
||||
testToPlist =
|
||||
let
|
||||
deriv = derivation { name = "test"; builder = "/bin/sh"; system = "aarch64-linux"; };
|
||||
in {
|
||||
expr = mapAttrs (const (generators.toPlist { })) {
|
||||
value = {
|
||||
nested.values = rec {
|
||||
int = 42;
|
||||
float = 0.1337;
|
||||
bool = true;
|
||||
emptystring = "";
|
||||
string = "fn\${o}\"r\\d";
|
||||
newlinestring = "\n";
|
||||
path = /. + "/foo";
|
||||
null_ = null;
|
||||
list = [ 3 4 "test" ];
|
||||
emptylist = [];
|
||||
attrs = { foo = null; "foo b/ar" = "baz"; };
|
||||
emptyattrs = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
expected = { value = builtins.readFile ./test-to-plist-expected.plist; };
|
||||
};
|
||||
|
||||
testToLuaEmptyAttrSet = {
|
||||
expr = generators.toLua {} {};
|
||||
expected = ''{}'';
|
||||
};
|
||||
|
||||
testToLuaEmptyList = {
|
||||
expr = generators.toLua {} [];
|
||||
expected = ''{}'';
|
||||
};
|
||||
|
||||
testToLuaListOfVariousTypes = {
|
||||
expr = generators.toLua {} [ null 43 3.14159 true ];
|
||||
expected = ''
|
||||
{
|
||||
nil,
|
||||
43,
|
||||
3.14159,
|
||||
true
|
||||
}'';
|
||||
};
|
||||
|
||||
testToLuaString = {
|
||||
expr = generators.toLua {} ''double-quote (") and single quotes (')'';
|
||||
expected = ''"double-quote (\") and single quotes (')"'';
|
||||
};
|
||||
|
||||
testToLuaAttrsetWithLuaInline = {
|
||||
expr = generators.toLua {} { x = generators.mkLuaInline ''"abc" .. "def"''; };
|
||||
expected = ''
|
||||
{
|
||||
["x"] = ("abc" .. "def")
|
||||
}'';
|
||||
};
|
||||
|
||||
testToLuaAttrsetWithSpaceInKey = {
|
||||
expr = generators.toLua {} { "some space and double-quote (\")" = 42; };
|
||||
expected = ''
|
||||
{
|
||||
["some space and double-quote (\")"] = 42
|
||||
}'';
|
||||
};
|
||||
|
||||
testToLuaWithoutMultiline = {
|
||||
expr = generators.toLua { multiline = false; } [ 41 43 ];
|
||||
expected = ''{ 41, 43 }'';
|
||||
};
|
||||
|
||||
testToLuaEmptyBindings = {
|
||||
expr = generators.toLua { asBindings = true; } {};
|
||||
expected = "";
|
||||
};
|
||||
|
||||
testToLuaBindings = {
|
||||
expr = generators.toLua { asBindings = true; } { x1 = 41; _y = { a = 43; }; };
|
||||
expected = ''
|
||||
_y = {
|
||||
["a"] = 43
|
||||
}
|
||||
x1 = 41
|
||||
'';
|
||||
};
|
||||
|
||||
testToLuaPartialTableBindings = {
|
||||
expr = generators.toLua { asBindings = true; } { "x.y" = 42; };
|
||||
expected = ''
|
||||
x.y = 42
|
||||
'';
|
||||
};
|
||||
|
||||
testToLuaIndentedBindings = {
|
||||
expr = generators.toLua { asBindings = true; indent = " "; } { x = { y = 42; }; };
|
||||
expected = " x = {\n [\"y\"] = 42\n }\n";
|
||||
};
|
||||
|
||||
testToLuaBindingsWithSpace = testingThrow (
|
||||
generators.toLua { asBindings = true; } { "with space" = 42; }
|
||||
);
|
||||
|
||||
testToLuaBindingsWithLeadingDigit = testingThrow (
|
||||
generators.toLua { asBindings = true; } { "11eleven" = 42; }
|
||||
);
|
||||
|
||||
testToLuaBasicExample = {
|
||||
expr = generators.toLua {} {
|
||||
cmd = [ "typescript-language-server" "--stdio" ];
|
||||
settings.workspace.library = generators.mkLuaInline ''vim.api.nvim_get_runtime_file("", true)'';
|
||||
};
|
||||
expected = ''
|
||||
{
|
||||
["cmd"] = {
|
||||
"typescript-language-server",
|
||||
"--stdio"
|
||||
},
|
||||
["settings"] = {
|
||||
["workspace"] = {
|
||||
["library"] = (vim.api.nvim_get_runtime_file("", true))
|
||||
}
|
||||
}
|
||||
}'';
|
||||
};
|
||||
|
||||
# CLI
|
||||
|
||||
|
||||
@@ -141,14 +141,6 @@ checkConfigError "The option .*enable.* does not exist. Definition values:\n\s*-
|
||||
checkConfigError "attribute .*enable.* in selection path .*config.enable.* not found" "$@" ./disable-define-enable.nix ./disable-declare-enable.nix
|
||||
checkConfigError "attribute .*enable.* in selection path .*config.enable.* not found" "$@" ./disable-enable-modules.nix
|
||||
|
||||
checkConfigOutput '^true$' 'config.positive.enable' ./disable-module-with-key.nix
|
||||
checkConfigOutput '^false$' 'config.negative.enable' ./disable-module-with-key.nix
|
||||
checkConfigError 'Module ..*disable-module-bad-key.nix. contains a disabledModules item that is an attribute set, presumably a module, that does not have a .key. attribute. .*' 'config.enable' ./disable-module-bad-key.nix
|
||||
|
||||
# Not sure if we want to keep supporting module keys that aren't strings, paths or v?key, but we shouldn't remove support accidentally.
|
||||
checkConfigOutput '^true$' 'config.positive.enable' ./disable-module-with-toString-key.nix
|
||||
checkConfigOutput '^false$' 'config.negative.enable' ./disable-module-with-toString-key.nix
|
||||
|
||||
# Check _module.args.
|
||||
set -- config.enable ./declare-enable.nix ./define-enable-with-custom-arg.nix
|
||||
checkConfigError 'while evaluating the module argument .*custom.* in .*define-enable-with-custom-arg.nix.*:' "$@"
|
||||
@@ -166,7 +158,6 @@ checkConfigError 'The option .* does not exist. Definition values:\n\s*- In .*'
|
||||
checkConfigOutput '^true$' "$@" ./define-module-check.nix
|
||||
|
||||
# Check coerced value.
|
||||
set --
|
||||
checkConfigOutput '^"42"$' config.value ./declare-coerced-value.nix
|
||||
checkConfigOutput '^"24"$' config.value ./declare-coerced-value.nix ./define-value-string.nix
|
||||
checkConfigError 'A definition for option .* is not.*string or signed integer convertible to it.*. Definition values:\n\s*- In .*: \[ \]' config.value ./declare-coerced-value.nix ./define-value-list.nix
|
||||
@@ -190,7 +181,7 @@ checkConfigOutput '^"foo"$' config.submodule.foo ./declare-submoduleWith-special
|
||||
## shorthandOnlyDefines config behaves as expected
|
||||
checkConfigOutput '^true$' config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-shorthand.nix
|
||||
checkConfigError 'is not of type `boolean' config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-noshorthand.nix
|
||||
checkConfigError "You're trying to define a value of type \`bool'\n\s*rather than an attribute set for the option" config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-shorthand.nix
|
||||
checkConfigError "You're trying to declare a value of type \`bool'\n\s*rather than an attribute-set for the option" config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-shorthand.nix
|
||||
checkConfigOutput '^true$' config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-noshorthand.nix
|
||||
|
||||
## submoduleWith should merge all modules in one swoop
|
||||
@@ -255,8 +246,6 @@ checkConfigError 'A definition for option .* is not of type .*' \
|
||||
## Freeform modules
|
||||
# Assigning without a declared option should work
|
||||
checkConfigOutput '^"24"$' config.value ./freeform-attrsOf.nix ./define-value-string.nix
|
||||
# Shorthand modules interpret `meta` and `class` as config items
|
||||
checkConfigOutput '^true$' options._module.args.value.result ./freeform-attrsOf.nix ./define-freeform-keywords-shorthand.nix
|
||||
# No freeform assignments shouldn't make it error
|
||||
checkConfigOutput '^{ }$' config ./freeform-attrsOf.nix
|
||||
# but only if the type matches
|
||||
@@ -362,24 +351,6 @@ checkConfigOutput 'ok' config.freeformItems.foo.bar ./adhoc-freeformType-survive
|
||||
# because of an `extendModules` bug, issue 168767.
|
||||
checkConfigOutput '^1$' config.sub.specialisation.value ./extendModules-168767-imports.nix
|
||||
|
||||
# Class checks, evalModules
|
||||
checkConfigOutput '^{ }$' config.ok.config ./class-check.nix
|
||||
checkConfigOutput '"nixos"' config.ok.class ./class-check.nix
|
||||
checkConfigError 'The module .*/module-class-is-darwin.nix was imported into nixos instead of darwin.' config.fail.config ./class-check.nix
|
||||
checkConfigError 'The module foo.nix#darwinModules.default was imported into nixos instead of darwin.' config.fail-anon.config ./class-check.nix
|
||||
|
||||
# Class checks, submoduleWith
|
||||
checkConfigOutput '^{ }$' config.sub.nixosOk ./class-check.nix
|
||||
checkConfigError 'The module .*/module-class-is-darwin.nix was imported into nixos instead of darwin.' config.sub.nixosFail.config ./class-check.nix
|
||||
|
||||
# submoduleWith type merge with different class
|
||||
checkConfigError 'error: A submoduleWith option is declared multiple times with conflicting class values "darwin" and "nixos".' config.sub.mergeFail.config ./class-check.nix
|
||||
|
||||
# _type check
|
||||
checkConfigError 'Could not load a value as a module, because it is of type "flake", in file .*/module-imports-_type-check.nix' config.ok.config ./module-imports-_type-check.nix
|
||||
checkConfigOutput '^true$' "$@" config.enable ./declare-enable.nix ./define-enable-with-top-level-mkIf.nix
|
||||
checkConfigError 'Could not load a value as a module, because it is of type "configuration", in file .*/import-configuration.nix.*please only import the modules that make up the configuration.*' config ./import-configuration.nix
|
||||
|
||||
# doRename works when `warnings` does not exist.
|
||||
checkConfigOutput '^1234$' config.c.d.e ./doRename-basic.nix
|
||||
# doRename adds a warning.
|
||||
@@ -387,10 +358,6 @@ checkConfigOutput '^"The option `a\.b. defined in `.*/doRename-warnings\.nix. ha
|
||||
config.result \
|
||||
./doRename-warnings.nix
|
||||
|
||||
# Anonymous modules get deduplicated by key
|
||||
checkConfigOutput '^"pear"$' config.once.raw ./merge-module-with-key.nix
|
||||
checkConfigOutput '^"pear\\npear"$' config.twice.raw ./merge-module-with-key.nix
|
||||
|
||||
cat <<EOF
|
||||
====== module tests ======
|
||||
$pass Pass
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
{ lib, ... }: {
|
||||
options = {
|
||||
sub = {
|
||||
nixosOk = lib.mkOption {
|
||||
type = lib.types.submoduleWith {
|
||||
class = "nixos";
|
||||
modules = [ ];
|
||||
};
|
||||
};
|
||||
# Same but will have bad definition
|
||||
nixosFail = lib.mkOption {
|
||||
type = lib.types.submoduleWith {
|
||||
class = "nixos";
|
||||
modules = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
mergeFail = lib.mkOption {
|
||||
type = lib.types.submoduleWith {
|
||||
class = "nixos";
|
||||
modules = [ ];
|
||||
};
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
imports = [
|
||||
{
|
||||
options = {
|
||||
sub = {
|
||||
mergeFail = lib.mkOption {
|
||||
type = lib.types.submoduleWith {
|
||||
class = "darwin";
|
||||
modules = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
config = {
|
||||
_module.freeformType = lib.types.anything;
|
||||
ok =
|
||||
lib.evalModules {
|
||||
class = "nixos";
|
||||
modules = [
|
||||
./module-class-is-nixos.nix
|
||||
];
|
||||
};
|
||||
|
||||
fail =
|
||||
lib.evalModules {
|
||||
class = "nixos";
|
||||
modules = [
|
||||
./module-class-is-nixos.nix
|
||||
./module-class-is-darwin.nix
|
||||
];
|
||||
};
|
||||
|
||||
fail-anon =
|
||||
lib.evalModules {
|
||||
class = "nixos";
|
||||
modules = [
|
||||
./module-class-is-nixos.nix
|
||||
{ _file = "foo.nix#darwinModules.default";
|
||||
_class = "darwin";
|
||||
config = {};
|
||||
imports = [];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
sub.nixosOk = { _class = "nixos"; };
|
||||
sub.nixosFail = { imports = [ ./module-class-is-darwin.nix ]; };
|
||||
};
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{ lib, ... }:
|
||||
# I think this might occur more realistically in a submodule
|
||||
{
|
||||
imports = [ (lib.mkIf true { enable = true; }) ];
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
{ config, ... }: {
|
||||
class = { "just" = "data"; };
|
||||
a = "one";
|
||||
b = "two";
|
||||
meta = "meta";
|
||||
|
||||
_module.args.result =
|
||||
let r = builtins.removeAttrs config [ "_module" ];
|
||||
in builtins.trace (builtins.deepSeq r r) (r == {
|
||||
a = "one";
|
||||
b = "two";
|
||||
class = { "just" = "data"; };
|
||||
meta = "meta";
|
||||
});
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
moduleWithKey = { config, ... }: {
|
||||
config = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./declare-enable.nix
|
||||
];
|
||||
disabledModules = [ { } ];
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
moduleWithKey = {
|
||||
key = "disable-module-with-key.nix#moduleWithKey";
|
||||
config = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
positive = mkOption {
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
./declare-enable.nix
|
||||
moduleWithKey
|
||||
];
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
negative = mkOption {
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
./declare-enable.nix
|
||||
moduleWithKey
|
||||
];
|
||||
disabledModules = [ moduleWithKey ];
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
moduleWithKey = {
|
||||
key = 123;
|
||||
config = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
positive = mkOption {
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
./declare-enable.nix
|
||||
moduleWithKey
|
||||
];
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
negative = mkOption {
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
./declare-enable.nix
|
||||
moduleWithKey
|
||||
];
|
||||
disabledModules = [ 123 ];
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{ lib, ... }:
|
||||
let
|
||||
myconf = lib.evalModules { modules = [ { } ]; };
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
# We can't do this. A configuration is not equal to its set of a modules.
|
||||
# Equating those would lead to a mess, as specialArgs, anonymous modules
|
||||
# that can't be deduplicated, and possibly more come into play.
|
||||
myconf
|
||||
];
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
moduleWithoutKey = {
|
||||
config = {
|
||||
raw = "pear";
|
||||
};
|
||||
};
|
||||
|
||||
moduleWithKey = {
|
||||
key = __curPos.file + "#moduleWithKey";
|
||||
config = {
|
||||
raw = "pear";
|
||||
};
|
||||
};
|
||||
|
||||
decl = {
|
||||
options = {
|
||||
raw = mkOption {
|
||||
type = types.lines;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
once = mkOption {
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
decl
|
||||
moduleWithKey
|
||||
moduleWithKey
|
||||
];
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
twice = mkOption {
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
decl
|
||||
moduleWithoutKey
|
||||
moduleWithoutKey
|
||||
];
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
_class = "darwin";
|
||||
config = {};
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
_class = "nixos";
|
||||
config = {};
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
imports = [ { _type = "flake"; } ];
|
||||
}
|
||||
@@ -34,7 +34,7 @@ with lib.systems.doubles; lib.runTests {
|
||||
testredox = mseteq redox [ "x86_64-redox" ];
|
||||
testgnu = mseteq gnu (linux /* ++ kfreebsd ++ ... */);
|
||||
testillumos = mseteq illumos [ "x86_64-solaris" ];
|
||||
testlinux = mseteq linux [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "mips64el-linux" "mipsel-linux" "riscv32-linux" "riscv64-linux" "x86_64-linux" "powerpc64-linux" "powerpc64le-linux" "m68k-linux" "s390-linux" "s390x-linux" "microblaze-linux" "microblazeel-linux" "loongarch64-linux" ];
|
||||
testlinux = mseteq linux [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "mips64el-linux" "mipsel-linux" "riscv32-linux" "riscv64-linux" "x86_64-linux" "powerpc64-linux" "powerpc64le-linux" "m68k-linux" "s390-linux" "s390x-linux" "microblaze-linux" "microblazeel-linux" ];
|
||||
testnetbsd = mseteq netbsd [ "aarch64-netbsd" "armv6l-netbsd" "armv7a-netbsd" "armv7l-netbsd" "i686-netbsd" "m68k-netbsd" "mipsel-netbsd" "powerpc-netbsd" "riscv32-netbsd" "riscv64-netbsd" "x86_64-netbsd" ];
|
||||
testopenbsd = mseteq openbsd [ "i686-openbsd" "x86_64-openbsd" ];
|
||||
testwindows = mseteq windows [ "i686-cygwin" "x86_64-cygwin" "i686-windows" "x86_64-windows" ];
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>nested</key>
|
||||
<dict>
|
||||
<key>values</key>
|
||||
<dict>
|
||||
<key>attrs</key>
|
||||
<dict>
|
||||
<key>foo b/ar</key>
|
||||
<string>baz</string>
|
||||
</dict>
|
||||
<key>bool</key>
|
||||
<true/>
|
||||
<key>emptyattrs</key>
|
||||
<dict>
|
||||
|
||||
</dict>
|
||||
<key>emptylist</key>
|
||||
<array>
|
||||
|
||||
</array>
|
||||
<key>emptystring</key>
|
||||
<string></string>
|
||||
<key>float</key>
|
||||
<real>0.133700</real>
|
||||
<key>int</key>
|
||||
<integer>42</integer>
|
||||
<key>list</key>
|
||||
<array>
|
||||
<integer>3</integer>
|
||||
<integer>4</integer>
|
||||
<string>test</string>
|
||||
</array>
|
||||
<key>newlinestring</key>
|
||||
<string>
|
||||
</string>
|
||||
<key>path</key>
|
||||
<string>/foo</string>
|
||||
<key>string</key>
|
||||
<string>fn${o}"r\d</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -476,14 +476,6 @@ rec {
|
||||
check = x: isDerivation x && hasAttr "shellPath" x;
|
||||
};
|
||||
|
||||
pkgs = addCheck
|
||||
(unique { message = "A Nixpkgs pkgs set can not be merged with another pkgs set."; } attrs // {
|
||||
name = "pkgs";
|
||||
descriptionClass = "noun";
|
||||
description = "Nixpkgs package set";
|
||||
})
|
||||
(x: (x._type or null) == "pkgs");
|
||||
|
||||
path = mkOptionType {
|
||||
name = "path";
|
||||
descriptionClass = "noun";
|
||||
@@ -704,7 +696,6 @@ rec {
|
||||
, specialArgs ? {}
|
||||
, shorthandOnlyDefinesConfig ? false
|
||||
, description ? null
|
||||
, class ? null
|
||||
}@attrs:
|
||||
let
|
||||
inherit (lib.modules) evalModules;
|
||||
@@ -716,7 +707,7 @@ rec {
|
||||
) defs;
|
||||
|
||||
base = evalModules {
|
||||
inherit class specialArgs;
|
||||
inherit specialArgs;
|
||||
modules = [{
|
||||
# This is a work-around for the fact that some sub-modules,
|
||||
# such as the one included in an attribute set, expects an "args"
|
||||
@@ -771,14 +762,9 @@ rec {
|
||||
functor = defaultFunctor name // {
|
||||
type = types.submoduleWith;
|
||||
payload = {
|
||||
inherit modules class specialArgs shorthandOnlyDefinesConfig description;
|
||||
inherit modules specialArgs shorthandOnlyDefinesConfig description;
|
||||
};
|
||||
binOp = lhs: rhs: {
|
||||
class =
|
||||
if lhs.class == null then rhs.class
|
||||
else if rhs.class == null then lhs.class
|
||||
else if lhs.class == rhs.class then lhs.class
|
||||
else throw "A submoduleWith option is declared multiple times with conflicting class values \"${toString lhs.class}\" and \"${toString rhs.class}\".";
|
||||
modules = lhs.modules ++ rhs.modules;
|
||||
specialArgs =
|
||||
let intersecting = builtins.intersectAttrs lhs.specialArgs rhs.specialArgs;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,57 +0,0 @@
|
||||
let
|
||||
lib = import ../../lib;
|
||||
inherit (lib)
|
||||
add attrNames elemAt foldl' genList length replaceStrings sort toLower trace;
|
||||
|
||||
maintainers = import ../maintainer-list.nix;
|
||||
simplify = replaceStrings [ "-" "_" ] [ "" "" ];
|
||||
compare = a: b: simplify (toLower a) < simplify (toLower b);
|
||||
namesSorted =
|
||||
sort
|
||||
(a: b: a.key < b.key)
|
||||
(map
|
||||
(n: let pos = builtins.unsafeGetAttrPos n maintainers;
|
||||
in assert pos == null -> throw "maintainers entry ${n} is malformed";
|
||||
{ name = n; line = pos.line; key = toLower (simplify n); })
|
||||
(attrNames maintainers));
|
||||
before = { name, line, key }:
|
||||
foldl'
|
||||
(acc: n: if n.key < key && (acc == null || n.key > acc.key) then n else acc)
|
||||
null
|
||||
namesSorted;
|
||||
errors = foldl' add 0
|
||||
(map
|
||||
(i: let a = elemAt namesSorted i;
|
||||
b = elemAt namesSorted (i + 1);
|
||||
lim = let t = before a; in if t == null then "the initial {" else t.name;
|
||||
in if a.line >= b.line
|
||||
then trace
|
||||
("maintainer ${a.name} (line ${toString a.line}) should be listed "
|
||||
+ "after ${lim}, not after ${b.name} (line ${toString b.line})")
|
||||
1
|
||||
else 0)
|
||||
(genList (i: i) (length namesSorted - 1)));
|
||||
in
|
||||
assert errors == 0; "all good!"
|
||||
|
||||
# generate edit commands to sort the list.
|
||||
# may everything following the last current entry (closing } ff) in the wrong place
|
||||
# with lib;
|
||||
# concatStringsSep
|
||||
# "\n"
|
||||
# (let first = foldl' (acc: n: if n.line < acc then n.line else acc) 999999999 namesSorted;
|
||||
# commands = map
|
||||
# (i: let e = elemAt namesSorted i;
|
||||
# begin = foldl'
|
||||
# (acc: n: if n.line < e.line && n.line > acc then n.line else acc)
|
||||
# 1
|
||||
# namesSorted;
|
||||
# end =
|
||||
# foldl' (acc: n: if n.line > e.line && n.line < acc then n.line else acc)
|
||||
# 999999999
|
||||
# namesSorted;
|
||||
# in "${toString e.line},${toString (end - 1)} p")
|
||||
# (genList (i: i) (length namesSorted));
|
||||
# in map
|
||||
# (c: "sed -ne '${c}' maintainers/maintainer-list.nix")
|
||||
# ([ "1,${toString (first - 1)} p" ] ++ commands))
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -I nixpkgs=. -i bash -p "import ./maintainers/scripts/convert-to-import-cargo-lock" nix-prefetch-git
|
||||
|
||||
convert-to-import-cargo-lock "$@"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user