Hello everyone,
I am quite hyped about guix home
and am currently trying to get my shell working with it (before venturing to more exotic stuff such as trying to manage my .emacs.d with it). However, I can't seem to get profile loading to work properly (described in this section of the Guix cookbook article about Advanced package management). It is essentially a for
loop for loading the profiles one by one.
This is all the more confusing since the home configuration produced as a result of the guix home import DIR
command already features a procedure loading the .bash_profile
file which contains said for
loop (I am talking about the (bash-profile ...)
section in my pastebin'd home config).
Now, I know that guix home
is still quite a new thing, but how have you gotten around to doing this? Could you - more generally speaking - provide examples of how you've gotten your home config setup so far?
I'd be very glad for your input.
Have a good day, fellows :)
EDIT: Okay, something must have gone wrong somewhere. I have been wondering in the first place why loading the profile files didn't work. guix home import DIR
copies your existing .bash* files to DIR. Then, in your home-config.scm
(my filename), there is a (local-file ...)
form, which essentially copies the file provided to the store (in this case, to ~/.guix-home
) given a specific name (in my case, bash_profile
). In other words, given the configuration which I had pastepin'd above, there was a .bash_profile file present which already contained the for
-loop necessary for the profile loading. This should not have been a problem in the first place, because IIUC, those files are ultimately interpreted by bash, which doesn't have a problem with a for-loop.
u/HighlyRegardedExpert mentioned that what is necessary for guix home
and its (bash-profile ...)
-section to do its magic is the insertion of the "source /path/to/profile/etc/profile \n" string for each profile. Long story short, I wrote a set of procedures which do exactly that, but for a number of profiles (those found in the directory $GUIX_EXTRA_PROFILES
). However, that doesn't work either. Omitting something like (plain-file ...)
or (local-file ...)
doesn't seem to work, because a file-like object is expected as input. A string doesn't work, a list of strings doesn't work either. Thus, I used (plain-file ...)
to manually create bash_profile
with those strings. It results to the following file:
hapster@giks ~$ cat .guix-home/files/bash_profile # 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 source /home/hapster/.guix-extra-profiles/basics/basics/etc/profile source /home/hapster/.guix-extra-profiles/emacs/emacs/etc/profile source /home/hapster/.guix-extra-profiles/games/games/etc/profile source /home/hapster/.guix-extra-profiles/media/media/etc/profile source /home/hapster/.guix-extra-profiles/musicprod/musicprod/etc/profile source /home/hapster/.guix-extra-profiles/productivity/productivity/etc/profile source /home/hapster/.guix-extra-profiles/programming/programming/etc/profile source /home/hapster/.guix-extra-profiles/ui/ui/etc/profile export PATH=$HOME/.scripts:$PATH export GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles export GUILE_LOAD_PATH=$HOME/.config/guix/core:$HOME/.config/guix/nonguix:$HOME/.config/guix/gaming:$GUILE_LOAD_PATH export GUILE_LOAD_COMPILED_PATH=$HOME/.config/guix/core:$GUILE_LOAD_COMPILED_PATH export EDITOR=/gnu/store/adbmrmd009afzsv2r8xp6w1xrlbh7iwg-emacs-native-comp-28.0.60-191.307d164/bin/emacs export VISUAL=/gnu/store/adbmrmd009afzsv2r8xp6w1xrlbh7iwg-emacs-native-comp-28.0.60-191.307d164/bin/emacs export SHELL=/gnu/store/87kif0bpf0anwbsaw0jvg8fyciw4sz67-bash-5.0.16/bin/bash
This clearly shows that the creation of bash_profile is successful and that my procedures do the right thing. Still, when booting up the machine, the profiles are clearly NOT loaded, because I can't see any of the programs I am used to see. For instance, emacs doesn't open. However, when I manually copy these source
commands and apply them, I can start emacs, but only from THIS INSTANCE of the terminal emulator. However, the environment variables show up just fine (those were defined in the (environment-variables ...)
-field of the (home-bash-configuration ...)
).
Honestly, I've reached the end of my wits and am sufficiently frustrated to give up for now. The only thing I could think of now - but I can't be bothered to try - is that I might try using the (home-bash-extension ...)
record instead of the (home-bash-configuration ...)
record, because then my additions are appended to the end of the respective file ((bash-profile ...)
in my case).
For those interested, these are the procedures I wrote (I'm a programming newb):
(define (guix-list-profiles) (let* ((profiles-dir (getenv "GUIX_EXTRA_PROFILES")) (dir-entries (cddr (scandir profiles-dir))) (profiles (map (lambda (entry) (string-append profiles-dir "/" entry "/" entry)) dir-entries))) (map (lambda (prof) (string-append prof "/etc/profile")) profiles))) (define guix-profiles (guix-list-profiles)) (define (guix-source-profiles profiles) (cond ((null? profiles) (string-append "")) (else (string-append "source " (car profiles) "\n" (guix-source-profiles (cdr profiles))))))
Also find the (bash-profile ...)
-section of my (home-bash-configuration ...)
-record:
(bash-profile ;; (list (local-file ;; "/home/hapster/.config/guix/home/.bash_profile" ;; "bash_profile")) (list (plain-file "bash_profile" (guix-source-profiles guix-profiles))))
I hope you are more successful with your setting up of guix home
. I will lay low on that front for some time to await further development. And the guix-devel discussion mentioned by u/9bladed makes me hope that my futile attempts might become unncessary before long :)
Have a good day, fellows!