replaceDependencies: Fix with ca-derivations (#415661)

This commit is contained in:
Philip Taron
2025-10-09 17:20:58 +00:00
committed by GitHub
2 changed files with 24 additions and 4 deletions

View File

@@ -43,7 +43,7 @@ let
inherit (builtins) unsafeDiscardStringContext appendContext; inherit (builtins) unsafeDiscardStringContext appendContext;
inherit (lib) inherit (lib)
listToAttrs listToAttrs
isStorePath isStringLike
readFile readFile
attrValues attrValues
mapAttrs mapAttrs
@@ -53,6 +53,16 @@ let
; ;
inherit (lib.attrsets) mergeAttrsList; inherit (lib.attrsets) mergeAttrsList;
isNonCaStorePath =
x:
if isStringLike x then
let
str = toString x;
in
builtins.substring 0 1 str == "/" && (dirOf str == builtins.storeDir)
else
false;
toContextlessString = x: unsafeDiscardStringContext (toString x); toContextlessString = x: unsafeDiscardStringContext (toString x);
warn = if verbose then lib.warn else (x: y: y); warn = if verbose then lib.warn else (x: y: y);
@@ -90,7 +100,7 @@ let
realisation = realisation =
drv: drv:
if isStorePath drv then if isNonCaStorePath drv then
# Input-addressed and fixed-output derivations have their realisation as outPath. # Input-addressed and fixed-output derivations have their realisation as outPath.
toContextlessString drv toContextlessString drv
else else

View File

@@ -12,20 +12,30 @@
}: }:
let let
inherit (lib) inherit (lib)
isStorePath isStringLike
substring substring
stringLength stringLength
optionalString optionalString
escapeShellArgs escapeShellArgs
concatMap concatMap
; ;
isNonCaStorePath =
x:
if isStringLike x then
let
str = toString x;
in
builtins.substring 0 1 str == "/" && (dirOf str == builtins.storeDir)
else
false;
in in
if replacements == [ ] then if replacements == [ ] then
drv drv
else else
let let
drvName = drvName =
if isStorePath drv then if isNonCaStorePath drv then
# Reconstruct the name from the actual store path if available. # Reconstruct the name from the actual store path if available.
substring 33 (stringLength (baseNameOf drv)) (baseNameOf drv) substring 33 (stringLength (baseNameOf drv)) (baseNameOf drv)
else if drv ? drvAttrs.name then else if drv ? drvAttrs.name then