aboutsummaryrefslogtreecommitdiff
#!/bin/sh
# GNU Guix --- Functional package management for GNU
# Copyright © 2017 sharlatan <sharlatanus@gmail.com>
# Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
# Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
# Copyright © 2019–2020, 2022 Tobias Geerinckx-Rice <me@tobias.gr>
# Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
# Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
# Copyright © 2020 Daniel Brooks <db48x@db48x.net>
# Copyright © 2021 Jakub Kądziołka <kuba@kadziolka.net>
# Copyright © 2021 Chris Marusich <cmmarusich@gmail.co2022-04-02doc: Document inclusion requirements for new translations....Julien Lepiller
2022-02-15doc: Move build commands to @example for clarity....Ludovic Courtès
2022-01-31doc: Add a rule of thumb to guide enabling new committers....Maxim Cournoyer
2022-01-28doc: Mention how to remedy "source file ... newer than compiled error"....Guix Together
2022-01-28doc: Explain the use of make clean-go when an ABI mismatch occurs....Guix Together
2022-01-10style: Add '--styling' option....Ludovic Courtès
2021-12-20doc: Remove extra closing paren....Ludovic Courtès
2021-12-02doc: Give more details about generating patches with base commit information....Leo Famulari
2021-11-17doc: Improve wording for param spec of `./configure`....Rostislav Svoboda
2021-10-25Add 'guix shell'....Ludovic Courtès
2021-10-14doc: Fix typo....Marius Bakke
2021-10-04maint: Improve default diff hunk header detection....Sarah Morgensen
2021-09-22doc: Add item to "Submitting Patches" section....zimoun
2021-07-05doc: Change Debbugs usertags user to "guix"....Chris Marusich
2021-06-23doc: Document the use of Debbugs usertags....Chris Marusich
2021-06-18doc: Clarify Git commit signing; fix typo....Ludovic Courtès
2021-06-18doc: Explain more reasons for commit revocation....Ludovic Courtès
2021-06-18doc: Add "Addressing Issues" section....Ludovic Courtès
2021-06-18doc: Structure the "Commit Access" section....Ludovic Courtès
2021-06-18Start enabling substitutes from bordeaux.guix.gnu.org....Christopher Baines
2021-06-06doc: Add reference for ‘git-version’ and ‘hg-version’....Xinglu Chen
2021-06-06doc: Pluralize "package."...Matthew James Kraai
2021-06-04doc: Mention virtualization module and add missing closing parenthesis....Solene Rapenne
2021-05-30doc: Fix typos....Tobias Geerinckx-Rice
2021-05-25doc: Remove reference to mips64....Efraim Flashner
2021-05-23doc: Correct spelling...Filip Lajszczak
2021-05-22doc: Add information about first patch....Filip Lajszczak
2021-05-20The #guix channel is hosted by Libera Chat....Tobias Geerinckx-Rice
2021-05-13doc: Show how to enable Guile support for Geiser....Jelle Licht
2021-05-04doc: Fix typos....Tobias Geerinckx-Rice
2021-04-26doc: Clarify the utility of the development branches....Leo Famulari
2021-04-25doc: Document translation process....Julien Lepiller
2021-04-04doc: Remind developers to build Guix....Leo Famulari
2021-04-01doc: Discourage ambiguous package names....Tobias Geerinckx-Rice via Bug reports for GNU Guix
2021-03-18doc: Document the guidelines for removing inactive committers....Leo Famulari
2021-03-15services/qemu-binfmt: Use the F flag and the static output of QEMU....Maxim Cournoyer
2021-03-10doc: Fix grammar....Tobias Geerinckx-Rice
2021-02-13doc: Try again to the improve the branching workflow....Leo Famulari
2021-02-11doc: Try to improve the branching workflow....Leo Famulari
2021-01-29doc: Update guidance about Rust package naming....Hartmut Goebel
2021-01-20doc: Replace TP with Weblate mentions....Julien Lepiller
2021-01-03doc: Running Guix Before It Is Installed: mention ./bootstrap...Rovanion Luckey
2020-12-17doc: Emacs Packages: Fix typos....Nicolas Goaziou
2020-12-17doc: Add Emacs packaging guidelines....Maxim Cournoyer
2020-12-14doc: Note different texlive-tiny & texline-union natures....Tobias Geerinckx-Rice
2020-12-14doc: Link to "Pattern Matching" in Guile....Ludovic Courtès
2020-11-12maint: update-guix-package: Optionally add sources to store....Maxim Cournoyer
2020-10-24build: Add GUIX_GIT_KEYRING variable for make authenticate....Miguel Ángel Arruga Vivas
2020-10-20doc: More uses of @lisp instead of @example....Ludovic Courtès
2020-10-19maint: update-guix-package: Prevent accidentally breaking guix pull....Maxim Cournoyer
added <guixbuilder${i}>" fi done } sys_delete_build_user() { for i in $(seq -w 1 10); do userdel -f guixbuilder${i} done _msg "${INF}delete group guixbuild" groupdel -f guixbuild } sys_enable_guix_daemon() { # Run the daemon, and set it to automatically start on boot. local info_path local local_bin local var_guix _debug "--- [ ${FUNCNAME[0]} ] ---" info_path="/usr/local/share/info" local_bin="/usr/local/bin" var_guix="/var/guix/profiles/per-user/root/current-guix" case "$INIT_SYS" in upstart) { initctl reload-configuration; cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \ /etc/init/ && configure_substitute_discovery /etc/init/guix-daemon.conf && start guix-daemon; } && _msg "${PAS}enabled Guix daemon via upstart" ;; systemd) { install_unit() { local dest="/etc/systemd/system/$1" rm -f "$dest" cp ~root/.config/guix/current/lib/systemd/system/"$1" "$dest" chmod 664 "$dest" systemctl daemon-reload systemctl enable "$1" } install_unit guix-daemon.service configure_substitute_discovery \ /etc/systemd/system/guix-daemon.service # Install after guix-daemon.service to avoid a harmless warning. # systemd .mount units must be named after the target directory. # Here we assume a hard-coded name of /gnu/store. install_unit gnu-store.mount systemctl daemon-reload && systemctl start guix-daemon; } && _msg "${PAS}enabled Guix daemon via systemd" ;; sysv-init) { mkdir -p /etc/init.d; cp ~root/.config/guix/current/etc/init.d/guix-daemon \ /etc/init.d/guix-daemon; chmod 775 /etc/init.d/guix-daemon; configure_substitute_discovery /etc/init.d/guix-daemon update-rc.d guix-daemon defaults && update-rc.d guix-daemon enable && service guix-daemon start; } && _msg "${PAS}enabled Guix daemon via sysv" ;; openrc) { mkdir -p /etc/init.d; cp ~root/.config/guix/current/etc/openrc/guix-daemon \ /etc/init.d/guix-daemon; chmod 775 /etc/init.d/guix-daemon; configure_substitute_discovery /etc/init.d/guix-daemon rc-update add guix-daemon default && rc-service guix-daemon start; } && _msg "${PAS}enabled Guix daemon via OpenRC" ;; NA|*) _msg "${ERR}unsupported init system; run the daemon manually:" echo " ~root/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild" ;; esac _msg "${INF}making the guix command available to other users" [ -e "$local_bin" ] || mkdir -p "$local_bin" ln -sf "${var_guix}/bin/guix" "$local_bin" [ -e "$info_path" ] || mkdir -p "$info_path" for i in "${var_guix}"/share/info/*; do ln -sf "$i" "$info_path" done } sys_delete_guix_daemon() { # Disabled, stop and remove the various guix daemons. local info_path local local_bin local var_guix _debug "--- [ $FUNCNAME ] ---" info_path="/usr/local/share/info" local_bin="/usr/local/bin" case "$INIT_SYS" in upstart) _msg "${INF}stopping guix-daemon" stop guix-daemon _msg "${INF}removing guix-daemon" rm /etc/init/guix-daemon.conf ;; systemd) _msg "${INF}disabling guix-daemon" systemctl disable guix-daemon _msg "${INF}stopping guix-daemon" systemctl stop guix-daemon _msg "${INF}removing guix-daemon" rm -f /etc/systemd/system/guix-daemon.service if [ -x /etc/systemd/system/gnu-store.mount ]; then _msg "${INF}disabling gnu-store.mount" systemctl disable gnu-store.mount _msg "${INF}stopping gnu-store.mount" systemctl stop gnu-store.mount _msg "${INF}removing gnu-store.mount" rm -f /etc/systemd/system/gnu-store.mount fi systemctl daemon-reload ;; sysv-init) update-rc.d guix-daemon disable service guix-daemon stop rm -rf /etc/init.d/guix-daemon ;; NA|*) _msg "${ERR}unsupported init system; disable, stop and remove the daemon manually:" echo " ${ROOT_HOME}/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild" ;; esac _msg "${INF}removing $local_bin/guix" rm -f "$local_bin"/guix _msg "${INF}removing $info_path/guix*" rm -f "$info_path"/guix* } sys_authorize_build_farms() { # authorize the public key(s) of the build farm(s) local hosts=( bordeaux.guix.gnu.org ci.guix.gnu.org ) if prompt_yes_no "Permit downloading pre-built package binaries from the \ project's build farms?"; then for host in "${hosts[@]}"; do local key=~root/.config/guix/current/share/guix/$host.pub [ -f "$key" ] \ && guix archive --authorize < "$key" \ && _msg "${PAS}Authorized public key for $host" done else _msg "${INF}Skipped authorizing build farm public keys" fi } sys_create_init_profile() { # Define for better desktop integration # This will not take effect until the next shell or desktop session! [ -d "/etc/profile.d" ] || mkdir /etc/profile.d # Just in case cat <<"EOF" > /etc/profile.d/zzz-guix.sh # Explicitly initialize XDG base directory variables to ease compatibility # with Guix System: see <https://issues.guix.gnu.org/56050#3>. export XCURSOR_PATH="${XCURSOR_PATH:-/usr/local/share/icons:/usr/share/icons}" export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}" export XDG_CONFIG_DIRS="${XDG_CONFIG_DIRS:-/etc/xdg}" export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" # no default for XDG_RUNTIME_DIR (depends on foreign distro for semantics) # _GUIX_PROFILE: `guix pull` profile _GUIX_PROFILE="$HOME/.config/guix/current" export PATH="$_GUIX_PROFILE/bin${PATH:+:}$PATH" # GUIX_PROFILE: User's default profile and home profile GUIX_PROFILE="$HOME/.guix-profile" [ -f "$GUIX_PROFILE/etc/profile" ] && . "$GUIX_PROFILE/etc/profile" [ -L "$GUIX_PROFILE" ] && \ GUIX_LOCPATH="$GUIX_PROFILE/lib/locale${GUIX_LOCPATH:+:}$GUIX_LOCPATH" # Export INFOPATH so that the updated info pages can be found # and read by both /usr/bin/info and/or $GUIX_PROFILE/bin/info # When INFOPATH is unset, add a trailing colon so that Emacs # searches 'Info-default-directory-list'. export INFOPATH="$_GUIX_PROFILE/share/info:$GUIX_PROFILE/share/info:$INFOPATH" GUIX_PROFILE="$HOME/.guix-home/profile" [ -f "$GUIX_PROFILE/etc/profile" ] && . "$GUIX_PROFILE/etc/profile" [ -L "$GUIX_PROFILE" ] && \ GUIX_LOCPATH="$GUIX_PROFILE/lib/locale${GUIX_LOCPATH:+:}$GUIX_LOCPATH" export GUIX_LOCPATH # Make Guix modules available export GUILE_LOAD_PATH="$_GUIX_PROFILE/share/guile/site/3.0${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH" export GUILE_LOAD_COMPILED_PATH="$_GUIX_PROFILE/lib/guile/3.0/site-ccache${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" EOF } sys_create_shell_completion() { # Symlink supported shell completions system-wide var_guix=/var/guix/profiles/per-user/root/current-guix bash_completion=/etc/bash_completion.d zsh_completion=/usr/share/zsh/site-functions fish_completion=/usr/share/fish/vendor_completions.d { # Just in case for dir_shell in $bash_completion $zsh_completion $fish_completion; do [ -d "$dir_shell" ] || mkdir -p $dir_shell done; ln -sf ${var_guix}/etc/bash_completion.d/* "$bash_completion"; ln -sf ${var_guix}/share/zsh/site-functions/* "$zsh_completion"; ln -sf ${var_guix}/share/fish/vendor_completions.d/* "$fish_completion"; } && _msg "${PAS}installed shell completion" } sys_customize_bashrc() { prompt_yes_no "Customize users Bash shell prompt for Guix?" || return 0 for bashrc in /home/*/.bashrc /root/.bashrc; do test -f "$bashrc" || continue grep -Fq '$GUIX_ENVIRONMENT' "$bashrc" && continue cp "${bashrc}" "${bashrc}.bak" echo ' # Automatically added by the Guix install script. if [ -n "$GUIX_ENVIRONMENT" ]; then if [[ $PS1 =~ (.*)"\\$" ]]; then PS1="${BASH_REMATCH[1]} [env]\\\$ " fi fi ' >> "$bashrc" done _msg "${PAS}Bash shell prompt successfully customized for Guix" } sys_maybe_setup_selinux() { if ! [ -f /sys/fs/selinux/policy ] then return fi local c for c in semodule restorecon do if ! command -v "$c" &>/dev/null then return fi done prompt_yes_no "Install SELinux policy that might be required to run guix-daemon?" \ || return 0 local var_guix=/var/guix/profiles/per-user/root/current-guix semodule -i "${var_guix}/share/selinux/guix-daemon.cil" restorecon -R /gnu /var/guix } sys_delete_init_profile() { _msg "${INF}removing /etc/profile.d/guix.sh" rm -f /etc/profile.d/guix.sh } sys_delete_user_profiles() { _msg "${INF}removing ${ROOT_HOME}/.guix-profile" rm -f ${ROOT_HOME}/.guix-profile rm -rf ${ROOT_HOME}/.cache/guix _msg "${INF}removing .guix-profile, .cache/guix and .config/guix of all /home users" for user in `ls -1 /home`; do rm -f /home/$user/.guix-profile rm -rf /home/$user/.cache/guix rm -rf /home/$user/.config/guix done } welcome() { local uninstall_flag="$1" local char cat<<"EOF" ░░░ ░░░ ░░▒▒░░░░░░░░░ ░░░░░░░░░▒▒░░ ░░▒▒▒▒▒░░░░░░░ ░░░░░░░▒▒▒▒▒░ ░▒▒▒░░▒▒▒▒▒ ░░░░░░░▒▒░ ░▒▒▒▒░ ░░░░░░ ▒▒▒▒▒ ░░░░░░ ▒▒▒▒▒ ░░░░░ ░▒▒▒▒▒ ░░░░░ ▒▒▒▒▒ ░░░░░ ▒▒▒▒▒ ░░░░░ ░▒▒▒▒▒░░░░░ ▒▒▒▒▒▒░░░ ▒▒▒▒▒▒░ _____ _ _ _ _ _____ _ / ____| \ | | | | | / ____| (_) | | __| \| | | | | | | __ _ _ ___ __ | | |_ | . ' | | | | | | |_ | | | | \ \/ / | |__| | |\ | |__| | | |__| | |_| | |> < \_____|_| \_|\____/ \_____|\__,_|_/_/\_\ https://www.gnu.org/software/guix/ EOF if [ '--uninstall' = "$uninstall_flag" ]; then echo "${WARN}This script will uninstall GNU Guix from your system" echo "To install, run this script with no parameters." else echo "This script installs GNU Guix on your system" echo "To uninstall, pass in the '--uninstall' parameter." fi # Don't use ‘read -p’ here! It won't display when run non-interactively. echo -n "Press return to continue..."$'\r' if ! read -r char; then echo die "Can't read standard input. Hint: don't pipe scripts into a shell." fi if [ "$char" ]; then echo echo "...that ($char) was not a return!" _msg "${WAR}Use newlines to automate installation, e.g.: yes '' | ${0##*/}" _msg "${WAR}Any other method is unsupported and likely to break in future." fi } main_install() { local tmp_path welcome _msg "Starting installation ($(date))" chk_term chk_init_sys add_init_sys_require chk_require "${REQUIRE[@]}" chk_gpg_keyring chk_sys_arch chk_sys_nscd _msg "${INF}system is ${ARCH_OS}" umask 0022 tmp_path="$(mktemp -t -d guix.XXXXXX)" if [ -z "${GUIX_BINARY_FILE_NAME}" ]; then guix_get_bin_list "${GNU_URL}" guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path" GUIX_BINARY_FILE_NAME=${BIN_VER}.tar.xz else if ! [[ $GUIX_BINARY_FILE_NAME =~ $ARCH_OS ]]; then _err "$ARCH_OS not in ${GUIX_BINARY_FILE_NAME}; aborting" fi _msg "${INF}Using manually provided binary ${GUIX_BINARY_FILE_NAME}" GUIX_BINARY_FILE_NAME=$(realpath "$GUIX_BINARY_FILE_NAME") fi sys_create_store "${GUIX_BINARY_FILE_NAME}" "${tmp_path}" sys_create_build_user sys_maybe_setup_selinux sys_enable_guix_daemon sys_authorize_build_farms sys_create_init_profile sys_create_shell_completion sys_customize_bashrc _msg "${INF}cleaning up ${tmp_path}" rm -r "${tmp_path}" _msg "${PAS}Guix has successfully been installed!" _msg "${INF}Run 'info guix' to read the manual." # Required to source /etc/profile in desktop environments. _msg "${INF}Please log out and back in to complete the installation." } main_uninstall() { welcome --uninstall _msg "Starting uninstall process ($(date))" chk_term chk_require "${REQUIRE[@]}" # it's ok to leave the gpg key chk_init_sys chk_sys_arch _msg "${INF}system is ${ARCH_OS}" # stop the build, package system. sys_delete_guix_daemon # stop people from accessing their profiles. sys_delete_user_profiles # kill guix off all the guts of guix sys_delete_store # clean up the system sys_delete_init_profile sys_delete_build_user # these directories are created on the fly during usage. _msg "${INF}removing /etc/guix" rm -rf /etc/guix _msg "${INF}removing /var/log/guix" rm -rf /var/log/guix _msg "${PAS}Guix has successfully been uninstalled!" } main() { # expect no parameters # or '--uninstall' if [ 0 -eq $# ]; then main_install else local uninstall_flag="$1" if [ '--uninstall' = "${uninstall_flag}" ]; then main_uninstall else echo "unsupported parameters: $@" exit 1 fi fi } main "$@"