From 075597b340f937b082561e8d796170614fbd7c3c Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 14 Mar 2024 23:53:56 +0000 Subject: [PATCH] stdenv: don't discard string context from ContentAddressed derivations Without the change build for packages that use `disallowedReferences` fails in `contentAddressedByDefault = true` mode: $ nix build -f. ruby_3_1 --arg config '{ contentAddressedByDefault = true; }' ... error: derivation contains an illegal reference specifier '/0j3hif3ni7zl5zhlzzr5q2q23z66136mnzp75pyiqp5c72q14im2' error: 1 dependencies of derivation '/nix/store/39ji7qp225pxvrm8cgvzmyjqsyis2n0h-ruby-3.1.2.drv' failed to build Original intent of https://github.com/NixOS/nixpkgs/pull/211783 was to avoid pulling in actual derivation for reference scanning purposes. Unfortunately CA derivations's outputPath are placeholders until they are instantiated. Let's restore string context for CA derivations for now. --- pkgs/stdenv/generic/make-derivation.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index d4d5ee46638a..ca878fe1032d 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -139,7 +139,7 @@ let # Turn a derivation into its outPath without a string context attached. # See the comment at the usage site. unsafeDerivationToUntrackedOutpath = drv: - if isDerivation drv + if isDerivation drv && (!drv.__contentAddressed or false) then builtins.unsafeDiscardStringContext drv.outPath else drv;