From fd653b992ac92a758b85b9da83d817594b218493 Mon Sep 17 00:00:00 2001 From: toonn Date: Sun, 16 Aug 2020 21:02:02 +0200 Subject: [PATCH] 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; }`. --- pkgs/data/fonts/joypixels/default.nix | 59 ++++++++++++++------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/pkgs/data/fonts/joypixels/default.nix b/pkgs/data/fonts/joypixels/default.nix index 64d5973710a..128fd69ced1 100644 --- a/pkgs/data/fonts/joypixels/default.nix +++ b/pkgs/data/fonts/joypixels/default.nix @@ -34,40 +34,41 @@ let inherit (stdenv.hostPlatform.parsed) kernel; 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 -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 { pname = "joypixels"; version = "6.0.0"; - src = with systemSpecific; fetchurl { - inherit name; - url = "https://cdn.joypixels.com/distributions/${systemTag}/font/${version}/${fontFile}"; - sha256 = { - darwin = "043980g0dlp8vd4qkbx6298fwz8ns0iwbxm0f8czd9s7n2xm4npq"; - }.${kernel.name} or "1vxqsqs93g4jyp01r47lrpcm0fmib2n1vysx32ksmfxmprimb75s"; - }; + src = assert !acceptLicense -> throwLicense; + with systemSpecific; fetchurl { + inherit name; + url = "https://cdn.joypixels.com/distributions/${systemTag}/font/${version}/${fontFile}"; + sha256 = { + darwin = "043980g0dlp8vd4qkbx6298fwz8ns0iwbxm0f8czd9s7n2xm4npq"; + }.${kernel.name} or "1vxqsqs93g4jyp01r47lrpcm0fmib2n1vysx32ksmfxmprimb75s"; + }; dontUnpack = true; @@ -85,7 +86,7 @@ stdenv.mkDerivation rec { homepage = "https://www.joypixels.com/fonts"; license = let free-license = joypixels-free-license; appendix = joypixels-license-appendix; - in { + in with systemSpecific; { spdxId = "LicenseRef-JoyPixels-Free-6.0-with-${capitalized}-Appendix"; fullName = "${free-license.fullName} with ${appendix.fullName}"; url = free-license.url;