joypixels: run install hooks

Also clean up formatting.
This commit is contained in:
Jan Tojnar 2020-10-22 03:31:18 +02:00
parent 196c828153
commit 5902a08028
No known key found for this signature in database
GPG Key ID: 7FAB2A15F7A607A4

View File

@ -1,55 +1,58 @@
{ stdenv, fetchurl, config { stdenv
, fetchurl
, config
, acceptLicense ? config.joypixels.acceptLicense or false , acceptLicense ? config.joypixels.acceptLicense or false
}: }:
let inherit (stdenv.hostPlatform.parsed) kernel; let
inherit (stdenv.hostPlatform.parsed) kernel;
systemSpecific = { systemSpecific = {
darwin = rec { darwin = rec {
systemTag = "nix-darwin"; systemTag = "nix-darwin";
capitalized = systemTag; capitalized = systemTag;
fontFile = "JoyPixels-SBIX.ttf"; fontFile = "JoyPixels-SBIX.ttf";
};
}.${kernel.name} or rec {
systemTag = "nixos";
capitalized = "NixOS";
fontFile = "joypixels-android.ttf";
};
joypixels-free-license = with systemSpecific; {
spdxId = "LicenseRef-JoyPixels-Free-6.0";
fullName = "JoyPixels Free License Agreement 6.0";
url = "https://cdn.joypixels.com/distributions/${systemTag}/license/free-license.pdf";
free = false;
}; };
}.${kernel.name} or rec {
systemTag = "nixos";
capitalized = "NixOS";
fontFile = "joypixels-android.ttf";
};
joypixels-license-appendix = with systemSpecific; { joypixels-free-license = with systemSpecific; {
spdxId = "LicenseRef-JoyPixels-NixOS-Appendix"; spdxId = "LicenseRef-JoyPixels-Free-6.0";
fullName = "JoyPixels ${capitalized} License Appendix"; fullName = "JoyPixels Free License Agreement 6.0";
url = "https://cdn.joypixels.com/distributions/${systemTag}/appendix/joypixels-license-appendix.pdf"; url = "https://cdn.joypixels.com/distributions/${systemTag}/license/free-license.pdf";
free = false; free = false;
}; };
throwLicense = throw '' joypixels-license-appendix = with systemSpecific; {
Use of the JoyPixels font requires acceptance of the license. spdxId = "LicenseRef-JoyPixels-NixOS-Appendix";
- ${joypixels-free-license.fullName} [1] fullName = "JoyPixels ${capitalized} License Appendix";
- ${joypixels-license-appendix.fullName} [2] url = "https://cdn.joypixels.com/distributions/${systemTag}/appendix/joypixels-license-appendix.pdf";
free = false;
};
You can express acceptance by setting acceptLicense to true in your throwLicense = throw ''
configuration. Note that this is not a free license so it requires allowing Use of the JoyPixels font requires acceptance of the license.
unfree licenses. - ${joypixels-free-license.fullName} [1]
- ${joypixels-license-appendix.fullName} [2]
configuration.nix: You can express acceptance by setting acceptLicense to true in your
nixpkgs.config.allowUnfree = true; configuration. Note that this is not a free license so it requires allowing
nixpkgs.config.joypixels.acceptLicense = true; unfree licenses.
config.nix: configuration.nix:
allowUnfree = true; nixpkgs.config.allowUnfree = true;
joypixels.acceptLicense = true; nixpkgs.config.joypixels.acceptLicense = true;
[1]: ${joypixels-free-license.url} config.nix:
[2]: ${joypixels-license-appendix.url} allowUnfree = true;
''; joypixels.acceptLicense = true;
[1]: ${joypixels-free-license.url}
[2]: ${joypixels-license-appendix.url}
'';
in in
@ -69,7 +72,11 @@ stdenv.mkDerivation rec {
dontUnpack = true; dontUnpack = true;
installPhase = with systemSpecific; '' installPhase = with systemSpecific; ''
runHook preInstall
install -Dm644 $src $out/share/fonts/truetype/${fontFile} install -Dm644 $src $out/share/fonts/truetype/${fontFile}
runHook postInstall
''; '';
meta = with stdenv.lib; { meta = with stdenv.lib; {
@ -80,8 +87,10 @@ stdenv.mkDerivation rec {
of files ranging from png, svg, iconjar, sprites, and fonts. of files ranging from png, svg, iconjar, sprites, and fonts.
''; '';
homepage = "https://www.joypixels.com/fonts"; homepage = "https://www.joypixels.com/fonts";
license = let free-license = joypixels-free-license; license =
appendix = joypixels-license-appendix; let
free-license = joypixels-free-license;
appendix = joypixels-license-appendix;
in with systemSpecific; { in with systemSpecific; {
spdxId = "LicenseRef-JoyPixels-Free-6.0-with-${capitalized}-Appendix"; spdxId = "LicenseRef-JoyPixels-Free-6.0-with-${capitalized}-Appendix";
fullName = "${free-license.fullName} with ${appendix.fullName}"; fullName = "${free-license.fullName} with ${appendix.fullName}";