unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH v2] gnu: Add dub-build-system.
@ 2017-01-30 23:42 Danny Milosavljevic
  2017-02-01 22:13 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Danny Milosavljevic @ 2017-01-30 23:42 UTC (permalink / raw)
  To: guix-devel

* guix/build-system/dub.scm: New file.
* guix/build/dub-build-system.scm: New file.
* Makefile.am (MODULES): Add them.
---
 Makefile.am                     |   2 +
 guix/build-system/dub.scm       | 141 ++++++++++++++++++++++++++++++++++++++++
 guix/build/dub-build-system.scm | 106 ++++++++++++++++++++++++++++++
 3 files changed, 249 insertions(+)
 create mode 100644 guix/build-system/dub.scm
 create mode 100644 guix/build/dub-build-system.scm

diff --git a/Makefile.am b/Makefile.am
index 360c356f1..f6622e455 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -64,6 +64,7 @@ MODULES =					\
   guix/build-system/ant.scm			\
   guix/build-system/cargo.scm			\
   guix/build-system/cmake.scm			\
+  guix/build-system/dub.scm			\
   guix/build-system/emacs.scm			\
   guix/build-system/asdf.scm			\
   guix/build-system/glib-or-gtk.scm		\
@@ -88,6 +89,7 @@ MODULES =					\
   guix/build/download.scm			\
   guix/build/cargo-build-system.scm		\
   guix/build/cmake-build-system.scm		\
+  guix/build/dub-build-system.scm		\
   guix/build/emacs-build-system.scm		\
   guix/build/asdf-build-system.scm		\
   guix/build/git.scm				\
