どのnixパッケージが特定のファイル/バイナリ/コマンドを提供しますか?

どのnixパッケージが特定のファイル/バイナリ/コマンドを提供しますか?

どちらが何であるか、どうやって知ることができますか?ニックスPG-パッケージはシステムにインストールされない可能性がある特定のファイル/コマンドを提供しますか?

他のパッケージマネージャは次のようにこの機能を提供します。

nixにも同様の機能がありますか?

文脈:どのパッケージがそれを提供したのかを調べようと努力していましたが、grepそのgnugrepパッケージがそれを提供したことに気づきました(誰が考えたのでしょうか?)。次回は、推測ゲームをしないために、この質問に答えるための体系的な方法を探しています。

私が試したこと:

ベストアンサー1

パッケージをインストール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

これニックスチートシートNixとUbuntuでそれらのコマンドの有用なリストを提供します。


インデックス作成には時間がかかります(ネットワークの速度とサイズによって異なります)。--filter-prefix '/bin/'ユーティリティを見つけるときにユーティリティを使用すると時間を短縮できます(私の場合は8:10 - > 2:50分)。シェルを呼び出した直後にインデックスを作成すると、対話が減る可能性があります。

$ 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
...

おすすめ記事