guix-install.sh: Prompt for configuring substitutes discovery.

Also ensure prompt_yes_no always print the message with a trailing space,
which is more pleasing to the eye.

* etc/guix-daemon.conf.in <--discover=no>: New guix-daemon option.
* etc/guix-daemon.service.in: Likewise.
* etc/init.d/guix-daemon.in: Likewise.
* etc/openrc/guix-daemon.in: Likewise.
* etc/guix-install.sh (configure_substitute_discovery): New procedure.
(sys_enable_guix_daemon): Ask the user whether automatic substitute discovery
should be enabled.  Set the '--discover' argument accordingly.
(prompt_yes_no): Add a trailing space to the message.
(sys_authorize_build_farms): Remove trailing space from the message argument.
* NEWS (Distribution): Add news.
This commit is contained in:
Maxim Cournoyer 2021-07-05 16:44:29 -04:00
parent ac3444968a
commit 4cbe0127a6
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
6 changed files with 28 additions and 8 deletions

5
NEWS
View File

@ -14,8 +14,9 @@ Please send Guix bug reports to bug-guix@gnu.org.
* Changes in 1.4.0 (since 1.3.0)
** Package management
* New 'deb' format for the 'guix pack' command
*** New 'deb' format for the 'guix pack' command
** Distribution
*** The installation script can now enable local substitute servers discovery
* Changes in 1.3.0 (since 1.2.0)
** Package management
*** POWER9 (powerpc64le-linux) is now supported as a technology preview

View File

@ -7,4 +7,4 @@ start on runlevel [2345]
stop on runlevel [016]
exec @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild
exec @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild --discover=no

View File

@ -6,7 +6,8 @@
Description=Build daemon for GNU Guix
[Service]
ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild
ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \
--build-users-group=guixbuild --discover=no
Environment='GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale' LC_ALL=en_US.utf8
RemainAfterExit=yes
StandardOutput=syslog

View File

@ -96,7 +96,7 @@ _debug()
# $1: The prompt question.
prompt_yes_no() {
while true; do
read -rp "$1" yn
read -rp "$1 " yn
case $yn in
[Yy]*) return 0;;
[Nn]*) return 1;;
@ -249,6 +249,16 @@ chk_sys_nscd()
fi
}
# Configure substitute discovery according to user's preferences.
# $1 is the installed service file to edit.
configure_substitute_discovery() {
if grep -q -- '--discover=no' "$1" && \
prompt_yes_no "Would you like the Guix daemon to automatically \
discover substitute servers on the local network? (yes/no)"; then
sed -i 's/--discover=no/--discover=yes/' "$1"
fi
}
# ------------------------------------------------------------------------------
#+MAIN
@ -397,6 +407,7 @@ sys_enable_guix_daemon()
{ 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"
;;
@ -426,6 +437,9 @@ sys_enable_guix_daemon()
-e 's/^Environment=\(.*\)$/Environment=\1 LC_ALL=en_US.UTF-8';
fi;
configure_substitute_discovery \
/etc/systemd/system/guix-daemon.service
systemctl daemon-reload &&
systemctl enable guix-daemon &&
systemctl start guix-daemon; } &&
@ -437,6 +451,8 @@ sys_enable_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; } &&
@ -448,6 +464,8 @@ sys_enable_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"
@ -472,7 +490,7 @@ sys_enable_guix_daemon()
sys_authorize_build_farms()
{ # authorize the public key of the build farm
if prompt_yes_no "Permit downloading pre-built package binaries from the \
project's build farm? (yes/no) "; then
project's build farm? (yes/no)"; then
guix archive --authorize \
< "~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub" \
&& _msg "${PAS}Authorized public key for ci.guix.gnu.org"

View File

@ -36,7 +36,7 @@ start)
-E LC_ALL=en_US.utf8 \
-p "/var/run/guix-daemon.pid" \
@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \
--build-users-group=guixbuild
--build-users-group=guixbuild --discover=no
fi
;;
stop)

View File

@ -20,7 +20,7 @@
export GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale
export LC_ALL=en_US.utf8
command="@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon"
command_args="--build-users-group=guixbuild"
command_args="--build-users-group=guixbuild --discover=no"
command_background="yes"
pidfile="/var/run/guix-daemon.pid"