diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-09-21 01:01:45 +0200 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-10-04 16:30:10 +0200 |
commit | 467e428f0061bc25841ab7e555aee25bfa24c39b (patch) | |
tree | de432bfd5c4c79f9eb37c5a68eec01373e07fe9a /lib/fileset/default.nix | |
parent | ac2c8d321c879aa36046d404661e8a3e9c7a93fe (diff) |
lib.fileset.trace: init
Diffstat (limited to 'lib/fileset/default.nix')
-rw-r--r-- | lib/fileset/default.nix | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/fileset/default.nix b/lib/fileset/default.nix index ab26112c94709..8eee7cf70003a 100644 --- a/lib/fileset/default.nix +++ b/lib/fileset/default.nix @@ -6,12 +6,14 @@ let _coerceMany _toSourceFilter _unionMany + _printFileset ; inherit (builtins) isList isPath pathExists + seq typeOf ; @@ -275,4 +277,39 @@ If a directory does not recursively contain any file, it is omitted from the sto _unionMany ]; + /* + 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. + + Type: + trace :: FileSet -> Any -> Any + + Example: + trace (unions [ ./Makefile ./src ./tests/run.sh ]) null + => + trace: /home/user/src/myProject + trace: - Makefile (regular) + trace: - src (all files in directory) + trace: - tests + trace: - run.sh (regular) + null + */ + trace = + /* + The file set to trace. + + This argument can also be a path, + which gets [implicitly coerced to a file set](#sec-fileset-path-coercion). + */ + 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.trace: argument" fileset; + in + seq + (_printFileset actualFileset) + (x: x); + } |