NixOS / nixpkgs-vet

Tool to vet (check) Nixpkgs, including its pkgs/by-name directory
MIT License
29 stars 7 forks source link

Incorrect warning for "contains the path expression ... which may point outside the directory of that package" #113

Open Mic92 opened 1 month ago

Mic92 commented 1 month ago

In this pull request: https://github.com/NixOS/nixpkgs/pull/344127

With the following nix-shell:

{                                   
  pkgs ? import ../../../.. { },    
}:                                  
pkgs.switch-to-configuration-ng

in pkgs/by-name/sw/switch-to-configuration-ng, I get:

 if result/bin/nixpkgs-vet --base "$base" .; then
    exit 0
  else
    exitCode=$?
    echo "To run locally: ./ci/nixpkgs-vet.sh $GITHUB_BASE_REF https://github.com/$GITHUB_REPOSITORY.git"
    echo "If you're having trouble, ping @NixOS/nixpkgs-vet"
    exit "$exitCode"
  fi
  shell: /usr/bin/bash -e {0}
  env:
    mergedSha: ed7535a632177a6c51f0011a40445af80c0c1d2e
    base: /tmp/tmp.oS66tb8QYG
    TMPDIR: /home/runner/work/_temp
    CLICOLOR_FORCE: 1
- pkgs/by-name/sw/switch-to-configuration-ng: File shell.nix at line 2 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/sw/switch-to-configuration-ng directory.

The nix-shell points to the toplevel of nixpkgs, so it should not produce this error.