Skip to content

NPV 127

Philip Taron edited this page Feb 16, 2026 · 1 revision

NPV-127: Absolute path expression in Nix file

Description

Nix files under pkgs/by-name must not contain absolute path expressions (paths starting with /). Absolute paths are machine-specific and not allowed in Nixpkgs.

Error message

{relative_package_dir}: File {subpath} at line {line} contains the absolute path expression "{text}", which is not allowed in nixpkgs.

Example

Given pkgs/by-name/aa/aa/package.nix:

{ someDrv }: someDrv // { escape = /foo; }

The error is:

pkgs/by-name/aa/aa: File package.nix at line 1 contains the absolute path expression "/foo", which is not allowed in nixpkgs.

How to fix

Remove the absolute path. Use relative paths within the package directory, or pass the path as a callPackage argument. If you need to reference a system path at build time, use a string instead (e.g., "/foo" as a string, not /foo as a Nix path).

Clone this wiki locally