Open Janrupf opened 3 months ago
Temporary fix:
home.activation.createTargetFileDirectoriesFixup =
let
isSymlink = entry: (!lib.isString entry) && (entry.method == "symlink");
entryPath = entry: if lib.isString entry then entry else entry.directory;
cfg = config.home.persistence;
persistenceRoots = lib.attrNames cfg;
mkdirPersistentLocations = map (root:
let
persistentDiskPath = cfg.${root}.persistentStoragePath;
persistentDirectories =
# Collect all directories which are symlinks
(map entryPath (lib.filter isSymlink cfg.${root}.directories)) ++
# And all directories of files
(map lib.dirOf (map entryPath (cfg.${root}.files)));
completePaths = map (path: lib.path.append (/. + root) path) persistentDirectories;
mkdirCommands = lib.concatMapStrings (completePath: "run mkdir -p ${lib.escapeShellArg completePath}\n") completePaths;
in ''
# mkdir's for ${root}
${mkdirCommands}
''
) persistenceRoots;
in
config.lib.dag.entryBetween [ "writeBoundary" ] [ "createTargetFileDirectories" ] (
lib.concatMapStrings (cmds: "${cmds}\n") mkdirPersistentLocations
);
This should create all directories as intended when put into the home-manager configuration.
I've also ran into this problem.
The temporary fix works, although for me with one minor modification; I had to change lib.dirOf
to just dirOf
.
Adding the following configuration creates a broken symlink
persistent
in/home/janrupf
:Inspecting:
So the symlink does point to the correct location afterall - the issue is, that location is never created. The creation is supposed to happen here: https://github.com/nix-community/impermanence/blob/a33ef102a02ce77d3e39c25197664b7a636f9c30/home-manager.nix#L451-L461
Inspecting the flake output reveals that the command added to
home.activation.createTargetFileDirectories
ismkdir -p /persistent/home/janrupf/.
- notice the dot at the end. I think this is caused by thedirOf
call on line 458.