guix-install.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. #!/bin/sh
  2. # GNU Guix --- Functional package management for GNU
  3. # Copyright © 2017 sharlatan <sharlatanus@gmail.com>
  4. # Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
  5. # Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
  6. # Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  7. # Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
  8. # Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
  9. # Copyright © 2020 Daniel Brooks <db48x@db48x.net>
  10. # Copyright © 2021 Jakub Kądziołka <kuba@kadziolka.net>
  11. # Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
  12. # Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  13. #
  14. # This file is part of GNU Guix.
  15. #
  16. # GNU Guix is free software; you can redistribute it and/or modify it
  17. # under the terms of the GNU General Public License as published by
  18. # the Free Software Foundation; either version 3 of the License, or (at
  19. # your option) any later version.
  20. #
  21. # GNU Guix is distributed in the hope that it will be useful, but
  22. # WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU General Public License
  27. # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  28. # We require Bash but for portability we'd rather not use /bin/bash or
  29. # /usr/bin/env in the shebang, hence this hack.
  30. if [ "x$BASH_VERSION" = "x" ]
  31. then
  32. exec bash "$0" "$@"
  33. fi
  34. set -e
  35. [ "$UID" -eq 0 ] || { echo "This script must be run as root."; exit 1; }
  36. REQUIRE=(
  37. "dirname"
  38. "readlink"
  39. "wget"
  40. "gpg"
  41. "grep"
  42. "which"
  43. "sed"
  44. "sort"
  45. "getent"
  46. "mktemp"
  47. "rm"
  48. "chmod"
  49. "uname"
  50. "groupadd"
  51. "tail"
  52. "tr"
  53. "xz"
  54. )
  55. PAS=$'[ \033[32;1mPASS\033[0m ] '
  56. ERR=$'[ \033[31;1mFAIL\033[0m ] '
  57. WAR=$'[ \033[33;1mWARN\033[0m ] '
  58. INF="[ INFO ] "
  59. DEBUG=0
  60. GNU_URL="https://ftp.gnu.org/gnu/guix/"
  61. #GNU_URL="https://alpha.gnu.org/gnu/guix/"
  62. # The following associative array holds set of GPG keys used to sign the
  63. # releases, keyed by their corresponding Savannah user ID.
  64. declare -A GPG_SIGNING_KEYS
  65. GPG_SIGNING_KEYS[15145]=3CE464558A84FDC69DB40CFB090B11993D9AEBB5 # ludo
  66. GPG_SIGNING_KEYS[127547]=27D586A4F8900854329FF09F1260E46482E63562 # maxim
  67. # ------------------------------------------------------------------------------
  68. #+UTILITIES
  69. _err()
  70. { # All errors go to stderr.
  71. printf "[%s]: %s\n" "$(date +%s.%3N)" "$1"
  72. }
  73. _msg()
  74. { # Default message to stdout.
  75. printf "[%s]: %s\n" "$(date +%s.%3N)" "$1"
  76. }
  77. _debug()
  78. {
  79. if [ "${DEBUG}" = '1' ]; then
  80. printf "[%s]: %s\n" "$(date +%s.%3N)" "$1"
  81. fi
  82. }
  83. # Return true if user answered yes, false otherwise.
  84. # $1: The prompt question.
  85. prompt_yes_no() {
  86. while true; do
  87. read -rp "$1 " yn
  88. case $yn in
  89. [Yy]*) return 0;;
  90. [Nn]*) return 1;;
  91. *) _msg "Please answer yes or no."
  92. esac
  93. done
  94. }
  95. chk_require()
  96. { # Check that every required command is available.
  97. declare -a warn
  98. local c
  99. _debug "--- [ ${FUNCNAME[0]} ] ---"
  100. for c in "$@"; do
  101. command -v "$c" &>/dev/null || warn+=("$c")
  102. done
  103. [ "${#warn}" -ne 0 ] &&
  104. { _err "${ERR}Missing commands: ${warn[*]}.";
  105. return 1; }
  106. _msg "${PAS}verification of required commands completed"
  107. }
  108. chk_gpg_keyring()
  109. { # Check whether the Guix release signing public key is present.
  110. _debug "--- [ ${FUNCNAME[0]} ] ---"
  111. local user_id
  112. local gpg_key_id
  113. local exit_flag
  114. for user_id in "${!GPG_SIGNING_KEYS[@]}"; do
  115. gpg_key_id=${GPG_SIGNING_KEYS[$user_id]}
  116. # Without --dry-run this command will create a ~/.gnupg owned by root on
  117. # systems where gpg has never been used, causing errors and confusion.
  118. if ! gpg --dry-run --list-keys "$gpg_key_id" >/dev/null 2>&1; then
  119. if prompt_yes_no "${INF}The following OpenPGP public key is \
  120. required to verify the Guix binary signature: $gpg_key_id.
  121. Would you like me to fetch it for you? (yes/no)"; then
  122. wget "https://sv.gnu.org/people/viewgpg.php?user_id=$user_id" \
  123. --no-verbose -O- | gpg --import -
  124. else
  125. _err "${ERR}Missing OpenPGP public key ($gpg_key_id).
  126. Fetch it with this command:
  127. wget \"https://sv.gnu.org/people/viewgpg.php?user_id=$user_id\" -O - | \
  128. sudo -i gpg --import -"
  129. exit_flag=yes
  130. fi
  131. fi
  132. done
  133. if [ "$exit_flag" = yes ]; then
  134. exit 1
  135. fi
  136. }
  137. chk_term()
  138. { # Check for ANSI terminal for color printing.
  139. if [ -t 2 ]; then
  140. if [ "${TERM+set}" = 'set' ]; then
  141. case "$TERM" in
  142. xterm*|rxvt*|urxvt*|linux*|vt*|eterm*|screen*)
  143. ;;
  144. *)
  145. ERR="[ FAIL ] "
  146. PAS="[ PASS ] "
  147. ;;
  148. esac
  149. fi
  150. fi
  151. }
  152. chk_init_sys()
  153. { # Return init system type name.
  154. if [[ $(/sbin/init --version 2>/dev/null) =~ upstart ]]; then
  155. _msg "${INF}init system is: upstart"
  156. INIT_SYS="upstart"
  157. return 0
  158. elif [[ $(systemctl 2>/dev/null) =~ -\.mount ]]; then
  159. _msg "${INF}init system is: systemd"
  160. INIT_SYS="systemd"
  161. return 0
  162. elif [[ -f /etc/init.d/cron && ! -h /etc/init.d/cron ]]; then
  163. _msg "${INF}init system is: sysv-init"
  164. INIT_SYS="sysv-init"
  165. return 0
  166. elif [[ $(openrc --version 2>/dev/null) =~ \(OpenRC\) ]]; then
  167. _msg "${INF}init system is: OpenRC"
  168. INIT_SYS="openrc"
  169. return 0
  170. else
  171. INIT_SYS="NA"
  172. _err "${ERR}Init system could not be detected."
  173. fi
  174. }
  175. chk_sys_arch()
  176. { # Check for operating system and architecture type.
  177. local os
  178. local arch
  179. os="$(uname -s)"
  180. arch="$(uname -m)"
  181. case "$arch" in
  182. i386 | i486 | i686 | i786 | x86)
  183. local arch=i686
  184. ;;
  185. x86_64 | x86-64 | x64 | amd64)
  186. local arch=x86_64
  187. ;;
  188. aarch64)
  189. local arch=aarch64
  190. ;;
  191. armv7l)
  192. local arch=armhf
  193. ;;
  194. ppc64le | powerpc64le)
  195. local arch=powerpc64le
  196. ;;
  197. *)
  198. _err "${ERR}Unsupported CPU type: ${arch}"
  199. exit 1
  200. esac
  201. case "$os" in
  202. Linux | linux)
  203. local os=linux
  204. ;;
  205. *)
  206. _err "${ERR}Your operation system (${os}) is not supported."
  207. exit 1
  208. esac
  209. ARCH_OS="${arch}-${os}"
  210. }
  211. chk_sys_nscd()
  212. { # Check if nscd is up and suggest to start it or install it
  213. if [ "$(type -P pidof)" ]; then
  214. if [ ! "$(pidof nscd)" ]; then
  215. _msg "${WAR}We recommend installing and/or starting your distribution 'nscd' service"
  216. _msg "${WAR}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
  217. fi
  218. else
  219. _msg "${INF}We cannot determine if your distribution 'nscd' service is running"
  220. _msg "${INF}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
  221. fi
  222. }
  223. # Configure substitute discovery according to user's preferences.
  224. # $1 is the installed service file to edit.
  225. configure_substitute_discovery() {
  226. if grep -q -- '--discover=no' "$1" && \
  227. prompt_yes_no "Would you like the Guix daemon to automatically \
  228. discover substitute servers on the local network? (yes/no)"; then
  229. sed -i 's/--discover=no/--discover=yes/' "$1"
  230. fi
  231. }
  232. # ------------------------------------------------------------------------------
  233. #+MAIN
  234. guix_get_bin_list()
  235. { # Scan GNU archive and save list of binaries
  236. local gnu_url="$1"
  237. local -a bin_ver_ls
  238. local latest_ver
  239. local default_ver
  240. _debug "--- [ ${FUNCNAME[0]} ] ---"
  241. # Filter only version and architecture
  242. bin_ver_ls=("$(wget "$gnu_url" --no-verbose -O- \
  243. | sed -n -e 's/.*guix-binary-\([0-9.]*[a-z0-9]*\)\..*.tar.xz.*/\1/p' \
  244. | sort -Vu)")
  245. latest_ver="$(echo "${bin_ver_ls[0]}" \
  246. | grep -oE "([0-9]{1,2}\.){2}[0-9]{1,2}[a-z0-9]*" \
  247. | tail -n1)"
  248. default_ver="guix-binary-${latest_ver}.${ARCH_OS}"
  249. if [[ "${#bin_ver_ls}" -ne "0" ]]; then
  250. _msg "${PAS}Release for your system: ${default_ver}"
  251. else
  252. _err "${ERR}Could not obtain list of Guix releases."
  253. exit 1
  254. fi
  255. # Use default to download according to the list and local ARCH_OS.
  256. BIN_VER="${default_ver}"
  257. }
  258. guix_get_bin()
  259. { # Download and verify binary package.
  260. local url="$1"
  261. local bin_ver="$2"
  262. local dl_path="$3"
  263. local wget_args=()
  264. _debug "--- [ ${FUNCNAME[0]} ] ---"
  265. _msg "${INF}Downloading Guix release archive"
  266. wget --help | grep -q '\--show-progress' \
  267. && wget_args=("--no-verbose" "--show-progress")
  268. if wget "${wget_args[@]}" -P "$dl_path" \
  269. "${url}/${bin_ver}.tar.xz" "${url}/${bin_ver}.tar.xz.sig"; then
  270. _msg "${PAS}download completed."
  271. else
  272. _err "${ERR}could not download ${url}/${bin_ver}.tar.xz."
  273. exit 1
  274. fi
  275. pushd "${dl_path}" >/dev/null
  276. if gpg --verify "${bin_ver}.tar.xz.sig" >/dev/null 2>&1; then
  277. _msg "${PAS}Signature is valid."
  278. popd >/dev/null
  279. else
  280. _err "${ERR}could not verify the signature."
  281. exit 1
  282. fi
  283. }
  284. sys_create_store()
  285. { # Unpack and install /gnu/store and /var/guix
  286. local pkg="$1"
  287. local tmp_path="$2"
  288. _debug "--- [ ${FUNCNAME[0]} ] ---"
  289. if [[ -e "/var/guix" || -e "/gnu" ]]; then
  290. _err "${ERR}A previous Guix installation was found. Refusing to overwrite."
  291. exit 1
  292. fi
  293. cd "$tmp_path"
  294. tar --extract --file "$pkg" && _msg "${PAS}unpacked archive"
  295. _msg "${INF}Installing /var/guix and /gnu..."
  296. mv "${tmp_path}/var/guix" /var/
  297. mv "${tmp_path}/gnu" /
  298. _msg "${INF}Linking the root user's profile"
  299. mkdir -p ~root/.config/guix
  300. ln -sf /var/guix/profiles/per-user/root/current-guix \
  301. ~root/.config/guix/current
  302. GUIX_PROFILE=~root/.config/guix/current
  303. # shellcheck disable=SC1090
  304. source "${GUIX_PROFILE}/etc/profile"
  305. _msg "${PAS}activated root profile at ${GUIX_PROFILE}"
  306. }
  307. sys_create_build_user()
  308. { # Create the group and user accounts for build users.
  309. _debug "--- [ ${FUNCNAME[0]} ] ---"
  310. if getent group guixbuild > /dev/null; then
  311. _msg "${INF}group guixbuild exists"
  312. else
  313. groupadd --system guixbuild
  314. _msg "${PAS}group <guixbuild> created"
  315. fi
  316. if getent group kvm > /dev/null; then
  317. _msg "${INF}group kvm exists and build users will be added to it"
  318. local KVMGROUP=,kvm
  319. fi
  320. for i in $(seq -w 1 10); do
  321. if id "guixbuilder${i}" &>/dev/null; then
  322. _msg "${INF}user is already in the system, reset"
  323. usermod -g guixbuild -G guixbuild${KVMGROUP} \
  324. -d /var/empty -s "$(which nologin)" \
  325. -c "Guix build user $i" \
  326. "guixbuilder${i}";
  327. else
  328. useradd -g guixbuild -G guixbuild${KVMGROUP} \
  329. -d /var/empty -s "$(which nologin)" \
  330. -c "Guix build user $i" --system \
  331. "guixbuilder${i}";
  332. _msg "${PAS}user added <guixbuilder${i}>"
  333. fi
  334. done
  335. }
  336. sys_enable_guix_daemon()
  337. { # Run the daemon, and set it to automatically start on boot.
  338. local info_path
  339. local local_bin
  340. local var_guix
  341. _debug "--- [ ${FUNCNAME[0]} ] ---"
  342. info_path="/usr/local/share/info"
  343. local_bin="/usr/local/bin"
  344. var_guix="/var/guix/profiles/per-user/root/current-guix"
  345. case "$INIT_SYS" in
  346. upstart)
  347. { initctl reload-configuration;
  348. cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
  349. /etc/init/ &&
  350. configure_substitute_discovery /etc/init/guix-daemon.conf &&
  351. start guix-daemon; } &&
  352. _msg "${PAS}enabled Guix daemon via upstart"
  353. ;;
  354. systemd)
  355. { # systemd .mount units must be named after the target directory.
  356. # Here we assume a hard-coded name of /gnu/store.
  357. # XXX Work around <https://issues.guix.gnu.org/41356> until next release.
  358. if [ -f ~root/.config/guix/current/lib/systemd/system/gnu-store.mount ]; then
  359. cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
  360. /etc/systemd/system/;
  361. chmod 664 /etc/systemd/system/gnu-store.mount;
  362. systemctl daemon-reload &&
  363. systemctl enable gnu-store.mount;
  364. fi
  365. cp ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
  366. /etc/systemd/system/;
  367. chmod 664 /etc/systemd/system/guix-daemon.service;
  368. # Work around <https://bugs.gnu.org/36074>, present in 1.0.1.
  369. sed -i /etc/systemd/system/guix-daemon.service \
  370. -e "s/GUIX_LOCPATH='/'GUIX_LOCPATH=/";
  371. # Work around <https://bugs.gnu.org/35671>, present in 1.0.1.
  372. if ! grep en_US /etc/systemd/system/guix-daemon.service >/dev/null;
  373. then sed -i /etc/systemd/system/guix-daemon.service \
  374. -e 's/^Environment=\(.*\)$/Environment=\1 LC_ALL=en_US.UTF-8';
  375. fi;
  376. configure_substitute_discovery \
  377. /etc/systemd/system/guix-daemon.service
  378. systemctl daemon-reload &&
  379. systemctl enable guix-daemon &&
  380. systemctl start guix-daemon; } &&
  381. _msg "${PAS}enabled Guix daemon via systemd"
  382. ;;
  383. sysv-init)
  384. { mkdir -p /etc/init.d;
  385. cp ~root/.config/guix/current/etc/init.d/guix-daemon \
  386. /etc/init.d/guix-daemon;
  387. chmod 775 /etc/init.d/guix-daemon;
  388. configure_substitute_discovery /etc/init.d/guix-daemon
  389. update-rc.d guix-daemon defaults &&
  390. update-rc.d guix-daemon enable &&
  391. service guix-daemon start; } &&
  392. _msg "${PAS}enabled Guix daemon via sysv"
  393. ;;
  394. openrc)
  395. { mkdir -p /etc/init.d;
  396. cp ~root/.config/guix/current/etc/openrc/guix-daemon \
  397. /etc/init.d/guix-daemon;
  398. chmod 775 /etc/init.d/guix-daemon;
  399. configure_substitute_discovery /etc/init.d/guix-daemon
  400. rc-update add guix-daemon default &&
  401. rc-service guix-daemon start; } &&
  402. _msg "${PAS}enabled Guix daemon via OpenRC"
  403. ;;
  404. NA|*)
  405. _msg "${ERR}unsupported init system; run the daemon manually:"
  406. echo " ~root/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild"
  407. ;;
  408. esac
  409. _msg "${INF}making the guix command available to other users"
  410. [ -e "$local_bin" ] || mkdir -p "$local_bin"
  411. ln -sf "${var_guix}/bin/guix" "$local_bin"
  412. [ -e "$info_path" ] || mkdir -p "$info_path"
  413. for i in "${var_guix}"/share/info/*; do
  414. ln -sf "$i" "$info_path"
  415. done
  416. }
  417. sys_authorize_build_farms()
  418. { # authorize the public key of the build farm
  419. if prompt_yes_no "Permit downloading pre-built package binaries from the \
  420. project's build farm? (yes/no)"; then
  421. guix archive --authorize \
  422. < ~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub \
  423. && _msg "${PAS}Authorized public key for ci.guix.gnu.org"
  424. else
  425. _msg "${INF}Skipped authorizing build farm public keys"
  426. fi
  427. }
  428. sys_create_init_profile()
  429. { # Define for better desktop integration
  430. # This will not take effect until the next shell or desktop session!
  431. [ -d "/etc/profile.d" ] || mkdir /etc/profile.d # Just in case
  432. cat <<"EOF" > /etc/profile.d/guix.sh
  433. # Explicitly initialize XDG base directory variables to ease compatibility
  434. # with Guix System: see <https://issues.guix.gnu.org/56050#3>.
  435. export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
  436. export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
  437. export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
  438. export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}"
  439. export XDG_CONFIG_DIRS="${XDG_CONFIG_DIRS:-/etc/xdg}"
  440. export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
  441. # no default for XDG_RUNTIME_DIR (depends on foreign distro for semantics)
  442. # _GUIX_PROFILE: `guix pull` profile
  443. _GUIX_PROFILE="$HOME/.config/guix/current"
  444. export PATH="$_GUIX_PROFILE/bin${PATH:+:}$PATH"
  445. # Export INFOPATH so that the updated info pages can be found
  446. # and read by both /usr/bin/info and/or $GUIX_PROFILE/bin/info
  447. # When INFOPATH is unset, add a trailing colon so that Emacs
  448. # searches 'Info-default-directory-list'.
  449. export INFOPATH="$_GUIX_PROFILE/share/info:$INFOPATH"
  450. # GUIX_PROFILE: User's default profile
  451. # Prefer the one from 'guix home' if it exists.
  452. GUIX_PROFILE="$HOME/.guix-home/profile"
  453. [ -L $GUIX_PROFILE ] || GUIX_PROFILE="$HOME/.guix-profile"
  454. [ -L $GUIX_PROFILE ] || return
  455. GUIX_LOCPATH="$GUIX_PROFILE/lib/locale"
  456. export GUIX_LOCPATH
  457. [ -f "$GUIX_PROFILE/etc/profile" ] && . "$GUIX_PROFILE/etc/profile"
  458. # set XDG_DATA_DIRS to include Guix installations
  459. export XDG_DATA_DIRS="$GUIX_PROFILE/share:$XDG_DATA_DIRS"
  460. EOF
  461. }
  462. sys_create_shell_completion()
  463. { # Symlink supported shell completions system-wide
  464. var_guix=/var/guix/profiles/per-user/root/current-guix
  465. bash_completion=/etc/bash_completion.d
  466. zsh_completion=/usr/share/zsh/site-functions
  467. fish_completion=/usr/share/fish/vendor_completions.d
  468. { # Just in case
  469. for dir_shell in $bash_completion $zsh_completion $fish_completion; do
  470. [ -d "$dir_shell" ] || mkdir -p $dir_shell
  471. done;
  472. ln -sf ${var_guix}/etc/bash_completion.d/* "$bash_completion";
  473. ln -sf ${var_guix}/share/zsh/site-functions/* "$zsh_completion";
  474. ln -sf ${var_guix}/share/fish/vendor_completions.d/* "$fish_completion"; } &&
  475. _msg "${PAS}installed shell completion"
  476. }
  477. welcome()
  478. {
  479. cat<<"EOF"
  480. ░░░ ░░░
  481. ░░▒▒░░░░░░░░░ ░░░░░░░░░▒▒░░
  482. ░░▒▒▒▒▒░░░░░░░ ░░░░░░░▒▒▒▒▒░
  483. ░▒▒▒░░▒▒▒▒▒ ░░░░░░░▒▒░
  484. ░▒▒▒▒░ ░░░░░░
  485. ▒▒▒▒▒ ░░░░░░
  486. ▒▒▒▒▒ ░░░░░
  487. ░▒▒▒▒▒ ░░░░░
  488. ▒▒▒▒▒ ░░░░░
  489. ▒▒▒▒▒ ░░░░░
  490. ░▒▒▒▒▒░░░░░
  491. ▒▒▒▒▒▒░░░
  492. ▒▒▒▒▒▒░
  493. _____ _ _ _ _ _____ _
  494. / ____| \ | | | | | / ____| (_)
  495. | | __| \| | | | | | | __ _ _ ___ __
  496. | | |_ | . ' | | | | | | |_ | | | | \ \/ /
  497. | |__| | |\ | |__| | | |__| | |_| | |> <
  498. \_____|_| \_|\____/ \_____|\__,_|_/_/\_\
  499. This script installs GNU Guix on your system
  500. https://www.gnu.org/software/guix/
  501. EOF
  502. echo -n "Press return to continue..."
  503. read -r
  504. }
  505. main()
  506. {
  507. local tmp_path
  508. welcome
  509. _msg "Starting installation ($(date))"
  510. chk_term
  511. chk_require "${REQUIRE[@]}"
  512. chk_gpg_keyring
  513. chk_init_sys
  514. chk_sys_arch
  515. chk_sys_nscd
  516. _msg "${INF}system is ${ARCH_OS}"
  517. umask 0022
  518. tmp_path="$(mktemp -t -d guix.XXX)"
  519. if [ -z "${GUIX_BINARY_FILE_NAME}" ]; then
  520. guix_get_bin_list "${GNU_URL}"
  521. guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
  522. GUIX_BINARY_FILE_NAME=${BIN_VER}.tar.xz
  523. else
  524. if ! [[ $GUIX_BINARY_FILE_NAME =~ $ARCH_OS ]]; then
  525. _err "$ARCH_OS not in ${GUIX_BINARY_FILE_NAME}; aborting"
  526. fi
  527. _msg "${INF}Using manually provided binary ${GUIX_BINARY_FILE_NAME}"
  528. GUIX_BINARY_FILE_NAME=$(realpath "$GUIX_BINARY_FILE_NAME")
  529. fi
  530. sys_create_store "${GUIX_BINARY_FILE_NAME}" "${tmp_path}"
  531. sys_create_build_user
  532. sys_enable_guix_daemon
  533. sys_authorize_build_farms
  534. sys_create_init_profile
  535. sys_create_shell_completion
  536. _msg "${INF}cleaning up ${tmp_path}"
  537. rm -r "${tmp_path}"
  538. _msg "${PAS}Guix has successfully been installed!"
  539. _msg "${INF}Run 'info guix' to read the manual."
  540. # Required to source /etc/profile in desktop environments.
  541. _msg "${INF}Please log out and back in to complete the installation."
  542. }
  543. main "$@"