Initial commit

This is a service designed to provide information about Guix. At the
moment, this initial prototype gathers up information about packages,
the associated metadata and derivations.

The initial primary use case is to compare two different revisions of
Guix, detecting which packages are new, no longer present, updated or
otherwise different.

It's based on the Mumi project.

[1]: https://git.elephly.net/software/mumi.git
This commit is contained in:
Christopher Baines 2019-02-06 16:14:44 +00:00
commit 5a9262b38d
Signed by: cbaines
GPG key ID: 5E28A33B0B84F577
32 changed files with 9457 additions and 0 deletions

View file

@ -0,0 +1,39 @@
(define-module (guix-data-service model guix-revision)
#:use-module (ice-9 match)
#:use-module (squee)
#:export (most-recent-n-guix-revisions
commit->revision-id
insert-guix-revision
guix-revision-exists?))
(define (most-recent-n-guix-revisions conn n)
(exec-query conn "SELECT * FROM guix_revisions ORDER BY id DESC LIMIT 10"))
(define (commit->revision-id conn commit)
(match (exec-query
conn "SELECT id FROM guix_revisions WHERE commit = $1 LIMIT 1"
(list commit))
(((id))
id)))
(define (insert-guix-revision conn url commit store_path)
(define insert
(string-append "INSERT INTO guix_revisions "
"(url, commit, store_path) VALUES "
"('" url "', '"
commit "', '"
store_path "') "
"RETURNING id;"))
(map car (exec-query conn insert)))
(define (guix-revision-exists? conn url commit)
(define query
(string-append "SELECT EXISTS("
"SELECT 1 FROM guix_revisions WHERE url = '" url "' "
"AND commit = '" commit "')"
";"))
(let ((result (caar
(exec-query conn query))))
(string=? result "t")))