diff options
Diffstat (limited to 'pkgs/data/fonts/iosevka/default.nix')
-rw-r--r-- | pkgs/data/fonts/iosevka/default.nix | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/pkgs/data/fonts/iosevka/default.nix b/pkgs/data/fonts/iosevka/default.nix index f7fce315e8c..4864edde71d 100644 --- a/pkgs/data/fonts/iosevka/default.nix +++ b/pkgs/data/fonts/iosevka/default.nix @@ -1,5 +1,5 @@ { - stdenv, lib, + stdenv, lib, pkgs, fetchFromGitHub, fetchurl, nodejs, ttfautohint-nox, otfcc, @@ -8,7 +8,9 @@ design ? [], upright ? [], italic ? [], oblique ? [], family ? null, weights ? [], # Custom font set name. Required if any custom settings above. - set ? null + set ? null, + # Extra parameters. Can be used for ligature mapping. + extraParameters ? null }: assert (design != []) -> set != null; @@ -19,38 +21,43 @@ assert (family != null) -> set != null; assert (weights != []) -> set != null; let - installPackageLock = import ./package-lock.nix { inherit fetchurl lib; }; + system = builtins.currentSystem; + nodePackages = import ./node-packages.nix { inherit pkgs system nodejs; }; in let pname = if set != null then "iosevka-${set}" else "iosevka"; in let - version = "1.14.3"; + version = "2.3.0"; name = "${pname}-${version}"; src = fetchFromGitHub { owner = "be5invis"; repo ="Iosevka"; rev = "v${version}"; - sha256 = "0ba8hwxi88bp2jb9xfhk95nnlv8ykl74cv62xr4ybzm3b8ahpwqf"; + sha256 = "1qnbxhx9wvij9zia226mc3sy8j7bfsw5v1cvxvsbbwjskwqdamvv"; }; in with lib; -let unwords = concatStringsSep " "; in +let quote = str: "\"" + str + "\""; in +let toTomlList = list: "[" + (concatMapStringsSep ", " quote list) +"]"; in +let unlines = concatStringsSep "\n"; in let param = name: options: - if options != [] then "${name}='${unwords options}'" else null; - config = unwords (lib.filter (x: x != null) [ + if options != [] then "${name}=${toTomlList options}" else null; + config = unlines (lib.filter (x: x != null) [ + "[buildPlans.${pname}]" (param "design" design) (param "upright" upright) (param "italic" italic) (param "oblique" oblique) - (if family != null then "family='${family}'" else null) + (if family != null then "family=\"${family}\"" else null) (param "weights" weights) ]); - custom = design != [] || upright != [] || italic != [] || oblique != [] - || family != null || weights != []; + installNodeModules = unlines (lib.mapAttrsToList + (name: value: "mkdir -p node_modules/${name}\n cp -r ${value.outPath}/lib/node_modules/. node_modules") + nodePackages); in stdenv.mkDerivation { @@ -58,33 +65,25 @@ stdenv.mkDerivation { nativeBuildInputs = [ nodejs ttfautohint-nox otfcc ]; - passAsFile = [ "installPackageLock" ]; - installPackageLock = installPackageLock ./package-lock.json; - - preConfigure = '' - HOME=$TMPDIR - source "$installPackageLockPath"; - npm --offline rebuild - ''; + passAsFile = [ "config" "extraParameters" ]; + config = config; + extraParameters = extraParameters; configurePhase = '' - runHook preConfigure - - ${optionalString custom ''make custom-config set=${set} ${config}''} - - runHook postConfigure + mkdir -p node_modules/.bin + ${installNodeModules} + ${optionalString (set != null) ''mv "$configPath" private-build-plans.toml''} + ${optionalString (extraParameters != null) ''cat "$extraParametersPath" >> parameters.toml''} ''; - makeFlags = lib.optionals custom [ "custom" "set=${set}" ]; + buildPhase = '' + npm run build -- ttf::${pname} + ''; installPhase = '' - runHook preInstall - fontdir="$out/share/fonts/$pname" install -d "$fontdir" install "dist/$pname/ttf"/* "$fontdir" - - runHook postInstall ''; enableParallelBuilding = true; @@ -98,6 +97,6 @@ stdenv.mkDerivation { ''; license = licenses.ofl; platforms = platforms.all; - maintainers = with maintainers; [ cstrahan jfrankenau ttuegel ]; + maintainers = with maintainers; [ cstrahan jfrankenau ttuegel babariviere ]; }; } |