Document searching upwards and fix documentation for installables

This commit is contained in:
Alexander Bantyev 2022-01-14 17:53:07 +03:00
parent e3690ab393
commit f055cc5a0b
No known key found for this signature in database
GPG key ID: E081FF12ADCB4AD5
2 changed files with 27 additions and 12 deletions

View file

@ -137,15 +137,6 @@ Currently the `type` attribute can be one of the following:
*path* must be a directory in the file system containing a file
named `flake.nix`.
If the directory or any of its parents is a Git repository, then
this is essentially equivalent to `git+file://<path>` (see below),
except that the `dir` parameter is derived automatically. For
example, if `/foo/bar` is a Git repository, then the flake reference
`/foo/bar/flake` is equivalent to `/foo/bar?dir=flake`.
If the directory is not inside a Git repository, then the flake
contents is the entire contents of *path*.
*path* generally must be an absolute path. However, on the command
line, it can be a relative path (e.g. `.` or `./foo`) which is
interpreted as relative to the current directory. In this case, it

View file

@ -58,8 +58,32 @@ the Nix store. Here are the recognised types of installables:
flake reference and *attrpath* is an optional attribute path. For
more information on flakes, see [the `nix flake` manual
page](./nix3-flake.md). Flake references are most commonly a flake
identifier in the flake registry (e.g. `nixpkgs`) or a path
(e.g. `/path/to/my-flake` or `.`).
identifier in the flake registry (e.g. `nixpkgs`), or a raw path
(e.g. `/path/to/my-flake` or `.` or `../foo`), or a full URL
(e.g. `github:nixos/nixpkgs` or `path:.`)
When the flake reference is a raw path (a path without any URL
scheme), it is interpreted in the following way:
- If the supplied path does not contain `flake.nix`, then Nix
searches for a directory containing `flake.nix` upwards of the
supplied path (until a filesystem boundary or a git repository
root). For example, if `/foo/bar/flake.nix` exists, then supplying
`/foo/bar/baz/` will find the directory `/foo/bar/`;
- If `flake.nix` is in a Git repository, then this is essentially
equivalent to `git+file://<directory>` (see [the `nix flake`
manual page](./nix3-flake.md)), except that the `dir` parameter is
derived automatically. For example, if `/foo/bar` is a Git
repository and `/foo/bar/baz` contains `flake.nix`, then the flake
reference `/foo/bar/baz` is equivalent to
`git+file:///foo/bar?dir=baz`. Note that it will only include
files indexed by git. In particular, files which are matched by
`.gitignore` will not be available in the flake. If this is
undesireable, specify `path:<directory>` explicitly;
- If the directory is not inside a Git repository, then it is
equivalent to `path:<directory>` (see [the `nix flake` manual
page](./nix3-flake.md)), which includes the entire contents of the
path.
If *attrpath* is omitted, Nix tries some default values; for most
subcommands, the default is `defaultPackage.`*system*