query
On this page

traceVal

lib.fileset.traceVal

Docs pulled from | This Revision | about 3 hours ago


Incrementally evaluate and trace a file set in a pretty way. This function is only intended for debugging purposes. The exact tracing format is unspecified and may change.

This function returns the given file set. In comparison, trace takes another argument to return.

This variant is useful for tracing file sets passed as arguments to other functions.

Inputs

fileset

The file set to trace and return.

This argument can also be a path, which gets implicitly coerced to a file set.

Type

traceVal :: FileSet -> FileSet

Examples

lib.fileset.traceVal usage example

toSource {
  root = ./.;
  fileset = traceVal (unions [
    ./Makefile
    ./src
    ./tests/run.sh
  ]);
}
=>
trace: /home/user/src/myProject
trace: - Makefile (regular)
trace: - src (all files in directory)
trace: - tests
trace:   - run.sh (regular)
"/nix/store/...-source"

Noogle detected

Implementation

The following is the current implementation of this function.

traceVal =
    fileset:
    let
      # "fileset" would be a better name, but that would clash with the argument name,
      # and we cannot change that because of https://github.com/nix-community/nixdoc/issues/76
      actualFileset = _coerce "lib.fileset.traceVal: Argument" fileset;
    in
    seq (_printFileset actualFileset)
      # We could also return the original fileset argument here,
      # but that would then duplicate work for consumers of the fileset, because then they have to coerce it again
      actualFileset;