+461
-270
lib/fileset/default.nix
+461
-270
lib/fileset/default.nix
······A file set is a (mathematical) set of local files that can be added to the Nix store for use in Nix derivations.File sets are easy and safe to use, providing obvious and composable semantics with good error messages to prevent mistakes.···All functions accepting file sets as arguments can also accept [paths](https://nixos.org/manual/nix/stable/language/values.html#type-path) as arguments.···This is in contrast to using [paths in string interpolation](https://nixos.org/manual/nix/stable/language/values.html#type-path), which does add the entire referenced path to the store.··················# but that would then duplicate work for consumers of the fileset, because then they have to coerce it againAdd the local files contained in `fileset` to the store as a single [store path](https://nixos.org/manual/nix/stable/glossary#gloss-store-path) rooted at `root`.The result is the store path as a string-like value, making it usable e.g. as the `src` of a derivation, or in string interpolation:···-(required) The local directory [path](https://nixos.org/manual/nix/stable/language/values.html#type-path) that will correspond to the root of the resulting store path.Paths in [strings](https://nixos.org/manual/nix/stable/language/values.html#type-string), including Nix store paths, cannot be passed as `root`.···Changing `root` only affects the directory structure of the resulting store path, it does not change which files are added to the store.The only way to change which files get added to the store is by changing the `fileset` attribute.···If a directory does not recursively contain any file, it is omitted from the store path contents.······The resulting list of files can be turned back into a file set using [`lib.fileset.unions`](#function-library-lib.fileset.unions).···············See also [Difference (set theory)](https://en.wikipedia.org/wiki/Complement_(set_theory)#Relative_complement).·········-A file set can be turned back into a source using [`toSource`](#function-library-lib.fileset.toSource).-Turning the result of this function back into a source using `toSource` will therefore not preserve empty directories.······Create a file set containing all [Git-tracked files](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository) in a repository.This function behaves like [`gitTrackedWith { }`](#function-library-lib.fileset.gitTrackedWith) - using the defaults.-The [path](https://nixos.org/manual/nix/stable/language/values#type-path) to the working directory of a local Git repository.···Create a file set containing all [Git-tracked files](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository) in a repository.···-(optional, default: `false`) Whether to recurse into [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to also include their tracked files.-If `true`, this is equivalent to passing the [--recurse-submodules](https://git-scm.com/docs/git-ls-files#Documentation/git-ls-files.txt---recurse-submodules) flag to `git ls-files`.-The [path](https://nixos.org/manual/nix/stable/language/values#type-path) to the working directory of a local Git repository.throw "lib.fileset.gitTrackedWith: Expected the attribute `recurseSubmodules` of the first argument to be a boolean, but it's a ${typeOf recurseSubmodules} instead."
······A file set is a (mathematical) set of local files that can be added to the Nix store for use in Nix derivations.File sets are easy and safe to use, providing obvious and composable semantics with good error messages to prevent mistakes.···All functions accepting file sets as arguments can also accept [paths](https://nixos.org/manual/nix/stable/language/values.html#type-path) as arguments.···This is in contrast to using [paths in string interpolation](https://nixos.org/manual/nix/stable/language/values.html#type-path), which does add the entire referenced path to the store.··················# but that would then duplicate work for consumers of the fileset, because then they have to coerce it againAdd the local files contained in `fileset` to the store as a single [store path](https://nixos.org/manual/nix/stable/glossary#gloss-store-path) rooted at `root`.The result is the store path as a string-like value, making it usable e.g. as the `src` of a derivation, or in string interpolation:···+: The local directory [path](https://nixos.org/manual/nix/stable/language/values.html#type-path) that will correspond to the root of the resulting store path.Paths in [strings](https://nixos.org/manual/nix/stable/language/values.html#type-string), including Nix store paths, cannot be passed as `root`.···Changing `root` only affects the directory structure of the resulting store path, it does not change which files are added to the store.The only way to change which files get added to the store is by changing the `fileset` attribute.···If a directory does not recursively contain any file, it is omitted from the store path contents.······The resulting list of files can be turned back into a file set using [`lib.fileset.unions`](#function-library-lib.fileset.unions).+: The file set whose file paths to return. This argument can also be a path, which gets [implicitly coerced to a file set](#sec-fileset-path-coercion).···+: The first file set. This argument can also be a path, which gets [implicitly coerced to a file set](#sec-fileset-path-coercion).+: The second file set. This argument can also be a path, which gets [implicitly coerced to a file set](#sec-fileset-path-coercion).······+: A list of file sets. The elements can also be paths, which get [implicitly coerced to file sets](#sec-fileset-path-coercion).···+: The first file set. This argument can also be a path, which gets [implicitly coerced to a file set](#sec-fileset-path-coercion).+: The second file set. This argument can also be a path, which gets [implicitly coerced to a file set](#sec-fileset-path-coercion).···See also [Difference (set theory)](https://en.wikipedia.org/wiki/Complement_(set_theory)#Relative_complement).+: The positive file set. The result can only contain files that are also in this file set. This argument can also be a path, which gets [implicitly coerced to a file set](#sec-fileset-path-coercion).+: The negative file set. The result will never contain files that are also in this file set. This argument can also be a path, which gets [implicitly coerced to a file set](#sec-fileset-path-coercion).·········+A file set can be turned back into a source using [`toSource`](#function-library-lib.fileset.toSource).+Turning the result of this function back into a source using `toSource` will therefore not preserve empty directories.······Create a file set containing all [Git-tracked files](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository) in a repository.This function behaves like [`gitTrackedWith { }`](#function-library-lib.fileset.gitTrackedWith) - using the defaults.+: The [path](https://nixos.org/manual/nix/stable/language/values#type-path) to the working directory of a local Git repository.···Create a file set containing all [Git-tracked files](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository) in a repository.···+: Whether to recurse into [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to also include their tracked files.+If `true`, this is equivalent to passing the [--recurse-submodules](https://git-scm.com/docs/git-ls-files#Documentation/git-ls-files.txt---recurse-submodules) flag to `git ls-files`.+: The [path](https://nixos.org/manual/nix/stable/language/values#type-path) to the working directory of a local Git repository.throw "lib.fileset.gitTrackedWith: Expected the attribute `recurseSubmodules` of the first argument to be a boolean, but it's a ${typeOf recurseSubmodules} instead."