Next: , Up: 安装   [Contents][Index]


2.1 二进制文件安装

这个小节介绍如何在任意的系统上用独立的Guix二进制文件包安装Guix和它的依赖。这通常比从源代码安装更快,下一小节会介绍如何从源代码安装。唯一的需求是有GNU tar和Xz。

注: 我们推荐使用这个shell安装脚本。这个脚本自动执行下述的下载、安装并且初始化Guix的过程。它需要以root用户身份运行。作为root用户,因此你可以运行这个:

cd /tmp
wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
chmod +x guix-install.sh
./guix-install.sh

If you’re running Debian or a derivative such as Ubuntu, you can instead install the package (it might be a version older than 1.4.0 but you can update it afterwards by running ‘guix pull’):

sudo apt install guix

Likewise on openSUSE:

sudo zypper install guix

When you’re done, see 设置应用程序 for extra configuration you might need, and 入门 for your first steps!

安装步骤如下:

  1. Download the binary tarball from ‘https://ftp.gnu.org/gnu/guix/guix-binary-1.4.0.x86_64-linux.tar.xz’, where x86_64-linux can be replaced with i686-linux for an i686 (32-bits) machine already running the kernel Linux, and so on (see GNU发行版).

    请确保下载相关的.sig文件,并且用它验证文件包的可靠性,方法如下:

    $ wget https://ftp.gnu.org/gnu/guix/guix-binary-1.4.0.x86_64-linux.tar.xz.sig
    $ gpg --verify guix-binary-1.4.0.x86_64-linux.tar.xz.sig
    

    如果那个命令因为缺少所需的公钥而失败了,那么用这个命令导入它:

    $ wget 'https://sv.gnu.org/people/viewgpg.php?user_id=15145' \
          -qO - | gpg --import -
    

    再次运行gpg --verify命令。

    Take note that a warning like “This key is not certified with a trusted signature!” is normal.

  2. 现在你需要成为root用户。基于你的发行版,你可能需要执行su -sudo -i。以root用户身份,执行:
    # cd /tmp
    # tar --warning=no-timestamp -xf \
         /path/to/guix-binary-1.4.0.x86_64-linux.tar.xz
    # mv var/guix /var/ && mv gnu /
    

    This creates /gnu/store (see 仓库) and /var/guix. The latter contains a ready-to-use profile for root (see next step).

    不要在一个正常的Guix系统上解压这个文件包,因为那会把现有的重要的文件覆盖。

    The --warning=no-timestamp option makes sure GNU tar does not emit warnings about “implausibly old time stamps” (such warnings were triggered by GNU tar 1.26 and older; recent versions are fine). They stem from the fact that all the files in the archive have their modification time set to 1 (which means January 1st, 1970). This is done on purpose to make sure the archive content is independent of its creation time, thus making it reproducible.

  3. 使profile出现在~root/.config/guix/current,这是guix pull安装更新的位置(see Invoking guix pull):
    # mkdir -p ~root/.config/guix
    # ln -sf /var/guix/profiles/per-user/root/current-guix \
             ~root/.config/guix/current
    

    Source etc/profile to augment PATH and other relevant environment variables:

    # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
      source $GUIX_PROFILE/etc/profile
    
  4. 像下面解释的那样为“构建用户”创建用户组和用户(see 设置构建环境)。
  5. 运行后台进程,并设置为开机自启动。

    如果你的主机的发行版使用systemd init系统,可以用这些命令:

    # cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
         ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
         /etc/systemd/system/
    # systemctl enable --now gnu-store.mount guix-daemon
    

    You may also want to arrange for guix gc to run periodically:

    # cp ~root/.config/guix/current/lib/systemd/system/guix-gc.service \
         ~root/.config/guix/current/lib/systemd/system/guix-gc.timer \
         /etc/systemd/system/
    # systemctl enable --now guix-gc.timer
    

    You may want to edit guix-gc.service to adjust the command line options to fit your needs (see Invoking guix gc).

    如果你的主机的发行版使用Upstart init系统:

    # initctl reload-configuration
    # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
         /etc/init/
    # start guix-daemon
    

    此外,你可以手动启动后台进程:

    # ~root/.config/guix/current/bin/guix-daemon \
           --build-users-group=guixbuild
    
  6. 使机器上的其他用户也可以使用guix命令:
    # mkdir -p /usr/local/bin
    # cd /usr/local/bin
    # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
    

    最好让这个用户手册的Info版也可以被访问:

    # mkdir -p /usr/local/share/info
    # cd /usr/local/share/info
    # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
      do ln -s $i ; done
    

    That way, assuming /usr/local/share/info is in the search path, running info guix will open this manual (see Other Info Directories in GNU Texinfo, for more details on changing the Info search path).

  7. To use substitutes from ci.guix.gnu.org, bordeaux.guix.gnu.org or a mirror (see substitutes), authorize them:
    # guix archive --authorize < \
         ~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub
    # guix archive --authorize < \
         ~root/.config/guix/current/share/guix/bordeaux.guix.gnu.org.pub
    

    注: If you do not enable substitutes, Guix will end up building everything from source on your machine, making each installation and upgrade very expensive. See 关于信任二进制文件, for a discussion of reasons why one might want do disable substitutes.

  8. 每个用户可能需要执行一些额外的步骤以使各自的Guix环境可用,see 设置应用程序

瞧,安装完成了!

你可以通过给root profile安装一个软件包来确认Guix可以正常工作。

# guix install hello

二进制安装包可以通过在Guix源代码树里运行下面这些命令来重现和验证:

make guix-binary.系统.tar.xz

... 这个命令会执行:

guix pack -s 系统 --localstatedir \
  --profile-name=current-guix guix

See Invoking guix pack,了解这个方便的工具。


Next: 需求, Up: 安装   [Contents][Index]