1
0
Fork 0
mirror of https://github.com/NixOS/nix.dev.git synced 2024-10-18 14:32:43 -04:00

add proper examples to file system paths

This commit is contained in:
Valentin Gagarin 2022-09-01 10:44:35 +02:00
parent c36c6ed732
commit 8f1dd17106

View file

@ -657,30 +657,62 @@ is equivalent to
Nix language offers convenience syntax for file system paths. Nix language offers convenience syntax for file system paths.
Absolute paths always start with a slash (`/`): Absolute paths always start with a slash (`/`).
Example:
```nix
/absolute/path
```
/absolute/path /absolute/path
Paths are relative when they contain at least one slash (`/`) but to not start with one. Paths are relative when they contain at least one slash (`/`) but to not start with one.
They are relative to the file containing the expression: They evaluate to the path relative to the file containing the expression.
The following examples assume the containing Nix file is in `/current/directory` (or `nix repl` is run in `/current/directory`).
Example:
```nix ```nix
./relative ./relative
``` ```
/current/directory/relative
Example:
```nix ```nix
relative/path relative/path
``` ```
/current/directory/relative/path
One dot (`.`) denotes the same directory. One dot (`.`) denotes the same directory.
This is typically used to specify the current directory: This is typically used to specify the current directory.
Example:
```nix ```nix
./. ./.
``` ```
/current/directory
Two dots (`..`) denote the parent directory. Two dots (`..`) denote the parent directory.
Example:
```nix
../.
```
/current
#### Search path #### Search path
Also known as “angle bracket syntax”. Also known as “angle bracket syntax”.