システムパッケージのリストとその説明を作成するには?

システムパッケージのリストとその説明を作成するには?

システム全体にインストールされているすべてのパッケージのリストを含むファイルを作成する必要があります。

私はreplで見ることpnameができ、meta各パッケージで利用可能です。

nix-repl> emacs.pname
"emacs"

nix-repl> emacs.meta.description
"The extensible, customizable GNU text editor"

configuration.nixで以下を実行しようとすると、pis型にand etc属性はpathありません。setpnamemeta

  environment.etc."packages".text = with lib;
    builtins.concatStringsSep "\n" (builtins.sort builtins.lessThan (lib.unique
      (builtins.map (
            p: "${p.pname} ${p.meta.description}"
      ) config.environment.systemPackages)));

パッケージ名と説明を取得するには/etc/packages

ベストアンサー1

を使用して派生した名前を取得できますlib.getName

すべてのパッケージには属性が必要ですmetadescription一部のパッケージが見つからないことがあります。これらの状況を処理するために使用できますp.meta.description or "(none)"

それらを組み合わせると、次のようになります。

{
  environment.etc."packages".text = with lib;
    builtins.concatStringsSep "\n" (builtins.sort builtins.lessThan (lib.unique
      (builtins.map (
            p: "${getName p} ${p.meta.description or "(none)"}"
      ) config.environment.systemPackages)));
}

おすすめ記事