Flakes corresponding to a local path can also be referred to by a direct
path reference, either `/absolute/path/to/the/flake` or`./relative/path/to/the/flake`.
Note that the leading `./` is mandatory for relative paths. If it is
omitted, the path will be interpreted as [URL-like syntax](#url-like-syntax),
which will cause error messages like this:
```console
error: cannot find flake 'flake:relative/path/to/the/flake' in the flake registries
```
The semantic of such a path is as follows:
* If the directory is part of a Git repository, then the input will be treated as a `git+file:` URL, otherwise it will be treated as a `path:` url;
* If the directory doesn't contain a `flake.nix` file, then Nix will search for such a file upwards in the file system hierarchy until it finds any of:
1. The Git repository root, or
2. The filesystem root (/), or
3. A folder on a different mount point.
Contrary to URL-like references, path-like flake references can contain arbitrary unicode characters (except `#` and `?`).
### Examples
* `.`: The flake to which the current directory belongs.
* `/home/alice/src/patchelf`: A flake in some other directory.
* `./../sub directory/with Ûñî©ôδ€`: A flake in another relative directory that
has Unicode characters in its name.
## Flake reference attributes
The following generic flake reference attributes are supported:
* `dir`: The subdirectory of the flake in which `flake.nix` is
located. This parameter enables having multiple flakes in a
repository or tarball. The default is the root directory of the
flake.
* `narHash`: The hash of the
[Nix Archive (NAR) serialisation][Nix Archive]
(in SRI format) of the
contents of the flake. This is useful for flake types such as
tarballs that lack a unique content identifier such as a Git commit
hash.
In addition, the following attributes are common to several flake
reference types:
* `rev`: A Git or Mercurial commit hash.
* `ref`: A Git or Mercurial branch or tag name.
Finally, some attributes are typically not specified by the user, but
can occur in *locked* flake references and are available to Nix code:
* `revCount`: The number of ancestors of the commit `rev`.
* `lastModified`: The timestamp (in seconds since the Unix epoch) of
the last modification of this version of the flake. For
Git/Mercurial flakes, this is the commit time of commit *rev*, while
for tarball flakes, it's the most recent timestamp of any file
inside the tarball.
## Types
Currently the `type` attribute can be one of the following:
* `indirect`: *The default*. These are symbolic references to flakes
that are looked up in [the flake registries](./nix3-registry.md).
These have the form
```
[flake:]<flake-id>(/<rev-or-ref>(/rev)?)?
```
These perform a lookup of `<flake-id>` in the flake registry. For
example, `nixpkgs` and `nixpkgs/release-20.09` are indirect flake
references. The specified `rev` and/or `ref` are merged with the
entry in the registry; see [nix registry](./nix3-registry.md) for
details.
For example, these are valid indirect flake references:
* `nixpkgs`
* `nixpkgs/nixos-unstable`
* `nixpkgs/a3a3dda3bacf61e8a39258a0ed9c924eeca8e293`
* `nixpkgs/nixos-unstable/a3a3dda3bacf61e8a39258a0ed9c924eeca8e293`
* `sub/dir` (if a flake named `sub` is in the registry)
* <a name="path-fetcher"></a>`path`: arbitrary local directories. The required attribute `path`
specifies the path of the flake. The URL form is
```
path:<path>(\?<params>)?
```
where *path* is an absolute path to a directory in the file system
containing a file named `flake.nix`.
If the flake at *path* is not inside a git repository, the `path:`
prefix is implied and can be omitted.
If *path* is a relative path (i.e. if it does not start with `/`),
it is interpreted as follows:
- If *path* is a command line argument, it is interpreted relative
to the current directory.
- If *path* is used in a `flake.nix`, it is interpreted relative to