gpt4 book ai didi

haskell - 如何使用 "nix search"搜索 Haskell 软件包?

转载 作者:行者123 更新时间:2023-12-02 13:46:40 24 4
gpt4 key购买 nike

我知道我可以使用 nix-env 搜索 Haskell 包

nix-env -f '<nixpkgs>' -qaP -A haskellPackages name_of_package

但是速度很慢并且没有缓存。如果我尝试使用新命令 nix search 所有 Haskell 包都会被隐藏。

$ nix search aeson
error: no results for the given search term(s)!

是否可以使用新的 nix search 命令搜索 Haskell 软件包?如果是这样,怎么办?

<小时/>

编辑:我在 this 中找到了一些关于此问题的讨论。 irc 日志,但我不太明白这些建议在实践中意味着什么。具体来说这部分:

20:49 <duairc> How do I make nix search include haskellPackages?
20:52 <ottidmes> duairc: you might try and call recurseIntoAttrs on haskellPackages
20:52 <rain1> thanks
20:52 <LnL> rain1: nix-env -f '<nixpkgs>' -qaP -A haskellPackages
20:54 <gchristensen> duairc: ^
20:54 <duairc> LnL: Thanks!
20:55 <LnL> err, wrong person
20:56 <LnL> you can also add an overlay that recurses, but that might make it
hard to find non haskell stuff if you're searching for something else
20:56 <ottidmes> I can confirm that
haskellPackages = super.recurseIntoAttrs super.haskellPackages; works though
20:58 <duairc> ottidmes: What do I do with that expression? Put it in
configuration.nix somewhere? If I type "nix search ghcid" then
will it find it?
20:59 <duairc> Ah, you're using super, so I guess it's an overlay
20:59 <clever> duairc: for `nix search` to find it, the overlay must be
somewhere in $HOME, i forget the exact path
20:59 <clever> duairc: configuration.nix only effects nixos-rebuild and
nothing else
21:00 <ottidmes> duairc: yeah, it should be put in your overlay that is
also used by nix-env the like, so not nixpkgs.overlays in your
configuration.nix as mentioned by clever, and then searching
for e.g. nix search nix-diff will result in:
* nixpkgs.haskellPackages.nix-diff (nix-diff)

最佳答案

根据 IRC 聊天,创建一个包含以下内容的 ~/.config/nixpkgs/overlays.nix 文件:

[
(self: super: {
haskellPackages = super.recurseIntoAttrs super.haskellPackages;
})
]

这是一个覆盖层,它将 haskellPackages 的 recurseForDerivations 属性设置为 true。 recurseForDerivations 告诉 nix 工具遍历该集合,在 nix search 的情况下搜索它。目前尚未记录,但已实现 here .

Nix wiki描述了覆盖层的放置位置和 Nixpkgs manual描述了叠加层的实际含义以及如何使用它们。

关于haskell - 如何使用 "nix search"搜索 Haskell 软件包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55431482/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com