joypixels: Move assert to allow override

By moving the assert concerning license acceptance into the src
attribute license acceptance can be expressed with an override,
`joypixels.override { acceptLicense = true; }`.
This commit is contained in:
toonn 2020-08-16 21:02:02 +02:00 committed by Jan Tojnar
parent ca61c67381
commit fd653b992a
No known key found for this signature in database
GPG key ID: 7FAB2A15F7A607A4

View file

@ -34,40 +34,41 @@ let inherit (stdenv.hostPlatform.parsed) kernel;
free = false; free = false;
}; };
throwLicense = throw ''
Use of the JoyPixels font requires acceptance of the license.
- ${joypixels-free-license.fullName} [1]
- ${joypixels-license-appendix.fullName} [2]
You can express acceptance by setting acceptLicense to true in your
configuration. Note that this is not a free license so it requires allowing
unfree licenses.
configuration.nix:
nixpkgs.config.allowUnfree = true;
nixpkgs.config.joypixels.acceptLicense = true;
config.nix:
allowUnfree = true;
joypixels.acceptLicense = true;
[1]: ${joypixels-free-license.url}
[2]: ${joypixels-license-appendix.url}
'';
in in
assert !acceptLicense -> throw ''
Use of the JoyPixels font requires acceptance of the license.
- ${joypixels-free-license.fullName} [1]
- ${joypixels-license-appendix.fullName} [2]
You can express acceptance by setting acceptLicense to true in your
configuration. Note that this is not a free license so it requires allowing
unfree licenses.
configuration.nix:
nixpkgs.config.allowUnfree = true;
nixpkgs.config.joypixels.acceptLicense = true;
config.nix:
allowUnfree = true;
joypixels.acceptLicense = true;
[1]: ${joypixels-free-license.url}
[2]: ${joypixels-license-appendix.url}
'';
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "joypixels"; pname = "joypixels";
version = "6.0.0"; version = "6.0.0";
src = with systemSpecific; fetchurl { src = assert !acceptLicense -> throwLicense;
inherit name; with systemSpecific; fetchurl {
url = "https://cdn.joypixels.com/distributions/${systemTag}/font/${version}/${fontFile}"; inherit name;
sha256 = { url = "https://cdn.joypixels.com/distributions/${systemTag}/font/${version}/${fontFile}";
darwin = "043980g0dlp8vd4qkbx6298fwz8ns0iwbxm0f8czd9s7n2xm4npq"; sha256 = {
}.${kernel.name} or "1vxqsqs93g4jyp01r47lrpcm0fmib2n1vysx32ksmfxmprimb75s"; darwin = "043980g0dlp8vd4qkbx6298fwz8ns0iwbxm0f8czd9s7n2xm4npq";
}; }.${kernel.name} or "1vxqsqs93g4jyp01r47lrpcm0fmib2n1vysx32ksmfxmprimb75s";
};
dontUnpack = true; dontUnpack = true;
@ -85,7 +86,7 @@ stdenv.mkDerivation rec {
homepage = "https://www.joypixels.com/fonts"; homepage = "https://www.joypixels.com/fonts";
license = let free-license = joypixels-free-license; license = let free-license = joypixels-free-license;
appendix = joypixels-license-appendix; appendix = joypixels-license-appendix;
in { 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}";
url = free-license.url; url = free-license.url;