emacs/var/elfeed/db/data/b6/b67d9842127c74c73d6d57fc1ec059a49a4f4edb
2022-01-03 12:49:32 -06:00

1 line
7.2 KiB
Plaintext

<!-- SC_OFF --><div class="md"><p>Hello everyone,</p> <p>I am quite hyped about <code>guix home</code> 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&#39;t seem to get profile loading to work properly (described <a href="https://guix.gnu.org/cookbook/en/html_node/Basic-setup-with-manifests.html">in this section</a> of the Guix cookbook article about Advanced package management). It is essentially a <code>for</code> loop for loading the profiles one by one.</p> <p>This is all the more confusing since the home configuration produced as a result of the <code>guix home import DIR</code> command already features a procedure loading the <code>.bash_profile</code> file which contains said <code>for</code> loop (I am talking about the <code>(bash-profile ...)</code> section in <a href="https://pastebin.com/jp9K5p6S">my pastebin&#39;d home config</a>).</p> <p>Now, I know that <code>guix home</code> 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&#39;ve gotten your home config setup so far?</p> <p>I&#39;d be very glad for your input.</p> <p>Have a good day, fellows :)</p> <p><strong>EDIT:</strong> Okay, something must have gone wrong somewhere. I have been wondering in the first place why loading the profile files didn&#39;t work. <code>guix home import DIR</code> copies your existing .bash* files to DIR. Then, in your <code>home-config.scm</code> (my filename), there is a <code>(local-file ...)</code> form, which essentially copies the file provided to the store (in this case, to <code>~/.guix-home</code>) given a specific name (in my case, <code>bash_profile</code>). In other words, given the configuration which I had pastepin&#39;d above, there was a .bash_profile file present which already contained the <code>for</code>-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&#39;t have a problem with a for-loop.</p> <p><a href="/u/HighlyRegardedExpert">u/HighlyRegardedExpert</a> mentioned that what is necessary for <code>guix home</code> and its <code>(bash-profile ...)</code>-section to do its magic is the insertion of the &quot;source /path/to/profile/etc/profile \n&quot; 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 <code>$GUIX_EXTRA_PROFILES</code>). However, that doesn&#39;t work either. Omitting something like <code>(plain-file ...)</code> or <code>(local-file ...)</code> doesn&#39;t seem to work, because a file-like object is expected as input. A string doesn&#39;t work, a list of strings doesn&#39;t work either. Thus, I used <code>(plain-file ...)</code> to manually create <code>bash_profile</code> with those strings. It results to the following file:</p> <pre><code>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 </code></pre> <p>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&#39;t see any of the programs I am used to see. For instance, emacs doesn&#39;t open. However, when I manually copy these <code>source</code> 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 <code>(environment-variables ...)</code>-field of the <code>(home-bash-configuration ...)</code>).</p> <p>Honestly, I&#39;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&#39;t be bothered to try - is that I might try using the (<code>home-bash-extension ...)</code> record instead of the <code>(home-bash-configuration ...)</code> record, because then my additions are appended to the end of the respective file (<code>(bash-profile ...)</code> in my case).</p> <p>For those interested, these are the procedures I wrote (I&#39;m a programming newb):</p> <pre><code>(define (guix-list-profiles) (let* ((profiles-dir (getenv &quot;GUIX_EXTRA_PROFILES&quot;)) (dir-entries (cddr (scandir profiles-dir))) (profiles (map (lambda (entry) (string-append profiles-dir &quot;/&quot; entry &quot;/&quot; entry)) dir-entries))) (map (lambda (prof) (string-append prof &quot;/etc/profile&quot;)) profiles))) (define guix-profiles (guix-list-profiles)) (define (guix-source-profiles profiles) (cond ((null? profiles) (string-append &quot;&quot;)) (else (string-append &quot;source &quot; (car profiles) &quot;\n&quot; (guix-source-profiles (cdr profiles)))))) </code></pre> <p>Also find the <code>(bash-profile ...)</code>-section of my <code>(home-bash-configuration ...)</code>-record:</p> <pre><code>(bash-profile ;; (list (local-file ;; &quot;/home/hapster/.config/guix/home/.bash_profile&quot; ;; &quot;bash_profile&quot;)) (list (plain-file &quot;bash_profile&quot; (guix-source-profiles guix-profiles)))) </code></pre> <p>I hope you are more successful with your setting up of <code>guix home</code>. I will lay low on that front for some time to await further development. And the guix-devel discussion mentioned by <a href="/u/9bladed">u/9bladed</a> makes me hope that my futile attempts might become unncessary before long :) </p> <p>Have a good day, fellows!</p> </div><!-- SC_ON --> &#32; submitted by &#32; <a href="https://www.reddit.com/user/olivuser"> /u/olivuser </a> <br/> <span><a href="https://www.reddit.com/r/GUIX/comments/qs8dxg/guix_home_how_to_execute_loops_shell_scripts/">[link]</a></span> &#32; <span><a href="https://www.reddit.com/r/GUIX/comments/qs8dxg/guix_home_how_to_execute_loops_shell_scripts/">[comments]</a></span>