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,30 +16,35 @@ let
|
||||||
#
|
#
|
||||||
# TODO(sterni): clean this up and expose it
|
# TODO(sterni): clean this up and expose it
|
||||||
directDrvDeps =
|
directDrvDeps =
|
||||||
if lib.versionAtLeast builtins.nixVersion "2.6"
|
let
|
||||||
then
|
getDeps =
|
||||||
# Since https://github.com/NixOS/nix/pull/1643, Nix apparently »preserves
|
if lib.versionAtLeast builtins.nixVersion "2.6"
|
||||||
# string context« through a readFile invocation. This has the side effect
|
then
|
||||||
# that it becomes possible to query the actual references a store path has.
|
# Since https://github.com/NixOS/nix/pull/1643, Nix apparently »preserves
|
||||||
# Not a 100% sure this is intended, but _very_ convenient for us here.
|
# string context« through a readFile invocation. This has the side effect
|
||||||
drvPath:
|
# that it becomes possible to query the actual references a store path has.
|
||||||
# if the passed path is not a derivation we can't necessarily get its
|
# Not a 100% sure this is intended, but _very_ convenient for us here.
|
||||||
# dependencies, since it may not be representable as a Nix string due to
|
drvPath:
|
||||||
# NUL bytes, e.g. compressed patch files imported into the Nix store.
|
builtins.attrNames (builtins.getContext (builtins.readFile drvPath))
|
||||||
if builtins.match "^.+\\.drv$" drvPath == null
|
else
|
||||||
then [ ]
|
# For Nix < 2.6 we have to rely on HACK, namely grepping for quoted
|
||||||
else builtins.attrNames (builtins.getContext (builtins.readFile drvPath))
|
# store path references in the file. In the future this should be
|
||||||
else
|
# replaced by a proper derivation parser.
|
||||||
# For Nix < 2.6 we have to rely on HACK, namely grepping for quoted store
|
drvPath: builtins.concatLists (
|
||||||
# path references in the file. In the future this should be replaced by
|
builtins.filter builtins.isList (
|
||||||
# a proper derivation parser.
|
builtins.split
|
||||||
drvPath: builtins.concatLists (
|
"\"(${lib.escapeRegex builtins.storeDir}/[[:alnum:]+._?=-]+.drv)\""
|
||||||
builtins.filter builtins.isList (
|
(builtins.readFile drvPath)
|
||||||
builtins.split
|
)
|
||||||
"\"(${lib.escapeRegex builtins.storeDir}/[[:alnum:]+._?=-]+.drv)\""
|
);
|
||||||
(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