mirror of
https://github.com/nix-community/impermanence
synced 2024-11-10 05:44:17 +00:00
home-manager: Create missing target directories for files
Create missing parent directories for nonexistent files in persistent storage. Reported in #53.
This commit is contained in:
parent
00df1e57bb
commit
6b474b097a
1 changed files with 41 additions and 26 deletions
|
@ -293,35 +293,50 @@ in
|
|||
cfg.${persistentStoragePath}.directories;
|
||||
|
||||
in
|
||||
mkIf (any (path: cfg.${path}.directories != [ ]) persistentStoragePaths) {
|
||||
createAndMountPersistentStoragePaths =
|
||||
dag.entryBefore
|
||||
[ "writeBoundary" ]
|
||||
''
|
||||
declare -A mountedPaths
|
||||
${(concatMapStrings mkBindMountsForPath persistentStoragePaths)}
|
||||
'';
|
||||
mkMerge [
|
||||
(mkIf (any (path: cfg.${path}.directories != [ ]) persistentStoragePaths) {
|
||||
createAndMountPersistentStoragePaths =
|
||||
dag.entryBefore
|
||||
[ "writeBoundary" ]
|
||||
''
|
||||
declare -A mountedPaths
|
||||
${(concatMapStrings mkBindMountsForPath persistentStoragePaths)}
|
||||
'';
|
||||
|
||||
unmountPersistentStoragePaths =
|
||||
dag.entryBefore
|
||||
[ "createAndMountPersistentStoragePaths" ]
|
||||
''
|
||||
unmountBindMounts() {
|
||||
${concatMapStrings mkUnmountsForPath persistentStoragePaths}
|
||||
}
|
||||
unmountPersistentStoragePaths =
|
||||
dag.entryBefore
|
||||
[ "createAndMountPersistentStoragePaths" ]
|
||||
''
|
||||
unmountBindMounts() {
|
||||
${concatMapStrings mkUnmountsForPath persistentStoragePaths}
|
||||
}
|
||||
|
||||
# Run the unmount function on error to clean up stray
|
||||
# bind mounts
|
||||
trap "unmountBindMounts" ERR
|
||||
'';
|
||||
# Run the unmount function on error to clean up stray
|
||||
# bind mounts
|
||||
trap "unmountBindMounts" ERR
|
||||
'';
|
||||
|
||||
runUnmountPersistentStoragePaths =
|
||||
dag.entryBefore
|
||||
[ reloadSystemd ]
|
||||
''
|
||||
unmountBindMounts
|
||||
'';
|
||||
};
|
||||
runUnmountPersistentStoragePaths =
|
||||
dag.entryBefore
|
||||
[ reloadSystemd ]
|
||||
''
|
||||
unmountBindMounts
|
||||
'';
|
||||
})
|
||||
(mkIf (any (path: cfg.${path}.files != [ ]) persistentStoragePaths) {
|
||||
createTargetFileDirectories =
|
||||
dag.entryBefore
|
||||
[ "writeBoundary" ]
|
||||
(concatMapStrings
|
||||
(persistentStoragePath:
|
||||
concatMapStrings
|
||||
(targetFilePath: ''
|
||||
mkdir -p ${concatPaths [ persistentStoragePath (dirOf targetFilePath) ]}
|
||||
'')
|
||||
cfg.${persistentStoragePath}.files)
|
||||
persistentStoragePaths);
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue