Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
files: add helper function
mkOutOfStoreSymlink
Using this function it is possible to make `home.file` create a symlink to a path outside the Nix store. For example, a Home Manager configuration containing home.file."foo".source = config.lib.file.mkOutOfStoreSymlink ./bar; would upon activation create a symlink `~/foo` that points to the absolute path of the `bar` file relative the configuration file. PR #1211
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
files-executable = ./executable.nix; | ||
files-hidden-source = ./hidden-source.nix; | ||
files-out-of-store-symlink = ./out-of-store-symlink.nix; | ||
files-source-with-spaces = ./source-with-spaces.nix; | ||
files-text = ./text.nix; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ config, lib, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
|
||
filePath = ./. + "/source with spaces!"; | ||
|
||
in { | ||
config = { | ||
home.file."oos".source = config.lib.file.mkOutOfStoreSymlink filePath; | ||
|
||
nmt.script = '' | ||
assertLinkExists "home-files/oos" | ||
storePath="$(readlink $TESTED/home-files/oos)" | ||
if [[ ! -L $storePath ]]; then | ||
fail "Expected $storePath to be a symbolic link, but it was not." | ||
fi | ||
actual="$(readlink "$storePath")" | ||
expected="${toString filePath}" | ||
if [[ $actual != $expected ]]; then | ||
fail "Symlink home-files/oos should point to $expected via the Nix store, but it actually points to $actual." | ||
fi | ||
''; | ||
}; | ||
} |