Skip to content

Commit

Permalink
flake-info: render longDescription for flake packages (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncfavier authored Feb 5, 2023
1 parent 188d618 commit eb9fa64
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions flake-info/assets/commands/flake_info.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
7 changes: 5 additions & 2 deletions flake-info/src/data/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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> = license
.map(OneOrMany::into_list)
.unwrap_or_default()
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -251,7 +254,7 @@ impl TryFrom<import::NixpkgsEntry> 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
Expand Down
2 changes: 2 additions & 0 deletions flake-info/src/data/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub enum FlakeEntry {
outputs: Vec<String>,
default_output: String,
description: Option<String>,
#[serde(rename = "longDescription")]
long_description: Option<String>,
license: Option<OneOrMany<StringOrStruct<License>>>,
},
/// An "application" that can be called using nix run <..>
Expand Down

0 comments on commit eb9fa64

Please sign in to comment.