2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/data-service.git synced 2023-12-14 03:23:03 +01:00
Service to store and provide data about Guix https://git.savannah.gnu.org/cgit/guix/data-service.git
Find a file
Christopher Baines 241d7e4889 Use libc-locales-for-target
To help find the right glibc-locales to use.
2023-12-04 11:11:39 +00:00
assets Bring back the old table header style 2020-01-02 21:19:18 +00:00
build-aux Add missing build-aux files 2019-04-16 22:21:07 +01:00
guix-data-service Use libc-locales-for-target 2023-12-04 11:11:39 +00:00
scripts Set %file-port-name-canonicalization when processing jobs 2023-12-04 11:06:27 +00:00
sqitch Support polling git repositories for new branches/revisions 2023-10-09 22:19:02 +01:00
tests Use fibers when processing new revisions 2023-11-05 13:46:20 +00:00
.dir-locals.el Stop using a pool of threads for database operations 2023-07-10 18:56:31 +01:00
.envrc Update guix-dev.scm and .envrc 2023-11-05 13:46:20 +00:00
.gitattributes Add a .gitattributes file 2019-04-14 10:01:58 +01:00
.gitignore Split out querying of build servers and substitute servers 2020-05-03 13:23:43 +01:00
bootstrap.sh Initial commit 2019-02-07 22:26:57 +00:00
configure.ac Add dependency on Guile-lzlib. 2020-08-26 11:27:54 +02:00
COPYING Initial commit 2019-02-07 22:26:57 +00:00
guile.am Generate .go files for the tests 2020-02-27 21:11:45 +00:00
guix-dev.scm Update guix-dev.scm and .envrc 2023-11-05 13:46:20 +00:00
Makefile.am Support polling git repositories for new branches/revisions 2023-10-09 22:19:02 +01:00
pre-inst-env.in Fix some comments 2020-02-16 22:29:11 +00:00
README Add commit message entry about UDP push notifications for commits 2023-09-27 15:36:00 +01:00
sqitch.conf Remove localhost from the Sqitch config 2019-07-16 18:20:56 +01:00
VERSION Initial commit 2019-02-07 22:26:57 +00:00

-*- mode: org -*-

The Guix Data Service processes, stores and provides data about Guix over
time.

It's written in Guile, stores data in a PostgreSQL database, and provides a
web interface and API to browse and access the data.

* Overview

The aim of the Guix Data Service is to provide a complementary interface to
Guix itself, providing a different way of interacting with Guix data, which
hopefully enables tools and services that otherwise wouldn't be feasible to
write.

For example, with the command line tooling or Guile API for Guix, you can
quickly and easily access information about packages, and manipulate
derivations. However, if you wish to compare two revisions of Guix, or look at
the history of the derivations for a package over recent Guix revisions, it
could take some time until you have the information you're looking for.

However, with the Guix Data Service, this information can be gathered
continuously, and stored in a way that makes these kind of queries much
quicker to answer. By storing data about multiple Guix revisions in a SQL
database (PostgreSQL), it becomes possible to quickly compare the data for
different revisions. By configuring the Guix Data Service to listen for
changes in the Guix Git repository, the database can be kept up to date.

* Local Development

There's no one right way of doing local development, but outlined here is a
recommended approach.

You will need to have:
 - The Guix package manager, either installed on any GNU/Linux distribution,
   or be using Guix as a system.
 - A running PostgreSQL service, version 10 or above is recommended
 - Git, so you can clone the repository
 - direnv, to manage environment variables

If you have any problems with the instructions here, you can ask for help on
the #guix IRC channel on Freenode. You can also email help-guix@gnu.org, please
include the step you got to, and the problem you encountered (with the error
message if applicable).

** Cloning the repository

To clone the Git repository, run the following command:

#+BEGIN_SRC shell
git clone https://git.savannah.gnu.org/git/guix/data-service.git guix-data-service
#+END_SRC

** Getting direnv working

direnv is used to update the environment within the shell to contain the
dependencies of the Guix Data Service. If you've just installed direnv, check
you've hooked it in to your shell https://direnv.net/docs/hook.html .

Change in to the =guix-data-service= directory. You should see direnv
prompting to trust the =.envrc= file contained within the repository.

Check the contents of the =.envrc= file, and if you trust it, run =direnv
allow=.

** Setup the database

Dumps of the database behind data.guix.gnu.org are available at
http://data.guix.gnu.org/dumps, use the following URL to download the latest
small dump.

http://data.guix.gnu.org/dumps/latest/guix_data_service_small.dump

There are multiple ways you can setup the database, the instructions here
involve creating a =guix_data_service= user with a password, then connecting
to the database over the local network interface.

To create the user and database use the scripts from PostgreSQL. The
=createuser= command will prompt for a password for the database user, you'll
need this at multiple points so it might be useful to keep it simple.

#+BEGIN_SRC shell
createuser guix_data_service --pwprompt
createdb guix_data_service --owner=guix_data_service
#+END_SRC

You may need to run these commands as the postgres user.

To restore the downloaded dump, run =pg_restore=. This command should prompt
for a password, at which point enter the password for the database user that
you set earlier.

#+BEGIN_SRC shell
pg_restore --jobs=4 --user=guix_data_service --no-tablespaces --host=127.0.0.1 --dbname=guix_data_service guix_data_service_small.dump
#+END_SRC

** Set the database paramstring

To setup the configuration for your local environment, create a file called
.local.envrc. To provide the password you've set for the =guix_data_service=
user, you'll need to set the =GUIX_DATA_SERVICE_DATABASE_PARAMSTRING=
environment variable in this file. Add the following line, replacing
THEPASSWORD with the password you set earlier.

#+BEGIN_SRC shell
export GUIX_DATA_SERVICE_DATABASE_PARAMSTRING="dbname=guix_data_service user=guix_data_service password=THEPASSWORD host=127.0.0.1"
#+END_SRC

After, run =direnv reload= to update the environment in your shell.

** Building the source files

The following three commands will compile the =.go= files and generate the
scripts used as entry points to the Guix Data Service.

#+BEGIN_SRC shell
./bootstrap.sh
./configure
make
#+END_SRC

** Run the web server

The =guix-data-service= script is the main entry point in to the service, run
it from the shell.

#+BEGIN_SRC shell
guix-data-service
#+END_SRC

You should now be able to access the Guix Data Service web interface through a
web browser using the URL http://localhost:8765/

To automatically restart the Guix Data Service when a change to the code is
made, you can use the rerun command:

#+BEGIN_SRC shell
rerun -d guix-data-service -p "**/*.scm" guix-data-service
#+END_SRC

** Checking the setup

You now should be ready to do local development. To double check that you can
change the code and see those changes, try changing the "Guix Data Service"
text within the index function, in the =(guix-data-service web view html)=
module (contained in the =guix-data-service/web/view/html.scm= file). That
text appears towards the top of the index page (the page with the path =/=).

* Contributing

Please send patches to guix-devel@gnu.org.

* Roadmap

Ideas for future enhancements to the Guix Data Service, in no particular
order.

** WebSub support for subscribing to branches and other changable state
** Link to other sites (Free Software Directory, Wikidata, Debian, ...)
** Track package replacements (grafts)
** Provide data in RDF formats (TTL, XML, ...)
** Provide statistics about Guix over time (with graphs)
** Receive UDP messages about pushes to Savannah

https://lists.gnu.org/archive/html/guix-devel/2023-09/msg00153.html