fix(nix/dependency-analyzer): ignore non-drv paths for Nix < 2.6
Looking for .drv file names in non .drv files doesn't make sense, as it less reliably a reference in those cases. Matches behavior of the function for Nix >= 2.6. Change-Id: I79fc1da3e55df869f03702fa5137d030790bc4eb Reviewed-on: https://cl.tvl.fyi/c/depot/+/11114 Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Reviewed-by: aspen <root@gws.fyi>
This commit is contained in:
parent
d1da9f5c84
commit
4a91197802
1 changed files with 29 additions and 24 deletions
|
@ -16,6 +16,8 @@ let
|
||||||
#
|
#
|
||||||
# TODO(sterni): clean this up and expose it
|
# TODO(sterni): clean this up and expose it
|
||||||
directDrvDeps =
|
directDrvDeps =
|
||||||
|
let
|
||||||
|
getDeps =
|
||||||
if lib.versionAtLeast builtins.nixVersion "2.6"
|
if lib.versionAtLeast builtins.nixVersion "2.6"
|
||||||
then
|
then
|
||||||
# Since https://github.com/NixOS/nix/pull/1643, Nix apparently »preserves
|
# Since https://github.com/NixOS/nix/pull/1643, Nix apparently »preserves
|
||||||
|
@ -23,16 +25,11 @@ let
|
||||||
# that it becomes possible to query the actual references a store path has.
|
# that it becomes possible to query the actual references a store path has.
|
||||||
# Not a 100% sure this is intended, but _very_ convenient for us here.
|
# Not a 100% sure this is intended, but _very_ convenient for us here.
|
||||||
drvPath:
|
drvPath:
|
||||||
# if the passed path is not a derivation we can't necessarily get its
|
builtins.attrNames (builtins.getContext (builtins.readFile drvPath))
|
||||||
# dependencies, since it may not be representable as a Nix string due to
|
|
||||||
# NUL bytes, e.g. compressed patch files imported into the Nix store.
|
|
||||||
if builtins.match "^.+\\.drv$" drvPath == null
|
|
||||||
then [ ]
|
|
||||||
else builtins.attrNames (builtins.getContext (builtins.readFile drvPath))
|
|
||||||
else
|
else
|
||||||
# For Nix < 2.6 we have to rely on HACK, namely grepping for quoted store
|
# For Nix < 2.6 we have to rely on HACK, namely grepping for quoted
|
||||||
# path references in the file. In the future this should be replaced by
|
# store path references in the file. In the future this should be
|
||||||
# a proper derivation parser.
|
# replaced by a proper derivation parser.
|
||||||
drvPath: builtins.concatLists (
|
drvPath: builtins.concatLists (
|
||||||
builtins.filter builtins.isList (
|
builtins.filter builtins.isList (
|
||||||
builtins.split
|
builtins.split
|
||||||
|
@ -40,6 +37,14 @@ let
|
||||||
(builtins.readFile drvPath)
|
(builtins.readFile drvPath)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
in
|
||||||
|
drvPath:
|
||||||
|
# if the passed path is not a derivation we can't necessarily get its
|
||||||
|
# dependencies, since it may not be representable as a Nix string due to
|
||||||
|
# NUL bytes, e.g. compressed patch files imported into the Nix store.
|
||||||
|
if builtins.match "^.+\\.drv$" drvPath == null
|
||||||
|
then [ ]
|
||||||
|
else getDeps drvPath;
|
||||||
|
|
||||||
# Maps a list of derivation to the list of corresponding `drvPath`s.
|
# Maps a list of derivation to the list of corresponding `drvPath`s.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue