From b0247ceedc72322f77c16fb490c0fdf6373a3f6b Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 15 Sep 2022 22:17:19 +0200 Subject: [PATCH] xdg.userDirs: avoid using $HOME 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. --- modules/misc/xdg-user-dirs.nix | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/modules/misc/xdg-user-dirs.nix b/modules/misc/xdg-user-dirs.nix index 9d29729a5..36f200eb9 100644 --- a/modules/misc/xdg-user-dirs.nix +++ b/modules/misc/xdg-user-dirs.nix @@ -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."; }; @@ -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.";