1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

home-environment: use declare -gr in activation init

This marks the setup variables as read-only. Just to add a bit extra
safety.
This commit is contained in:
Robert Helgesson 2021-07-27 23:50:33 +02:00
parent 47ad3655ec
commit ae8cb242f2
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -5,9 +5,9 @@ function setupVars() {
local profilesPath="$nixStateDir/profiles/per-user/$USER" local profilesPath="$nixStateDir/profiles/per-user/$USER"
local gcPath="$nixStateDir/gcroots/per-user/$USER" local gcPath="$nixStateDir/gcroots/per-user/$USER"
genProfilePath="$profilesPath/home-manager" declare -gr genProfilePath="$profilesPath/home-manager"
newGenPath="@GENERATION_DIR@"; declare -gr newGenPath="@GENERATION_DIR@";
newGenGcPath="$gcPath/current-home" declare -gr newGenGcPath="$gcPath/current-home"
local greatestGenNum local greatestGenNum
greatestGenNum=$( \ greatestGenNum=$( \
@ -16,14 +16,15 @@ function setupVars() {
| sed -E 's/ *([[:digit:]]+) .*/\1/') | sed -E 's/ *([[:digit:]]+) .*/\1/')
if [[ -n $greatestGenNum ]] ; then if [[ -n $greatestGenNum ]] ; then
oldGenNum=$greatestGenNum declare -gr oldGenNum=$greatestGenNum
newGenNum=$((oldGenNum + 1)) declare -gr newGenNum=$((oldGenNum + 1))
else else
newGenNum=1 declare -gr newGenNum=1
fi fi
if [[ -e $profilesPath/home-manager ]] ; then if [[ -e $profilesPath/home-manager ]] ; then
oldGenPath="$(readlink -e "$profilesPath/home-manager")" oldGenPath="$(readlink -e "$profilesPath/home-manager")"
declare -gr oldGenPath
fi fi
$VERBOSE_ECHO "Sanity checking oldGenNum and oldGenPath" $VERBOSE_ECHO "Sanity checking oldGenNum and oldGenPath"