mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
The current behavior of `home.file` is inconsistent when handling
recursive file with another, overlapping, non-recursive file.
Specifically, consider a configuration
```nix
home.file = {
"foo" = { source = ./foo; recursive = true; };
"foo/bar".text = "some other file";
};
```
where `./foo` is a directory containing a file `bar`. Switching to
this configuration will result in the `./foo` directory being
recursively symlinked while the "foo/bar" entry is ignored. Note,
building the home files derivation does log
> File conflict for file 'foo/bar'
On the other hand, the supposedly equivalent configuration
```nix
home.file = {
"foo" = { source = ./foo; recursive = true; };
abc = { target = "foo/bar"; text = "some other file"; };
};
```
results in the `./foo` directory not being recursively symlinked,
i.e., only the file `foo/bar` shows up in the built configuration.
This time the home files build log contains
> File conflict for file 'foo'
This commit makes the behavior more consistent in that we always
handle the file in a unified manner. The conflict resolution is
offered in three flavors, "ignore", "error", and "override" indicating
whether the recursively symlinked file wins, the entire build errors
out, and the regularly symlinked file wins.
The current default is "ignore" since it is the resolution that most
closely matches the current behavior, at least when the file attribute
name is used as the target path.
The other two resolutions can be chosen by setting the
`home.fileOverlapResolution` option, which is set as invisible due to
its experimental nature.