Noogλe
Function of the day
Create a file set containing all Git-tracked files in a repository. The first argument allows configuration with an attribute set, while the second argument is the path to the Git working tree.
gitTrackedWith
does not perform any filtering when the path is a Nix store path and not a repository. In this way, it accommodates the use case where the expression that makes thegitTracked
call does not reside in an actual git repository anymore, and has presumably already been fetched in a way that excludes untracked files. Fetchers with such equivalent behavior includebuiltins.fetchGit
,builtins.fetchTree
(experimental), andpkgs.fetchgit
when used withoutleaveDotGit
.If you don't need the configuration, you can use
gitTracked
instead.This is equivalent to the result of
unions
on all files returned bygit ls-files
(which uses--cached
by default).Currently this function is based on
builtins.fetchGit
As such, this function causes all Git-tracked files to be unnecessarily added to the Nix store, without being re-usable bytoSource
.This may change in the future.
Inputs
options
(attribute set)-
recurseSubmodules
(optional, default:false
)- Whether to recurse into Git submodules to also include their tracked files.
If
true
, this is equivalent to passing the --recurse-submodules flag togit ls-files
. path
- The path to the working directory of a local Git repository.
This directory must contain a
.git
file or subdirectory.
Type
gitTrackedWith :: { recurseSubmodules :: Bool ? false } -> Path -> FileSet
Examples
lib.fileset.gitTrackedWith
usage example# Include all files tracked by the Git repository in the current directory # and any submodules under it gitTracked { recurseSubmodules = true; } ./.