Reformat with nixfmt-rfc-style
This commit is contained in:
parent
90dfd51d7c
commit
d42faf4840
|
@ -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,30 +39,34 @@ 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
|
||||||
pname = "macos-fonts-base";
|
data = root.base;
|
||||||
version = with data; "${version}-${build}";
|
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 = ''
|
installPhase = ''
|
||||||
${ipsw}/bin/ipsw extract $src --dmg fs
|
${ipsw}/bin/ipsw extract $src --dmg fs
|
||||||
${_7zz}/bin/7zz e -i'!4.apfs' ${data.build}*/*.dmg
|
${_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
|
# This gives us some erros, ignore that
|
||||||
# Skipping overwrite because Apple has duplicate fonts for some reason
|
# Skipping overwrite because Apple has duplicate fonts for some reason
|
||||||
${_7zz}/bin/7zz e -i'!System/Library/Fonts' \
|
${_7zz}/bin/7zz e -i'!System/Library/Fonts' \
|
||||||
-i'!System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport' \
|
-i'!System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport' \
|
||||||
4.apfs -aos -o$out/share/fonts/apple || true
|
4.apfs -aos -o$out/share/fonts/apple || true
|
||||||
'';
|
'';
|
||||||
|
|
||||||
dontUnpack = true;
|
dontUnpack = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
103
flake.nix
103
flake.nix
|
@ -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: {
|
{
|
||||||
name = replaceStrings [ " " ] [ "-" ] (toLower font.name);
|
extraFonts = listToAttrs (
|
||||||
value = buildLocalFont font;
|
map (font: {
|
||||||
}) localFonts);
|
name = replaceStrings [ " " ] [ "-" ] (toLower font.name);
|
||||||
|
value = buildLocalFont font;
|
||||||
|
}) 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: {
|
{
|
||||||
inherit name;
|
packages = builtins.listToAttrs (
|
||||||
value = pkgs.${name} // {
|
map
|
||||||
type = "derivation";
|
(name: {
|
||||||
name = "dummy-attrset";
|
inherit name;
|
||||||
};
|
value = pkgs.${name} // {
|
||||||
}) [ "extraFonts" "appleFonts" ]);
|
type = "derivation";
|
||||||
formatter = pkgs.nixfmt;
|
name = "dummy-attrset";
|
||||||
});
|
};
|
||||||
|
})
|
||||||
|
[
|
||||||
|
"extraFonts"
|
||||||
|
"appleFonts"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
formatter = pkgs.nixfmt-rfc-style;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue