about summary refs log tree commit diff
path: root/pkgs/build-support/safe-discard-string-context.nix
blob: 293a15295d55486ca582c631ddf07c927530a5a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# | Discard the context of a string while ensuring that expected path
# validity invariants hold.
#
# This relies on import-from-derivation, but it is only useful in
# contexts where the string is going to be used in an
# import-from-derivation anyway.
#
# safeDiscardStringContext : String → String
{ writeText }: s:
  builtins.seq
    (import (writeText
               "discard.nix"
               "${builtins.substring 0 0 s}null\n"))
    (builtins.unsafeDiscardStringContext s)