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 let
root = lib.importJSON ./assets.json; root = lib.importJSON ./assets.json;
@ -32,12 +39,16 @@ let
}; };
}; };
}; };
in { in
{
extra = lib.mapAttrs' mkExtraFont root.extra; extra = lib.mapAttrs' mkExtraFont root.extra;
allExtra = (mkExtraFont "All Extra" root.all_extra).value; allExtra = (mkExtraFont "All Extra" root.all_extra).value;
base = let data = root.base; base =
in stdenvNoCC.mkDerivation { let
data = root.base;
in
stdenvNoCC.mkDerivation {
pname = "macos-fonts-base"; pname = "macos-fonts-base";
version = with data; "${version}-${build}"; version = with data; "${version}-${build}";

View file

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