Guix 安装
GNU Guix 安装包可以从它的主页 GuixSD 下载。这里除了描述如何安装和使用前的准备工作之外,还说明了关于 Guix 应用所需要的依赖。
这里我们主要关注的是如何在 Gnu/Linux 中安装软件包管理器,如果想要安装完整的操作系统(GuixSD)请参考系统安装。
在 GNU/Linux 中安装完 Guix 之后,可以在不干扰任何全体软件应用的情况下有 效补充系统中的可用工具。它的数据会保存在两个地方:/gnu/store 和 /var/guix。系统中的其他文件,像保存在 /etc 下的配置文件,都不会被影响。
从二进制文件安装
这里主要描述 Guix 如何在任意操作系统中从包含 Guix 和它的依赖的二进制文件包中安装。这样的安装方式相较于从源代码安装会快很多,从源代码安装的方式将在下一节进行说明。使用二进制文件包安装时仅仅需要系统中有 GNU Tar 和 Xz 两个工具。
安装步骤
下载二进制包,如果你在 x86_64 中安装时,其中 system 替换为 x86_64-linux,以此类推。
确定下载了相关的 .sig 文件用以验证二进制包
$ wget ftp://alpha.gnu.org/gnu/guix/guix-binary-0.14.0.system.tar.xz.sig $ gpg --verify guix-binary-0.14.0.system.tar.xz.sig
如果上面的命令执行失败了,说明系统中没有必要的公钥存在。运行下面的命令去导入公钥
$ gpg --keyserver pgp.mit.edu --recv-keys 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
然后重新运行
gpg --verify
命令。以 root 用户运行下面的命令
# cd /tmp # tar --warning=no-timestamp -xf \ guix-binary-0.14.0.system.tar.xz # mv var/guix /var/ && mv gnu /
这里将会创建 /gnu/store(参考The Store)和 /var/guix 两个目录。/var/guix 目录中包含 root 用户的可使用的 profile(参考下一步)。
不要在正在运行 Guix 的系统中解压这个 Tar 包,这样会覆盖原有的配置。
--warning=no-timestamp
选项使 GNU Tar 不会发出关于「implausibly old time stamps」(不合理的旧时间戳)的警告。(这种警告会出现在 1.26 或更老版本的 GNU Tar 中)创建 root 的 profile 在 ~/.guix-profile 中
# ln -sf /var/guix/profiles/per-user/root/guix-profile \ ~root/.guix-profile
Source etc/profile to augment PATH and other relevant environment variables:
# GUIX_PROFILE=$HOME/.guix-profile ; \ source $GUIX_PROFILE/etc/profile
- 参考 Build Environment Setup 为 build 创建用户和组
运行守护进程和开机启动
如果主机使用 systemd init 系统,可以通过下面的命令实现
# cp ~root/.guix-profile/lib/systemd/system/guix-daemon.service \ /etc/systemd/system/ # systemctl start guix-daemon && systemctl enable guix-daemon
如果主机使用 Upstart init 系统
# initctl reload-configuration # cp ~root/.guix-profile/lib/upstart/system/guix-daemon.conf /etc/init/ # start guix-daemon
或者可以一直手动启动
# ~root/.guix-profile/bin/guix-daemon --build-users-group=guixbuild
让系统中其他用户也可以使用 guix 命令
# mkdir -p /usr/local/bin # cd /usr/local/bin # ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix
也可以把 info 版的手册添加到 info 可访问路径
# mkdir -p /usr/local/share/info # cd /usr/local/share/info # for i in /var/guix/profiles/per-user/root/guix-profile/share/info/* ; do ln -s $i ; done
这里假设 /usr/local/share/info 是 info 应用的搜索路径,这样就可以使用 info guix 命令打开手册了。
从 hydra.gnu.org 使用 substitutes 或者它的镜像验证它们
# guix archive --authorize < ~root/.guix-profile/share/guix/hydra.gnu.org.pub
每个使用者可能需要做一些额外的设置去初始化Guix环境之后才能正常使用它,参见 Application Setup。
至此安装完成
可以安装一个简单的包到 root 的 profile 来验证 Guix 正常工作
# guix package -i hello
The guix package must remain available in root’s profile, or it would become subject to garbage collection—in which case you would find yourself badly handicapped by the lack of the guix command. In other words, do not remove guix by running guix package -r guix.
二进制安装包可以在 Guix 源码中运行以下命令来制作(重新制作)
make guix-binary.system.tar.xz
反过来,运行
guix pack -s system --localstatedir guix
参考 guix pack 获取更多关于这个好用工具的信息。
原文连接 Installation。