lib.fileset: file set functions
lib.fileset.toSource
Type:
toSource :: {
root :: Path,
fileset :: FileSet,
} -> SourceLike
Add the local files contained in fileset
to the store as a single 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:
stdenv.mkDerivation {
src = lib.fileset.toSource { ... };
# ...
}
The name of the store path is always source
.
structured function argument
-
:
root
-
(required) The local directory path that will correspond to the root of the resulting store path. Paths in strings, including Nix store paths, cannot be passed as
root
.root
has to be a directory.
Note
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.
-
fileset
-
(required) The file set whose files to import into the store. Currently the only way to construct file sets is using implicit coercion from paths. If a directory does not recursively contain any file, it is omitted from the store path contents.
Example
lib.fileset.toSource
usage example
# Import the current directory into the store but only include files under ./src
toSource { root = ./.; fileset = ./src; }
=> "/nix/store/...-source"
# The file set coerced from path ./bar could contain files outside the root ./foo, which is not allowed
toSource { root = ./foo; fileset = ./bar; }
=> <error>
# The root has to be a local filesystem path
toSource { root = "/nix/store/...-source"; fileset = ./.; }
=> <error>
Located at lib/fileset/default.nix:66 in <nixpkgs>
.