1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-13 06:39:44 +01:00

xdg-user-dirs: check for existing symlink

When a non-directory, such as a file or a dead symlink, already exists,
mkdir -p fails with "cannot create directory ‘...’: File exists".

This is a problem when, for example, a symlink points to a directory on
a filesystem that isn't mounted yet.
This commit is contained in:
novenary 2024-03-07 12:16:58 +02:00 committed by Mikilio
parent 942146ac90
commit 0c4a97f880
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F

View file

@ -137,7 +137,8 @@ in {
home.activation.createXdgUserDirectories = mkIf cfg.createDirectories (let
directoriesList = attrValues directories;
mkdir = (dir: ''run mkdir -p $VERBOSE_ARG "${dir}"'');
mkdir =
(dir: ''[[ -L "${dir}" ]] || run mkdir -p $VERBOSE_ARG "${dir}"'');
in lib.hm.dag.entryAfter [ "linkGeneration" ]
(strings.concatMapStringsSep "\n" mkdir directoriesList));
};