From eb9fa64c33c1c71921d9a48de5a40bdba2d46d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Sun, 5 Feb 2023 10:24:26 +0100 Subject: [PATCH] flake-info: render longDescription for flake packages (#607) --- flake-info/assets/commands/flake_info.nix | 5 +++-- flake-info/src/data/export.rs | 7 +++++-- flake-info/src/data/import.rs | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/flake-info/assets/commands/flake_info.nix b/flake-info/assets/commands/flake_info.nix index 19305af..d6cdb79 100644 --- a/flake-info/assets/commands/flake_info.nix +++ b/flake-info/assets/commands/flake_info.nix @@ -29,8 +29,9 @@ let # paths = builtins.listToAttrs ( map (output: {name = output; value = drv.${output};}) drv.outputs ); default_output = drv.outputName; } - // lib.optionalAttrs (drv ? meta && drv.meta ? description) { inherit (drv.meta) description; } - // lib.optionalAttrs (drv ? meta && drv.meta ? license) { inherit (drv.meta) license; } + // lib.optionalAttrs (drv ? meta.description) { inherit (drv.meta) description; } + // lib.optionalAttrs (drv ? meta.longDescription) { inherit (drv.meta) longDescription; } + // lib.optionalAttrs (drv ? meta.license) { inherit (drv.meta) license; } ) ) (validPkgs drvs); readApps = system: apps: lib.mapAttrsToList ( diff --git a/flake-info/src/data/export.rs b/flake-info/src/data/export.rs index ee21b11..ccd837d 100644 --- a/flake-info/src/data/export.rs +++ b/flake-info/src/data/export.rs @@ -115,6 +115,7 @@ impl TryFrom<(import::FlakeEntry, super::Flake)> for Derivation { outputs, default_output, description, + long_description, license, } => { let package_attr_set: Vec<_> = attribute_name.split(".").collect(); @@ -125,6 +126,8 @@ impl TryFrom<(import::FlakeEntry, super::Flake)> for Derivation { }) .into(); + let long_description = long_description.map(|s| s.render_markdown()).transpose()?; + let package_license: Vec = license .map(OneOrMany::into_list) .unwrap_or_default() @@ -152,7 +155,7 @@ impl TryFrom<(import::FlakeEntry, super::Flake)> for Derivation { package_description: description.clone(), package_maintainers: vec![maintainer.clone()], package_maintainers_set: maintainer.name.map_or(vec![], |n| vec![n]), - package_longDescription: None, + package_longDescription: long_description, package_hydra: (), package_system: String::new(), package_homepage: Vec::new(), @@ -251,7 +254,7 @@ impl TryFrom for Derivation { package_maintainers, package_maintainers_set, package_description: package.meta.description.clone(), - package_longDescription: long_description.clone(), + package_longDescription: long_description, package_hydra: (), package_system: package.system, package_homepage: package diff --git a/flake-info/src/data/import.rs b/flake-info/src/data/import.rs index 7a7de78..3d47b71 100644 --- a/flake-info/src/data/import.rs +++ b/flake-info/src/data/import.rs @@ -30,6 +30,8 @@ pub enum FlakeEntry { outputs: Vec, default_output: String, description: Option, + #[serde(rename = "longDescription")] + long_description: Option, license: Option>>, }, /// An "application" that can be called using nix run <..>