Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nlohmann optional #1

Merged
merged 77 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
bf69331
feat: add always-allow-substitutes
lovesegfault Mar 14, 2023
3ae1489
nix flakes metadata: Show lastModified timestamp for each input
wfranzini Jan 31, 2023
f7b8f8a
Introduce separate Serve protocol serialisers
Ericson2314 May 26, 2023
b4b1a07
store info alias created
vicky1999 Oct 13, 2023
5c65379
info store alias added to store-ping
vicky1999 Oct 13, 2023
db0d945
Document builtins.fetchTree
wentasah Jun 11, 2023
856fe13
fetchTree cleanup
edolstra Sep 28, 2023
4ce7a53
Update fetchTree docs
edolstra Sep 28, 2023
8eb4f73
fetchTree: Only use the registry if flakes are enabled
edolstra Sep 29, 2023
2084312
Merge pull request #9061 from edolstra/stabilize-fetchTree
edolstra Oct 13, 2023
da2b59a
Merge pull request #8047 from lovesegfault/always-allow-substitutes
roberth Oct 13, 2023
4112dd1
Mark fetchTree as stable
edolstra Sep 25, 2023
d070d8b
Merge pull request #9137 from obsidiansystems/serve-protocol
Ericson2314 Oct 13, 2023
a23cc14
Factor out Perl bindings Nix package
Ericson2314 Oct 13, 2023
e5ce53f
explicitly set meta.mainProgram
eclairevoyant Oct 15, 2023
6bf68c1
Merge pull request #8904 from wentasah/metadata-shows-last-modified
edolstra Oct 16, 2023
d12c614
Merge pull request #9152 from obsidiansystems/split-out-perl-nix
Ericson2314 Oct 16, 2023
c27d2f8
Add two more completions tests
Ericson2314 Apr 3, 2023
483d99c
Add API docs to some args-related functionality
Ericson2314 Oct 16, 2023
5442d9b
Merge pull request #9167 from obsidiansystems/pre-overhaul-completions
Ericson2314 Oct 16, 2023
f7a36f9
Fix language tests a bit
Ericson2314 Oct 16, 2023
b3fd7db
Detect cycles in flake follows.
vkryachko Oct 16, 2023
add066c
Fix broken move
tfc Oct 16, 2023
aa4f41d
Merge pull request #9170 from tfc/fix-broken-move
Ericson2314 Oct 16, 2023
d6066c9
Don't convert InputPaths to strings prematurely.
vkryachko Oct 16, 2023
abf7df2
Fix moves that accidentally copy anyway
tfc Oct 16, 2023
54b350d
Drop some moves that would happen anyway but forbid NRVO where appicable
tfc Oct 16, 2023
8c049a9
Merge pull request #9172 from tfc/bad-moves
Ericson2314 Oct 16, 2023
dcc5f80
Store info command help updates
vicky1999 Oct 17, 2023
a9b8595
Merge pull request #9162 from eclairevoyant/add-mainprogram
edolstra Oct 17, 2023
e92cac7
Merge pull request #9168 from obsidiansystems/fix-lang-tests-read-only
edolstra Oct 17, 2023
f62b550
fetchTree: Require the flakes experimental feature for the URL syntax
edolstra Oct 17, 2023
3470cd6
Mark some fetchers as experimental
edolstra Oct 17, 2023
ff68426
Name the protocol version types
Ericson2314 Oct 17, 2023
e36c917
Add protocol versions to `{Worker,Serve}Proto::*Conn`
Ericson2314 Mar 25, 2022
a0f071f
store info sh renamed
vicky1999 Oct 17, 2023
891dfb4
updated store ping to store info in files
vicky1999 Oct 17, 2023
9d1f42d
Merge pull request #9150 from vicky1999/fix/8914
Ericson2314 Oct 18, 2023
c1a1766
Merge pull request #9169 from vkryachko/follow_cycle
thufschmitt Oct 18, 2023
201c115
Merge pull request #9151 from edolstra/stabilize-fetchTree
edolstra Oct 18, 2023
e9ddf0b
Simplify parseHashTypeOpt
ShamrockLee Oct 9, 2023
aff177d
Elaborate the "unknown hash algorithm" error
ShamrockLee Oct 9, 2023
838c70f
treewide: Rename hashBase to hashFormat
ShamrockLee Oct 10, 2023
5043e6c
Document HashFormat
ShamrockLee Oct 18, 2023
e026f3e
treewide: Reference HashFormat members with scope
ShamrockLee Oct 13, 2023
231b0fc
Migrate HashFormat to scoped enumeration (enum struct)
ShamrockLee Oct 13, 2023
6b47635
Add helper function parseHashFormat[Opt] printHashFormat
ShamrockLee Oct 9, 2023
5088e65
primops: add builtins.convertHash
ShamrockLee Jan 29, 2023
34c5593
add a link to all maintainer meeting notes
fricklerhandwerk Oct 19, 2023
8b48fb1
Merge pull request #7708 from ShamrockLee/primop-rebasehash
fricklerhandwerk Oct 19, 2023
9adac23
update link to label
fricklerhandwerk Oct 19, 2023
36b15d9
link to popular issues from the contributing guide
fricklerhandwerk Oct 19, 2023
9bc7b4f
doc: generic closure supported key types (#9183)
hsjobeki Oct 19, 2023
ce42655
Merge pull request #9180 from fricklerhandwerk/meeting-notes-link
Ericson2314 Oct 19, 2023
6016a0e
Merge pull request #9181 from fricklerhandwerk/good-first-issue-label
Ericson2314 Oct 19, 2023
7ed294f
Merge pull request #9182 from fricklerhandwerk/popular-issues
Ericson2314 Oct 19, 2023
42f26eb
doc: complexity for '?' operator (#9184)
hsjobeki Oct 20, 2023
e58566a
doc: add reference to hasAttr in `?` operator (#9185)
hsjobeki Oct 20, 2023
9277eb2
libstore: Add apple-virt to system features when available
roberth Oct 19, 2023
bb645c5
system-features doc: kvm is Linux-only
roberth Oct 20, 2023
8a28ed2
Merge pull request #9187 from hercules-ci/issue-7619-apple-virt-syste…
Ericson2314 Oct 20, 2023
4d17c59
Merge pull request #9157 from obsidiansystems/protocol-versions
roberth Oct 20, 2023
af30226
Input::hasAllInfo(): Remove
edolstra Oct 20, 2023
3e6b9f9
Remove `prevInfos` as its dead code
Ericson2314 Oct 16, 2023
862d164
Remove the `ValidPathInfo` `==` operator
Ericson2314 Oct 16, 2023
e824ab3
Merge pull request #9195 from edolstra/remove-hasAllInfo
edolstra Oct 20, 2023
0f7e9d0
Input: Remove 'direct' field
edolstra Oct 20, 2023
85e5ac4
docker: publish images to ghcr.io (#8066)
baloo Oct 20, 2023
81ed1d5
Merge pull request #9197 from obsidiansystems/delete-dead-code
Ericson2314 Oct 20, 2023
091e5b4
Merge pull request #9198 from edolstra/remove-direct
edolstra Oct 20, 2023
935c998
Remove fetchers::Tree and move tarball-related stuff into its own header
edolstra Oct 20, 2023
7d3cd54
Merge pull request #9199 from edolstra/remove-tree
edolstra Oct 20, 2023
97a0c08
Expand derivation examples (#9048)
fricklerhandwerk Oct 20, 2023
5135e47
fix: adl_serializer for std::optional
aakropotkin Oct 21, 2023
3f0af2d
additional test cases
aakropotkin Oct 21, 2023
7ace482
restore static_asserts
aakropotkin Oct 21, 2023
7f18ed8
Merge branch 'patch-1' into nlohmann-optional
aakropotkin Oct 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ jobs:

docker_push_image:
needs: [check_secrets, tests]
permissions:
contents: read
packages: write
if: >-
github.event_name == 'push' &&
github.ref_name == 'master' &&
Expand All @@ -126,10 +129,30 @@ jobs:
- run: docker load -i ./result/image.tar.gz
- run: docker tag nix:$NIX_VERSION nixos/nix:$NIX_VERSION
- run: docker tag nix:$NIX_VERSION nixos/nix:master
# We'll deploy the newly built image to both Docker Hub and Github Container Registry.
#
# Push to Docker Hub first
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: docker push nixos/nix:$NIX_VERSION
- run: docker push nixos/nix:master
# Push to GitHub Container Registry as well
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/nix
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')

docker tag nix:$NIX_VERSION $IMAGE_ID:$NIX_VERSION
docker tag nix:$NIX_VERSION $IMAGE_ID:master
docker push $IMAGE_ID:$NIX_VERSION
docker push $IMAGE_ID:master
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ Check out the [security policy](https://github.com/NixOS/nix/security/policy).
1. Search for related issues that cover what you're going to work on.
It could help to mention there that you will work on the issue.

Issues labeled [good first issue](https://github.com/NixOS/nix/labels/good-first-issue) should be relatively easy to fix and are likely to get merged quickly.
Issues labeled [good first issue](https://github.com/NixOS/nix/labels/good%20first%20issue) should be relatively easy to fix and are likely to get merged quickly.
Pull requests addressing issues labeled [idea approved](https://github.com/NixOS/nix/labels/idea%20approved) or [RFC](https://github.com/NixOS/nix/labels/RFC) are especially welcomed by maintainers and will receive prioritised review.

If you are proficient with C++, addressing one of the [popular issues](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc) will be highly appreciated by maintainers and Nix users all over the world.
For far-reaching changes, please investigate possible blockers and design implications, and coordinate with maintainers before investing too much time in writing code that may not end up getting merged.

If there is no relevant issue yet and you're not sure whether your change is likely to be accepted, [open an issue](https://github.com/NixOS/nix/issues/new/choose) yourself.

2. Check for [pull requests](https://github.com/NixOS/nix/pulls) that might already cover the contribution you are about to make.
Expand Down
4 changes: 2 additions & 2 deletions doc/manual/src/advanced-topics/distributed-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ machine is accessible via SSH and that it has Nix installed. You can
test whether connecting to the remote Nix instance works, e.g.

```console
$ nix store ping --store ssh://mac
$ nix store info --store ssh://mac
```

will try to connect to the machine named `mac`. It is possible to
specify an SSH identity file as part of the remote store URI, e.g.

```console
$ nix store ping --store ssh://mac?ssh-key=/home/alice/my-key
$ nix store info --store ssh://mac?ssh-key=/home/alice/my-key
```

Since builds should be non-interactive, the key should not have a
Expand Down
1 change: 1 addition & 0 deletions doc/manual/src/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
- [output]{#gloss-output}

A [store object] produced by a [derivation].
See [the `outputs` argument to the `derivation` function](@docroot@/language/derivations.md#attr-outputs) for details.

[output]: #gloss-output

Expand Down
8 changes: 4 additions & 4 deletions doc/manual/src/installation/installing-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
To run the latest stable release of Nix with Docker run the following command:

```console
$ docker run -ti nixos/nix
Unable to find image 'nixos/nix:latest' locally
latest: Pulling from nixos/nix
$ docker run -ti ghcr.io/nixos/nix
Unable to find image 'ghcr.io/nixos/nix:latest' locally
latest: Pulling from ghcr.io/nixos/nix
5843afab3874: Pull complete
b52bf13f109c: Pull complete
1e2415612aa3: Pull complete
Digest: sha256:27f6e7f60227e959ee7ece361f75d4844a40e1cc6878b6868fe30140420031ff
Status: Downloaded newer image for nixos/nix:latest
Status: Downloaded newer image for ghcr.io/nixos/nix:latest
35ca4ada6e96:/# nix --version
nix (Nix) 2.3.12
35ca4ada6e96:/# exit
Expand Down
3 changes: 3 additions & 0 deletions doc/manual/src/language/advanced-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ Derivations can declare some infrequently used optional attributes.
useful for very trivial derivations (such as `writeText` in Nixpkgs)
that are cheaper to build than to substitute from a binary cache.

You may disable the effects of this attibute by enabling the
`always-allow-substitutes` configuration option in Nix.

> **Note**
>
> You need to have a builder configured which satisfies the
Expand Down
230 changes: 169 additions & 61 deletions doc/manual/src/language/derivations.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,98 +8,205 @@ It outputs an attribute set, and produces a [store derivation] as a side effect

[store derivation]: @docroot@/glossary.md#gloss-store-derivation

<!-- FIXME: add a section on output attributes -->

## Input attributes

### Required

- [`name`]{#attr-name} ([String](@docroot@/language/values.md#type-string))

A symbolic name for the derivation.
It is added to the [store derivation]'s [path](@docroot@/glossary.md#gloss-store-path) and its [output paths][output path].

Example: `name = "hello";`
It is added to the [store path] of the corresponding [store derivation] as well as to its [output paths](@docroot@/glossary.md#gloss-output-path).

[store path]: @docroot@/glossary.md#gloss-store-path

> **Example**
>
> ```nix
> derivation {
> name = "hello";
> # ...
> }
> ```
>
> The store derivation's path will be `/nix/store/<hash>-hello.drv`.
> The [output](#attr-outputs) paths will be of the form `/nix/store/<hash>-hello[-<output>]`

The store derivation's path will be `/nix/store/<hash>-hello.drv`, and the output paths will be of the form `/nix/store/<hash>-hello[-<output>]`
- [`system`]{#attr-system} ([String](@docroot@/language/values.md#type-string))

The system type on which the [`builder`](#attr-builder) executable is meant to be run.

A necessary condition for Nix to build derivations locally is that the `system` attribute matches the current [`system` configuration option].
It can automatically [build on other platforms](../advanced-topics/distributed-builds.md) by forwarding build requests to other machines.

Examples:

`system = "x86_64-linux";`

`system = builtins.currentSystem;`

[`builtins.currentSystem`](@docroot@/language/builtin-constants.md#builtins-currentSystem) has the value of the [`system` configuration option], and defaults to the system type of the current Nix installation.

[`system` configuration option]: @docroot@/command-ref/conf-file.md#conf-system

> **Example**
>
> Declare a derivation to be built on a specific system type:
>
> ```nix
> derivation {
> # ...
> system = "x86_64-linux";
> # ...
> }
> ```

> **Example**
>
> Declare a derivation to be built on the system type that evaluates the expression:
>
> ```nix
> derivation {
> # ...
> system = builtins.currentSystem;
> # ...
> }
> ```
>
> [`builtins.currentSystem`](@docroot@/language/builtin-constants.md#builtins-currentSystem) has the value of the [`system` configuration option], and defaults to the system type of the current Nix installation.

- [`builder`]{#attr-builder} ([Path](@docroot@/language/values.md#type-path) | [String](@docroot@/language/values.md#type-string))

Path to an executable that will perform the build.

Examples:

`builder = "/bin/bash";`

`builder = ./builder.sh;`

`builder = "${pkgs.python}/bin/python";`
> **Example**
>
> Use the file located at `/bin/bash` as the builder executable:
>
> ```nix
> derivation {
> # ...
> builder = "/bin/bash";
> # ...
> };
> ```

<!-- -->

> **Example**
>
> Copy a local file to the Nix store for use as the builder executable:
>
> ```nix
> derivation {
> # ...
> builder = ./builder.sh;
> # ...
> };
> ```

<!-- -->

> **Example**
>
> Use a file from another derivation as the builder executable:
>
> ```nix
> let pkgs = import <nixpkgs> {}; in
> derivation {
> # ...
> builder = "${pkgs.python}/bin/python";
> # ...
> };
> ```

### Optional

- [`args`]{#attr-args} ([List](@docroot@/language/values.md#list) of [String](@docroot@/language/values.md#type-string)) Default: `[ ]`
- [`args`]{#attr-args} ([List](@docroot@/language/values.md#list) of [String](@docroot@/language/values.md#type-string))

Default: `[ ]`

Command-line arguments to be passed to the [`builder`](#attr-builder) executable.

Example: `args = [ "-c" "echo hello world > $out" ];`
> **Example**
>
> Pass arguments to Bash to interpret a shell command:
>
> ```nix
> derivation {
> # ...
> builder = "/bin/bash";
> args = [ "-c" "echo hello world > $out" ];
> # ...
> };
> ```

- [`outputs`]{#attr-outputs} ([List](@docroot@/language/values.md#list) of [String](@docroot@/language/values.md#type-string)) Default: `[ "out" ]`
- [`outputs`]{#attr-outputs} ([List](@docroot@/language/values.md#list) of [String](@docroot@/language/values.md#type-string))

Symbolic outputs of the derivation.
Each output name is passed to the [`builder`](#attr-builder) executable as an environment variable with its value set to the corresponding [output path].
Default: `[ "out" ]`

[output path]: @docroot@/glossary.md#gloss-output-path
Symbolic outputs of the derivation.
Each output name is passed to the [`builder`](#attr-builder) executable as an environment variable with its value set to the corresponding [store path].

By default, a derivation produces a single output path called `out`.
However, derivations can produce multiple output paths.
By default, a derivation produces a single output called `out`.
However, derivations can produce multiple outputs.
This allows the associated [store objects](@docroot@/glossary.md#gloss-store-object) and their [closures](@docroot@/glossary.md#gloss-closure) to be copied or garbage-collected separately.

Examples:

Imagine a library package that provides a dynamic library, header files, and documentation.
A program that links against such a library doesn’t need the header files and documentation at runtime, and it doesn’t need the documentation at build time.
Thus, the library package could specify:

```nix
derivation {
# ...
outputs = [ "lib" "dev" "doc" ];
# ...
}
```

This will cause Nix to pass environment variables `lib`, `dev`, and `doc` to the builder containing the intended store paths of each output.
The builder would typically do something like

```bash
./configure \
--libdir=$lib/lib \
--includedir=$dev/include \
--docdir=$doc/share/doc
```

for an Autoconf-style package.

You can refer to each output of a derivation by selecting it as an attribute, e.g. `myPackage.lib` or `myPackage.doc`.

The first element of `outputs` determines the *default output*.
Therefore, in the given example, `myPackage` is equivalent to `myPackage.lib`.
> **Example**
>
> Imagine a library package that provides a dynamic library, header files, and documentation.
> A program that links against such a library doesn’t need the header files and documentation at runtime, and it doesn’t need the documentation at build time.
> Thus, the library package could specify:
>
> ```nix
> derivation {
> # ...
> outputs = [ "lib" "dev" "doc" ];
> # ...
> }
> ```
>
> This will cause Nix to pass environment variables `lib`, `dev`, and `doc` to the builder containing the intended store paths of each output.
> The builder would typically do something like
>
> ```bash
> ./configure \
> --libdir=$lib/lib \
> --includedir=$dev/include \
> --docdir=$doc/share/doc
> ```
>
> for an Autoconf-style package.

The name of an output is combined with the name of the derivation to create the name part of the output's store path, unless it is `out`, in which case just the name of the derivation is used.

> **Example**
>
>
> ```nix
> derivation {
> name = "example";
> outputs = [ "lib" "dev" "doc" "out" ];
> # ...
> }
> ```
>
> The store derivation path will be `/nix/store/<hash>-example.drv`.
> The output paths will be
> - `/nix/store/<hash>-example-lib`
> - `/nix/store/<hash>-example-dev`
> - `/nix/store/<hash>-example-doc`
> - `/nix/store/<hash>-example`

You can refer to each output of a derivation by selecting it as an attribute.
The first element of `outputs` determines the *default output* and ends up at the top-level.

> **Example**
>
> Select an output by attribute name:
>
> ```nix
> let
> myPackage = derivation {
> name = "example";
> outputs = [ "lib" "dev" "doc" "out" ];
> # ...
> };
> in myPackage.dev
> ```
>
> Since `lib` is the first output, `myPackage` is equivalent to `myPackage.lib`.

<!-- FIXME: refer to the output attributes when we have one -->

Expand All @@ -123,15 +230,16 @@ It outputs an attribute set, and produces a [store derivation] as a side effect
reside in the Nix store.

- A *derivation* causes that derivation to be built prior to the
present derivation; its default output path is put in the
environment variable.
present derivation. The environment variable is set to the [store path] of the derivation's default [output](#attr-outputs).

- Lists of the previous types are also allowed. They are simply
concatenated, separated by spaces.

- `true` is passed as the string `1`, `false` and `null` are
passed as an empty string.

<!-- FIXME: add a section on output attributes -->

## Builder execution

The [`builder`](#attr-builder) is executed as follows:
Expand Down
Loading