-
-
Notifications
You must be signed in to change notification settings - Fork 14
NPV 123
Philip Taron edited this page Feb 16, 2026
·
1 revision
Nix files under pkgs/by-name must not contain path expressions that resolve to locations outside the package's own directory. This creates hidden dependencies between internal Nixpkgs paths, making reorganization difficult.
{relative_package_dir}: File {subpath} at line {line} contains the path expression "{text}" which may point outside the directory of that package.
This is undesirable because it creates dependencies between internal paths, making it harder to reorganise Nixpkgs in the future.
Alternatives include:
- If you are creating a new version of a package with a common file between versions, consider following the recommendation in https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name#recommendation-for-new-packages-with-multiple-versions.
- If the path being referenced could be considered a stable interface with multiple uses, consider exposing it via a `pkgs` attribute, then taking it as a attribute argument in package.nix.
- If the path being referenced is internal and has multiple uses, consider passing the file as an explicit `callPackage` argument in `pkgs/top-level/all-packages.nix`.
- If the path being referenced is internal and will need to be modified independently of the original, consider copying it into the {relative_package_dir} directory.
Given pkgs/by-name/aa/aa/package.nix:
{ someDrv }: someDrv // { escape = ../.; }The error is:
pkgs/by-name/aa/aa: File package.nix at line 1 contains the path expression "../." which may point outside the directory of that package.
This is undesirable because it creates dependencies between internal paths, making it harder to reorganise Nixpkgs in the future.
Alternatives include:
- If you are creating a new version of a package with a common file between versions, consider following the recommendation in https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name#recommendation-for-new-packages-with-multiple-versions.
- If the path being referenced could be considered a stable interface with multiple uses, consider exposing it via a `pkgs` attribute, then taking it as a attribute argument in package.nix.
- If the path being referenced is internal and has multiple uses, consider passing the file as an explicit `callPackage` argument in `pkgs/top-level/all-packages.nix`.
- If the path being referenced is internal and will need to be modified independently of the original, consider copying it into the pkgs/by-name/aa/aa directory.
Follow one of the alternatives listed in the error message:
- For multi-version packages, see the
pkgs/by-nameREADME recommendation. - Expose shared files as
pkgsattributes and take them aspackage.nixarguments. - Pass the file as an explicit
callPackageargument inall-packages.nix. - Copy the file into the package directory if it needs independent modification.