Nix string builtins

  • concatStringsSep separator list - concat a list of strings with a separator between each element
  • fromJSON e - Convert a JSON string to a Nix value
  • hashString type s - Return a base-16 representation of the cryptographic hash of s under algorithm type, one of md5 or sha1/256/512
  • isString e - true if e is a string, otherwise false
  • match regex str - return a list of matches if regex matches str, otherwise null
  • replaceStrings from to s - replaces each element of from in s with the corresponding element in to
  • split regex str - returns a list of elements in str not matching regex, interleaved with lists of elements matching regex
  • stringLength e - length of string e
  • substring start len s - return the substring of length len from 0-indexed position start in string s
  • toFile name s - write s to a file in the Nix store with suffix name and return its path; CAVEAT: The result of a derivation cannot be antiquoted in such a string, though writeTextFile in nixpkgs can
  • toJSON e - return a JSON string representing e; standard types and data structures map to JSON naturally, but derivations and paths evaluate to store path strings
  • toXML e - return an XML representation of e