Skip to content

Commit

Permalink
xdg.userDirs: avoid using $HOME
Browse files Browse the repository at this point in the history
Instead of referencing the `HOME` environment variable, use the
`home.homeDirectory` option. This allows other modules to reference an
XDG user directory without having to support shell syntax.
  • Loading branch information
rycee committed Sep 16, 2022
1 parent 5408e27 commit b0247ce
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions modules/misc/xdg-user-dirs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,49 +34,65 @@ in {

desktop = mkOption {
type = with types; coercedTo path toString str;
default = "$HOME/Desktop";
default = "${config.home.homeDirectory}/Desktop";
defaultText =
literalExpression ''"''${config.home.homeDirectory}/Desktop"'';
description = "The Desktop directory.";
};

documents = mkOption {
type = with types; coercedTo path toString str;
default = "$HOME/Documents";
default = "${config.home.homeDirectory}/Documents";
defaultText =
literalExpression ''"''${config.home.homeDirectory}/Documents"'';
description = "The Documents directory.";
};

download = mkOption {
type = with types; coercedTo path toString str;
default = "$HOME/Downloads";
default = "${config.home.homeDirectory}/Downloads";
defaultText =
literalExpression ''"''${config.home.homeDirectory}/Downloads"'';
description = "The Downloads directory.";
};

music = mkOption {
type = with types; coercedTo path toString str;
default = "$HOME/Music";
default = "${config.home.homeDirectory}/Music";
defaultText =
literalExpression ''"''${config.home.homeDirectory}/Music"'';
description = "The Music directory.";
};

pictures = mkOption {
type = with types; coercedTo path toString str;
default = "$HOME/Pictures";
default = "${config.home.homeDirectory}/Pictures";
defaultText =
literalExpression ''"''${config.home.homeDirectory}/Pictures"'';
description = "The Pictures directory.";
};

publicShare = mkOption {
type = with types; coercedTo path toString str;
default = "$HOME/Public";
default = "${config.home.homeDirectory}/Public";
defaultText =
literalExpression ''"''${config.home.homeDirectory}/Public"'';
description = "The Public share directory.";
};

templates = mkOption {
type = with types; coercedTo path toString str;
default = "$HOME/Templates";
default = "${config.home.homeDirectory}/Templates";
defaultText =
literalExpression ''"''${config.home.homeDirectory}/Templates"'';
description = "The Templates directory.";
};

videos = mkOption {
type = with types; coercedTo path toString str;
default = "$HOME/Videos";
default = "${config.home.homeDirectory}/Videos";
defaultText =
literalExpression ''"''${config.home.homeDirectory}/Videos"'';
description = "The Videos directory.";
};

Expand All @@ -86,7 +102,7 @@ in {
defaultText = literalExpression "{ }";
example = literalExpression ''
{
XDG_MISC_DIR = "$HOME/Misc";
XDG_MISC_DIR = "''${config.home.homeDirectory}/Misc";
}
'';
description = "Other user directories.";
Expand Down

0 comments on commit b0247ce

Please sign in to comment.