unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54354: [BUG] guix home: on foreign distro, ~/.bash_profile is not initialized
@ 2022-03-12 13:07 florhizome
  2022-03-12 18:29 ` Liliana Marie Prikler
  0 siblings, 1 reply; 4+ messages in thread
From: florhizome @ 2022-03-12 13:07 UTC (permalink / raw)
  To: 54354

[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]


Hi guix' !
I have been trying to use guix home on my foreign distro partition
(manjaro); especially in order to set up additional profiles from
there, but my .bash_profile generated by guix doesn't seem to be
evaluated at all.

To describe the actual issue finally: None of the things that should happen through .bash_profile seem to
happen at the moment (it's just about different environment variables that
will not be set up.), but after running bash --login in my
terminal-emulator everything is as anticipated so my guess is that
.bash_profile actually isn't evaluated at all after login. I'm happy to hear
other suggestions and especially solutions.

I will attach the file that I use
for home configuration, as well as the current resulting .bashrc,
.bash_profile and .profile files.
I'm aware that there is duplicated code by the generated aliases in
.bashrc and that the prompt customization  for guix profiles added by
the "guix-defaults?" field does not work due to other related code that comes afterwards but I'm not sure it's related to that main issue.
I did the original set up using "guix home import" which seems to have
improved since I tried last in december last year when the generated
file didn't work at all.
Manjaro has a lot of stuff in it's .bashrc that i didn't want to
override, and maybe there are more cases of duplication there that I
don't know about what harm they might introduce.

Greetings, Florian


[-- Attachment #2: guix home declaration --]
[-- Type: text/plain, Size: 1662 bytes --]

(use-modules
  (gnu home)
  (gnu packages)
  (gnu packages base)
  (gnu services)
  (guix gexp)
  (gnu home services shells))


(define %enable-extra-profiles
  (plain-file "enable-profiles" 
               "for i in $GUIX_EXTRA_PROFILES/*; do
  profile=$i/$(basename \"$i\")
  if [ -f \"$profile\"/etc/profile ]; then
    GUIX_PROFILE=\"$profile\"
   . \"$GUIX_PROFILE\"/etc/profile
  fi
  unset profile
done"))


(home-environment
  (services
    (list (service
            home-bash-service-type
            (home-bash-configuration
	     (environment-variables 
	      '(("GUIX_EXTRA_PROFILES" . "/home/flo/.extra-profiles")
                ;;("ALTERNATE_EDITOR" . "\"\"")
                ("EDITOR" . "\"emacsclient -nw -q\"")
                ("VISUAL" . "\"emacsclient -c -a \"\"\"")
                ("GIT_EDITOR" . "\"emacs -nw -q\"")))	
              (aliases
                '(("cp" . "cp -i")
                  ("df" . "df -h")
                  ("egrep='egrep --colour" . "auto")
                  ("fgrep='fgrep --colour" . "auto")
                  ("free" . "free -m")
                  ("grep='grep --colour" . "auto")
                  ("ls='ls --color" . "auto")
                  ("more" . "less")
                  ("np" . "nano -w PKGBUILD")))
              (bashrc
                (list (local-file
                        "/home/flo/.config/guix/home/.bashrc"
                        "bashrc")))
              (bash-profile
                (list %enable-extra-profiles))	
              (bash-logout
               (list (local-file
                      "/home/flo/.config/guix/home/.bash_logout"
                      "bash_logout"))))))))

[-- Attachment #3: resulting "~/.profile" --]
[-- Type: text/plain, Size: 105 bytes --]

HOME_ENVIRONMENT=$HOME/.guix-home
. $HOME_ENVIRONMENT/setup-environment
$HOME_ENVIRONMENT/on-first-login

[-- Attachment #4: resulting "~/.bashrc" --]
[-- Type: text/plain, Size: 5186 bytes --]

alias cp="cp -i"
alias df="df -h"
alias egrep='egrep --colour="auto"
alias fgrep='fgrep --colour="auto"
alias free="free -m"
alias grep='grep --colour="auto"
alias ls='ls --color="auto"
alias more="less"
alias np="nano -w PKGBUILD"
# Bash initialization for interactive non-login shells and
# for remote shells (info "(bash) Bash Startup Files").

# Export 'SHELL' to child processes.  Programs such as 'screen'
# honor it and otherwise use /bin/sh.
export SHELL

if [[ $- != *i* ]]
then
    # We are being invoked from a non-interactive shell.  If this
    # is an SSH session (as in "ssh host command"), source
    # /etc/profile so we get PATH and other essential variables.
    [[ -n "$SSH_CLIENT" ]] && source /etc/profile

    # Don't do anything else.
    return
fi

# Source the system-wide file.
if [[ -e /etc/bashrc ]]; then
    source /etc/bashrc
fi

# Adjust the prompt depending on whether we're in 'guix environment'.
if [ -n "$GUIX_ENVIRONMENT" ]
then
    PS1='\u@\h \w [env]\$ '
else
    PS1='\u@\h \w\$ '
fi
alias ls='ls -p --color=auto'
alias ll='ls -l'
alias grep='grep --color=auto'
#
# ~/.bashrc
#

[[ $- != *i* ]] && return

colors() {
	local fgc bgc vals seq0

	printf "Color escapes are %s\n" '\e[${value};...;${value}m'
	printf "Values 30..37 are \e[33mforeground colors\e[m\n"
	printf "Values 40..47 are \e[43mbackground colors\e[m\n"
	printf "Value  1 gives a  \e[1mbold-faced look\e[m\n\n"

	# foreground colors
	for fgc in {30..37}; do
		# background colors
		for bgc in {40..47}; do
			fgc=${fgc#37} # white
			bgc=${bgc#40} # black

			vals="${fgc:+$fgc;}${bgc}"
			vals=${vals%%;}

			seq0="${vals:+\e[${vals}m}"
			printf "  %-9s" "${seq0:-(default)}"
			printf " ${seq0}TEXT\e[m"
			printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
		done
		echo; echo
	done
}

[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion

# Change the window title of X terminals
case ${TERM} in
	xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*)
		PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"'
		;;
	screen*)
		PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"'
		;;
esac

use_color=true

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.  Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs}    ]] \
	&& type -P dircolors >/dev/null \
	&& match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
	# Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
	if type -P dircolors >/dev/null ; then
		if [[ -f ~/.dir_colors ]] ; then
			eval $(dircolors -b ~/.dir_colors)
		elif [[ -f /etc/DIR_COLORS ]] ; then
			eval $(dircolors -b /etc/DIR_COLORS)
		fi
	fi

	if [[ ${EUID} == 0 ]] ; then
		PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] '
	else
		PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] '
	fi

	alias ls='ls --color=auto'
	alias grep='grep --colour=auto'
	alias egrep='egrep --colour=auto'
	alias fgrep='fgrep --colour=auto'
else
	if [[ ${EUID} == 0 ]] ; then
		# show root@ when we don't have colors
		PS1='\u@\h \W \$ '
	else
		PS1='\u@\h \w \$ '
	fi
fi

unset use_color safe_term match_lhs sh

alias cp="cp -i"                          # confirm before overwriting something
alias df='df -h'                          # human-readable sizes
alias free='free -m'                      # show sizes in MB
alias np='nano -w PKGBUILD'
alias more=less

xhost +local:root > /dev/null 2>&1

complete -cf sudo

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.  #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

shopt -s expand_aliases

# export QT_SELECT=4

# Enable history appending instead of overwriting.  #139609
shopt -s histappend

#
# # ex - archive extractor
# # usage: ex <file>
ex ()
{
  if [ -f $1 ] ; then
    case $1 in
      *.tar.bz2)   tar xjf $1   ;;
      *.tar.gz)    tar xzf $1   ;;
      *.bz2)       bunzip2 $1   ;;
      *.rar)       unrar x $1     ;;
      *.gz)        gunzip $1    ;;
      *.tar)       tar xf $1    ;;
      *.tbz2)      tar xjf $1   ;;
      *.tgz)       tar xzf $1   ;;
      *.zip)       unzip $1     ;;
      *.Z)         uncompress $1;;
      *.7z)        7z x $1      ;;
      *)           echo "'$1' cannot be extracted via ex()" ;;
    esac
  else
    echo "'$1' is not a valid file"
  fi
}


# BEGIN_KITTY_SHELL_INTEGRATION
if test -n "$KITTY_INSTALLATION_DIR" -a -e "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; then source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; fi
# END_KITTY_SHELL_INTEGRATION


[-- Attachment #5: resulting "~/.bash_profile" file --]
[-- Type: text/plain, Size: 635 bytes --]

# Setups system and user profiles and related variables
# /etc/profile will be sourced by bash automatically
# Setups home environment profile
if [ -f ~/.profile ]; then source ~/.profile; fi

# Honor per-interactive-shell startup file
if [ -f ~/.bashrc ]; then source ~/.bashrc; fi
for i in $GUIX_EXTRA_PROFILES/*; do
  profile=$i/$(basename "$i")
  if [ -f "$profile"/etc/profile ]; then
    GUIX_PROFILE="$profile"
   . "$GUIX_PROFILE"/etc/profile
  fi
  unset profile
done
export GUIX_EXTRA_PROFILES=/home/flo/.extra-profiles
export EDITOR="emacsclient -nw -q"
export VISUAL="emacsclient -c -a """
export GIT_EDITOR="emacs -nw -q"

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-18  8:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-12 13:07 bug#54354: [BUG] guix home: on foreign distro, ~/.bash_profile is not initialized florhizome
2022-03-12 18:29 ` Liliana Marie Prikler
2022-03-20 14:09   ` florhizome
2022-10-18  8:47     ` Andrew Tropin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).