Skip to content

Commit

Permalink
xdg-user-dirs: create directories after linkGeneration
Browse files Browse the repository at this point in the history
In the scenario where some XDG user directory is a symlink defined by
`home.file`, we want the symlink to be created before we try to
`mkdir -p` that directory, as it will then silently succeed. On the
other hand, if we create the directory first, creating the symlink
will fail.

We lose nothing by doing this as `linkGeneration` creates the
directories it needs.
  • Loading branch information
ncfavier authored and rycee committed Jul 25, 2022
1 parent 8419dfd commit dbed4c7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions modules/misc/xdg-user-dirs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,10 @@ in {

home.sessionVariables = directories;

home.activation = mkIf cfg.createDirectories {
createXdgUserDirectories = let
directoriesList = attrValues directories;
mkdir = (dir: ''$DRY_RUN_CMD mkdir -p $VERBOSE_ARG "${dir}"'');
in lib.hm.dag.entryAfter [ "writeBoundary" ]
(strings.concatMapStringsSep "\n" mkdir directoriesList);
};
home.activation.createXdgUserDirectories = mkIf cfg.createDirectories (let
directoriesList = attrValues directories;
mkdir = (dir: ''$DRY_RUN_CMD mkdir -p $VERBOSE_ARG "${dir}"'');
in lib.hm.dag.entryAfter [ "linkGeneration" ]
(strings.concatMapStringsSep "\n" mkdir directoriesList));
};
}

0 comments on commit dbed4c7

Please sign in to comment.