Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

LiteralPath (Relative/Absolute Path)

Definition

LiteralPath FilePath

Fields

FieldTypeDescription
contentsFilePathThe path string (e.g., ./foo.nix, /etc/config)

Description

LiteralPath represents paths written without angle brackets: relative paths like ./foo.nix, ../bar.nix, or absolute paths like /etc/nixos/configuration.nix. These are resolved relative to the current file or as absolute paths, distinct from search-path paths.

Nix Source ↔ AST

# Nix
./foo.nix

# AST
{
  "tag": "LiteralPath",
  "contents": "./foo.nix"
}
# Nix
../config.nix

# AST
{
  "tag": "LiteralPath",
  "contents": "../config.nix"
}
# Nix
/etc/nixos/configuration.nix

# AST
{
  "tag": "LiteralPath",
  "contents": "/etc/nixos/configuration.nix"
}
  • EnvPath: search paths like <nixpkgs>

Nix Library Access

syntax.mkLiteralPath "./foo.nix"
syntax.mkLiteralPath "/etc/nixos/configuration.nix"