Skip to content

Conversation

Sobte
Copy link

@Sobte Sobte commented May 28, 2024

Description of changes

I want to add windows fonts, just like vista-fonts and ttf-ms-win11-auto

Sorry, I accidentally rebase. I'm really sorry. I didn't mean to do that. #313500

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` label May 28, 2024
@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels May 28, 2024
@Sobte Sobte force-pushed the add_ms-win-font branch from f63fd60 to b591994 Compare May 28, 2024 11:05
@Sobte
Copy link
Author

Sobte commented May 28, 2024

For @Cryolitia's reviews in #313500 (comment)

Tks, I have changed it to use outputs

@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. labels May 28, 2024
Comment on lines 29403 to 29404
windows11-fonts = (callPackage ../data/fonts/windows-fonts { }).windows11;
windows10-fonts = (callPackage ../data/fonts/windows-fonts { }).windows10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
windows11-fonts = (callPackage ../data/fonts/windows-fonts { }).windows11;
windows10-fonts = (callPackage ../data/fonts/windows-fonts { }).windows10;
inherit (callPackage ../data/fonts/windows-fonts { }) windows10-fonts windows11-fonts;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tks, I have completed the modification

Comment on lines 51 to 63
''install -Dm644 ${source.${name}} -t $''
+ name
+ ''
/share/fonts/truetype
ln -s $''
+ name
+ ''
/share/fonts/truetype/*.{ttf,ttc} $out/share/fonts/truetype
install -Dm644 Windows/System32/Licenses/neutral/*/*/license.rtf -t $''
+ name
+ ''
/share/licenses
''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
''install -Dm644 ${source.${name}} -t $''
+ name
+ ''
/share/fonts/truetype
ln -s $''
+ name
+ ''
/share/fonts/truetype/*.{ttf,ttc} $out/share/fonts/truetype
install -Dm644 Windows/System32/Licenses/neutral/*/*/license.rtf -t $''
+ name
+ ''
/share/licenses
''
''
install -Dm644 ${source.${name}} -t ${name}/share/fonts/truetype
ln -s ${name}/share/fonts/truetype/*.{ttf,ttc} $out/share/fonts/truetype
install -Dm644 Windows/System32/Licenses/neutral/*/*/license.rtf -t ${name}/share/licenses
''

if this is wrong, then it just proves that the code before was not easy to understand

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My source code is this:

''install -Dm644 ${source.${name}} -t $'' + name + ''/share/fonts/truetype
  ln -s $'' + name + ''/share/fonts/truetype/*.{ttf,ttc} $out/share/fonts/truetype
  install -Dm644 Windows/System32/Licenses/neutral/*/*/license.rtf -t $'' + name + '' /share/licenses
''

Because it needs to go through nixfmt-rfc-style, it becomes commit like this, I tried to change it, it should be much better if I declare a variable.

Current Code:

let
  outHome = "$" + name;
in
(''
  install -Dm644 ${source.${name}} -t ${outHome}/share/fonts/truetype
  ln -s ${outHome}/share/fonts/truetype/*.{ttf,ttc} $out/share/fonts/truetype
  install -Dm644 Windows/System32/Licenses/neutral/*/*/license.rtf -t ${outHome}/share/licenses
'')


src = fetchurl { inherit url sha256; };

outputs = [ "out" ] ++ builtins.attrNames source;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do an output for every font.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for every language, not every font. Many latin world user may not care CJK fonts at all, and CJK fonts are really big.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, all default fonts are ~67.5M in total, 5 chinese fonts are ~84.5M in total.

stdenvNoCC.mkDerivation {
inherit pname version desc;

src = fetchurl { inherit url sha256; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
src = fetchurl { inherit url sha256; };
src = fetchurl {
inherit url sha256;
meta.license = lib.licenses.unfree;
};

just to make sure that we don't ever cache this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tks, I have added

pname = "windows11-fonts";
version = "10.0.22631.2428-2";
url = "https://software-static.download.prss.microsoft.com/dbazure/888969d5-f34g-4e03-ac9d-1f9786c66749/22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso";
sha256 = "sha256-yNvJa2HQTIsB+vbOB5T98zllx7NQ6qPrHmaXAZkClFw=";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sha256 = "sha256-yNvJa2HQTIsB+vbOB5T98zllx7NQ6qPrHmaXAZkClFw=";
hash = "sha256-yNvJa2HQTIsB+vbOB5T98zllx7NQ6qPrHmaXAZkClFw=";

pname,
version,
url,
sha256,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sha256,
hash,

windows11 = windows-fonts {
pname = "windows11-fonts";
version = "10.0.22631.2428-2";
url = "https://software-static.download.prss.microsoft.com/dbazure/888969d5-f34g-4e03-ac9d-1f9786c66749/22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the source of those?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pkgs attempts to download fonts directly from Microsoft, by
retrieving selective parts of the Windows 10 Enterprise 90-day evaluation edition.

visit: https://www.microsoft.com/en-us/evalcenter/evaluate-windows-10-enterprise
iso file: https://www.microsoft.com/en-us/evalcenter/download-windows-10-enterprise

win11 is the same as above

visit: https://www.microsoft.com/en-us/evalcenter/evaluate-windows-11-enterprise
iso file: https://www.microsoft.com/en-us/evalcenter/download-windows-11-enterprise

@@ -0,0 +1,164 @@
{
default = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to dedupe them?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two spec are slightly different, so I split them into two to facilitate subsequent spec updates.

@Sobte Sobte force-pushed the add_ms-win-font branch from b591994 to b26864a Compare May 28, 2024 17:17
@Sobte Sobte requested a review from SuperSandro2000 May 28, 2024 17:46
@Sobte
Copy link
Author

Sobte commented Jun 9, 2024

@SuperSandro2000 Please help review, thank you

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 9, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 2, 2025
@nixpkgs-ci nixpkgs-ci bot added the 12.first-time contribution This PR is the author's first one; please be gentle! label Jun 25, 2025
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 9, 2025
Copy link
Contributor

@dramforever dramforever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just made aware of this PR and I'm interested especially for the commonly used CJK fonts found here. I hope you don't mind the really late comments

Comment on lines 50 to 62
+ lib.strings.concatLines (
lib.lists.forEach (builtins.attrNames source) (
name:
let
outHome = "$" + name;
in
(''
install -Dm644 ${source.${name}} -t ${outHome}/share/fonts/truetype
ln -s ${outHome}/share/fonts/truetype/*.{ttf,ttc} $out/share/fonts/truetype
install -Dm644 Windows/System32/Licenses/neutral/*/*/license.rtf -t ${outHome}/share/licenses
'')
)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recognize that it is probably subjective which one is more hedious than the other, but I don't like this code generation at all. I would replace this with __structuredAttrs = true;. You can use an associative array to get output paths in that case. See another (rather, the only other?) example in Nixpkgs:

for outputName in ''${!outputs[@]} ; do
if [[ -n ''${outputDrvs[$outputName]} ]] ; then
ln -s "''${outputDrvs[$outputName]}" "''${outputs[$outputName]}"
else
touch "''${outputs[$outputName]}"
fi
done

However, the language list is still too complicated for bash associative arrays. I can see two options:

  1. mapAttrs them into an attrset of space-separated file names, do word split in bash
  2. invert the map, make them { "font.ttf" = "language"; ... } instead

version = "10.0.22631.2428-2";
url = "https://software-static.download.prss.microsoft.com/dbazure/888969d5-f34g-4e03-ac9d-1f9786c66749/22631.2428.231001-0608.23H2_NI_RELEASE_SVC_REFRESH_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso";
hash = "sha256-yNvJa2HQTIsB+vbOB5T98zllx7NQ6qPrHmaXAZkClFw=";
desc = "Microsoft Windows 11 fonts";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this end up being Some TrueType fonts from Microsoft Windows 11 fonts with "fonts" twice? Is that intended?

@Sobte
Copy link
Author

Sobte commented Aug 9, 2025

I was just made aware of this PR and I'm interested especially for the commonly used CJK fonts found here. I hope you don't mind the really late comments

Thank you so much for reviewing this PR! Your comments were very helpful, and I’ve made the suggested changes. Also, big thanks to @pluiedev for the assistance in completing this PR. I truly appreciate everyone’s time and support!

@Sobte Sobte force-pushed the add_ms-win-font branch from b26864a to 0a7478f Compare August 9, 2025 23:02
@Sobte Sobte marked this pull request as draft August 9, 2025 23:20
@Sobte Sobte closed this Aug 9, 2025
@Sobte Sobte force-pushed the add_ms-win-font branch from 0a7478f to 737e95f Compare August 9, 2025 23:29
@Sobte Sobte reopened this Aug 10, 2025
@Sobte Sobte changed the title windows11-fonts: init at 10.0.22631.2428-2, windows10-fonts: init at 10.0.19045.2006-1 windows11-fonts: init at 10.0.26100.1742-3, windows10-fonts: init at 10.0.19045.2006-1 Aug 10, 2025
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 10, 2025
@nixpkgs-ci nixpkgs-ci bot removed the 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. label Aug 10, 2025
@Sobte Sobte marked this pull request as ready for review August 10, 2025 01:03
meta = {
description = "Some TrueType fonts from ${os} (Arial, Bahnschrift, Calibri, ...)";
homepage = "https://learn.microsoft.com/typography/";
license = lib.licenses.unfree;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question of licensing, would you have to agree to the windows license? if so should that be a thing that a user would have to configure for because it's a custom license aka a EULA?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would say we need to do the same as the msvc sdk by adding the windows licence to config.nix like https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/windows/msvcSdk/default.nix if this is the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants