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

dependency-management.md: update niv references #1009

Merged
merged 3 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions maintainers/documentation-survey.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ To better navigate the material and judge its relevance, every entry should prov

### Nix

- https://nix.dev/manual/nix/2.18/command-ref/command-ref.html
- https://nix.dev/manual/nix/stable/command-ref/command-ref.html
- https://edolstra.github.io/pubs/phd-thesis.pdf

### Nix language

- https://edolstra.github.io/pubs/phd-thesis.pdf
- https://nix.dev/manual/nix/2.18/expressions/writing-nix-expressions.html
- https://nix.dev/manual/nix/stable/expressions/writing-nix-expressions.html
- https://github.com/tazjin/nix-1p

### Nixpkgs
Expand Down
2 changes: 1 addition & 1 deletion source/concepts/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Yes. There is:

- CPU architecture—great effort being made to avoid compilation of native instructions in favour of hardcoded supported ones.
- System's current time/date.
- The filesystem used for building (see also [`TMPDIR`](https://nix.dev/manual/nix/2.18/command-ref/env-common.html#env-TMPDIR)).
- The filesystem used for building (see also [`TMPDIR`](https://nix.dev/manual/nix/stable/command-ref/env-common.html#env-TMPDIR)).
- Linux kernel parameters, such as:
- [IPv6 capabilities](https://github.com/NixOS/nix/issues/5615).
- binfmt interpreters, e.g., those configured with [`boot.binfmt.emulatedSystems`](https://search.nixos.org/options?show=boot.binfmt.emulatedSystems).
Expand Down
16 changes: 8 additions & 8 deletions source/concepts/flakes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ What is usually referred to as "flakes" is:
- A policy for managing dependencies between {term}`Nix expressions<Nix expression>`.
- An [experimental feature] in Nix, implementing that policy and supporting functionality.

[experimental feature]: https://nix.dev/manual/nix/2.18/contributing/experimental-features.html
[experimental feature]: https://nix.dev/manual/nix/stable/contributing/experimental-features.html

## What are flakes?

Technically, a [flake](https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix3-flake.html#description) is a file system tree that contains a file named `flake.nix` in its root directory.
Technically, a [flake](https://nix.dev/manual/nix/stable/command-ref/new-cli/nix3-flake.html#description) is a file system tree that contains a file named `flake.nix` in its root directory.

Flakes add the following behavior to Nix:

1. A `flake.nix` file enforces a [schema], where:
- Other flakes are referenced as dependencies providing {term}`Nix language` code or other files.
- The values produced by the {term}`Nix expression`s in `flake.nix` are structured according to pre-defined use cases.

[schema]: https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix3-flake.html#flake-format
[schema]: https://nix.dev/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-format

1. References to other flakes can be specified using a dedicated [URL-like syntax](https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix3-flake.html#flake-references).
1. References to other flakes can be specified using a dedicated [URL-like syntax](https://nix.dev/manual/nix/stable/command-ref/new-cli/nix3-flake.html#flake-references).
A [flake registry] allows using symbolic identifiers for further brevity.
References can be automatically locked to their current specific version and later updated programmatically.

[flake registry]: https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix3-registry.html
[flake registry]: https://nix.dev/manual/nix/stable/command-ref/new-cli/nix3-registry.html

1. A [new command line interface], implemented as a separate experimental feature, leverages flakes by accepting flake references in order to build, run, or deploy software defined as a flake.

[new command line interface]: https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix.html
[new command line interface]: https://nix.dev/manual/nix/stable/command-ref/new-cli/nix.html

Nix handles flakes differently than regular {term}`Nix files <Nix file>` in the following ways:

Expand Down Expand Up @@ -55,12 +55,12 @@ In particular:
- The RFC was closed without conclusion, and some fundamental issues are not yet resolved.
For example:
- The notion of a [global flake registry](https://github.com/NixOS/flake-registry) saw [substantial criticism](https://github.com/NixOS/rfcs/pull/49#issuecomment-635635333) that was never addressed.
While the source references of [registry entries can be pinned](https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix3-registry-pin), local registry names in Nix expressions [introduce mutable system state](https://github.com/NixOS/nix/issues/7422) and are thus, in that regard, no improvement over channels as managed by [`nix-channel`](https://nix.dev/manual/nix/2.18/command-ref/nix-channel).
While the source references of [registry entries can be pinned](https://nix.dev/manual/nix/stable/command-ref/new-cli/nix3-registry-pin), local registry names in Nix expressions [introduce mutable system state](https://github.com/NixOS/nix/issues/7422) and are thus, in that regard, no improvement over channels as managed by [`nix-channel`](https://nix.dev/manual/nix/stable/command-ref/nix-channel).
- It is [impossible to parameterise flakes](https://github.com/NixOS/nix/issues/2861).
This means that [flakes downgrade ease of use of the `system` parameter](https://github.com/NixOS/nix/issues/3843) of derivations, for producers and consumers.
- the flakes proposal was criticised for [trying to solve too many problems at once](https://github.com/nixos/rfcs/pull/49#issuecomment-521998933) and [at the wrong abstraction layer](https://discourse.nixos.org/t/nixpkgs-cli-working-group-member-search/30517).
Part of this is that [the new command line interface and flakes are closely tied to each other](https://discourse.nixos.org/t/2023-03-06-nix-team-meeting-minutes-38/26056#cli-stabilisation-announcement-draft-4).
- As [predicted by RFC reviewers](https://github.com/NixOS/rfcs/pull/49#issuecomment-588990425), the original implementation introduced [regressions](https://discourse.nixos.org/t/nix-2-4-and-what-s-next/16257) in the [Nix 2.4 release](https://nix.dev/manual/nix/2.18/release-notes/rl-2.4.html), breaking some stable functionality without a [major version](https://semver.org/) increment.
- As [predicted by RFC reviewers](https://github.com/NixOS/rfcs/pull/49#issuecomment-588990425), the original implementation introduced [regressions](https://discourse.nixos.org/t/nix-2-4-and-what-s-next/16257) in the [Nix 2.4 release](https://nix.dev/manual/nix/stable/release-notes/rl-2.4.html), breaking some stable functionality without a [major version](https://semver.org/) increment.
- Copying sources to the Nix store prior to evaluation adds a [significant performance penalty](https://github.com/NixOS/nix/issues/3121), especially for large repositories such as {term}`Nixpkgs`.
Work to address this has been [in progress since May 2022](https://github.com/NixOS/nix/pull/6530), but risks introducing [its own set of issues](https://github.com/NixOS/nix/pull/6530#issuecomment-1850565931).
- New Nix users were and still are encouraged by various individuals to adopt flakes despite there being no stability guarantees and no timeline to conclude the experiment.
Expand Down
2 changes: 1 addition & 1 deletion source/contributing/how-to-contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ And it will lead to better code and documentation in the long run.

We can only fix issues that we know of, so please report any issue you encounter.

- Report issues with {term}`Nix` (including the [Nix reference manual](https://nixos.org/manual/nix/stable)) at <https://github.com/NixOS/nix/issues>.
- Report issues with {term}`Nix` (including the [Nix reference manual](https://nix.dev/manual/nix/stable)) at <https://github.com/NixOS/nix/issues>.

- Report issues with {term}`Nixpkgs` or {term}`NixOS` (including packages, configuration modules, the [Nixpkgs manual](https://nixos.org/manual/nixpkgs/stable), and the [NixOS manual](https://nixos.org/manual/nixos/stable)) at <https://github.com/NixOS/nixpkgs/issues>.

Expand Down
8 changes: 4 additions & 4 deletions source/guides/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ You will often encounter Nix language code samples that refer to `<nixpkgs>`.
`<...>` is special syntax that was [introduced in 2011] to conveniently access values from the environment variable [`$NIX_PATH`].

[introduced in 2011]: https://github.com/NixOS/nix/commit/1ecc97b6bdb27e56d832ca48cdafd3dbb5185a04
[`$NIX_PATH`]: https://nix.dev/manual/nix/2.18/command-ref/env-common.html#env-NIX_PATH
[`$NIX_PATH`]: https://nix.dev/manual/nix/stable/command-ref/env-common.html#env-NIX_PATH

This means, the value of a lookup path depends on external system state.
When using lookup paths, the same Nix expression can produce different results.

In most cases, `$NIX_PATH` is set to the latest channel when Nix is installed, and is therefore likely to differ from machine to machine.

:::{note}
[Channels](https://nix.dev/manual/nix/2.18/command-ref/nix-channel.html) are a mechanism for referencing remote Nix expressions and retrieving their latest version.
[Channels](https://nix.dev/manual/nix/stable/command-ref/nix-channel.html) are a mechanism for referencing remote Nix expressions and retrieving their latest version.
:::

The state of a subscribed channel is external to the Nix expressions relying on it.
Expand Down Expand Up @@ -198,7 +198,7 @@ We skip it in minimal examples to reduce distractions.

## Updating nested attribute sets

The [attribute set update operator](https://nix.dev/manual/nix/2.18/language/operators.html#update) merges two attribute sets.
The [attribute set update operator](https://nix.dev/manual/nix/stable/language/operators.html#update) merges two attribute sets.

Example:

Expand Down Expand Up @@ -264,7 +264,7 @@ If someone builds the project in a directory with a different name, they will ge
This can be the cause of needless rebuilds.

:::{tip}
Use [`builtins.path`](https://nix.dev/manual/nix/2.18/language/builtins.html#builtins-path) with the `name` attribute set to something fixed.
Use [`builtins.path`](https://nix.dev/manual/nix/stable/language/builtins.html#builtins-path) with the `name` attribute set to something fixed.

This will derive the symbolic name of the store path from `name` instead of the working directory:

Expand Down
9 changes: 5 additions & 4 deletions source/guides/recipes/dependency-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Import the generated `npins/default.nix` as the default value for the argument t
}
```

`nix-build` will call the top-level function with the empty attribute set `{}`, or with the attributes passed via [`--arg`](https://nixos.org/manual/nix/stable/command-ref/nix-build#opt-arg) or [`--argstr`](https://nixos.org/manual/nix/stable/command-ref/nix-build#opt-argstr).
`nix-build` will call the top-level function with the empty attribute set `{}`, or with the attributes passed via [`--arg`](https://nix.dev/manual/nix/stable/command-ref/nix-build#opt-arg) or [`--argstr`](https://nix.dev/manual/nix/stable/command-ref/nix-build#opt-argstr).
This pattern allows [overriding remote sources](overriding-sources-npins) programmatically.

Add `npins` to the development environment for your project to have it readily available:
Expand Down Expand Up @@ -63,7 +63,7 @@ See [](./sharing-dependencies) for details, and note that here you have to pass

As an example, we will use the previously created expression with an older version of Nixpkgs.

Enter the development environment, create a new directory, and set up niv with a different version of Nixpkgs:
Enter the development environment, create a new directory, and set up npins with a different version of Nixpkgs:

```shell-session
$ nix-shell
Expand Down Expand Up @@ -95,8 +95,9 @@ nix-build .. -A build --arg sources 'import ./npins'

## Migrating from `niv`

A previous version of this guide recommended using [`niv`](https://github.com/nmattia/niv/), which is not maintained anymore.
If you have a project using `niv`, import remote source definitions into `npins`:
A previous version of this guide recommended using [`niv`](https://github.com/nmattia/niv/), a similar pin manager written in Haskell.

If you have a project using `niv`, you can import remote source definitions into `npins`:

```shell-session
npins import-niv
Expand Down
12 changes: 6 additions & 6 deletions source/guides/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ This page is a collection of tips to solve problems you may encounter using Nix.

## What to do if a binary cache is down or unreachable?

Pass [`--option substitute false`](https://nix.dev/manual/nix/2.18/command-ref/conf-file#conf-substitute) to Nix commands.
Pass [`--option substitute false`](https://nix.dev/manual/nix/stable/command-ref/conf-file#conf-substitute) to Nix commands.

## How to force Nix to re-check if something exists in the binary cache?

Nix keeps track of what's available in binary caches so it doesn't have to query them on every command.
This includes negative answers, that is, if a given store path cannot be substituted.

Pass the [`--narinfo-cache-negative-ttl`](https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-narinfo-cache-negative-ttl) option to set the cache timeout in seconds.
Pass the [`--narinfo-cache-negative-ttl`](https://nix.dev/manual/nix/stable/command-ref/conf-file.html#conf-narinfo-cache-negative-ttl) option to set the cache timeout in seconds.

## How to fix: `error: querying path in database: database disk image is malformed`

Expand All @@ -22,7 +22,7 @@ Try:
$ sqlite3 /nix/var/nix/db/db.sqlite "pragma integrity_check"
```

Which will print the errors in the [database](https://nix.dev/manual/nix/2.18/glossary#gloss-nix-database).
Which will print the errors in the [database](https://nix.dev/manual/nix/stable/glossary#gloss-nix-database).
If the errors are due to missing references, the following may work:

```shell-session
Expand All @@ -34,7 +34,7 @@ $ sqlite3 /nix/var/nix/db/db.sqlite-bkp ".dump" | sqlite3 /nix/var/nix/db/db.sql

This is a [known issue](https://github.com/NixOS/nix/issues/1251).

It means that using a new version of Nix upgraded the SQLite schema of the [database](https://nix.dev/manual/nix/2.18/glossary#gloss-nix-database), and then you tried to use an older version Nix.
It means that using a new version of Nix upgraded the SQLite schema of the [database](https://nix.dev/manual/nix/stable/glossary#gloss-nix-database), and then you tried to use an older version Nix.

The solution is to dump the database, and use the old Nix version to re-import the data:

Expand All @@ -47,6 +47,6 @@ $ nix-store --load-db < /tmp/db.dump

## How to fix: `writing to file: Connection reset by peer`

This may mean you are trying to import a too large file or directory into the [Nix store](https://nix.dev/manual/nix/2.18/glossary#gloss-store), or your machine is running out of resources, such as disk space or memory.
This may mean you are trying to import a too large file or directory into the [Nix store](https://nix.dev/manual/nix/stable/glossary#gloss-store), or your machine is running out of resources, such as disk space or memory.

Try to reduce the size of the directory to import, or run [garbage collection](https://nix.dev/manual/nix/2.18/command-ref/nix-collect-garbage).
Try to reduce the size of the directory to import, or run [garbage collection](https://nix.dev/manual/nix/stable/command-ref/nix-collect-garbage).
4 changes: 2 additions & 2 deletions source/install-nix.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ $ nix --version
nix (Nix) 2.11.0
```

[multi-user installation]: https://nix.dev/manual/nix/2.18/installation/multi-user.html
[single-user installation]: https://nix.dev/manual/nix/2.18/installation/single-user.html
[multi-user installation]: https://nix.dev/manual/nix/stable/installation/multi-user.html
[single-user installation]: https://nix.dev/manual/nix/stable/installation/single-user.html
2 changes: 1 addition & 1 deletion source/reference/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Nix language

:::{seealso}
- [](reading-nix-language)
- [Nix language reference](https://nix.dev/manual/nix/2.18/language)
- [Nix language reference](https://nix.dev/manual/nix/stable/language)
:::

Nix expression
Expand Down
6 changes: 3 additions & 3 deletions source/reference/pinning-nixpkgs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

Specifying remote Nix expressions, such as the one provided by Nixpkgs, can be done in several ways:

- [`$NIX_PATH` environment variable](https://nix.dev/manual/nix/2.18/command-ref/env-common.html#env-NIX_PATH)
- [`-I` option](https://nix.dev/manual/nix/2.18/command-ref/opt-common.html#opt-I) to most of commands like `nix-build`, `nix-shell`, etc.
- [`fetchurl`](https://nix.dev/manual/nix/2.18/language/builtins.html#builtins-fetchurl), [`fetchTarball`](https://nix.dev/manual/nix/2.18/language/builtins.html#builtins-fetchTarball), [`fetchGit`](https://nix.dev/manual/nix/2.18/language/builtins.html#builtins-fetchGit) or [Nixpkgs fetchers](https://nixos.org/manual/nixpkgs/stable/#chap-pkgs-fetchers) in Nix expressions
- [`$NIX_PATH` environment variable](https://nix.dev/manual/nix/stable/command-ref/env-common.html#env-NIX_PATH)
- [`-I` option](https://nix.dev/manual/nix/stable/command-ref/opt-common.html#opt-I) to most of commands like `nix-build`, `nix-shell`, etc.
- [`fetchurl`](https://nix.dev/manual/nix/stable/language/builtins.html#builtins-fetchurl), [`fetchTarball`](https://nix.dev/manual/nix/stable/language/builtins.html#builtins-fetchTarball), [`fetchGit`](https://nix.dev/manual/nix/stable/language/builtins.html#builtins-fetchGit) or [Nixpkgs fetchers](https://nixos.org/manual/nixpkgs/stable/#chap-pkgs-fetchers) in Nix expressions

## Possible URL values

Expand Down
4 changes: 2 additions & 2 deletions source/tutorials/first-steps/ad-hoc-shell-environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ There are three things going on here:

## References

- [Nix manual: `nix-shell`](https://nix.dev/manual/nix/2.18/command-ref/nix-shell) (or run `man nix-shell`)
- [Nix manual: `-I` option](https://nix.dev/manual/nix/2.18/command-ref/opt-common.html#opt-I)
- [Nix manual: `nix-shell`](https://nix.dev/manual/nix/stable/command-ref/nix-shell) (or run `man nix-shell`)
- [Nix manual: `-I` option](https://nix.dev/manual/nix/stable/command-ref/opt-common.html#opt-I)

## Next steps

Expand Down
2 changes: 1 addition & 1 deletion source/tutorials/first-steps/declarative-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Exit the shell by typing `exit` or pressing `Ctrl`+`D`, then start it again with

- [`mkShell` documentation](https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-mkShell)
- Nixpkgs [shell functions and utilities](https://nixos.org/manual/nixpkgs/stable/#ssec-stdenv-functions) documentation
- [`nix-shell` documentation](https://nix.dev/manual/nix/2.18/command-ref/nix-shell)
- [`nix-shell` documentation](https://nix.dev/manual/nix/stable/command-ref/nix-shell)

## Next steps

Expand Down
8 changes: 4 additions & 4 deletions source/tutorials/first-steps/reproducible-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ It takes the following parameters relevant for our use case:
- `-p` lists packages that should be present in the interpreter's environment
- `-I` explicitly sets [the search path] for packages

More details on the options can be found in the [`nix-shell` reference documentation](https://nix.dev/manual/nix/2.18/command-ref/nix-shell.html#options).
More details on the options can be found in the [`nix-shell` reference documentation](https://nix.dev/manual/nix/stable/command-ref/nix-shell.html#options).

[`nix-shell` as a shebang interpreter]: https://nix.dev/manual/nix/2.18/command-ref/nix-shell.html#use-as-a--interpreter
[the search path]: https://nix.dev/manual/nix/2.18/command-ref/opt-common.html#opt-I
[`nix-shell` as a shebang interpreter]: https://nix.dev/manual/nix/stable/command-ref/nix-shell.html#use-as-a--interpreter
[the search path]: https://nix.dev/manual/nix/stable/command-ref/opt-common.html#opt-I

Create a file named `nixpkgs-releases.sh` with the following content:

Expand Down Expand Up @@ -97,4 +97,4 @@ Run the script:

- {ref}`reading-nix-language` to learn about the Nix language, which is used to declare packages and configurations.
- {ref}`declarative-reproducible-envs` to create reproducible shell environments with a declarative configuration file.
- [Garbage Collection](https://nix.dev/manual/nix/2.18/package-management/garbage-collection.html) – free up storage used by the programs made available through Nix
- [Garbage Collection](https://nix.dev/manual/nix/stable/package-management/garbage-collection.html) – free up storage used by the programs made available through Nix
2 changes: 1 addition & 1 deletion source/tutorials/module-system/a-basic-module/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The output of `evalModules` contains information about all evaluated modules, an
:caption: default.nix
```

Here's a helper script to parse and evaluate our `default.nix` file with [`nix-instantiate --eval`](https://nixos.org/manual/nix/stable/command-ref/nix-instantiate) and print the output as JSON:
Here's a helper script to parse and evaluate our `default.nix` file with [`nix-instantiate --eval`](https://nix.dev/manual/nix/stable/command-ref/nix-instantiate) and print the output as JSON:

```{literalinclude} eval.bash
:language: bash
Expand Down
Loading
Loading