我怎样才能找出哪个nixpgs -package 提供了给定的文件/命令,但系统上可能没有安装?
其他包管理器提供此功能,如下所示:
nix有类似的功能吗?
上下文:我试图弄清楚哪个包提供了grep
,然后才意识到它是由gnugrep
包提供的(谁会想到?)。我正在寻找一种系统的方法来回答此类问题,以避免下次再玩猜谜游戏。
我尝试过的事情:
nix-env -qa
仅搜索包名称小智 7
您可以安装该nix-index
包,构建索引,然后使用nix-locate
命令:
[nix-shell:~]$ nix-locate '/bin/grep'
perl532Packages.grepmail.out 75,569 x /nix/store/i4krsr02b3yymqhzz9kbz066rkjkn5zl-perl5.32.1-grepmail-5.3111/bin/grepmail
perl530Packages.grepmail.out 75,569 x /nix/store/vc2iv0zi7kb0fr04gahyx142i30xi0g6-perl5.30.3-grepmail-5.3111/bin/grepmail
patchutils_0_3_3.out 0 s /nix/store/yfl83agm8396xw9hir1rwvdanz13h9w5-patchutils-0.3.3/bin/grepdiff
patchutils.out 0 s /nix/store/wk1yk22f0f6ai478axaqr0yvwy6q7xl5-patchutils-0.3.4/bin/grepdiff
(patchutils.out) 248,584 x /nix/store/6jysbyhc43sjvfiyh1bpvi1n3zbz212r-bootstrap-tools/bin/grep
ipinfo.out 4,293,096 x /nix/store/7p4g03bi15705ipbkrc7vhb42cvgc54f-ipinfo-2.0.1/bin/grepip
grepm.out 1,540 x /nix/store/mfhzjhz2f3mwbg1pq1diblqfdcmcffhs-grepm-0.6/bin/grepm
grepcidr.out 19,576 x /nix/store/7x10lzg5389flnjhfwh4xycqi835knfy-grepcidr-2.0/bin/grepcidr
gnugrep.out 271,716 x /nix/store/ba3bf20z5rmd9vgyzsgamvwvb3i1idfn-gnugrep-3.6/bin/grep
(unixtools.col.out) 27,660 x /nix/store/0h4ih2jvl9gv3dnmld2vq5iyyv41cy7v-text_cmds-99/bin/grep
Run Code Online (Sandbox Code Playgroud)
Nix Cheatsheet提供了 Nix 和 Ubuntu 中相应命令的有用列表。
索引需要一些时间(取决于网络速度和大小)。--filter-prefix '/bin/'
当您寻找公用事业时,可以通过使用来减少时间(在我的例子中为 8:10 -> 2:50 分钟)。调用 shell 后立即建立索引也可以减少交互:
$ nix-shell -p nix-index --command 'nix-index --version; time nix-index --show-trace --filter-prefix '/bin/'; return'
Nixpkgs Files Indexer 0.1.3
+ querying available packages
+ generating index: 55661 paths found :: 23483 paths not in binary cache :: 08533 paths in queue
Error: fetching the file listing for store path '/nix/store/siv7varixjdfjs17i3qfrvyc072rx55j-ia-writer-duospace-20180721' failed
Caused by: response to GET 'http://cache.nixos.org/siv7varixjdfjs17i3qfrvyc072rx55j.ls' failed to parse (response saved to /run/user/1000/file_listing.json.2)
Caused by: expected value at line 1 column 1
+ generating index: 66306 paths found :: 23630 paths not in binary cache :: 00000 paths in queue
+ wrote index of 2,742,453 bytes
real 2m50,553s
user 2m39,151s
sys 0m26,571s
[nix-shell:~]$ nix-locate /bin/grep
...
(irccloud.out) 0 s /nix/store/dv7klxqz8pmyml05nrs5f5ddd3hb9nsw-irccloud-0.13.0-usr-target/bin/grep
fpc.out 732 r /nix/store/4p5nx2csq7xmag9cbkmg54qzj6kxr71j-fpc-3.2.0/bin/grep.tdf
gnugrep.out 257,000 x /nix/store/z3q9q9549ci7kbdgyq99r6crnvrky6v3-gnugrep-3.7/bin/grep
grepm.out 1,596 x /nix/store/746bg318dq0wm1z23lllbg74ymdyac3r-grepm-0.6/bin/grepm
grepcidr.out 22,088 x /nix/store/sja30zvm5nw7ic7gwddc3h89rdgiyza4-grepcidr-2.0/bin/grepcidr
...
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3643 次 |
最近记录: |