Unverified Commit 6b8936fa authored by Doron Behar's avatar Doron Behar Committed by GitHub
Browse files

nerd-fonts: fix and improve pname, version and license handling (#370225)

parents 80c49d8c d37ad3d2
Loading
Loading
Loading
Loading
+22 −13
Original line number Diff line number Diff line
@@ -9,19 +9,17 @@ let
  fontsInfo = lib.trivial.importJSON ./manifests/fonts.json;
  checksums = lib.trivial.importJSON ./manifests/checksums.json;

  releaseVersion = lib.removePrefix "v" releaseInfo.tag_name;

  convertAttrName =
    name:
    let
      lowerName = lib.strings.toLower name;
    in
    if builtins.match "[[:digit:]].*" lowerName != null then "_" + lowerName else lowerName;
    if builtins.match "^[[:digit:]].*" lowerName != null then "_" + lowerName else lowerName;

  convertVersion =
    version: date:
    if builtins.match "[[:digit:]].*" version != null then
      version
    else
      "0-unstable-" + builtins.head (lib.strings.splitString "T" date);
    version: if builtins.match "^[[:digit:]].*" version != null then "+" + version else "";

  convertLicense = import ./convert-license.nix lib;

@@ -36,8 +34,8 @@ let
      ...
    }:
    stdenvNoCC.mkDerivation {
      pname = lib.strings.toLower caskName;
      version = convertVersion version releaseInfo.published_at;
      pname = "nerd-fonts-" + lib.strings.toLower caskName;
      version = releaseVersion + convertVersion version;

      src =
        let
@@ -67,14 +65,25 @@ let
          runHook postInstall
        '';

      passthru.updateScript = {
      passthru = {
        inherit releaseVersion;
        updateScript = {
          command = ./update.py;
          supportedFeatures = [ "commit" ];
        };
      };

      meta = {
        description = "Nerd Fonts: " + description;
        license = convertLicense licenseId;
        license = lib.unique (
          (with lib.licenses; [
            # > Nerd Fonts source fonts, patched fonts, and folders with explict OFL SIL files
            ofl
            # > Nerd Fonts original source code files (such as `.sh`, `.py`, `font-patcher` and others)
            mit
          ])
          ++ lib.toList (convertLicense licenseId)
        );
        homepage = "https://nerdfonts.com/";
        changelog = "https://github.com/ryanoasis/nerd-fonts/blob/${releaseInfo.tag_name}/changelog.md";
        platforms = lib.platforms.all;
@@ -86,7 +95,7 @@ let
    };

  nerdFonts = lib.trivial.pipe fontsInfo [
    (map (font: lib.attrsets.nameValuePair (convertAttrName font.caskName) (makeNerdFont font)))
    (map (font: lib.nameValuePair (convertAttrName font.caskName) (makeNerdFont font)))
    builtins.listToAttrs
  ];
in
+1 −2
Original line number Diff line number Diff line
{
  "tag_name": "v3.3.0",
  "published_at": "2024-11-18T12:43:12Z"
  "tag_name": "v3.3.0"
}
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ os.chdir(os.path.join(os.path.dirname(os.path.abspath(__file__)), "manifests"))

release_info = slicedict(
    fetchjson(RELEASE_INFO_URL),
    ["tag_name", "published_at"]
    ["tag_name"]
)

tag_name = release_info["tag_name"]