pkgs/den-http-get-updater: assert no path is located in nix store

This commit is contained in:
Wroclaw 2025-05-18 19:35:34 +02:00
parent cb05ce5b44
commit 595c2828b0

View file

@ -44,7 +44,16 @@
}: }:
let let
realFileLocation = builtins.toString fileLocation; assertNoStorePathPrefix = path:
assert lib.assertMsg (!lib.hasPrefix builtins.storeDir path) ''
The path '${path}' is a store path.
den-http-get-updater must be evaluated in impure mode,
in order to modify target files, and this cannot be done
with files in the store.
''; path;
realFileLocation = assertNoStorePathPrefix (builtins.toString fileLocation);
prefetchList' = lib.map (x: prefetchList' = lib.map (x:
assert builtins.isNull x.prefetchUrlLocation || lib.isAttrs x.prefetchUrlLocation; assert builtins.isNull x.prefetchUrlLocation || lib.isAttrs x.prefetchUrlLocation;
@ -58,7 +67,7 @@ let
name = if x.unpack or unpack then "source" else null; name = if x.unpack or unpack then "source" else null;
mark = builtins.hashString "sha256" x.previousHash; mark = builtins.hashString "sha256" x.previousHash;
markRegexEscape = lib.escapeRegex mark; markRegexEscape = lib.escapeRegex mark;
realFileLocation = builtins.toString x.fileLocation or fileLocation; realFileLocation = assertNoStorePathPrefix (builtins.toString x.realFileLocation or fileLocation);
realFileLocationShellEscape = lib.escapeShellArg realFileLocation; realFileLocationShellEscape = lib.escapeShellArg realFileLocation;
prefetchUrlLocationShellEscape = lib.mapAttrs (_: lib.escapeShellArg) x.prefetchUrlLocation; prefetchUrlLocationShellEscape = lib.mapAttrs (_: lib.escapeShellArg) x.prefetchUrlLocation;
previousHashRegexEscape = lib.escapeRegex x.previousHash; previousHashRegexEscape = lib.escapeRegex x.previousHash;