diff --git a/guix/build-system/dub.scm b/guix/build-system/dub.scm
new file mode 100644
index 000000000..4b8d22ad9
--- /dev/null
+++ b/guix/build-system/dub.scm
@@ -0,0 +1,141 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
+;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;; Copyright © 2016 Danny Milosavljevic <dannym@scratchpost.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system dub)
+  #:use-module (guix search-paths)
+  #:use-module (guix store)
+  #:use-module (guix utils)
+  #:use-module (guix derivations)
+  #:use-module (guix packages)
+  #:use-module (guix build-system)
+  #:use-module (guix build-system gnu)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-26)
+  #:export (dub-build-system))
+
+(define (default-ldc)
+  "Return the default ldc package."
+  ;; Lazily resolve the binding to avoid a circular dependency.
+  (let ((ldc (resolve-interface '(gnu packages ldc))))
+    (module-ref ldc 'ldc)))
+
+(define (default-dub)
+  "Return the default dub package."
+  ;; Lazily resolve the binding to avoid a circular dependency.
+  (let ((ldc (resolve-interface '(gnu packages ldc))))
+    (module-ref ldc 'dub)))
+
+(define %dub-build-system-modules
+  ;; Build-side modules imported by default.
+  `((guix build dub-build-system)
+    (guix build syscalls)
+    ,@%gnu-build-system-modules))
+
+(define* (dub-build store name inputs
+                      #:key
+                      (tests? #t)
+                      (test-target #f)
+                      (configure-flags #f) ; XXX unused
+                      (dub-build-flags ''())
+                      (phases '(@ (guix build dub-build-system)
+                                  %standard-phases))
+                      (outputs '("out"))
+                      (search-paths '())
+                      (system (%current-system))
+                      (guile #f)
+                      (imported-modules %dub-build-system-modules)
+                      (modules '((guix build dub-build-system)
+                                 (guix build utils))))
+  "Build SOURCE using DUB, and with INPUTS."
+  (define builder
+    `(begin
+       (use-modules ,@modules)
+       (dub-build #:name ,name
+                    #:source ,(match (assoc-ref inputs "source")
+                                (((? derivation? source))
+                                 (derivation->output-path source))
+                                ((source)
+                                 source)
+                                (source
+                                 source))
+                    #:system ,system
+                    #:test-target ,test-target
+                    #:dub-build-flags ,dub-build-flags
+                    #:tests? ,tests?
+                    #:phases ,phases
+                    #:outputs %outputs
+                    #:search-paths ',(map search-path-specification->sexp
+                                          search-paths)
+                    #:inputs %build-inputs)))
+
+  (define guile-for-build
+    (match guile
+      ((? package?)
+       (package-derivation store guile system #:graft? #f))
+      (#f                                         ; the default
+       (let* ((distro (resolve-interface '(gnu packages commencement)))
+              (guile  (module-ref distro 'guile-final)))
+         (package-derivation store guile system #:graft? #f)))))
+
+  (build-expression->derivation store name builder
+                                #:inputs inputs
+                                #:system system
+                                #:modules imported-modules
+                                #:outputs outputs
+                                #:guile-for-build guile-for-build))
+
+(define* (lower name
+                #:key source inputs native-inputs outputs system target
+                (ldc (default-ldc))
+                (dub (default-dub))
+                #:allow-other-keys
+                #:rest arguments)
+  "Return a bag for NAME."
+
+  (define private-keywords
+    '(#:source #:target #:ldc #:dub #:inputs #:native-inputs #:outputs))
+
+  (and (not target) ;; TODO: support cross-compilation
+       (bag
+         (name name)
+         (system system)
+         (target target)
+         (host-inputs `(,@(if source
+                              `(("source" ,source))
+                              '())
+                        ,@inputs
+
+                        ;; Keep the standard inputs of 'gnu-build-system'
+                        ,@(standard-packages)))
+         (build-inputs `(("ldc" ,ldc)
+                         ("dub" ,dub)
+                         ,@native-inputs))
+         (outputs outputs)
+         (build dub-build)
+         (arguments (strip-keyword-arguments private-keywords arguments)))))
+
+(define dub-build-system
+  (build-system
+    (name 'dub)
+    (description
+     "DUB build system, to build D packages")
+    (lower lower)))
diff --git a/guix/build/dub-build-system.scm b/guix/build/dub-build-system.scm
new file mode 100644
index 000000000..e6dc5d2e9
--- /dev/null
+++ b/guix/build/dub-build-system.scm
@@ -0,0 +1,106 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 David Craven <david@craven.ch>
+;;; Copyright © 2017 Danny Milosavljevic <dannym@scratchpost.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build dub-build-system)
+  #:use-module ((guix build gnu-build-system) #:prefix gnu:)
+  #:use-module (guix build syscalls)
+  #:use-module (guix build utils)
+  #:use-module (ice-9 popen)
+  #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 ftw)
+  #:use-module (ice-9 format)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
+  #:export (%standard-phases
+            dub-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard Rust package build procedure.
+;;
+;; Code:
+
+;; FIXME: Needs to be parsed from url not package name.
+(define (package-name->d-package-name name)
+  "Return the package name of NAME."
+  (match (string-split name #\-)
+    (("d" rest ...)
+     (string-join rest "-"))
+    (_ #f)))
+
+(define* (configure #:key inputs #:allow-other-keys)
+  "Replace argo.toml [dependencies] section with guix inputs."
+  (system* "chmod" "+w" ".")
+  (mkdir "vendor")
+  (for-each
+    (match-lambda
+      ((name . path)
+       (let* ((d-package (package-name->d-package-name name))
+              (d-basename (basename path)))
+         (when (and d-package path)
+           (match (string-split (basename path) #\-)
+             ((_ ... version)
+              (symlink (string-append path "/lib/dub/" d-basename) (string-append "vendor/" d-basename))))))))
+    inputs)
+  ;(setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
+  (let* ((dir (mkdtemp! "/tmp/dub.XXXXXX")))
+    (setenv "HOME" dir)
+    (zero? (system* "dub" "add-path" (string-append (getcwd) "/vendor")))))
+
+(define* (build #:key (dub-build-flags '())
+                #:allow-other-keys)
+  "Build a given DUB package."
+  (if (or (zero? (system* "grep" "-q" "sourceLibrary" "package.json"))
+          (zero? (system* "grep" "-q" "sourceLibrary" "dub.sdl")) ; note: format is different!
+          (zero? (system* "grep" "-q" "sourceLibrary" "dub.json")))
+    #t
+    (let ((status (zero? (apply system* `("dub" "build" ,@dub-build-flags)))))
+      (system* "dub" "run") ; might fail for "targetType": "library"
+      status)))
+
+(define* (check #:key tests? #:allow-other-keys)
+  (if tests?
+    (zero? (system* "dub" "test"))
+    #t))
+
+(define* (install #:key inputs outputs #:allow-other-keys)
+  "Install a given DUB package."
+  (let* ((out (assoc-ref outputs "out"))
+         (outbin (string-append out "/bin"))
+         (outlib (string-append out "/lib/dub/" (basename out))))
+    (mkdir-p outbin)
+    ;; TODO remove "-test-application"
+    (copy-recursively "bin" outbin)
+    (mkdir-p outlib)
+    (delete-file-recursively "vendor") ; contains timestamps
+    (copy-recursively "." (string-append outlib))
+    #t))
+
+(define %standard-phases
+  (modify-phases gnu:%standard-phases
+    (replace 'configure configure)
+    (replace 'build build)
+    (replace 'check check)
+    (replace 'install install)))
+
+(define* (dub-build #:key inputs (phases %standard-phases)
+                      #:allow-other-keys #:rest args)
+  "Build the given DUB package, applying all of PHASES in order."
+  (apply gnu:gnu-build #:inputs inputs #:phases phases args))

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gnu: Add dub-build-system.
  2017-01-30 23:42 [PATCH v2] gnu: Add dub-build-system Danny Milosavljevic
@ 2017-02-01 22:13 ` Ludovic Courtès
  2017-02-02  9:11   ` Danny Milosavljevic
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2017-02-01 22:13 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> * guix/build-system/dub.scm: New file.
> * guix/build/dub-build-system.scm: New file.
> * Makefile.am (MODULES): Add them.

Nice work!

Do you have experience using it on real DUB packages?  IOW, how complete
is it?  :-)

For the final patch, could you add a short description under “Build
Systems” in guix.texi?

> +(define* (dub-build store name inputs
> +                      #:key
> +                      (tests? #t)
> +                      (test-target #f)
> +                      (configure-flags #f) ; XXX unused

You can remove keyword parameters that don’t make sense like this one.

> +(define-module (guix build dub-build-system)
> +  #:use-module ((guix build gnu-build-system) #:prefix gnu:)
> +  #:use-module (guix build syscalls)
> +  #:use-module (guix build utils)
> +  #:use-module (ice-9 popen)
> +  #:use-module (ice-9 rdelim)
> +  #:use-module (ice-9 ftw)
> +  #:use-module (ice-9 format)
> +  #:use-module (ice-9 match)
> +  #:use-module (srfi srfi-1)
> +  #:use-module (srfi srfi-26)
> +  #:export (%standard-phases
> +            dub-build))
> +
> +;; Commentary:
> +;;
> +;; Builder-side code of the standard Rust package build procedure.

s/Rust/DUB/  :-)

Maybe write “DUB, the build tool for D” (or similar) to clarify.

> +;; FIXME: Needs to be parsed from url not package name.
> +(define (package-name->d-package-name name)
> +  "Return the package name of NAME."

“Return the DUB package name corresponding to NAME, a Guix package
name.” (Correct?)

> +(define* (configure #:key inputs #:allow-other-keys)
> +  "Replace argo.toml [dependencies] section with guix inputs."

Maybe “Add INPUTS to the 'dependencies' section of 'argo.toml'.”?

> +  (system* "chmod" "+w" ".")

Rather: (chmod "." #o755).


> +  (mkdir "vendor")

“vendor”?

> +  (for-each
> +    (match-lambda
> +      ((name . path)
> +       (let* ((d-package (package-name->d-package-name name))
> +              (d-basename (basename path)))
> +         (when (and d-package path)
> +           (match (string-split (basename path) #\-)
> +             ((_ ... version)
> +              (symlink (string-append path "/lib/dub/" d-basename) (string-append "vendor/" d-basename))))))))
> +    inputs)

Could you add a comment above explaining why this needs to be done?

Please keep lines below 80 chars.  :-)

> +  ;(setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))

Remove.

> +  (let* ((dir (mkdtemp! "/tmp/dub.XXXXXX")))
> +    (setenv "HOME" dir)

If HOME is relied on, please add a comment explaining why.

> +(define* (build #:key (dub-build-flags '())
> +                #:allow-other-keys)
> +  "Build a given DUB package."
> +  (if (or (zero? (system* "grep" "-q" "sourceLibrary" "package.json"))
> +          (zero? (system* "grep" "-q" "sourceLibrary" "dub.sdl")) ; note: format is different!
> +          (zero? (system* "grep" "-q" "sourceLibrary" "dub.json")))
> +    #t

Would be best to avoid calling out to ‘grep’.  At worst you can do:

  (define (grep string file)
    (string-contains (call-with-input-file file get-string-all)
                     string))

(These files are probably small so it should be good enough.)

> +    (let ((status (zero? (apply system* `("dub" "build" ,@dub-build-flags)))))
> +      (system* "dub" "run") ; might fail for "targetType": "library"
> +      status)))

Should be (and (zero? (apply system* "dub" "build" dub-build-flags))
               (zero? (apply system* "dub" "run")))

Or is it important to ignore the exit status of “dub run”?

> +(define* (check #:key tests? #:allow-other-keys)
> +  (if tests?
> +    (zero? (system* "dub" "test"))
> +    #t))

To be sure, could you pass the file through etc/indent-code.el?

> +(define* (install #:key inputs outputs #:allow-other-keys)
> +  "Install a given DUB package."
> +  (let* ((out (assoc-ref outputs "out"))
> +         (outbin (string-append out "/bin"))
> +         (outlib (string-append out "/lib/dub/" (basename out))))

In other places these variables are just called “bin” and “lib”.

> +    (mkdir-p outbin)
> +    ;; TODO remove "-test-application"
> +    (copy-recursively "bin" outbin)
> +    (mkdir-p outlib)
> +    (delete-file-recursively "vendor") ; contains timestamps
> +    (copy-recursively "." (string-append outlib))

(string-append outlib) -> outlib.

> +(define* (dub-build #:key inputs (phases %standard-phases)
> +                      #:allow-other-keys #:rest args)
> +  "Build the given DUB package, applying all of PHASES in order."
> +  (apply gnu:gnu-build #:inputs inputs #:phases phases args))

You can remove this one since it’s unused.

Thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gnu: Add dub-build-system.
  2017-02-01 22:13 ` Ludovic Courtès
@ 2017-02-02  9:11   ` Danny Milosavljevic
  2017-02-09 17:06     ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Danny Milosavljevic @ 2017-02-02  9:11 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 6747 bytes --]

Hi Ludo,

> Do you have experience using it on real DUB packages?  IOW, how complete
> is it?  :-)

Yeah, I've tested it on a small subset of all code.dlang.org packages. About half of the ones I tested work fine. This is my log:

OK: (define-public d-taggedalgebraic
OK: (define-public d-memutils
NOT: (define-public d-libasync unittest failure
NOT: (define-public d-eventcore by libasync
OK: (define-public tsv-utils-dlang [bin directory?!]
OK: (define-public d-lapack
OK: (define-public d-cblas
OK: (define-public d-money
NOT: (define-public d-units-d unit tests fail
OK: (define-public d-libevent
NOT anymore: (define-public d-llvm-d
OK: (define-public d-htmld
OK: (define-public d-cssd
OK: (define-public d-openssl
NOT: (define-public d-mail can't find [d-]openssl
NOT: (define-public d-secured can't find [d-]openssl
NOT: (define-public d-botan-math [tests crash]
NOT: (define-public d-botan [dependency on d-botan-math - which will fail]
OK: (define-public d-urld
OK: (define-public isitthere
NOT: (define-public d-imaged ; dependency on undead which is probably bad.
OK: (define-public d-matplotlib-d [huge deps]
NOT: (define-public d-universal ; tests fail
NOT: (define-public d-future ; requires d-universal - which will fail
OK: (define-public d-docopt
NOT: (define-public d-requests ; depends on d-vibe-d - which will fail
OK: (define-public d-concepts
OK: (define-public d-gtk-d ; missing gdata
NOT: (define-public d-pyd ; Python 2 should be UCS-4 but isn't.
NOT: (define-public d-vibe-core ; depends on libasync - which will fail
NOT: (define-public d-vibe-d ; depends on d-libevent 2.0.1 - which it can't find for some reason
OK: (define-public d-derelict-util
NOT: (define-public d-derelict-sdl2 ; tries to write into d-derelict-util's immutable directory
NOT: (define-public d-derelict-ft ; tries to write into d-derelict-util's immutable directory
NOT: (define-public d-bdb2d ; unknown error 6995216
NOT: (define-public unde ; depends on d-bdb2d - which will fail
OK: (define-public d-wave-d
OK: (define-public d-assert-that
OK: (define-public d-compile-time-unittest
NOT: (define-public d-tcenal ; requires d-compile-time-unittest 0.0.3 but can't find it for some reason
NOT: (define-public d-libdparse ; requires newer ldc (requires ldc 1.1.0)
NOT: (define-public dfmt ; requires d-libdparse - which will fail.
???: (define-public d-antispam
???: (define-public d-userman
???: (define-public vibenews
OK: (define-public d-syscall-d
OK: (define-public d-quantities

And I've attached the actual package definitions (these are WIP).

>For the final patch, could you add a short description under “Build Systems” in guix.texi?

Sure.

>You can remove keyword parameters that don’t make sense like this one.

Yeah, but maybe I should use them instead. Will investigate :)

>s/Rust/DUB/  :-)

Whoops, thanks :)

>Rather: (chmod "." #o755).

Thanks. Note that it's a workaround because git-download leaves the build directory read-only for some reason. Should the problem be found and fixed there? Or is it on purpose?

>“vendor”?

Yeah, a Rust term which I reused here. It means a directory with all the bundled dependencies (here we symlink the dependencies from our store dynamically).

>Could you add a comment above explaining why this needs to be done?

Sure. (it prepares a directory which can be used to find all the (D) dependencies by going just one level down; earlier versions just used /gnu/store directly but that would mean if you put such a package (without any subdirs in it) into your profile it would pollute the root)

I'm just thinking out loud about the comment :)

Something like this?

;; Prepare one new directory with all the required dependencies.
;; It's necessary to do this (instead of just using /gnu/store as the directory) because we want to hide the libraries in subdirectories lib/dub/... instead of polluting the user's profile root.

>> +  ;(setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))  
>Remove.

Ok.

>If HOME is relied on, please add a comment explaining why.

The dub build system uses it to find or create the .dub directory wherein it puts everything it built. I've found the place in DUB where one could patch that out: In source/dub/dub.d it says:

        private void init()
        {
                import std.file : tempDir;
                version(Windows) {
                        m_dirs.systemSettings = Path(environment.get("ProgramData")) ~ "dub/";
                        m_dirs.userSettings = Path(environment.get("APPDATA")) ~ "dub/";
                } else version(Posix){
                        m_dirs.systemSettings = Path("/var/lib/dub/");
                        m_dirs.userSettings = Path(environment.get("HOME")) ~ ".dub/";
                        if (!m_dirs.userSettings.absolute)
                                m_dirs.userSettings = Path(getcwd()) ~ m_dirs.userSettings;
                }

                m_dirs.temp = Path(tempDir);

                m_config = new DubConfig(jsonFromFile(m_dirs.systemSettings ~ "settings.json", true), m_config);
                m_config = new DubConfig(jsonFromFile(Path(thisExePath).parentPath ~ "../etc/dub/settings.json", true), m_config);
                m_config = new DubConfig(jsonFromFile(m_dirs.userSettings ~ "settings.json", true), m_config);

                determineDefaultCompiler();
        }

Note the "/var/lib/dub/" and environment.get("HOME").

Do we want to? Which?

I feel uneasy using HOME since the packages themselves could misinterpret it as the real home directory of the user and install important things there - maybe that would cause silent throwaway. Works well enough it practise, though.

> +  (if (or (zero? (system* "grep" "-q" "sourceLibrary" "package.json"))
> +          (zero? (system* "grep" "-q" "sourceLibrary" "dub.sdl")) ; note: format is different!
> +          (zero? (system* "grep" "-q" "sourceLibrary" "dub.json")))

>Would be best to avoid calling out to ‘grep’.  At worst you can do:
>  (define (grep string file)
>    (string-contains (call-with-input-file file get-string-all)
>                     string))

Thanks. I'll use it. Will it break when it can't find the file? That would be bad. Usually there's only one of these files available.

(Note that the json files are JSON actually, so we could use json if we wanted. For the purpose we are using it for (finding out whether it's a source-only library "template" which can't be linked on its own) I think string search is much simpler and less brittle. Also, there's a custom yaml-like format (the sdl) which would need custom handling anyhow)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dpacks.scm --]
[-- Type: text/x-scheme, Size: 46615 bytes --]

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2016 Roel Janssen <roel@gnu.org>
;;; Copyright © 2015 Pjotr Prins <pjotr.guix@thebird.nl>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (wip dpacks)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system dub)
  #:use-module (gnu packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages gstreamer)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages libedit)
  #:use-module (gnu packages libevent)
  #:use-module (gnu packages llvm)
  #:use-module (gnu packages maths)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages textutils)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages xorg)
  #:use-module (gnu packages zip))


(define-public d-taggedalgebraic
  (package
    (name "d-taggedalgebraic")
    (version "0.10.5")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/s-ludwig/taggedalgebraic/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "008gbxn71s2l2dnj2qwgfx6yla30g4290l7p2y7vmwid1hrif4lh"))))
    (build-system dub-build-system)
    (home-page "https://vibed.org/")
    (synopsis "Event abstraction layer")
    (description "Event abstraction layer in D")
    (license (list license:expat)))) ; FIXME which MIT

;; OLD! There's a new allocator in D phobos.
(define-public d-memutils
  (package
    (name "d-memutils")
    (version "0.4.8")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/etcimon/memutils/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "15m78913gvnsqwx7b98dvdh6whi5mpi73vprnzgd479lp0hqm3bk"))))
    (build-system dub-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-version
           (lambda _
             (substitute* "dub.json"
               (("\"name\": \"memutils\",") (string-append "\"name\": \"memutils\", \"version\": \"" ,version "\",")))
             #t)))))
    (home-page "https://github.com/etcimon/memutils/")
    (synopsis "D allocator library")
    (description "Overhead allocators, allocator-aware containers and lifetime management for D objects")
    (license (list license:expat)))) ; FIXME which MIT

(define-public d-libasync
  (package
    (name "d-libasync")
    (version "0.8.2")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/etcimon/libasync/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "13jdl1bd4ixfd4q42jcjcapjw5brkfmx2a3682ml7b8hi8afp82n"))))
    (build-system dub-build-system)
    (propagated-inputs
     `(("d-memutils" ,d-memutils)))
    (home-page "https://vibed.org/")
    (synopsis "Async library")
    (description "Async library in D")
    (license (list license:expat)))) ; FIXME which MIT

(define-public d-eventcore
  (package
    (name "d-eventcore")
    (version "0.8.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/vibe-d/eventcore/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0c3avjpk906hfgys4apkn4h0mfs01hcbphlksq3hlchmdxxil8dv"))))
    (build-system dub-build-system)
    (propagated-inputs
     `(("d-taggedalgebraic" ,d-taggedalgebraic)
       ("d-libasync" ,d-libasync)))
    (home-page "https://vibed.org/")
    (synopsis "Event abstraction layer")
    (description "Event abstraction layer in D")
    (license (list license:expat)))) ; FIXME which MIT

(define-public tsv-utils-dlang
  (package
    (name "tsv-utils-dlang")
    (version "1.0.13")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/eBay/tsv-utils-dlang/archive/v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1hjm8v21wns59h369caxadpqnjzi38c510pp1dv2whp2ri9fkxr0"))))
    (build-system dub-build-system)
    (home-page "https://github.com/eBay/tsv-utils-dlang")
    (synopsis "Command line utilities for tabular data files")
    (description "This package provides command line utilities for tabular data files.

@itemize
@item tsv-filter - Filter data file rows via numeric and string comparisons.
@item tsv-select - Keep a subset of the columns (fields) in the input.
@item tsv-summarize - Aggregate field values, summarizing across the entire file or grouped by key.
@item tsv-join - Join lines from multiple files using fields as a key.
@item tsv-append - Concatenate TSV files. Header aware; supports source file tracking.
@item tsv-uniq - Filter out duplicate lines using fields as a key.
@item tsv-sample - Uniform and weighted random sampling or permutation of input lines.
@item csv2tsv - Convert CSV files to TSV.
@item number-lines - Number the input lines.
@end itemize
")
    (license license:boost1.0)))

; TODO stringex
; TODO libdparse
; TODO xcb-util-wm-d xkbcommon-d rx
; d-syscall-d, d2sqlite3, dlib, d-libgmp, d-cairod[?]
; TODO d-vibelog
; TODO d-gfm d-dgame pixelperfectengine
; TODO libssh-d mondo

; web frameworks: hunt oauth mustache-d cgi_d
; parser combinators: pry
; audio: dplug
; mir-algorithm (tensors)
; opengl: dlsl erupted
; openwebif-client-d (in vibe.d)
; sockjs-d (in vibe.d)
; dmech (3D physics engine)
; painlessjson

; TODO apps: qscript, gbaid, timer

; async: libuv asynchronous

; serialization: cbor jsonserialized yamlserialized

; vibe-d-postgresql

; random numbers: mir-random.
; autocompletion: dcd

; GUI engines: poison dlangui
; HTML: embaked
; datetimeformat
; database: dpq2(postgres) database
; ORM: entity

(define-public d-lapack
  (package
    (name "d-lapack")
    (version "0.1.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/dataPulverizer/lapack/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "13msbi5nff8b3ldvfmhaxs4aghwbpd5kxyhw38q3ix275ki1j65d"))))
    (build-system dub-build-system)
    (inputs
     `(("lapack" ,lapack)))
    (home-page "http://www.active-analytics.com/")
    (synopsis "LAPACK linear algebra bindings for D")
    (description "This package provides LAPACK (linear algebra)
bindings for D.")
    (license license:boost1.0)))

(define-public d-cblas
  (package
    (name "d-cblas")
    (version "1.0.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/DlangScience/cblas/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0wk0gdchx6jg75lrqcmv6l82gl3js89a4gywb6q78asvh883152n"))))
    (build-system dub-build-system)
    (home-page "https://github.com/DlangScience/cblas")
    (synopsis "D BLAS bindings")
    (description "This package provides D BLAS bindings.")
    (license license:boost1.0)))

(define-public d-money
  (package
    (name "d-money")
    (version "2.0.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/qznc/d-money/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1wj8yrjsgfdjlslf67sfgd8mq7pxif6i5lpq2cf2chyqs61rl01a"))))
    (build-system dub-build-system)
    (home-page "https://github.com/qznc/d-money")
    (synopsis "D money type")
    (description "This package provides a D money type.")
    (license license:boost1.0)))

;; Tests fail
(define-public d-units-d
  (package
    (name "d-units-d")
    (version "0.1.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/nordlow/units-d/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1km2s0hjiv0wkry0npgd3y1k617hh9x63zdph5f0nixz3cvb80fi"))))
    (build-system dub-build-system)
    (home-page "https://github.com/nordlow/units-d")
    (synopsis "D units and quantities")
    (description "This package provides units and quantities for D.")
    (license license:boost1.0)))

(define-public d-quantities
  (package
    (name "d-quantities")
    (version "0.5.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/biozic/quantities/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0dk25c2226n5h6bfznsffhjjayxn89m445xdcb04lkv0r8slc5cq"))))
    (build-system dub-build-system)
    (home-page "https://github.com/biozic/quantities")
    (synopsis "D quantities")
    (description "This package provides quantities in D.")
    (license license:boost1.0)))

(define-public d-libevent
  (package
    (name "d-libevent")
    (version "2.0.2")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/s-ludwig/libevent/archive/"
                                  "v" version "+2.0.16.tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1xxn8j8l7lvl3q6qc8zg25p0vvfjim70z9awyp57ysp95cms75qj"))))
    (build-system dub-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-version
           (lambda _
             (substitute* "package.json"
               (("\"name\": \"libevent\",") (string-append "\"name\": \"libevent\", \"version\": \"" ,version "\",")))
             #t)))))
    (arguments
     `(#:tests? #f))
    (home-page "https://libevent.org/")
    (synopsis "D libevent bindings")
    (description "This package provides libevent bindings for D.")
    (license license:bsd-3)))

;; Earlier versions worked, this one doesn't work.
(define-public d-llvm-d
  (package
    (name "d-llvm-d")
    (version "2.0.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/Calrama/llvm-d/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1mpzxr8jjmpnbf245fnbib6fnwz8jihwlarazhi704f6ypqg92vr"))))
    (build-system dub-build-system)
    (home-page "https://github.com/Calrama/llvm-d")
    (synopsis "D LLVM bindings")
    (description "This package provides LLVM bindings for D.")
    (license license:expat))) ; FIXME which MIT

(define-public d-htmld
  (package
    (name "d-htmld")
    (version "0.2.16")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/eBookingServices/htmld/archive/"
                                  "v0.2.12.tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0ax6d90aiaaz3r7xaiqvjc1l1vsfpxcbi3ni432fb99v13ds6x06"))))
    (build-system dub-build-system)
    (home-page "https://github.com/eBookingServices/htmld")
    (synopsis "D HTML")
    (description "This package provides HTML for D.")
    (license license:expat))) ; FIXME which MIT

(define-public d-cssd
  (package
    (name "d-cssd")
    (version "0.1.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/eBookingServices/cssd/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1i0q7fiqz9lrcrx0518vm0z18kbnxys39dpy39ih1d0np0swwghl"))))
    (build-system dub-build-system)
    (home-page "https://github.com/eBookingServices/cssd")
    (synopsis "D CSS")
    (description "This package provides CSS for D.")
    (license license:expat))) ; FIXME which MIT

(define-public d-openssl
  (package
    (name "d-openssl")
    (version "1.1.5")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/s-ludwig/openssl/archive/"
                                  "v" version "+1.0.1g.tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1simn912hpkmx1i476n4avzc62yyy2qk84hjy2pm661xg4x2bh82"))))
    (build-system dub-build-system)
    (inputs
     `(("openssl" ,openssl)))
    (home-page "https://github.com/anton-dutov/mail")
    (synopsis "D OpenSSL")
    (description "This package provides OpenSSL bindings for D.")
    (license license:openssl))) ; FIXME or SSLEay

(define-public d-mail
  (package
    (name "d-mail")
    (version "0.3.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/anton-dutov/mail/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "00yfzfc5rvar9mwi20ypynbdpcwqnbl0il8xgbqn0ccijvi3nsj4"))))
    (build-system dub-build-system)
    (inputs
     `(("d-openssl" ,d-openssl)
       ;("openssl" ,openssl)
))
    (home-page "https://github.com/anton-dutov/mail")
    (synopsis "D E-Mail")
    (description "This package provides E-Mail for D.")
    (license license:expat))) ; FIXME

(define-public d-secured
  (package
    (name "d-secured")
    (version "0.8.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/LightBender/SecureD/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1dp8nw7n0iiwi26d8vrzl7fp47zm31j2ks8pq5qljb0sl50l9wvz"))))
    (build-system dub-build-system)
    (inputs
     `(("d-openssl" ,d-openssl)))
    (home-page "https://github.com/LightBender/SecureD")
    (synopsis "D OpenSSL")
    (description "This package provides OpenSSL bindings for D ???? FIXME.")
    (license license:boost1.0)))

(define-public d-botan-math
  (package
    (name "d-botan-math")
    (version "1.0.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/etcimon/botan-math/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1hdjslw8qsj0w691pppqv2imc0jq4adyck2ibr809l62z02yf933"))))
    (build-system dub-build-system)
    (home-page "https://github.com/etcimon/botan")
    (synopsis "D Matrix Math")
    (description "This package provides Matrix math for D.")
    (license license:bsd-2)))

(define-public d-botan
  (package
    (name "d-botan")
    (version "1.12.8")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/etcimon/botan/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1kcysq9y3qwxmx784dy6xijv889yxyf47f6cjijh78hlfccnwa60"))))
    (build-system dub-build-system)
    (inputs
     `(("d-memutils" ,d-memutils)
       ("d-botan-math" ,d-botan-math)))
    (home-page "https://github.com/etcimon/botan")
    (synopsis "D OpenSSL")
    (description "This package provides OpenSSL bindings for D ???? FIXME.")
    (license license:bsd-2)))

(define-public d-urld
  (package
    (name "d-urld")
    (version "2.1.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/dhasenan/urld/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "14rzvswfz97jfzhfhw65l2k07c27vp64mr4yh4sad9pfssrb09y5"))))
    (build-system dub-build-system)
    (home-page "https://github.com/dhasenan/urld")
    (synopsis "D URL parsing")
    (description "This package provides URL parsing for D.")
    (license license:expat))) ; FIXME which MIT

(define-public isitthere ; FIXME maybe a library
  (package
    (name "isitthere")
    (version "0.2.8")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/BBasile/IsItThere/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0fqqkv5nb24hi1hmpcxwda1r2878qpsdzfvbmr13pfwd5fyijw92"))))
    (build-system dub-build-system)
    (home-page "https://github.com/BBasile/isitthere")
    (synopsis "D perfect hashing")
    (description "This package provides Perfect Hashing for D.")
    (license license:boost1.0)))

;; Uses std.stream (sigh...)
(define-public d-imaged
  (package
    (name "d-imaged")
    (version "1.0.2")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/v--/imaged/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "13f40paigyfmzbgrl6d03dxn53y9p060bqp04svr000facz4b1aw"))))
    (build-system dub-build-system)
    ; FIXME add undead
    (home-page "https://github.com/callumenator/imaged")
    (synopsis "D image serializers")
    (description "This package provides image serializers for D.")
    (license license:boost1.0)))

;; TODO tests: offscreen!
(define-public d-matplotlib-d
  (package
    (name "d-matplotlib-d")
    (version "0.1.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/koji-kojiro/matplotlib-d/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0wfzvi0apmkx27pbwdbak15r6gakzps2kv130v6s2jj1mfgqwki5"))))
    (build-system dub-build-system)
    (arguments
     '(#:phases
       (modify-phases %standard-phases
         (add-before
          'build 'pre-build
          (lambda* (#:key inputs #:allow-other-keys)
            (let ((xorg-server (assoc-ref inputs "xorg-server")))
              ;; Tests require a running X server.
              (system (format #f "~a/bin/Xvfb :1 &" xorg-server))
              (setenv "DISPLAY" ":1")
              ;; For the missing /etc/machine-id.
              (setenv "DBUS_FATAL_WARNINGS" "0")
              (system* "sleep" "2")
              #t))))))
    (native-inputs
     `(("python-2" ,python-2)
       ("python2-matplotlib" ,python2-matplotlib) ; probably not a native-input
       ("xorg-server" ,xorg-server)
       ;("shared-mime-info" ,shared-mime-info)

))
    (home-page "https://github.com/koji-kojiro/matplotlib-d")
    (synopsis "D matplotlib bindings")
    (description "This package provides matplotlib bindings for D.")
    (license license:expat)))

;; broken
(define-public d-universal
  (package
    (name "d-universal")
    (version "0.1.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/evenex/universal/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "09jkmircarp78k5kwfcm6qywls9sr7wiz74hjrc86q6950s5yzii"))))
    (build-system dub-build-system)
    (home-page "https://github.com/evenex/universal")
    (synopsis "D universal products and coproducts")
    (description "This package provides Tuple and Union for D.")
    (license license:expat)))

;; depends on broken
(define-public d-future
  (package
    (name "d-future")
    (version "0.1.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/evenex/future/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0di1nad95r7wpc5yawfzbkm7j270b4slgbnifbymx4gsbwfg7qwa"))))
    (build-system dub-build-system)
    (inputs
     `(("d-universal" ,d-universal)))
    (home-page "https://github.com/evenex/future")
    (synopsis "D futures")
    (description "This package provides futures for D.")
    (license license:expat)))

(define-public d-docopt
  (package
    (name "d-docopt")
    (version "0.6.1-b.6")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/docopt/docopt.d/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1m0irkn6m9gw7xrija6w6kmxk1s8j9zn35vmpw3kdg1vkr4w8i1c"))))
    (build-system dub-build-system)
    (home-page "https://github.com/rwtolbert/docopt.d")
    (synopsis "D docopt")
    (description "This package provides docopt for D.")
    (license license:expat)))

;; dependency is broken
(define-public d-requests
  (package
    (name "d-requests")
    (version "0.4.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/ikod/dlang-requests/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "10mpxkqagfnzcas8n85lvb9888pgp357nz5zyfd853v0hfgsndjf"))))
    (build-system dub-build-system)
    (inputs
     `(("d-vibe-d" ,d-vibe-d)))
    (home-page "https://github.com/ikod/dlang-requests")
    (synopsis "D requests")
    (description "This package provides @code{requests} for D.")
    (license license:boost1.0)))

(define-public d-concepts
  (package
    (name "d-concepts")
    (version "0.0.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/atilaneves/concepts/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "16q0bdlxv56bklgnqy0pzbgyvp1xwc667bdhpwk9cslyqiwvzzki"))))
    (build-system dub-build-system)
    (home-page "https://github.com/atilaneves/concepts")
    (synopsis "D concepts")
    (description "This package provides concepts for D.")
    (license license:bsd-3))) ; FIXME which

; TODO d-gtk-d-2 is gtkD-1.7.8.zip gtkd.org/Downloads/sources/GtkD-1.7.8.zip
(define-public d-gtk-d
  (package
    (name "d-gtk-d")
    (version "3.5.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/gtkd-developers/GtkD/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0yib5mccmfaq65fjvqywnb9518p87i57qjn6glwyan0izpppp8vj"))))
    (build-system dub-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-libnames
           (lambda* (#:key inputs #:allow-other-keys)
             (substitute* "src/gtkc/paths.d"
                (("\"libatk-1\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "atk") "/lib/libatk-1.0.so.0\""))
                (("\"libcairo\\.so\\.2\"") (string-append "\"" (assoc-ref inputs "cairo") "/lib/libcairo.so.2\""))
                (("\"libgdk-3\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "gtk+") "/lib/libgdk-3.so.0\""))
                (("\"libgdk_pixbuf-2.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "gdk-pixbuf") "/lib/libgdk_pixbuf-2.0.so.0\""))
                (("\"libglib-2\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "glib") "/lib/libglib-2.0.so.0\""))
                (("\"libgmodule-2\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "glib") "/lib/libgmodule-2.0.so.0\""))
                (("\"libgobject-2\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "glib") "/lib/libgobject-2.0.so.0\""))
                (("\"libgio-2\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "glib") "/lib/libgio-2.0.so.0\""))
                (("\"libgthread-2\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "glib") "/lib/libgthread-2.0.so.0\""))
                (("\"libgtk-3\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "gtk+") "/lib/libgtk-3.so.0\""))
                (("\"libpango-1\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "pango") "/lib/libpango-1.0.so.0\""))
                (("\"libpangocairo-1\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "pango") "/lib/libpangocairo-1.0.so.0\""))
                (("\"libgdkglext-3\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "gtkglext") "/lib/libgdkglext-3.0.so.0\""))
                (("\"libgtkglext-3\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "gtkglext") "/lib/libgtkglext-3.0.so.0\""))
                ;(("\"libgdata-4\\.0\\.so\\.4\"") (string-append "\"" (assoc-ref inputs "libgdata") "/lib/libgda-4.0.so.4\""))
                (("\"libgtksourceview-3\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "gtksourceview") "/lib/libgtksourceview-3.0.so.0\""))
                (("\"libgtksourceview-3\\.0\\.so\\.1\"") (string-append "\"" (assoc-ref inputs "gtksourceview") "/lib/libgtksourceview-3.0.so.1\""))
                (("\"libgstreamer-1\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "gstreamer") "/lib/libgstreamer-1.0.so.0\""))
                (("\"libgstvideo-1\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "gstreamer") "/lib/libgstvideo-1.0.so.0\""))
                (("\"libvte-2\\.91\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "vte") "/lib/libvte-2.91.so.0\""))
                (("\"libpeas-1\\.0\\.so\\.0\"") (string-append "\"" (assoc-ref inputs "libpeas") "/lib/libpeas-1.0.so.0\"")))
             #t)))))
    (inputs
     `(("atk" ,atk)
       ("cairo" ,cairo) ; and pangocairo
       ("gtk+" ,gtk+) ; and gdk
       ("gdk-pixbuf" ,gdk-pixbuf)
       ("glib" ,glib) ; and gmodule, gobject, gio, gthread
       ("pango" ,pango)
       ("gtkglext" ,gtkglext) ; and gdkglext
       ; ("libgdata" ,libgdata)
       ("gtksourceview" ,gtksourceview) ; 0 and 1
       ("gstreamer" ,gstreamer) ; and gstvideo
       ("vte" ,vte)
       ("libpeas" ,libpeas)))
    (home-page "https://gtkd.org/")
    (synopsis "D Gtk bindings")
    ;; FIXME fails loading object.Exception@src/gtkc/Loader.d(123): Library load failed (libglib-2.0.so.0): libglib-2.0.so.0: cannot open shared object file: No such file or directo
    (description "This package provides Gtk and gstreamer and gtkgl and peas and sv and vte and glib bindings for D.")
    (license license:boost1.0))) ; FIXME LGPL with additional exceptions

;; Source-only library
(define-public d-pyd
  (package
    (name "d-pyd")
    (version "0.9.9")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/ariovistus/pyd/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0s13nlwq1azp3df0arwb19biizq4a6l42rhqz3230x9dmga7mgbp"))))
    (build-system dub-build-system)
    (native-inputs
     `(("python-2" ,python-2)))
    (home-page "https://github.com/ariovistus/pyd")
    (synopsis "D CPython API")
    (description "This package provides a CPython API for D.")
    (license license:expat))) ; FIXME which

(define-public d-vibe-core
  (package
    (name "d-vibe-core")
    (version "1.0.0-alpha.14")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/vibe-d/vibe-core/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1y02aqzw4phzd55l7by34p4bivbr6y980m2vxbbqb7r265xza5z5"))))
    (build-system dub-build-system)
    (propagated-inputs
     `(("d-eventcore" ,d-eventcore)))
    (home-page "https://vibed.org/")
    (synopsis "Vibe")
    (description "High-level declarative REST and web application framework with async IO i nD, core part")
    (license (list license:expat)))) ; FIXME which MIT

; FIXME vibe-d: redis, data, core, crypto, mongodb,, inet, diet, web, textfilter, stream, utils, mail, http
(define-public d-vibe-d
  (package
    (name "d-vibe-d")
    (version "0.8.0-beta.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/rejectedsoftware/vibe.d/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0f5gy4xy6cx03fi6nbbxj2303iz6jn7x7d0h3qd7hcr2lv1hlxy2"))))
    (build-system dub-build-system)
    (inputs
     `(("d-libevent" ,d-libevent)))
    ; FIXME openssl
    (home-page "http://vibed.org/")
    (synopsis "Vibe")
    (description "This package provides Vibe.")
    (license license:expat)))

(define-public d-derelict-util
  (package
    (name "d-derelict-util")
    (version "3.0.0-alpha.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/DerelictOrg/DerelictUtil/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0h44518dslci5c4pabwh1dlp10s43xlq3zpi3lsrc1a2bc07gaxb"))))
    (build-system dub-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-version
           (lambda _
             (substitute* "dub.sdl"
               (("name \"derelict-util\"") (string-append "name \"derelict-util\"
version \"" ,version "\"")))
             #t)))))
    (home-page "https://derelictorg.github.io/index.html")
    (synopsis "D derelict utils")
    (description "This package provides derelict utils.")
    (license license:boost1.0)))

(define-public d-derelict-sdl2
  (package
    (name "d-derelict-sdl2")
    (version "3.0.0-alpha.2")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/DerelictOrg/DerelictSDL2/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "06d395j28il1pg8j23xs6ajpbsjbcakjx79psi8wzfm701vbl97y"))))
    (build-system dub-build-system)
    (inputs
     `(("d-derelict-util" ,d-derelict-util)))
    (home-page "https://github.com/DerelictOrg/DerelictSDL2")
    (synopsis "D SDL bindings")
    (description "This package provides bindings to SDL2, SDL2_image, SDL2_mixer, SDL2_ttf and SDL2_net for D.")
    (license license:boost1.0)))

(define-public d-derelict-ft
  (package
    (name "d-derelict-ft")
    (version "1.1.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/DerelictOrg/DerelictFT/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1xsg9k38bq6d2r09fpwb7zwhbvjq5yi6g0p0yb7kg1ac2mfswphk"))))
    (build-system dub-build-system)
    (inputs
     `(("d-derelict-util" ,d-derelict-util))) ; derelict-util ~>2.0.6
    (home-page "https://github.com/DerelictOrg/DerelictFT")
    (synopsis "D Freetype bindings")
    (description "This package provides bindings to Freetype for D.")
    (license license:boost1.0)))

(define-public d-derelict-gl3
  (package
    (name "d-derelict-gl3")
    (version "2.0.0-alpha.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/DerelictOrg/DerelictGL3/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1bqlvv9bw2pihyjb3h3ss5bcn3ijacs9chqc2n97c4qw4q2r8chb"))))
    (build-system dub-build-system)
    (inputs
     `(("d-derelict-util" ,d-derelict-util))) ; derelict-util >=3.0.0-alpha.1 <3.1.0 cannot be satisfied.
    (home-page "https://github.com/DerelictOrg/DerelictGL3")
    (synopsis "D OpenGL bindings")
    (description "This package provides bindings to OpenGL for D.")
    (license license:boost1.0)))

; TODO derelict-: mpg123, gles, glfw3, fi, util, assimp3, nanovg, alure, theora, ogg, vorbis, pq, allegro5, ft[freetype], hdfs, newton, libui, portmidi, steamworks, imgui, physfs, bgfx, vulkan, sdl2_gfx, fmod, ode, sfml2, _extras-sndfile, cuda, _extras-fann, _extras-bass, _extras-vg, cl, cef[chromium], sass, _extras-nanomsg, _extras-opencl, _extras-udis86, _extras-anttweakbar, _extras-escapi, _extras-purple, _extras-glib, _extras-opendbx
; TODO meld game engine on top of derelict.

;; Fails test
(define-public d-bdb2d
  (package
    (name "d-bdb2d")
    (version "5.3.28")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/unDEFER/bdb2d/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1d2aa9rb22lja2nc2gh550dgkf5dyr25jbg7lz3p1gd3dahszsnj"))))
    (build-system dub-build-system)
    (inputs
     `(("bdb" ,bdb)))
    (home-page "http://unde.su/")
    (synopsis "D BerkeleyDB bindings")
    (description "This package provides bindings to BerkeleyDB for D.")
    (license license:gpl3+)))

(define-public unde
  (package
    (name "unde")
    (version "0.2.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/unDEFER/unde/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0g57dlgmbs99rkk5n2g08brgjfrriiqsdsk569n50n7yisfwxkir"))))
    (build-system dub-build-system)
    (inputs
     `(("d-bdb2d" ,d-bdb2d)
       ("d-derelict-ft" ,d-derelict-ft)
       ("d-derelict-sdl2" ,d-derelict-sdl2)))
    (home-page "http://unde.su/")
    (synopsis "Desktop environment")
    (description "This package provides a desktop environment.")
    (license license:gpl3+)))

(define-public d-wave-d
  (package
    (name "d-wave-d")
    (version "1.0.6")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/d-gamedev-team/wave-d/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "10q9hq0ilqr44qqgmzlc90z7h2bpl79jp2jrkwwy5r6q8xn2jxf2"))))
    (build-system dub-build-system)
    (home-page "http://github.com/d-gamedev-team/wave-d/")
    (synopsis "Wave file loader/emitter")
    (description "This package provides a Wave file loader/emitter for D.")
    (license license:public-domain)))

(define-public d-assert-that
  (package
    (name "d-assert-that")
    (version "0.0.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/youxkei/assert_that/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1nk2ikln6k5s3qs7z10f050jc2v0gsrpqsngwcc1n1d36d5gscr4"))))
    (build-system dub-build-system)
    (home-page "https://github.com/youxkei/assert_that")
    (synopsis "Assert function with pattern matching")
    (description "This package provides an @code{assert} function with pattern matching.")
    (license license:cc0)))

(define-public d-compile-time-unittest
  (package
    (name "d-compile-time-unittest")
    (version "0.0.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/youxkei/compile-time-unittest/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0032q3mhi90dpa9pb3yf9d7h1a5asjzkpqw1knfh3mpi9dlrp992"))))
    (build-system dub-build-system)
    (home-page "https://github.com/youxkei/compile-time-unittest")
    (synopsis "Run unit tests at compile time")
    (description "This package provides mixin to run unit tests at compile time in D.")
    (license license:cc0)))

(define-public d-tcenal
  (package
    (name "d-tcenal")
    (version "0.0.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/youxkei/tcenal/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0wxrasg805sfnajjy7nnwhp4wjs2m6sdfd870cp0c2cc74jmk7fr"))))
    (build-system dub-build-system)
    (inputs
     `(("d-assert-that" ,d-assert-that)
       ("d-compile-time-unittest" ,d-compile-time-unittest)))
    (home-page "https://github.com/youxkei/tcenal")
    (synopsis "Compile-time syntax extension")
    (description "This package provides compile-time syntax extension for D.
Example: See @url{https://github.com/youxkei/swapop}.")
    (license license:cc0)))

(define-public d-libdparse
  (package
    (name "d-libdparse")
    (version "0.7.0-beta.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/Hackerpilot/libdparse/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0w5kfgim2x6a10r9wr1plvqbzhc87d08a2wb502why5m4szyrj4m"))))
    (build-system dub-build-system)
    (home-page "https://github.com/Hackerpilot/libdparse")
    (synopsis "Library for lexing and parsing D source code")
    (description "This package provides Library for lexing and parsing D source code.")
    (license license:boost1.0)))

(define-public dfmt ; FIXME finish
  (package
    (name "dfmt")
    (version "0.5.0-beta.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/Hackerpilot/dfmt/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0wxrasg805sfnajjy8nnwhp4wjs2m6sdfd870cp0c2cc74jmk2fr"))))
    (build-system dub-build-system)
    (inputs
     `(("d-libdparse" ,d-libdparse)))
    (home-page "https://github.com/Hackerpilot/dfmt")
    (synopsis "Formatter for D source code")
    (description "Dfmt is a formatter for D source code.")
    (license license:boost1.0)))

(define-public d-antispam
  (package
    (name "d-antispam")
    (version "0.0.7")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/rejectedsoftware/antispam/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "1kdfinfw91y8pyxrqhwwkazfva9mrv1lhz7rf20scj7dshhq5siy"))))
    (build-system dub-build-system)
    (inputs
     `(("d-vibe-d" ,d-vibe-d)))
    (home-page "https://github.com/rejectedsoftware/antispam")
    (synopsis "Naive antispam filter")
    (description "This package provides a naive antispam filter.")
    (license license:gpl3)))

(define-public d-userman
  (package
    (name "d-userman")
    (version "0.4.0-beta.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/rejectedsoftware/d-userman/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0053q4mhi90dpa9pb4yf9d7h1a5asjzkpqw1knfh3mpi9dlrp992"))))
    (build-system dub-build-system)
    (inputs
     `(("d-vibe-d" ,d-vibe-d)))
    (home-page "https://github.com/rejectedsoftware/userman")
    (synopsis "User and group storage, authentication and administration.")
    (description "This package provides user and group storage, authentication and administration.")
    (license license:gpl3)))

(define-public vibenews
  (package
    (name "vibenews")
    (version "0.7.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/rejectedsoftware/vibenews/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0073q3mhi90dpa9pb4yf9d7h1a5asjzkpqw1knfh3mpi9dlrp992"))))
    (build-system dub-build-system)
    (inputs
     `(("d-vibe-d" ,d-vibe-d)
       ("d-antispam" ,d-antispam)
       ("d-userman" ,d-userman)))
    (home-page "https://github.com/rejectedsoftware/antispam")
    (synopsis "Naive antispam filter")
    (description "This package provides a naive antispam filter.")
    (license license:agpl3)))

(define-public d-syscall-d
  (package
    (name "d-syscall-d")
    (version "0.4.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/kubo39/syscall-d/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "151ipgyz1qaampdkc9a8jzypkji72wiqgbjhckl4mvf0akq92fri"))))
    (build-system dub-build-system)
    (home-page "https://github.com/kubo39/syscall-d")
    (synopsis "Syscalls in D")
    (description "This package provides syscall interface in D.")
    (license license:expat)))

(define-public d-sqlite-d
  (package
    (name "d-sqlite-d")
    (version "0.1.5")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/UplinkCoder/sqlite-d/archive/"
                                  "v" version ".tar.gz"))
              (file-name (string-append name "-" version ".tar.gz"))
              (sha256
               (base32
                "0yf7ibgnq2v8w82fz3sxdhad0rxwaxvv07xvw5abv692yd4sjkrk"))))
    (build-system dub-build-system)
    (home-page "https://github.com/UplinkCoder/sqlite-d")
    (synopsis "Sqlite reader in D")
    (description "This package provides a D-native Sqlite database reader.")
    (license license:boost1.0)))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gnu: Add dub-build-system.
  2017-02-02  9:11   ` Danny Milosavljevic
@ 2017-02-09 17:06     ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2017-02-09 17:06 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Hello!

Danny Milosavljevic <dannym@scratchpost.org> skribis:

>> Do you have experience using it on real DUB packages?  IOW, how complete
>> is it?  :-)
>
> Yeah, I've tested it on a small subset of all code.dlang.org packages. About half of the ones I tested work fine. This is my log:

Impressive!  I guess we can consider the importer mostly ready.  :-)

>>Rather: (chmod "." #o755).
>
> Thanks. Note that it's a workaround because git-download leaves the build directory read-only for some reason. Should the problem be found and fixed there? Or is it on purpose?

It’s not really on purpose, it’s just that the checkout in /gnu/store is
read-only and the ‘unpack’ phase simply copies it as-is.

>>Could you add a comment above explaining why this needs to be done?
>
> Sure. (it prepares a directory which can be used to find all the (D) dependencies by going just one level down; earlier versions just used /gnu/store directly but that would mean if you put such a package (without any subdirs in it) into your profile it would pollute the root)
>
> I'm just thinking out loud about the comment :)
>
> Something like this?
>
> ;; Prepare one new directory with all the required dependencies.
> ;; It's necessary to do this (instead of just using /gnu/store as the directory) because we want to hide the libraries in subdirectories lib/dub/... instead of polluting the user's profile root.

Sounds good (with wrapped lines).

>>If HOME is relied on, please add a comment explaining why.
>
> The dub build system uses it to [...]

No need to comment here, I trust you to do the right thing ;-), but
please just provide an explanation as a comment so people later can know
why things are done this way.

>> +  (if (or (zero? (system* "grep" "-q" "sourceLibrary" "package.json"))
>> +          (zero? (system* "grep" "-q" "sourceLibrary" "dub.sdl")) ; note: format is different!
>> +          (zero? (system* "grep" "-q" "sourceLibrary" "dub.json")))
>
>>Would be best to avoid calling out to ‘grep’.  At worst you can do:
>>  (define (grep string file)
>>    (string-contains (call-with-input-file file get-string-all)
>>                     string))
>
> Thanks. I'll use it. Will it break when it can't find the file? That
> would be bad. Usually there's only one of these files available.

Then you can do, say:

  (or (not (file-exists? file))
      (string-contains …))

With these issues addressed, I think you can push the updated patch.

Thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-09 17:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-30 23:42 [PATCH v2] gnu: Add dub-build-system Danny Milosavljevic
2017-02-01 22:13 ` Ludovic Courtès
2017-02-02  9:11   ` Danny Milosavljevic
2017-02-09 17:06     ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).