From af0557cf82080ab51bf82e1352f861d8ee6e469d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 5 Nov 2014 15:15:00 +0100 Subject: [PATCH] Allow marking licenses as unfree This allows licenses like the Amazon Software License to be identified properly while still preventing packages with those licenses from being distributed in the Nixpkgs/NixOS channels. --- lib/licenses.nix | 17 ++++++++++++++--- pkgs/stdenv/generic/default.nix | 5 ++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/licenses.nix b/lib/licenses.nix index aea7841c071e..372adea4f9ad 100644 --- a/lib/licenses.nix +++ b/lib/licenses.nix @@ -25,6 +25,7 @@ rec { shortName = "asl"; fullName = "Amazon Software License"; url = http://aws.amazon.com/asl/; + free = false; }; amd = { @@ -290,11 +291,21 @@ rec { url = http://www.tcl.tk/software/tcltk/license.html; }; - unfree = "unfree"; + unfree = { + fullName = "Unfree"; + free = false; + }; - unfreeRedistributable = "unfree-redistributable"; + unfreeRedistributable = { + fullName = "Unfree redistributable"; + free = false; + }; - unfreeRedistributableFirmware = "unfree-redistributable-firmware"; + unfreeRedistributableFirmware = { + fullName = "Unfree redistributable firmware"; + # Note: we currently consider these "free" for inclusion in the + # channel and NixOS images. + }; unlicense = { shortName = "Unlicense"; diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 399843c27603..038afc585c28 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -41,6 +41,9 @@ let unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null); + isUnfree = licenses: lib.lists.any (l: + !l.free or true || l == "unfree" || l == "unfree-redistributable") licenses; + # The stdenv that we are producing. result = @@ -84,7 +87,7 @@ let unsafeGetAttrPos "name" attrs; pos' = if pos != null then "‘" + pos.file + ":" + toString pos.line + "’" else "«unknown-file»"; in - if !allowUnfree && (let l = lib.lists.toList attrs.meta.license or []; in lib.lists.elem "unfree" l || lib.lists.elem "unfree-redistributable" l) && !(allowUnfreePredicate attrs) then + if !allowUnfree && isUnfree (lib.lists.toList attrs.meta.license or []) && !allowUnfreePredicate attrs then throw '' Package ‘${attrs.name}’ in ${pos'} has an unfree license, refusing to evaluate. ${forceEvalHelp "Unfree"}''