home-manager: use XDG configuration directory

This commit is contained in:
Robert Helgesson 2017-10-28 23:01:42 +02:00
parent a4c0fead1f
commit efb5256d28
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86

View file

@ -26,8 +26,9 @@ function setConfigFile() {
return return
fi fi
local defaultConfFile="${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home.nix"
local confFile local confFile
for confFile in "$HOME/.config/nixpkgs/home.nix" \ for confFile in "$defaultConfFile" \
"$HOME/.nixpkgs/home.nix" ; do "$HOME/.nixpkgs/home.nix" ; do
if [[ -e "$confFile" ]] ; then if [[ -e "$confFile" ]] ; then
HOME_MANAGER_CONFIG="$confFile" HOME_MANAGER_CONFIG="$confFile"
@ -36,14 +37,14 @@ function setConfigFile() {
done done
errorEcho "No configuration file found." \ errorEcho "No configuration file found." \
"Please create one at ~/.config/nixpkgs/home.nix" "Please create one at $defaultConfFile"
exit 1 exit 1
} }
function setHomeManagerNixPath() { function setHomeManagerNixPath() {
local path local path
for path in "@HOME_MANAGER_PATH@" \ for path in "@HOME_MANAGER_PATH@" \
"$HOME/.config/nixpkgs/home-manager" \ "${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home-manager" \
"$HOME/.nixpkgs/home-manager" ; do "$HOME/.nixpkgs/home-manager" ; do
if [[ -e "$path" || "$path" =~ ^https?:// ]] ; then if [[ -e "$path" || "$path" =~ ^https?:// ]] ; then
export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$path" export NIX_PATH="$NIX_PATH${NIX_PATH:+:}home-manager=$path"