Reformat with nixfmt-rfc-style

This commit is contained in:
Artemis Tosini 2024-07-15 19:30:45 +00:00
parent 90dfd51d7c
commit d42faf4840
Signed by: artemist
GPG key ID: ADFFE553DCBB831E
2 changed files with 100 additions and 52 deletions

View file

@ -1,4 +1,11 @@
{ lib, fetchurl, stdenvNoCC, unzip, ipsw, _7zz }:
{
lib,
fetchurl,
stdenvNoCC,
unzip,
ipsw,
_7zz,
}:
let
root = lib.importJSON ./assets.json;
@ -32,30 +39,34 @@ let
};
};
};
in {
in
{
extra = lib.mapAttrs' mkExtraFont root.extra;
allExtra = (mkExtraFont "All Extra" root.all_extra).value;
base = let data = root.base;
in stdenvNoCC.mkDerivation {
pname = "macos-fonts-base";
version = with data; "${version}-${build}";
base =
let
data = root.base;
in
stdenvNoCC.mkDerivation {
pname = "macos-fonts-base";
version = with data; "${version}-${build}";
src = fetchurl { inherit (data) url hash; };
src = fetchurl { inherit (data) url hash; };
installPhase = ''
${ipsw}/bin/ipsw extract $src --dmg fs
${_7zz}/bin/7zz e -i'!4.apfs' ${data.build}*/*.dmg
installPhase = ''
${ipsw}/bin/ipsw extract $src --dmg fs
${_7zz}/bin/7zz e -i'!4.apfs' ${data.build}*/*.dmg
mkdir -p $out/share/fonts/apple
mkdir -p $out/share/fonts/apple
# This gives us some erros, ignore that
# Skipping overwrite because Apple has duplicate fonts for some reason
${_7zz}/bin/7zz e -i'!System/Library/Fonts' \
-i'!System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport' \
4.apfs -aos -o$out/share/fonts/apple || true
'';
# This gives us some erros, ignore that
# Skipping overwrite because Apple has duplicate fonts for some reason
${_7zz}/bin/7zz e -i'!System/Library/Fonts' \
-i'!System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport' \
4.apfs -aos -o$out/share/fonts/apple || true
'';
dontUnpack = true;
};
dontUnpack = true;
};
}

103
flake.nix
View file

@ -10,10 +10,17 @@
};
};
outputs = { self, nixpkgs, flake-utils, artemist }:
outputs =
{
self,
nixpkgs,
flake-utils,
artemist,
}:
with nixpkgs.lib;
{
overlays.default = (final: prev:
overlays.default = (
final: prev:
let
localFonts = [
{
@ -125,31 +132,41 @@
author = "Kontrapunkt";
}
];
buildLocalFont = { name, files ? [ ], dir ? null, license, author }:
buildLocalFont =
{
name,
files ? [ ],
dir ? null,
license,
author,
}:
let
types = {
ttf = "truetype";
otf = "opentype";
};
pathEndsWith = suffix: path:
pathEndsWith =
suffix: path:
let
str = toString path;
sufLen = stringLength suffix;
sLen = stringLength str;
in sufLen <= sLen && suffix
== substring (sLen - sufLen) sufLen str;
in
sufLen <= sLen && suffix == substring (sLen - sufLen) sufLen str;
copyType = extension: pathName:
copyType =
extension: pathName:
let
filteredFiles = filter (pathEndsWith ("." + extension)) files;
filename = file:
lists.last (strings.splitString "/" (toString file));
in (optionalString (filteredFiles != [ ]) ''
filename = file: lists.last (strings.splitString "/" (toString file));
in
(optionalString (filteredFiles != [ ]) ''
mkdir -p $out/share/fonts/${pathName}
'') + concatStringsSep "\n" (map (file:
"cp -v ${file} $out/share/fonts/${pathName}/${filename file}")
filteredFiles);
'')
+ concatStringsSep "\n" (
map (file: "cp -v ${file} $out/share/fonts/${pathName}/${filename file}") filteredFiles
);
copyTypeDir = extension: pathName: ''
if [ -n "$(shopt -s nullglob; echo ${dir}/*.${extension})" ]; then
@ -158,10 +175,12 @@
fi
'';
in final.stdenvNoCC.mkDerivation {
in
final.stdenvNoCC.mkDerivation {
inherit name;
dontUnpack = true;
installPhase = mapAttrsToList copyType types
installPhase =
mapAttrsToList copyType types
++ optional (dir != null) (mapAttrsToList copyTypeDir types);
passthru.font = true;
@ -172,30 +191,48 @@
description = "${name} font by ${author}";
};
};
in {
extraFonts = listToAttrs (map (font: {
name = replaceStrings [ " " ] [ "-" ] (toLower font.name);
value = buildLocalFont font;
}) localFonts);
in
{
extraFonts = listToAttrs (
map (font: {
name = replaceStrings [ " " ] [ "-" ] (toLower font.name);
value = buildLocalFont font;
}) localFonts
);
appleFonts = final.callPackage ./apple {
ipsw = if final ? ipsw then final.ipsw else artemist.packages.${final.stdenv.system}.ipsw;
};
});
} // flake-utils.lib.eachDefaultSystem (system:
}
);
}
// flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default artemist.overlays.default ];
overlays = [
self.overlays.default
artemist.overlays.default
];
config.allowUnfree = true;
};
in {
packages = builtins.listToAttrs (map (name: {
inherit name;
value = pkgs.${name} // {
type = "derivation";
name = "dummy-attrset";
};
}) [ "extraFonts" "appleFonts" ]);
formatter = pkgs.nixfmt;
});
in
{
packages = builtins.listToAttrs (
map
(name: {
inherit name;
value = pkgs.${name} // {
type = "derivation";
name = "dummy-attrset";
};
})
[
"extraFonts"
"appleFonts"
]
);
formatter = pkgs.nixfmt-rfc-style;
}
);
}