首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在configuration.nix中找到一个Nix包的名称来安装它?

如何在configuration.nix中找到一个Nix包的名称来安装它?
EN

Unix & Linux用户
提问于 2015-12-18 17:37:25
回答 3查看 21.9K关注 0票数 29

假设我使用nix-env's --query操作搜索要安装的包:

代码语言:javascript
复制
$ nix-env -qa 'aspell.*en'
aspell-dict-en-7.1-0

我用/etc/nixos/configuration.nix (NixOS的主要配置文件)编写了这个包名:

代码语言:javascript
复制
environment.systemPackages = with pkgs; [
  aspell-dict-en
];

但是,如果我运行sudo nixos-rebuild switch、NixOS命令到更新配置并安装声明性指定的所有系统范围的包,则会出现错误:

代码语言:javascript
复制
error: undefined variable ‘aspell-dict-en’ at /etc/nixos/configuration.nix:44:5

我知道,对于许多包(虽然不是全部),nix-env返回的名称和environment.systemPackages配置选项中应该指定的名称是不同的,但我不理解逻辑。如何安装通过nix-env找到的软件包?

EN

回答 3

Unix & Linux用户

发布于 2019-11-03 16:55:47

代码语言:javascript
复制
nix-env -v -qaP '*' | grep "nvim"

我会将nix-env -v -qaP '*'的结果保存到一个文件中(因为返回通常需要一段时间)。

请记住,nix似乎忽略了haskellPackages下的一些事情(可能还有其他)。您可以通过haskellPackages等子类别通过nix-env -f '<nixpkgs>' -qaPA haskellPackages搜索包。

尼克斯-env搜索目前相当令人沮丧,因为它将需要5+秒,然后回来与一个error: regex error.

票数 1
EN

Unix & Linux用户

发布于 2019-06-22 09:09:25

除了Mirzhans选项之外,您还可以像/nix/store一样检查grep -irw "programm-name" /nix/store。但这可能有点让人困惑。此外,在您的主目录中,您可以检查.local/share目录中安装的程序/应用程序。

票数 0
EN

Unix & Linux用户

发布于 2022-12-06 13:57:07

如果您知道与包相关的可执行文件的名称,也可以使用nix-locate (https://github.com/bennofs/nix-index)。

代码语言:javascript
复制
nix-locate bin/hello      
haskellPackages.hscharm.out                     765,944 x /nix/store/m64bng6pyhq3dy1j0v6r5q7vymnbfrzx-hscharm-0.0.2/bin/hellocharm
haskellPackages.hello.out                       773,048 x /nix/store/gzkp9400ah5wzycfijcnw717b8v6i8gm-hello-1.0.0.2/bin/hello
python-cosmopolitan.out                       2,767,939 x /nix/store/cnz516l462r73k19pqf7kykdsxsj4zw5-python-cosmopolitan-3.6.14/bin/hello.com
mbedtls.out                                      48,720 x /nix/store/p9yww15m79lmdg678ipaqrvwi9wvj01r-mbedtls-2.28.0/bin/hello
(lutris-free.out)                                     0 s /nix/store/xyhi94jj4jbbmbl5wy83d91k4pnrw51g-lutris-fhs/usr/bin/hello
(lutris-free.out)                                     0 s /nix/store/av0syxwqf3a4mviiahiq4rv033dbj1gc-lutris-usr-target/bin/hello
hpx.out                                         234,312 x /nix/store/fb980g5ddz16k0bfc8qd0jcf2x7bsw2a-hpx-1.7.1/bin/hello_world_1
hpx.out                                         243,904 x /nix/store/fb980g5ddz16k0bfc8qd0jcf2x7bsw2a-hpx-1.7.1/bin/hello_world_2
hpx.out                                         270,464 x /nix/store/fb980g5ddz16k0bfc8qd0jcf2x7bsw2a-hpx-1.7.1/bin/hello_world_distributed
hello.out                                        55,656 x /nix/store/9ywyxky6cv809jh143f8yxg5kc4bk2yq-hello-2.12/bin/hello
hello-wayland.out                                84,280 x /nix/store/djp0pk61bx3ynxh9w65pnv1vq3z2ja07-hello-wayland-unstable-2020-07-27/bin/hello-wayland
fltk14.bin                                      877,328 x /nix/store/nwkr6p4pmrmx7cnkhya823mhv7x8fski-fltk-1.4.x-2021-12-21-bin/bin/hello
fltk14.bin                                       21,000 x /nix/store/nwkr6p4pmrmx7cnkhya823mhv7x8fski-fltk-1.4.x-2021-12-21-bin/bin/hello-shared
fltk.bin                                        604,656 x /nix/store/v3ijc814y1bmhfr2ca7da95m58jk2a37-fltk-1.3.8-bin/bin/hello
票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/250263

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档