Note use of direnv with guix.
[mediagoblin.git] / guix-env.scm
1 ;;; GNU MediaGoblin -- federated, autonomous media hosting
2 ;;; Copyright © 2015, 2016 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
4 ;;; Copyright © 2019 Ben Sturmfels <ben@sturm.com.au>
5 ;;;
6 ;;; This program is free software: you can redistribute it and/or modify
7 ;;; it under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation, either version 3 of the License, or
9 ;;; (at your option) any later version.
10 ;;;
11 ;;; This program is distributed in the hope that it will be useful,
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; ========================================
17 ;;;
18 ;;; ... This file is also part of GNU MediaGoblin, but we're leaving it
19 ;;; under GPLv3 for easy merge back and forth between Guix proper. It
20 ;;; also borrows some code directly from Guix.
21 ;;;
22 ;;; ========================================
23 ;;;
24 ;;; With `guix environment' you can use guix as kind of a universal
25 ;;; virtualenv, except a universal virtualenv with magical time traveling
26 ;;; properties and also, not just for Python.
27 ;;;
28 ;;; Ok, here's how to use this thing! First, install Guix.
29 ;;; Then do:
30 ;;; guix environment -l guix-env.scm --pure
31 ;;;
32 ;;; You'll need to run the above command every time you close your terminal or
33 ;;; restart your system, so a handy way to save having to remember is to install
34 ;;; "direnv" an then create a ".envrc" file in your current directory containing
35 ;;; the following and then run "direnv allow" when prompted:
36 ;;; use guix -l guix-env.scm --pure
37 ;;;
38 ;;; To set things up for the first time, you'll also need to run:
39 ;;; git submodule init
40 ;;; git submodule update
41 ;;; ./bootstrap.sh
42 ;;; ./configure --with-python3 --without-virtualenv
43 ;;; make
44 ;;; python3 -m venv --system-site-packages . && bin/python setup.py develop --no-deps
45 ;;;
46 ;;; ... wait whaaat, what's that last line! I thought you said this
47 ;;; was a reasonable virtualenv replacement! Well it is and it will
48 ;;; be, but there's a catch, and the catch is that Guix doesn't know
49 ;;; about this directory and "setup.py dist" is technically necessary
50 ;;; for certain things to run, so we have a virtualenv with nothing
51 ;;; in it but this project itself.
52 ;;;
53 ;;; The devtools/update_extlib.sh script won't run on Guix due to missing
54 ;;; "/usr/bin/env", so then run:
55 ;;; node node_modules/.bin/bower install
56 ;;; ./devtools/update_extlib.sh
57 ;;; bin/gmg dbupdate
58 ;;; bin/gmg adduser --username admin --password a --email admin@example.com
59 ;;; ./lazyserver.sh
60 ;;;
61 ;;; So anyway, now you can do:
62 ;;; PYTHONPATH="${PYTHONPATH}:$(pwd)" ./runtests.sh
63 ;;;
64 ;;; Now notably this is goofier looking than running a virtualenv,
65 ;;; but soon I'll do something truly evil (I hope) that will make
66 ;;; the virtualenv and path-hacking stuff unnecessary.
67 ;;;
68 ;;; Have fun!
69 ;;;
70 ;;; Known issues:
71 ;;; - currently fails to upload h264 source video: "GStreamer: missing H.264 decoder"
72
73 (use-modules (ice-9 match)
74 (srfi srfi-1)
75 (guix packages)
76 (guix licenses)
77 (guix download)
78 (guix git-download)
79 (guix build-system gnu)
80 (guix build-system python)
81 (gnu packages)
82 (gnu packages autotools)
83 (gnu packages base)
84 (gnu packages certs)
85 (gnu packages check)
86 (gnu packages databases)
87 (gnu packages python)
88 (gnu packages python-crypto)
89 (gnu packages python-web)
90 (gnu packages python-xyz)
91 (gnu packages sphinx)
92 (gnu packages gstreamer)
93 (gnu packages glib)
94 (gnu packages rsync)
95 (gnu packages ssh)
96 (gnu packages time)
97 (gnu packages version-control)
98 ((guix licenses) #:select (expat zlib) #:prefix license:))
99
100 ;; =================================================================
101 ;; These packages are on their way into Guix proper but haven't made
102 ;; it in yet... or they're old versions of packages we're pinning
103 ;; ourselves to...
104 ;; =================================================================
105
106 (define python-pytest-forked
107 (package
108 (name "python-pytest-forked")
109 (version "1.0.2")
110 (source
111 (origin
112 (method url-fetch)
113 (uri (pypi-uri "pytest-forked" version))
114 (sha256
115 (base32
116 "0f4y1jhcg70xhm220pdb8r24n01knhn749aqlr14vmgbsb7allnk"))))
117 (build-system python-build-system)
118 (propagated-inputs
119 `(("python-pytest" ,python-pytest)
120 ("python-setuptools-scm" ,python-setuptools-scm)))
121 (home-page
122 "https://github.com/pytest-dev/pytest-forked")
123 (synopsis
124 "run tests in isolated forked subprocesses")
125 (description
126 "run tests in isolated forked subprocesses")
127 (license license:expat)))
128
129 ;; =================================================================
130
131 (define mediagoblin
132 (package
133 (name "mediagoblin")
134 (version "0.8.1")
135 (source
136 (origin
137 (method url-fetch)
138 (uri (pypi-uri "mediagoblin" version))
139 (sha256
140 (base32
141 "0p2gj4z351166d1zqmmd8wc9bzb69w0fjm8qq1fs8dw2yhcg2wwv"))))
142 (build-system python-build-system)
143 (arguments
144 ;; Complains about missing gunicorn. Not sure where that comes from.
145 '(#:tests? #f))
146 (native-inputs
147 `(("python-pytest" ,python-pytest)
148 ("nss-certs" ,nss-certs)))
149 (propagated-inputs
150 `(("python-alembic" ,python-alembic)
151 ("python-pytest-xdist" ,python-pytest-xdist)
152 ("python-pytest-forked" ,python-pytest-forked)
153 ("python-celery" ,python-celery)
154 ("python-kombu" ,python-kombu)
155 ("python-webtest" ,python-webtest)
156 ("python-pastedeploy" ,python-pastedeploy)
157 ("python-paste" ,python-paste)
158 ("python-pastescript" ,python-pastescript)
159 ("python-translitcodec" ,python-translitcodec)
160 ("python-babel" ,python-babel)
161 ("python-configobj" ,python-configobj)
162 ("python-dateutil" ,python-dateutil)
163 ("python-itsdangerous" ,python-itsdangerous)
164 ("python-jinja2" ,python-jinja2)
165 ("python-jsonschema" ,python-jsonschema)
166 ("python-lxml" ,python-lxml)
167 ("python-markdown" ,python-markdown)
168 ("python-oauthlib" ,python-oauthlib)
169 ("python-pillow" ,python-pillow)
170 ("python-py-bcrypt" ,python-py-bcrypt)
171 ("python-pyld" ,python-pyld)
172 ("python-pytz" ,python-pytz)
173 ("python-requests" ,python-requests)
174 ("python-setuptools" ,python-setuptools)
175 ("python-six" ,python-six)
176 ("python-sphinx" ,python-sphinx)
177 ("python-docutils" ,python-docutils)
178 ("python-sqlalchemy" ,python-sqlalchemy)
179 ("python-unidecode" ,python-unidecode)
180 ("python-werkzeug" ,python-werkzeug)
181 ("python-exif-read" ,python-exif-read)
182 ("python-wtforms" ,python-wtforms)))
183 (home-page "http://mediagoblin.org/")
184 (synopsis "Web application for media publishing")
185 (description "MediaGoblin is a web application for publishing all kinds of
186 media.")
187 (license agpl3+)))
188
189 (package
190 (inherit mediagoblin)
191 (name "mediagoblin-hackenv")
192 (version "git")
193 (inputs
194 `(;;; audio/video stuff
195 ("gstreamer" ,gstreamer)
196 ("gst-libav" ,gst-plugins-base)
197 ("gst-plugins-base" ,gst-plugins-base)
198 ("gst-plugins-good" ,gst-plugins-good)
199 ("gst-plugins-bad" ,gst-plugins-bad)
200 ("gst-plugins-ugly" ,gst-plugins-ugly)
201 ("gobject-introspection" ,gobject-introspection)
202 ;; useful to have!
203 ("coreutils" ,coreutils)
204 ;; used by runtests.sh!
205 ("which" ,which)
206 ("git" ,git)
207 ("automake" ,automake)
208 ("autoconf" ,autoconf)
209 ,@(package-inputs mediagoblin)))
210 (propagated-inputs
211 `(("python" ,python)
212 ("python-virtualenv" ,python-virtualenv)
213 ("python-pygobject" ,python-pygobject)
214 ("python-gst" ,python-gst)
215 ;; Needs python-gst in order for all tests to pass
216 ("python-numpy" ,python-numpy) ; this pulls in texlive...
217 ; and texlive-texmf is very large...
218 ("python-chardet", python-chardet)
219 ("python-psycopg2" ,python-psycopg2)
220 ;; For developing
221 ("openssh" ,openssh)
222 ("git" ,git)
223 ("rsync" ,rsync)
224 ,@(package-propagated-inputs mediagoblin))))