about summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-10-11T12·28+0200
committerclbot <clbot@tvl.fyi>2022-10-11T18·35+0000
commit8149ca5c3802d0dd757224afb74f6b46cc55a7dd (patch)
tree21b0c2cfa3b4383d496b06d92cde995299c04c3a /nix
parent0025a6fd64465e1c1fd42ec4e86535cf184e0ad4 (diff)
fix(nix/dependency-analyzer): don't read from non-drv store paths r/5108
Emitting dependencies on non-drv store paths from drv directDrvDeps is
fine and actually correct, even though the Nix 2.3 version can't do it
at the moment (but this would change when the placeholder implementation
is replaced using a drv parser). However, we can't necessarily determine
the dependencies of non-drv store paths because such store paths may be
binary files that can't be read in by readFile due to NUL bytes.

Change-Id: Ifbd101adaee4f32f10c010fa79e19b9b1127fc6a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6945
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'nix')
-rw-r--r--nix/dependency-analyzer/default.nix8
1 files changed, 7 insertions, 1 deletions
diff --git a/nix/dependency-analyzer/default.nix b/nix/dependency-analyzer/default.nix
index c988d9409da4..e127c82d7777 100644
--- a/nix/dependency-analyzer/default.nix
+++ b/nix/dependency-analyzer/default.nix
@@ -38,7 +38,13 @@ let
     # string context« through a readFile invocation. This has the side effect
     # 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.
-      drvPath: builtins.attrNames (builtins.getContext (builtins.readFile drvPath))
+      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 builtins.attrNames (builtins.getContext (builtins.readFile drvPath))
     else
     # For Nix < 2.6 we have to rely on HACK, namely grepping for quoted store
     # path references in the file. In the future this should be replaced by