这GUIX 下级手册指出
因此,您几乎可以在任何要插入常规包的地方插入劣质包:在清单中、在操作系统声明的包字段中,等等。
但是,我无法弄清楚在重写包的输入时如何使用 Inferior。例如这个清单,基于手册的定义包变体部分,对我不起作用:
(use-modules (guix inferior) (guix channels) (guix packages)
(srfi srfi-1))
(use-package-modules docker)
(use-package-modules python-xyz)
(define mychannels
(list (channel
(name 'guix)
(url "https://git.savannah.gnu.org/git/guix.git")
;; Last commit that still has python-pyyaml 5.4.1.
(commit
"d3e1a94391a838332b0565d56762a58cf87ac6b1"))))
(define myinferior
(inferior-for-channels mychannels))
(define pyyaml5
(first (lookup-inferior-packages myinferior "python-pyyaml")))
(define pyyaml5-instead-of-pyyaml6
;; This is a procedure to replace pyyaml 6.0 by pyyaml 5.4.1.
;; The line below does not work, raises this error:
;; In procedure package-properties: Wrong type argument:
;; #<inferior-package [email protected] 7f42653831b0>
(package-input-rewriting `((,python-pyyaml . , pyyaml5)))
;; The line below does work (and has a similar result).
;(package-input-rewriting `((,python-pyyaml . , python-pyyaml-for-awscli)))
)
(define docker-compose-with-pyyaml5
(pyyaml5-instead-of-pyyaml6 docker-compose))
(packages->manifest
(list pyyaml5
(specification->package "python")
docker-compose-with-pyyaml5
))
docker-compose
仅适用于python-pyyaml
5.4.1,频道中的版本已升级至6.0。因此,我尝试进行的重写是将输入重写为docker-compose
使用python-pyyaml
早期版本的通道中的 5.4.1。但是,我的尝试失败了
Backtrace:
In guix/packages.scm:
1269:17 19 (supported-package? #<package [email protected] gu…> …)
In guix/memoization.scm:
101:0 18 (_ #<hash-table 7fa05e6274c0 152/223> #<package docker…> …)
In guix/packages.scm:
1247:37 17 (_)
1507:16 16 (package->bag _ _ _ #:graft? _)
1608:48 15 (thunk)
1403:25 14 (inputs _)
In srfi/srfi-1.scm:
586:29 13 (map1 (("python-cached-property" #<package python-…>) …))
586:29 12 (map1 (("python-distro" #<package python-distro@1.…>) …))
586:29 11 (map1 (("python-docker" #<package python-docker@5.…>) …))
586:29 10 (map1 (("python-dockerpty" #<package python-docker…>) …))
586:29 9 (map1 (("python-docopt" #<package python-docopt@0.…>) …))
586:29 8 (map1 (("python-dotenv" #<package python-dotenv@0.…>) …))
586:29 7 (map1 (("python-jsonschema" #<package python-jsons…>) …))
586:17 6 (map1 (("python-pyyaml" #<package python-pyyaml@6.…>) …))
In guix/packages.scm:
1360:20 5 (rewrite ("python-pyyaml" #<package [email protected]…>))
In guix/memoization.scm:
101:0 4 (_ #<hash-table 7fa06ac0b540 8/31> #<package python-py…> …)
In guix/packages.scm:
1377:22 3 (_)
1435:37 2 (loop #<inferior-package [email protected] 7fa06304b3…>)
In ice-9/boot-9.scm:
1685:16 1 (raise-exception _ #:continuable? _)
1685:16 0 (raise-exception _ #:continuable? _)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure package-properties: Wrong type argument: #<inferior-package [email protected] 7fa06304b3f0>
我怎样才能用劣质的输入重写呢?
python-pyyaml
显然频道中现在有一个5.4.1,名为python-pyyaml-for-awscli
.使用该包重写输入docker-compose
确实可以按预期工作,因此据我所知,我在重写输入时使用了正确的语法。 (我不确定反引号、点和逗号的作用,也许那里有错误。)
(对于 XY 问题,我现在可以docker-compose
使用运行python-pyaml-for-awscli
,但是我仍然对如何使用 Inferior 感兴趣,因为接下来可能没有这样的包可用。)
答案1
显然,现在有一个modify-inputs
GUIX 1.3.0 中还没有的功能,我不知道是否有一个“nightly”在线文档可以链接到。
这有效:
(use-modules (guix inferior) (guix channels) (guix packages)
(srfi srfi-1))
(use-package-modules docker)
(use-package-modules python-xyz)
(define mychannels
(list (channel
(name 'guix)
(url "https://git.savannah.gnu.org/git/guix.git")
;; Last commit with pyyaml 5.4.1.
(commit
"d3e1a94391a838332b0565d56762a58cf87ac6b1"))))
(define myinferior
(inferior-for-channels mychannels))
(define pyyaml5
(first (lookup-inferior-packages myinferior "python-pyyaml")))
(define (also-pyyaml5-instead-of-pyyaml6 apackage)
;; This is a procedure to replace pyyaml 6.0 by pyyaml 5.4.1.
(package
(inherit apackage)
(inputs
(modify-inputs (package-inputs apackage)
(replace "python-pyyaml" pyyaml5)))))
(define also-docker-compose-with-pyyaml5
(also-pyyaml5-instead-of-pyyaml6 docker-compose))
(packages->manifest
(list python-pyyaml
(specification->package "python")
also-docker-compose-with-pyyaml5))
现在docker-compose
使用 5.4.1 版本python-pyyaml
,配置文件的其余部分使用 6.0。
我仍然不清楚是否可以使用下级 with package-input-rewriting
,但 usingmodify-inputs
可以实现同样的效果,并且它有效。