gnu: gnome-shell-extension-noannoyance: Use the copy-build-system.
[jackhill/guix/guix.git] / etc / guix-install.sh
index a0777c8..bfd3842 100755 (executable)
@@ -3,6 +3,7 @@
 # Copyright © 2017 sharlatan <sharlatanus@gmail.com>
 # Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
 # Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
+# Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
 #
 # This file is part of GNU Guix.
 #
@@ -85,14 +86,12 @@ _debug()
 
 chk_require()
 { # Check that every required command is available.
-    declare -a cmds
     declare -a warn
-
-    cmds=(${1})
+    local c
 
     _debug "--- [ $FUNCNAME ] ---"
 
-    for c in ${cmds[@]}; do
+    for c in "$@"; do
         command -v "$c" &>/dev/null || warn+=("$c")
     done
 
@@ -101,10 +100,17 @@ chk_require()
           return 1; }
     
     _msg "${PAS}verification of required commands completed"
+}
+
+chk_gpg_keyring()
+{ # Check whether the Guix release signing public key is present.
+    _debug "--- [ $FUNCNAME ] ---"
 
-    gpg --list-keys ${OPENPGP_SIGNING_KEY_ID} >/dev/null 2>&1 || (
+    # Without --dry-run this command will create a ~/.gnupg owned by root on
+    # systems where gpg has never been used, causing errors and confusion.
+    gpg --dry-run --list-keys ${OPENPGP_SIGNING_KEY_ID} >/dev/null 2>&1 || (
         _err "${ERR}Missing OpenPGP public key.  Fetch it with this command:"
-        echo "  gpg --keyserver pool.sks-keyservers.net --recv-keys ${OPENPGP_SIGNING_KEY_ID}"
+        echo "  wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import -"
         exit 1
     )
 }
@@ -339,6 +345,17 @@ sys_enable_guix_daemon()
             { cp "${ROOT_HOME}/.config/guix/current/lib/systemd/system/guix-daemon.service" \
                  /etc/systemd/system/;
               chmod 664 /etc/systemd/system/guix-daemon.service;
+
+             # Work around <https://bugs.gnu.org/36074>, present in 1.0.1.
+             sed -i /etc/systemd/system/guix-daemon.service \
+                 -e "s/GUIX_LOCPATH='/'GUIX_LOCPATH=/";
+
+             # Work around <https://bugs.gnu.org/35671>, present in 1.0.1.
+             if ! grep en_US /etc/systemd/system/guix-daemon.service >/dev/null;
+             then sed -i /etc/systemd/system/guix-daemon.service \
+                      -e 's/^Environment=\(.*\)$/Environment=\1 LC_ALL=en_US.UTF-8';
+             fi;
+
               systemctl daemon-reload &&
                   systemctl start guix-daemon &&
                   systemctl enable guix-daemon; } &&
@@ -362,13 +379,11 @@ sys_enable_guix_daemon()
 }
 
 sys_authorize_build_farms()
-{ # authorize the public keys of the two build farms
+{ # authorize the public key of the build farm
     while true; do
-        read -p "Permit downloading pre-built package binaries from the project's build farms? (yes/no) " yn
+        read -p "Permit downloading pre-built package binaries from the project's build farm? (yes/no) " yn
         case $yn in
-            [Yy]*) guix archive --authorize < "${ROOT_HOME}/.config/guix/current/share/guix/hydra.gnu.org.pub" &&
-                         _msg "${PAS}Authorized public key for hydra.gnu.org";
-                   guix archive --authorize < "${ROOT_HOME}/.config/guix/current/share/guix/ci.guix.gnu.org.pub" &&
+            [Yy]*) guix archive --authorize < "${ROOT_HOME}/.config/guix/current/share/guix/ci.guix.gnu.org.pub" &&
                        _msg "${PAS}Authorized public key for ci.guix.gnu.org";
                    break;;
             [Nn]*) _msg "${INF}Skipped authorizing build farm public keys"
@@ -378,6 +393,32 @@ sys_authorize_build_farms()
     done
 }
 
+sys_create_init_profile()
+{ # Create /etc/profile.d/guix.sh for better desktop integration
+    [ -d "/etc/profile.d" ] || mkdir /etc/profile.d # Just in case
+    cat <<"EOF" > /etc/profile.d/guix.sh
+# _GUIX_PROFILE: `guix pull` profile
+_GUIX_PROFILE="$HOME/.config/guix/current"
+if [ -L $_GUIX_PROFILE ]; then
+  export PATH="$_GUIX_PROFILE/bin${PATH:+:}$PATH"
+  # Export INFOPATH so that the updated info pages can be found
+  # and read by both /usr/bin/info and/or $GUIX_PROFILE/bin/info
+  export INFOPATH="$_GUIX_PROFILE/share/info${INFOPATH:+:}$INFOPATH"
+fi
+
+# GUIX_PROFILE: User's default profile
+GUIX_PROFILE="$HOME/.guix-profile"
+[ -L $GUIX_PROFILE ] || return
+GUIX_LOCPATH="$GUIX_PROFILE/lib/locale"
+export GUIX_PROFILE GUIX_LOCPATH
+
+eval `guix package --search-paths=prefix 2> /dev/null`
+
+# set XDG_DATA_DIRS to include Guix installations
+export XDG_DATA_DIRS="$GUIX_PROFILE/share:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}"
+EOF
+}
+
 welcome()
 {
     cat<<"EOF"
@@ -417,12 +458,14 @@ main()
     _msg "Starting installation ($(date))"
 
     chk_term
-    chk_require "${REQUIRE[*]}"
+    chk_require "${REQUIRE[@]}"
+    chk_gpg_keyring
     chk_init_sys
     chk_sys_arch
 
     _msg "${INF}system is ${ARCH_OS}"
 
+    umask 0022
     tmp_path="$(mktemp -t -d guix.XXX)"
 
     guix_get_bin_list "${GNU_URL}"
@@ -432,6 +475,7 @@ main()
     sys_create_build_user
     sys_enable_guix_daemon
     sys_authorize_build_farms
+    sys_create_init_profile
 
     _msg "${INF}cleaning up ${tmp_path}"
     rm -r "${tmp_path}"