AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 698811
Accepted
BlackShift
BlackShift
Asked: 2022-04-12 21:01:47 +0800 CST2022-04-12 21:01:47 +0800 CST 2022-04-12 21:01:47 +0800 CST

在 GUIX 中,如何使用旧版本的包,不再在频道中?

  • 772

GUIX 吸引我的部分原因是可以同时“安装”各种不同版本的软件包,而不会相互干扰。但我不知道如何实际使用这些不同的版本。

例如,最近,该pyyaml软件包已从 5.4.1 升级到 6.0。由于各种原因,我想继续使用 5.4.1。(我只是在这里使用 pyyaml 作为示例。)我的商店中确实有旧版本:

$ ls -d1 /gnu/store/*pyyaml*
/gnu/store/22v8l25b33vs65wjd9ap28n772bvlih3-python-pyyaml-5.4.1/
/gnu/store/2j2s1jd6y8x7mlqjp968955misx1qw1c-python-pyyaml-6.0/
/gnu/store/54imz4x65s3xbjrgrfswgk815gfkhk4b-python-pyyaml-5.4.1/
/gnu/store/6537a8na1rbilffqqi642q0lipqfi2zg-python-pyyaml-5.4.1.drv
/gnu/store/6flrrmhq203vg6awdw7r2lsmzix4g2rh-python-pyyaml-6.0-guile-builder
/gnu/store/73k3qdz9rdh64pl7a0f0951zm2pbx5s2-python-pyyaml-5.4.1.drv
/gnu/store/7bcbwi93ihz8v2sdzmj6l9vhjqaxr14l-python-pyyaml-5.4.1-builder
...

如何使用这些旧版本?

仅单独使用这样的旧版本就可以了。例如,我希望这样的事情可以工作:

$ guix shell "[email protected]" python
guix shell: error: python-pyyaml: package not found for version 5.4.1

预计会出现此错误,因为旧版本在我的频道中不可用。所以也许有可能以某种方式指定要使用的旧版本的频道,但我不知道如何。


关于 XY 问题的侧节点,这个问题的直接原因是 docker-compose 现在不再工作了:

$ guix shell docker-compose
guix shell: error: build of `/gnu/store/8qhvnw5mwra9i6ji24xlywcpdl0rdznn-docker-compose-1.29.2.drv' failed
$ zcat /var/log/guix/drvs/8q/hvnw5mwra9i6ji24xlywcpdl0rdznn-docker-compose-1.29.2.drv.gz
...checking requirements: ERROR: docker-compose==1.29.2 ContextualVersionConflict(PyYAML 6.0 (/gnu/store/igfl4023dzvl8vi6xs1m96lcsr4fdw07-python-pyyaml-6.0/lib/python3.9/site-packages), Requirement.parse('PyYAML<6,>=3.10'), {'docker-compose'})

但是,我并不特别关心 docker-compose (wrt this question)。如果有的话,这个问题是我用 GUIX 原生工具替换它的旅程的一部分。

(另外,我知道 pyyaml 6 会强制其用户使用一些安全功能,因此不应再使用 pyyaml 5;pyyaml 仅用作示例。)

guix
  • 3 3 个回答
  • 248 Views

3 个回答

  • Voted
  1. Best Answer
    BlackShift
    2022-04-15T01:03:22+08:002022-04-15T01:03:22+08:00

    第三次是魅力,使用低级的清单似乎是最好的。

    详情请参阅info guix Inferiors。这是信息页面的快照。(有趣的是,他们的用例与我的非常相似:为 guile 解释器使用旧版本的 json 库,而不是为 python 解释器使用旧版本的 yaml 库。)

         Note: The functionality described here is a “technology preview” as
         of version 0.0-git.  As such, the interface is subject to change.
    
       Sometimes you might need to mix packages from the revision of Guix
    you’re currently running with packages available in a different revision
    of Guix.  Guix “inferiors” allow you to achieve that by composing
    different Guix revisions in arbitrary ways.
    
       ...
    
       When combined with channels (*note Channels::), inferiors provide a
    simple way to interact with a separate revision of Guix.  For example,
    let’s assume you want to install in your profile the current ‘guile’
    package, along with the ‘guile-json’ as it existed in an older revision
    of Guix—perhaps because the newer ‘guile-json’ has an incompatible API
    and you want to run your code against the old API.  To do that, you
    could write a manifest for use by ‘guix package --manifest’ (*note
    Invoking guix package::); in that manifest, you would create an inferior
    for that old Guix revision you care about, and you would look up the
    ‘guile-json’ package in the inferior.
    

    它继续举一个例子。以下是适用于此特定用例的相同示例:

    $ cat mypyyamlmanifest.scm
    (use-modules (guix inferior) (guix channels)
                 (srfi srfi-1))
    
    (define channels
      (list (channel
             (name 'guix)
             (url "https://git.savannah.gnu.org/git/guix.git")
             (commit
              ;; The commit with the python-pyyaml 5.4.1
              "d3e1a94391a838332b0565d56762a58cf87ac6b1"))))
    
    (define inferior
      (inferior-for-channels channels))
    
    (packages->manifest
     (list (first (lookup-inferior-packages inferior "python-pyyaml"))
           (specification->package "python")))
    
    $ guix shell -m mypyyamlmanifest.scm 
    ...
    
    $ python3 -c "import yaml; print(yaml.__version__)"
    5.4.1
    

    反思为什么要花这么长时间才能找到这些信息。(也许 GUIX 开发人员会读到这个,也许我可以用它自己为文档提供补丁。)

    guix info guix package是我使用清单的起点。描述中有关于如何制作清单的--manifest简短示例,并且没有谈论渠道。有一个链接指向--export-manifest我遵循的描述,以了解如何重新创建为我的第一个答案创建的环境。该部分解释说此导出不包含频道信息,这使我得出结论,清单根本不包含频道信息,并且需要第二个文件(我的第二个答案)。--export-manifest描述链接到它的--export-channels正下方,起初我没有阅读,因为我只是调整了我现有的channels.scm. 但是,该部分最终解释了需要劣等者。

    --manifest如果部分guix package解释可以直接在清单中定义通道,我可能会更容易理解。

    如果我理解正确,劣质在技术上与渠道不同,所以上面的最后一句话是错误的,不可能在清单中定义渠道。然而在实践中,似乎可以只对清单中的所有包使用劣质包,从而有效地对清单中的通道进行硬编码。这让我想知道直接在清单中允许通道规范是否更简单。


    在回答问题时,这个解决方案仍然不足以解决触发问题的初始问题: running docker-compose,因为docker-compose仍然使用python-pyyaml来自原始频道的。可以让包使用劣质作为输入,使用modify-inputs. 这使得只docker-compose使用劣质频道中的过时频道成为可能python-pyyaml,而让配置文件的其余部分使用python-pyyaml原始频道中较新的频道。

    • 1
  2. BlackShift
    2022-04-12T23:58:09+08:002022-04-12T23:58:09+08:00

    感谢出色的info guix页面,我认为这是可行的:

    guix shell \
        --with-git-url=python-pyyaml="https://github.com/yaml/pyyaml.git" \
        --with-branch=python-pyyaml="release/5.4.1" \
        python-pyyaml python
    

    但是,如果https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/python-xyz.scm?h=d3e1a94391a838332b0565d56762a58cf87ac6b1# n3907。

    如,pyyaml是一个非常简单的包,它很好地托管在 github 上,遵循标准的 git 分支和 Python 安装程序。但是有些包可能更复杂,这样简单的替换可能不起作用。

    是否有某种方法可以在通道 git url 上指定特定提交以用于包?(或者一个完整的guix shell命令?)


    编辑:这个解决方案不好的另一个原因是它不适用于--export-manifest:

    $ guix shell \
        --with-git-url=python-pyyaml="https://github.com/yaml/pyyaml.git" \
        --with-branch=python-pyyaml="release/5.4.1" \
        --export-manifest \
        python-pyyaml python > mymanifest.scm
    
    $ guix shell -m mymanifest.scm
    guix shell: error: the source of [email protected] is not a Git 
    

    与mymanifest.scm:

    $ cat mymanifest.scm
    ;; What follows is a "manifest" equivalent to the command line you gave.
    ;; You can store it in a file that you may then pass to any 'guix' command
    ;; that accepts a '--manifest' (or '-m') option.
    
    (use-modules (guix transformations))
    
    (define transform1
      (options->transformation
        '((with-git-url
            .
            "python-pyyaml=https://github.com/yaml/pyyaml.git")
          (with-branch . "python-pyyaml=release/5.4.1"))))
    
    (packages->manifest
      (list (transform1
              (specification->package "python-pyyaml"))
            (transform1 (specification->package "python"))))
    
    • 0
  3. BlackShift
    2022-04-14T23:29:54+08:002022-04-14T23:29:54+08:00

    这可能更 GUIXy:

    • 从仍然具有 pyyaml 5.4.1 的提交创建一个通道文件。
    • 从该频道文件创建配置文件。
    • 激活该配置文件。
    • 使用所需的包创建清单。
    • 使用该清单创建一个外壳。
    $ cat mypyyamlchannels.scm
    (list (channel
            (name 'guix)
            (url "https://git.savannah.gnu.org/git/guix.git")
            (branch "master")
            (commit
              "d3e1a94391a838332b0565d56762a58cf87ac6b1")
            (introduction
              (make-channel-introduction
                "9edb3f66fd807b096b48283debdcddccfea34bad"
                (openpgp-fingerprint
                  "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA")))))
    
    $ guix pull -C mypyyamlchannels.scm -p mypyyamlprofile
    
    $ GUIX_PROFILE="$(realpath mypyyamlprofile)"
    
    $ . "$GUIX_PROFILE/etc/profile"
    
    $ guix shell python-pyyaml python --export-manifest > mypyyamlmanifest.scm
    
    $ cat mypyyamlmanifest.scm 
    ;; What follows is a "manifest" equivalent to the command line you gave.
    ;; You can store it in a file that you may then pass to any 'guix' command
    ;; that accepts a '--manifest' (or '-m') option.
    
    (specifications->manifest
      (list "python-pyyaml" "python"))
    
    $ guix shell -m mypyyamlmanifest.scm
    

    但这有两个缺点:

    • 这有点冗长。它需要 2 个文件(通道和清单)和 4 个命令(guix pull、set GUIX_PROFILE、源配置文件、guix shell)和 2 个符号链接(mypyyamlprofile,mypyyamlprofile-1-link)来重新创建相同的环境。不工作的转换解决方案只需要 1 个清单文件和 1 个 guix shell 命令。有没有办法将通道和清单文件组合成一个单一的东西,然后可以用来在一个命令中实例化一个 shell?
    • 它不允许来自主通道的混合和匹配。我想混合需要创建一个通道文件来组合默认通道,然后以某种方式从具有特定提交的通道中挑选 python-pyyaml 包。这可能会引入不一致,但这些可能会得到解决。

    编辑:显然劣质将允许混合和匹配更容易:

       Sometimes you might need to mix packages from the revision of Guix
    you’re currently running with packages available in a different revision
    of Guix.  Guix “inferiors” allow you to achieve that by composing
    different Guix revisions in arbitrary ways.
    
    • 0

相关问题

  • guix pull 抛出“匹配错误”

  • `guix install` 和 `guix pull` 有什么区别?

  • `~/.guix-profile` 和 `~/.config/guix/current` 有什么区别

  • guix系统重新配置中要指定的文件是什么?

  • 在 GuixSD 上找不到 mkfs.vfat

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve