gnu: Add r-all.
[jackhill/guix/guix.git] / guix / import / snix.scm
index bcc4d6b..56934e8 100644 (file)
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2010, 2011, 2012, 2013 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
   #:use-module (srfi srfi-37)
   #:use-module (system foreign)
   #:use-module (rnrs bytevectors)
-  #:use-module (guix utils)
+
+  ;; Use the 'package-name->name+version' procedure that works with
+  ;; hyphen-separate name/version, not the one that works with '@'-separated
+  ;; name/version.  Subtle!
+  #:use-module ((guix utils) #:hide (package-name->name+version))
+  #:use-module ((guix build utils) #:select (package-name->name+version))
+
   #:use-module (guix import utils)
+  #:use-module (guix base16)
   #:use-module (guix base32)
   #:use-module (guix config)
   #:use-module (guix gnu-maintenance)
@@ -276,7 +283,7 @@ ATTRIBUTE is true, only that attribute is considered."
   platform = (import ~a/pkgs/top-level/platforms.nix).sheevaplug;
 }" nixpkgs)))
       (apply open-pipe* OPEN_READ
-             %nix-instantiate "--strict" "--eval-only" "--xml"
+             "nix-instantiate" "--strict" "--eval-only" "--xml"
 
              ;; Pass a dummy `crossSystem' argument so that `buildInputs' and
              ;; `nativeBuildInputs' are not coalesced.
@@ -310,6 +317,29 @@ attributes, or #f if NAME cannot be found."
           (_
            attributes))))
 
+(define (license-variable license)
+  "Return the name of the (guix licenses) variable for LICENSE."
+  (match license
+    ("GPLv2+"    'gpl2+)
+    ("GPLv3+"    'gpl3+)
+    ("LGPLv2+"   'lgpl2.1+)
+    ("LGPLv2.1+" 'lgpl2.1+)
+    ("LGPLv3+"   'lgpl3+)
+    (('attribute-set _ ...)
+     ;; At some point in 2013, Nixpkgs switched to attribute sets to represent
+     ;; licenses.  These are listed in lib/licenses.nix.
+     (match (and=> (find-attribute-by-name "shortName" license)
+                   attribute-value)
+       ("agpl3Plus"  'agpl3+)
+       ("gpl2Plus"   'gpl2+)
+       ("gpl3Plus"   'gpl3+)
+       ("lgpl2Plus"  'lgpl2.0+)
+       ("lgpl21Plus" 'lgpl2.1+)
+       ("lgpl3Plus"  'lgpl3+)
+       ((? string? x) x)
+       (_             license)))
+    (_           license)))
+
 (define (package-source-output-path package)
   "Return the output path of the \"src\" derivation of PACKAGE."
   (derivation-source-output-path (attribute-value package)))
@@ -369,16 +399,6 @@ location of DERIVATION."
                (x x))
              uri))
 
-       (define (license-variable license)
-         ;; Return the name of the (guix licenses) variable for LICENSE.
-         (match license
-           ("GPLv2+"    'gpl2+)
-           ("GPLv3+"    'gpl3+)
-           ("LGPLv2+"   'lgpl2.1+)
-           ("LGPLv2.1+" 'lgpl2.1+)
-           ("LGPLv3+"   'lgpl3+)
-           (_           license)))
-
        (let* ((source  (find-attribute-by-name "src" attributes))
               (urls    (source-urls source))
               (sha256  (source-sha256 source))