summary refs log tree commit diff
path: root/lib/licenses.nix
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2014-07-30 19:19:56 +0200
committerVladimír Čunát <vcunat@gmail.com>2014-07-30 19:22:09 +0200
commit229e5c41df8db960de9d57b247107b6239a60383 (patch)
tree2145b211b3377381c577b749882349c3f5ce18d9 /lib/licenses.nix
parent0f2101215dd31409fc56bea2cf72006871f1ef9e (diff)
downloadnixpkgs-229e5c41df8db960de9d57b247107b6239a60383.tar
nixpkgs-229e5c41df8db960de9d57b247107b6239a60383.tar.gz
nixpkgs-229e5c41df8db960de9d57b247107b6239a60383.tar.bz2
nixpkgs-229e5c41df8db960de9d57b247107b6239a60383.tar.lz
nixpkgs-229e5c41df8db960de9d57b247107b6239a60383.tar.xz
nixpkgs-229e5c41df8db960de9d57b247107b6239a60383.tar.zst
nixpkgs-229e5c41df8db960de9d57b247107b6239a60383.zip
lib/licenses.nix: allow choosing license by its shortName
Example: license = licenses."GPL-2.0+";
This comes with some performance cost during eval of licenses.nix,
but that's probably negligible.
Diffstat (limited to 'lib/licenses.nix')
-rw-r--r--lib/licenses.nix15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/licenses.nix b/lib/licenses.nix
index 29144264ddd..ce1d1960c9f 100644
--- a/lib/licenses.nix
+++ b/lib/licenses.nix
@@ -4,7 +4,7 @@ let
     };
 in
 
-rec {
+let licenses = rec {
   /* License identifiers from spdx.org where possible.
    * If you cannot find your license here, then look for a similar license or
    * add it to this list. The URL mentioned above is a good source for inspiration.
@@ -87,7 +87,7 @@ rec {
     fullName = "Eclipse Public License 1.0";
   };
 
-  free = "free";
+  free.shortName = "free";
 
   gpl2 = spdx {
     shortName = "GPL-2.0";
@@ -237,11 +237,11 @@ rec {
     url = http://www.tcl.tk/software/tcltk/license.html;
   };
 
-  unfree = "unfree";
+  unfree.shortName = "unfree";
 
-  unfreeRedistributable = "unfree-redistributable";
+  unfreeRedistributable.shortName = "unfree-redistributable";
 
-  unfreeRedistributableFirmware = "unfree-redistributable-firmware";
+  unfreeRedistributableFirmware.shortName = "unfree-redistributable-firmware";
 
   wadalab = {
     shortName = "wadalab";
@@ -264,5 +264,8 @@ rec {
     fullName = "Zope Public License 2.1";
   };
 
-}
+}; in
+  # add the same attrmaps, but named by their shortNames (creating e.g. licenses."GPL-2.0+")
+  with { inherit (import ./attrsets.nix) mapAttrs' nameValuePair; };
+  licenses // (mapAttrs' (_: value: nameValuePair value.shortName value) licenses)