I have some home directory configs I declare like this:
home.file."path/to/example" = {
enable = true;
recursive = true;
source =
if lib.trivial.inPureEvalMode
then config.programs.pathToExampleFlake # set to store version of example flake
else lib.warn "Using impure symlink for example config!" config.lib.file.mkOutOfStoreSymlink "/absolute/path/to/example/flake";
};
This allows me to just nixos-rebuild switch --impure and I have interactive versions for quick prototyping of any relevant configs.
But when switching from impure to pure, the existence of the symlink means the example flake I use will get overridden with a symlink to its own nix store version.
Is there a way to ensure home.file doesn’t follow symlinks when overriding stuff? Or to manually remove the symlinks before overriding the directory?
I use --impure here more as a hacky way to pass a (1-bit) argument to the flake. I find that it conveys the right meaning (I feel the symlinked version is the ‘impure’ version of my config), even though I know it doesn’t effect the functionality of mkOutOfStoreSymlink.
With override I mean that the directory I symlink to is overridden by symlinks to the store. So I have an ‘Example’ flake in path (/absolute/path/to/example/flake) with only output directory=./., I add this flake to my NixOS config (which uses home-manager as a module) and effectively do
where I have removed the extra if ... then ... else logic. If I have used the mkOutOfStoreSymlink method on the nixos rebuild before, then during this next build, path/to/example is symlinked to /absolute/path/to/example/flake, and then home-manager goes and puts inputs.ExampleFlake.directory into the nix store and tries to symlink path/to/example to this nix store location, but for some reason then just overrides all files in /absolute/path/to/example/flake with symlinks to their version in the nix store, meaning the original flake used to create the config has now become read-only.