depot/third_party/nixpkgs/pkgs/build-support/dev-shell-tools/default.nix
Default email f34ce41345 Project import generated by Copybara.
GitOrigin-RevId: b73c2221a46c13557b1b3be9c2070cc42cf01eb3
2024-07-27 08:49:29 +02:00

16 lines
613 B
Nix

{ lib }:
let
inherit (builtins) typeOf;
in
rec {
# This function closely mirrors what this Nix code does:
# https://github.com/NixOS/nix/blob/2.8.0/src/libexpr/primops.cc#L1102
# https://github.com/NixOS/nix/blob/2.8.0/src/libexpr/eval.cc#L1981-L2036
valueToString = value:
# We can't just use `toString` on all derivation attributes because that
# would not put path literals in the closure. So we explicitly copy
# those into the store here
if typeOf value == "path" then "${value}"
else if typeOf value == "list" then toString (map valueToString value)
else toString value;
}