all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#31395] [PATCH 0/2] Add Snap! educational programming language
@ 2018-05-09 21:44 Nicolas Goaziou
  2018-05-09 21:46 ` [bug#31395] [PATCH 1/2] gnu: Add js-filesaver Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-05-09 21:44 UTC (permalink / raw)
  To: 31395

Hello,

The following two patches add Snap!. The application itself consists of --
mostly -- an HTML file, a bunch of ".js" files, and some art files in
subdirectories. 

Since it is a webapp, there is no executable. In order to provide something to
run, the package generates a Bash script that opens the HTML file using
`xdg-open'.

Regards,

Nicolas Goaziou (2):
  gnu: Add js-filesaver.
  gnu: Add snap.

 gnu/packages/education.scm  | 82 ++++++++++++++++++++++++++++++++++++-
 gnu/packages/javascript.scm | 39 ++++++++++++++++++
 2 files changed, 119 insertions(+), 2 deletions(-)

-- 
2.17.0

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

* [bug#31395] [PATCH 1/2] gnu: Add js-filesaver.
  2018-05-09 21:44 [bug#31395] [PATCH 0/2] Add Snap! educational programming language Nicolas Goaziou
@ 2018-05-09 21:46 ` Nicolas Goaziou
  2018-05-09 21:46   ` [bug#31395] [PATCH 2/2] gnu: Add snap Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-05-09 21:46 UTC (permalink / raw)
  To: 31395

* gnu/packages/javascript.scm (js-filesaver): New variable.
---
 gnu/packages/javascript.scm | 39 +++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index a54d4ecab..e2742faa1 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2018 Nicolas Goaziou <mail@nicolasgoaziou.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -368,6 +369,44 @@ to ES5 without causing run-time errors in older engines.  In many cases, this
 means that these shams cause many ES5 methods to silently fail.")
     (license license:expat)))
 
+(define-public js-filesaver
+  (package
+    (name "js-filesaver")
+    (version "1.3.8")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/eligrey/FileSaver.js/"
+                                  "archive/" version ".tar.gz"))
+              (file-name (string-append name "-" version))
+              (sha256
+               (base32
+                "1rkhfqs5plaj628kzj7qgm5qahy4v7ihygifidqr6g6265mil97h"))))
+    (build-system minify-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-uglification
+           ;; Remove "export" keyword which prevents the file from being
+           ;; uglified by uglify-js.  Moreover, that keyword is not present in
+           ;; the minified version of the library some projects are using,
+           ;; e.g.,
+           ;; <https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/blob/master/FileSaver.min.js>
+           (lambda _
+             (substitute* "src/FileSaver.js"
+               (("export ") ""))
+             #t)))))
+    (home-page
+     "https://eligrey.com/blog/saving-generated-files-on-the-client-side/")
+    (synopsis "HTML5 saveAs() FileSaver implementation")
+    (description "@file{FileSaver.js} implements the @code{saveAs()}
+FileSaver interface in browsers that do not natively support it.
+
+@file{FileSaver.js} is the solution to saving files on the
+client-side, and is perfect for webapps that need to generate files,
+or for saving sensitive information that shouldn't be sent to an
+external server.")
+    (license license:expat)))
+
 (define-public mujs
   (package
     (name "mujs")
-- 
2.17.0

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

* [bug#31395] [PATCH 2/2] gnu: Add snap.
  2018-05-09 21:46 ` [bug#31395] [PATCH 1/2] gnu: Add js-filesaver Nicolas Goaziou
@ 2018-05-09 21:46   ` Nicolas Goaziou
  2018-05-10  2:36     ` Eric Bavier
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-05-09 21:46 UTC (permalink / raw)
  To: 31395

* gnu/packages/education.scm (snap): New variable.
---
 gnu/packages/education.scm | 82 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 80 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/education.scm b/gnu/packages/education.scm
index 58f06c310..679c69d79 100644
--- a/gnu/packages/education.scm
+++ b/gnu/packages/education.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
 ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2018 Nicolas Goaziou <mail@nicolasgoaziou.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,17 +23,21 @@
 (define-module (gnu packages education)
   #:use-module (ice-9 regex)
   #:use-module (gnu packages)
-  #:use-module (gnu packages qt)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages databases)
+  #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gtk)
+  #:use-module (gnu packages javascript)
   #:use-module (gnu packages kde-frameworks) ; extra-cmake-modules
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages qt)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages xml)
@@ -41,8 +46,9 @@
   #:use-module (guix download)
   #:use-module (guix svn-download)
   #:use-module (guix utils)
-  #:use-module (guix build-system gnu)
   #:use-module (guix build-system cmake)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
   #:use-module (srfi srfi-1))
 
 (define-public gcompris
@@ -224,3 +230,75 @@ Useful support functions and an extensive progress tracker, topical lessons
 and the ability to create your own practice lessons make learning to type
 easy.")
     (license license:gpl2)))
+
+(define-public snap
+  (package
+    (name "snap")
+    (version "4.1.2.7")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/archive/"
+             version ".tar.gz"))
+       (file-name (string-append name "-" version))
+       (sha256
+        (base32
+         "0yf3x133n9ady4zr9z8cab98qfp9v69x9qjfl8ia05zxzy7d3y5z"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (let* ((out (assoc-ref %outputs "out"))
+                (share (string-append out "/share/snap"))
+                (root (string-append "Snap--Build-Your-Own-Blocks-"
+                                     ,version)))
+           (setenv "PATH" (string-append
+                           (assoc-ref %build-inputs "gzip") "/bin:"
+                           (assoc-ref %build-inputs "tar") "/bin"))
+           (invoke "tar" "xvzf" (assoc-ref %build-inputs "source"))
+           (mkdir-p share)
+           (with-directory-excursion root
+             (copy-recursively "." share))
+           ;; Replace the sole minified file in the package.
+           (with-directory-excursion share
+             (delete-file "FileSaver.min.js")
+             (symlink (string-append (assoc-ref %build-inputs "js-filesaver")
+                                     "/share/javascript/FileSaver.min.js")
+                      "FileSaver.min.js"))
+           ;; Create a "snap" executable.
+           (let* ((bin (string-append out "/bin"))
+                  (script (string-append bin "/snap"))
+                  (bash (string-append (assoc-ref %build-inputs "bash")
+                                       "/bin/bash"))
+                  (xdg-open (string-append (assoc-ref %build-inputs "xdg-utils")
+                                           "/bin/xdg-open"))
+                  (snap (string-append share "/snap.html")))
+             (mkdir-p bin)
+             (call-with-output-file script
+               (lambda (port)
+                 (format port "#!~a\n~a '~a'" bash xdg-open snap)))
+             (chmod script #o555)))
+         #t)))
+    (native-inputs
+     `(("gzip" ,gzip)
+       ("tar" ,tar)
+       ("js-filesaver" ,js-filesaver)))
+    (inputs
+     `(("bash" ,bash-minimal)
+       ("xdg-utils" ,xdg-utils)))
+    (home-page "https://snap.berkeley.edu")
+    (synopsis "Visual, blocks based programming language inspired by Scratch")
+    (description "Snap! (formerly BYOB) is a visual, drag-and-drop
+programming language.  It is an extended reimplementation of Scratch (a
+project of the Lifelong Kindergarten Group at the MIT Media Lab) that
+allows you to Build Your Own Blocks.  It also features first class
+lists, first class procedures, and continuations.  These added
+capabilities make it suitable for a serious introduction to computer
+science for high school or college students.
+
+This package provides a @command{snap} executable calling @command{xdg-open}
+to open a the application in a web browser.")
+    (license license:agpl3+)))
-- 
2.17.0

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

* [bug#31395] [PATCH 2/2] gnu: Add snap.
  2018-05-09 21:46   ` [bug#31395] [PATCH 2/2] gnu: Add snap Nicolas Goaziou
@ 2018-05-10  2:36     ` Eric Bavier
  2018-05-10 13:10       ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Bavier @ 2018-05-10  2:36 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: 31395

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

Hello Nicolas,

This package looks fun, thanks for working on it, I played with it for
a while in my browser :)

Just a few comments:

On Wed,  9 May 2018 23:46:22 +0200
Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> * gnu/packages/education.scm (snap): New variable.
> ---
>  gnu/packages/education.scm | 82 +++++++++++++++++++++++++++++++++++++-
>  1 file changed, 80 insertions(+), 2 deletions(-)
> 
[...]
> @@ -224,3 +230,75 @@ Useful support functions and an extensive progress tracker, topical lessons
>  and the ability to create your own practice lessons make learning to type
>  easy.")
>      (license license:gpl2)))
> +
> +(define-public snap
> +  (package
> +    (name "snap")
> +    (version "4.1.2.7")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append
> +             "https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/archive/"
> +             version ".tar.gz"))

I think we're trying to stay away from Github's auto-generated tarballs
now, because they are not guaranteed to remain the same over time.  

Unfortunately this project doesn't seem to upload its own release
tarballs.  I would instead use a git checkout.

> +       (file-name (string-append name "-" version))
> +       (sha256
> +        (base32
> +         "0yf3x133n9ady4zr9z8cab98qfp9v69x9qjfl8ia05zxzy7d3y5z"))))
> +    (build-system trivial-build-system)
> +    (arguments
> +     `(#:modules ((guix build utils))
> +       #:builder
> +       (begin
> +         (use-modules (guix build utils))
> +         (let* ((out (assoc-ref %outputs "out"))
> +                (share (string-append out "/share/snap"))
> +                (root (string-append "Snap--Build-Your-Own-Blocks-"
> +                                     ,version)))
> +           (setenv "PATH" (string-append
> +                           (assoc-ref %build-inputs "gzip") "/bin:"
> +                           (assoc-ref %build-inputs "tar") "/bin"))
> +           (invoke "tar" "xvzf" (assoc-ref %build-inputs "source"))
> +           (mkdir-p share)
> +           (with-directory-excursion root
> +             (copy-recursively "." share))

This could be simplified to '(copy-recursively root share)', and the
mkdir-p can even be left out because copy-recursively will create it
for you.

> +           ;; Replace the sole minified file in the package.
> +           (with-directory-excursion share
> +             (delete-file "FileSaver.min.js")
> +             (symlink (string-append (assoc-ref %build-inputs "js-filesaver")
> +                                     "/share/javascript/FileSaver.min.js")
> +                      "FileSaver.min.js"))
> +           ;; Create a "snap" executable.
> +           (let* ((bin (string-append out "/bin"))
> +                  (script (string-append bin "/snap"))
> +                  (bash (string-append (assoc-ref %build-inputs "bash")
> +                                       "/bin/bash"))
> +                  (xdg-open (string-append (assoc-ref %build-inputs "xdg-utils")
> +                                           "/bin/xdg-open"))
> +                  (snap (string-append share "/snap.html")))
> +             (mkdir-p bin)
> +             (call-with-output-file script
> +               (lambda (port)
> +                 (format port "#!~a\n~a '~a'" bash xdg-open snap)))

You could maybe use '(which "sh")' and '(which xdg-open)'.  A
matter of taste, I think.

> +             (chmod script #o555)))
> +         #t)))
> +    (native-inputs
> +     `(("gzip" ,gzip)
> +       ("tar" ,tar)
> +       ("js-filesaver" ,js-filesaver)))

js-filesave should go in "inputs", right?

> +    (inputs
> +     `(("bash" ,bash-minimal)
> +       ("xdg-utils" ,xdg-utils)))
> +    (home-page "https://snap.berkeley.edu")
> +    (synopsis "Visual, blocks based programming language inspired by Scratch")

We can leave out "inspired by Scratch" in the synopsis.

> +    (description "Snap! (formerly BYOB) is a visual, drag-and-drop
> +programming language.  It is an extended reimplementation of Scratch (a
> +project of the Lifelong Kindergarten Group at the MIT Media Lab) that
> +allows you to Build Your Own Blocks.  It also features first class
> +lists, first class procedures, and continuations.  These added
> +capabilities make it suitable for a serious introduction to computer
> +science for high school or college students.
> +
> +This package provides a @command{snap} executable calling @command{xdg-open}
> +to open a the application in a web browser.")
           ^
s/a the/the/

> +    (license license:agpl3+)))

Otherwise looks good and works for me.

Thanks,
`~Eric

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [bug#31395] [PATCH 2/2] gnu: Add snap.
  2018-05-10  2:36     ` Eric Bavier
@ 2018-05-10 13:10       ` Nicolas Goaziou
  2018-05-10 13:47         ` Eric Bavier
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-05-10 13:10 UTC (permalink / raw)
  To: Eric Bavier; +Cc: 31395

Hello,

Eric Bavier <ericbavier@centurylink.net> writes:

> This package looks fun, thanks for working on it, I played with it for
> a while in my browser :)

Heh.

> Just a few comments:

Thank you for the review.

>> +       (uri (string-append
>> +             "https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/archive/"
>> +             version ".tar.gz"))
>
> I think we're trying to stay away from Github's auto-generated tarballs
> now, because they are not guaranteed to remain the same over time.
>
> Unfortunately this project doesn't seem to upload its own release
> tarballs.  I would instead use a git checkout.

Version is a tag, therefore a commit, so I would think it should remain
identical over time. Besides a number of packages use this (e.g.,
audacity...)

Granted, I'm not well-versed in Github technology. Yet, using a git
checkout slightly complicates the package, and its subsequent updates,
so I'd rather only use it if absolutely necessary.

WDYT?

>> +           (mkdir-p share)
>> +           (with-directory-excursion root
>> +             (copy-recursively "." share))
>
> This could be simplified to '(copy-recursively root share)', and the
> mkdir-p can even be left out because copy-recursively will create it
> for you.

OK.

>> +           (let* ((bin (string-append out "/bin"))
>> +                  (script (string-append bin "/snap"))
>> +                  (bash (string-append (assoc-ref %build-inputs "bash")
>> +                                       "/bin/bash"))
>> +                  (xdg-open (string-append (assoc-ref %build-inputs "xdg-utils")
>> +                                           "/bin/xdg-open"))
>> +                  (snap (string-append share "/snap.html")))
>> +             (mkdir-p bin)
>> +             (call-with-output-file script
>> +               (lambda (port)
>> +                 (format port "#!~a\n~a '~a'" bash xdg-open snap)))
>
> You could maybe use '(which "sh")' and '(which xdg-open)'.  A
> matter of taste, I think.

So (which "sh") should be in the (format ...) call instead of the `bash'
binding above? This is shorter, indeed.

>> +    (native-inputs
>> +     `(("gzip" ,gzip)
>> +       ("tar" ,tar)
>> +       ("js-filesaver" ,js-filesaver)))
>
> js-filesave should go in "inputs", right?

Correct.

>> +    (inputs
>> +     `(("bash" ,bash-minimal)
>> +       ("xdg-utils" ,xdg-utils)))
>> +    (home-page "https://snap.berkeley.edu")
>> +    (synopsis "Visual, blocks based programming language inspired by Scratch")
>
> We can leave out "inspired by Scratch" in the synopsis.

OK.

>> +This package provides a @command{snap} executable calling @command{xdg-open}
>> +to open a the application in a web browser.")
>            ^
> s/a the/the/

OK.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

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

* [bug#31395] [PATCH 2/2] gnu: Add snap.
  2018-05-10 13:10       ` Nicolas Goaziou
@ 2018-05-10 13:47         ` Eric Bavier
  2018-05-10 15:58           ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Bavier @ 2018-05-10 13:47 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: 31395

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

On Thu, 10 May 2018 15:10:00 +0200
Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Hello,
> 
> Eric Bavier <ericbavier@centurylink.net> writes:
> 
> >> +       (uri (string-append
> >> +             "https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/archive/"
> >> +             version ".tar.gz"))  
> >
> > I think we're trying to stay away from Github's auto-generated tarballs
> > now, because they are not guaranteed to remain the same over time.
> >
> > Unfortunately this project doesn't seem to upload its own release
> > tarballs.  I would instead use a git checkout.  
> 
> Version is a tag, therefore a commit, so I would think it should remain
> identical over time. Besides a number of packages use this (e.g.,
> audacity...)

It's worse than that.  See e.g.
https://marc.info/?l=openbsd-ports&m=151973450514279&w=2

Many other packages use it because the issue was only brought to light
more recently.

> 
> Granted, I'm not well-versed in Github technology. Yet, using a git
> checkout slightly complicates the package, and its subsequent updates,
> so I'd rather only use it if absolutely necessary.
> 
> WDYT?

I don't think it would make the package more difficult.  If anything I
think it could make it easier.  E.g. it wouldn't need the tar and gzip
inputs and wouldn't need to untar.

You don't need to use a git hash at all.  If the release is tagged, you
can use that in the git-reference commit.  E.g. a recent package I
made, "ghostwriter", does this.

HTH,
`~Eric

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [bug#31395] [PATCH 2/2] gnu: Add snap.
  2018-05-10 13:47         ` Eric Bavier
@ 2018-05-10 15:58           ` Nicolas Goaziou
  2018-05-11  2:32             ` Eric Bavier
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-05-10 15:58 UTC (permalink / raw)
  To: Eric Bavier; +Cc: 31395

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

Eric Bavier <ericbavier@centurylink.net> writes:

> It's worse than that.  See e.g.
> https://marc.info/?l=openbsd-ports&m=151973450514279&w=2
>
> Many other packages use it because the issue was only brought to light
> more recently.

I see. Thank you for the reference.

> You don't need to use a git hash at all.  If the release is tagged, you
> can use that in the git-reference commit.  E.g. a recent package I
> made, "ghostwriter", does this.

OK. I used `git-reference'. One difficulty I encountered is the working
directory when using `git-reference' is non-trivial. I though it would
put me in the cloned repository, but instead, it left me in an empty
directory, which is neither the source directory nor the output
directory. Maybe it should be documented in the manual.

Also, note that I couldn't use (which "sh") or (which "xdg-open"), since
both returned #f. Probably a PATH problem, so I sticked to my previous
way of finding bash and xdg-open.

Here is the updated patch. Let me know what you think.


[-- Attachment #2: snap, take 2 --]
[-- Type: text/x-diff, Size: 5261 bytes --]

From e675d2300fd36e82943d0dabf80160d67afd4c99 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Date: Wed, 9 May 2018 23:27:21 +0200
Subject: [PATCH 2/2] gnu: Add snap.

* gnu/packages/education.scm (snap): New variable.
---
 gnu/packages/education.scm | 73 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 71 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/education.scm b/gnu/packages/education.scm
index 58f06c310..72cd7c61b 100644
--- a/gnu/packages/education.scm
+++ b/gnu/packages/education.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
 ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2018 Nicolas Goaziou <mail@nicolasgoaziou.fr>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,27 +23,33 @@
 (define-module (gnu packages education)
   #:use-module (ice-9 regex)
   #:use-module (gnu packages)
-  #:use-module (gnu packages qt)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages databases)
+  #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gtk)
+  #:use-module (gnu packages javascript)
   #:use-module (gnu packages kde-frameworks) ; extra-cmake-modules
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages qt)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages xml)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module (guix svn-download)
   #:use-module (guix utils)
-  #:use-module (guix build-system gnu)
   #:use-module (guix build-system cmake)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
   #:use-module (srfi srfi-1))
 
 (define-public gcompris
@@ -224,3 +231,65 @@ Useful support functions and an extensive progress tracker, topical lessons
 and the ability to create your own practice lessons make learning to type
 easy.")
     (license license:gpl2)))
+
+(define-public snap
+  (package
+    (name "snap")
+    (version "4.1.2.7")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/jmoenig/Snap--Build-Your-Own-Blocks.git")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0cy3jhqqpmivqnfm9kmlnh3fhf3m3y4xqhikblk8vfjprh6vmcvd"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (let* ((source (assoc-ref %build-inputs "source"))
+                (out (assoc-ref %outputs "out"))
+                (share (string-append out "/share/snap")))
+           (copy-recursively source share)
+           ;; Replace the sole minified file in the package.
+           (with-directory-excursion share
+             (delete-file "FileSaver.min.js")
+             (symlink (string-append (assoc-ref %build-inputs "js-filesaver")
+                                     "/share/javascript/FileSaver.min.js")
+                      "FileSaver.min.js"))
+           ;; Create a "snap" executable.
+           (let* ((bin (string-append out "/bin"))
+                  (script (string-append bin "/snap"))
+                  (snap (string-append share "/snap.html"))
+                  (bash (string-append (assoc-ref %build-inputs "bash")
+                                       "/bin/sh"))
+                  (xdg-open (string-append (assoc-ref %build-inputs "xdg-utils")
+                                           "/bin/xdg-open")))
+             (mkdir-p bin)
+             (call-with-output-file script
+               (lambda (port)
+                 (format port "#!~a\n~a '~a'" bash xdg-open snap)))
+             (chmod script #o555)))
+         #t)))
+    (inputs
+     `(("bash" ,bash-minimal)
+       ("js-filesaver" ,js-filesaver)
+       ("xdg-utils" ,xdg-utils)))
+    (home-page "https://snap.berkeley.edu")
+    (synopsis "Visual, blocks based programming language")
+    (description "Snap! (formerly BYOB) is a visual, drag-and-drop
+programming language.  It is an extended reimplementation of Scratch (a
+project of the Lifelong Kindergarten Group at the MIT Media Lab) that
+allows you to Build Your Own Blocks.  It also features first class
+lists, first class procedures, and continuations.  These added
+capabilities make it suitable for a serious introduction to computer
+science for high school or college students.
+
+This package provides a @command{snap} executable calling @command{xdg-open}
+to open the application in a web browser, for offline usage.")
+    (license license:agpl3+)))
-- 
2.17.0


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

* [bug#31395] [PATCH 2/2] gnu: Add snap.
  2018-05-10 15:58           ` Nicolas Goaziou
@ 2018-05-11  2:32             ` Eric Bavier
  2018-05-11  8:46               ` bug#31395: " Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Bavier @ 2018-05-11  2:32 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: 31395

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

On Thu, 10 May 2018 17:58:43 +0200
Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Eric Bavier <ericbavier@centurylink.net> writes:
> 
> > It's worse than that.  See e.g.
> > https://marc.info/?l=openbsd-ports&m=151973450514279&w=2
> >
> > Many other packages use it because the issue was only brought to light
> > more recently.  
> 
> I see. Thank you for the reference.
> 
> > You don't need to use a git hash at all.  If the release is tagged, you
> > can use that in the git-reference commit.  E.g. a recent package I
> > made, "ghostwriter", does this.  
> 
> OK. I used `git-reference'. One difficulty I encountered is the working
> directory when using `git-reference' is non-trivial. I though it would
> put me in the cloned repository, but instead, it left me in an empty
> directory, which is neither the source directory nor the output
> directory. Maybe it should be documented in the manual.

Maybe, yeah.  The builders get dropped into the temporary build
directory to start.

> 
> Also, note that I couldn't use (which "sh") or (which "xdg-open"), since
> both returned #f. Probably a PATH problem, so I sticked to my previous
> way of finding bash and xdg-open.

Indeed, "which" looks in PATH, so what you've done is fine.

> 
> Here is the updated patch. Let me know what you think.
> 

LGTM!

Thanks,
`~Eric

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* bug#31395: [PATCH 2/2] gnu: Add snap.
  2018-05-11  2:32             ` Eric Bavier
@ 2018-05-11  8:46               ` Nicolas Goaziou
  0 siblings, 0 replies; 9+ messages in thread
From: Nicolas Goaziou @ 2018-05-11  8:46 UTC (permalink / raw)
  To: Eric Bavier; +Cc: 31395-done

Hello,

Eric Bavier <ericbavier@centurylink.net> writes:

> Maybe, yeah.  The builders get dropped into the temporary build
> directory to start.

Yes, I expected that. 

However, `url-fetch' puts the downloaded file in front of you in the
temporary build directory. You can start to operate on it right away.

This is not the case with `git-fetch', which puts the data elsewhere.
Elsewhere being retrieved by the under documented 

  (assoc-ref %build-inputs "source")

Anyway, this is only tangential to the patch. I'm thinking out loud.

> LGTM!

Applied. Thank you!

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

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

end of thread, other threads:[~2018-05-11  8:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09 21:44 [bug#31395] [PATCH 0/2] Add Snap! educational programming language Nicolas Goaziou
2018-05-09 21:46 ` [bug#31395] [PATCH 1/2] gnu: Add js-filesaver Nicolas Goaziou
2018-05-09 21:46   ` [bug#31395] [PATCH 2/2] gnu: Add snap Nicolas Goaziou
2018-05-10  2:36     ` Eric Bavier
2018-05-10 13:10       ` Nicolas Goaziou
2018-05-10 13:47         ` Eric Bavier
2018-05-10 15:58           ` Nicolas Goaziou
2018-05-11  2:32             ` Eric Bavier
2018-05-11  8:46               ` bug#31395: " Nicolas Goaziou

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.