In the case where `/nix` is a link, for example, on macOS Catalina,
`builtins.storeDir` returns `/nix`, not the canonical location.
This causes tests on existing files to result in Home Manager thinking
those files are outside of the store.
This change uses `readlink` on the store path so that the tests work
as intended.
(cherry picked from commit 0e9b7aab3c)
When a configuration file would be written to an existing file, rather
than failing switch (and having the user have to move or delete those
files), move the files automatically to a new path.
Closes#585
Add parens to expression so the `-exec` includes files matching both.
Otherwise (before this change) the `-exec` is only invoked for
links (`-type l`):
file or (link -> doexec)
=>
(file or link) -> doexec
In particular support source files whose name start with `.` or
contain characters not allowed in the nix store, such as spaces.
Also add some test cases for `home.file`.
In particular, don't bother attempting to do substitution of the home
files and home generation derivations since these rarely, if ever,
could be substituted.
Fixes#330
Unfortunately systemd derives nonsensical unit names when the unit
file is a link to a link to a file. This commit ensures that any file
whose target path matches the pattern `*/systemd/user/*` will be
reachable with only one link hop.
This also reverts f52ec0df7c, which
contained a temporary fix. This commit is an improvements in that it
is more explicit and also handles unit files given directly as a home
file source.
By sanitizing the home file name in the derivation name, the home file
name is no longer exposed to the naming restrictions for nix store
paths.
For example, it is now possible to define home files with spaces in
their names without providing a target or source attribute.