Update gitile

Julien LepillerMon Apr 18 10:38:26+0200 2022

2478c24

Update gitile

modules/packages/gitile.scm

1-
;;; GNU Guix --- Functional package management for GNU
2-
;;; Copyright ?? 2020 Julien Lepiller <julien@lepiller.eu>
3-
;;;
4-
;;; This file is part of GNU Guix.
5-
;;;
6-
;;; GNU Guix is free software; you can redistribute it and/or modify it
7-
;;; under the terms of the GNU General Public License as published by
8-
;;; the Free Software Foundation; either version 3 of the License, or (at
9-
;;; your option) any later version.
10-
;;;
11-
;;; GNU Guix is distributed in the hope that it will be useful, but
12-
;;; 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-
;;; You should have received a copy of the GNU General Public License
17-
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
18-
;;;
19-
;;; Some of the help text was taken from the default dovecot.conf files.
1+
;;;; Copyright (C) 2020, 2021 Julien Lepiller <julien@lepiller.eu>
2+
;;;;
3+
;;;; SPDX-License-Identifier: AGPL-3.0-or-later
4+
;;;;
5+
;;;; This program is free software: you can redistribute it and/or modify
6+
;;;; it under the terms of the GNU Affero General Public License as published by
7+
;;;; the Free Software Foundation, either version 3 of the License, or
8+
;;;; (at your option) any later version.
9+
;;;;
10+
;;;; This program is distributed in the hope that it will be useful,
11+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13+
;;;; GNU Affero General Public License for more details.
14+
;;;;
15+
;;;; You should have received a copy of the GNU Affero General Public License
16+
;;;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
17+
;;;;
2018
2119
(define-module (packages gitile)
20+
  #:use-module (guix packages)
21+
  #:use-module (guix licenses)
22+
  #:use-module (guix build-system gnu)
23+
  #:use-module (guix git-download)
24+
  #:use-module (guix git)
2225
  #:use-module (gnu packages autotools)
2326
  #:use-module (gnu packages gnupg)
2427
  #:use-module (gnu packages guile)
2528
  #:use-module (gnu packages guile-xyz)
2629
  #:use-module (gnu packages pkg-config)
2730
  #:use-module (gnu packages texinfo)
28-
  #:use-module (gnu packages tls)
29-
  #:use-module (guix build-system gnu)
30-
  #:use-module (guix git-download)
31-
  #:use-module (guix packages)
32-
  #:use-module (guix licenses))
31+
  #:use-module (gnu packages tls))
3332
34-
(define my-guile-git
33+
(define my-guile-syntax-highlight
3534
  (package
36-
    (inherit guile-git)
35+
    (inherit guile-syntax-highlight)
3736
    (source (origin
3837
              (method git-fetch)
3938
              (uri (git-reference
40-
                     (url "https://gitlab.com/roptat/guile-git")
41-
                     (commit "c39ab944d8004d3ab751a9e27336469afec081eb")))
42-
              (file-name (git-file-name "guile-git" "0.4.0.c39ab94"))
39+
                     (url "https://git.dthompson.us/guile-syntax-highlight.git")
40+
                     (commit "897fa5156ff41588e0d281eb00e4e94de63ccd8a")))
41+
              (file-name (git-file-name "guile-syntax-highlight" "0.1.897fa51"))
4342
              (sha256
4443
               (base32
45-
                "0hknsv9r7pjahmxkvd7zpz93saki5kymh88xs6pb4h9d0ssp4fmp"))))
44+
                "18zlg4mkgd3swgv2ggfz91ivnnzc0zhvc9ybgrxg1y762va9hyvj"))))
4645
    (native-inputs
4746
     `(("autoconf" ,autoconf)
4847
       ("automake" ,automake)
4948
       ("texinfo" ,texinfo)
50-
       ,@(package-native-inputs guile-git)))))
49+
       ,@(package-native-inputs guile-syntax-highlight)))))
5150
52-
(define my-guile-syntax-highlight
51+
(define-public gitile
5352
  (package
54-
    (inherit guile-syntax-highlight)
53+
    (name "gitile")
54+
    (version "0.1.4")
5555
    (source (origin
5656
              (method git-fetch)
5757
              (uri (git-reference
58-
                     (url "https://git.dthompson.us/guile-syntax-highlight.git")
59-
                     (commit "51727cbb7fc05ef743aab2d7b16314ea1ed790e4")))
60-
              (file-name (git-file-name "guile-syntax-highlight" "0.1.51727cb"))
58+
                     (url "https://git.lepiller.eu/git/gitile")
59+
                     (commit "aab4989efe4b5bcd3b1ac7fe108e1290de975fc0")))
60+
              (file-name (git-file-name name "0.1.4.aab4989"))
6161
              (sha256
6262
               (base32
63-
                "1cvacy4y5qxajygb1qg8hvhjdf2xnnwnm5j918cabsi8wfwchig7"))))
63+
                "0rslmrqspv32pbf9qz0glm8d3cxb1bz1sgi6ak2zl7blg25lw2l1"))))
64+
    (build-system gnu-build-system)
65+
    (arguments
66+
     `(#:modules ((guix build utils)
67+
                  (guix build gnu-build-system)
68+
                  (ice-9 rdelim)
69+
                  (ice-9 popen))
70+
       #:make-flags (list "GUILE_AUTO_COMPILE=0")
71+
       #:phases
72+
       (modify-phases %standard-phases
73+
         (add-after 'install-bin 'wrap-program
74+
           (lambda* (#:key inputs outputs #:allow-other-keys)
75+
             ;; Wrap the 'gitile' command to refer to the right modules.
76+
             (let* ((out    (assoc-ref outputs "out"))
77+
                    (commonmark (assoc-ref inputs "guile-commonmark"))
78+
                    (git    (assoc-ref inputs "guile-git"))
79+
                    (bytes  (assoc-ref inputs "guile-bytestructures"))
80+
                    (fibers (assoc-ref inputs "guile-fibers"))
81+
                    (gcrypt (assoc-ref inputs "guile-gcrypt"))
82+
                    (syntax-highlight (assoc-ref inputs "guile-syntax-highlight"))
83+
                    (deps   (list out commonmark git bytes fibers gcrypt
84+
                                  syntax-highlight))
85+
                    (guile  (assoc-ref %build-inputs "guile"))
86+
                    (effective (read-line
87+
                                (open-pipe* OPEN_READ
88+
                                            (string-append guile "/bin/guile")
89+
                                            "-c" "(display (effective-version))")))
90+
                    (mods   (string-drop-right  ;drop trailing colon
91+
                             (string-join deps
92+
                                          (string-append "/share/guile/site/"
93+
                                                         effective ":")
94+
                                          'suffix)
95+
                             1))
96+
                    (objs   (string-drop-right
97+
                             (string-join deps
98+
                                          (string-append "/lib/guile/" effective
99+
                                                         "/site-ccache:")
100+
                                          'suffix)
101+
                             1)))
102+
               (wrap-program (string-append out "/bin/gitile")
103+
                 `("GUILE_LOAD_PATH" ":" prefix (,mods))
104+
                 `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,objs)))))))))
105+
    (propagated-inputs
106+
     `(("guile-commonmark" ,guile-commonmark)
107+
       ("guile-git" ,guile-git)
108+
       ("guile-gcrypt" ,guile-gcrypt)
109+
       ("guile-syntax-highlight" ,my-guile-syntax-highlight)
110+
       ("gnutls" ,gnutls)
111+
       ("guile-fibers" ,guile-fibers)))
64112
    (native-inputs
65113
     `(("autoconf" ,autoconf)
66114
       ("automake" ,automake)
67-
       ("texinfo" ,texinfo)
68-
       ,@(package-native-inputs guile-syntax-highlight)))))
69-
70-
(define-public gitile
71-
  (let ((commit "fac1f0ccdbaca794451ae43526b1bbffacd8161a")
72-
	(revision "0"))
73-
    (package
74-
      (name "gitile")
75-
      (version (git-version "0.0" revision commit))
76-
      (source (origin
77-
                (method git-fetch)
78-
                (uri (git-reference
79-
                       (url "https://git.lepiller.eu/git/gitile")
80-
                       (commit commit)))
81-
                (file-name (git-file-name name version))
82-
                (sha256
83-
                 (base32
84-
                  "048pm743gnxashggngw3zlsr13wf0k686n3j23czc4988gz7mfvp"))))
85-
      (build-system gnu-build-system)
86-
      (arguments
87-
       `(#:modules ((guix build utils)
88-
                    (guix build gnu-build-system)
89-
                    (ice-9 rdelim)
90-
                    (ice-9 popen))
91-
         #:make-flags (list "GUILE_AUTO_COMPILE=0")
92-
         #:phases
93-
         (modify-phases %standard-phases
94-
           (add-after 'install 'install-bin
95-
             (lambda* (#:key outputs #:allow-other-keys)
96-
               (install-file "scripts/gitile"
97-
                             (string-append (assoc-ref outputs "out")
98-
                                            "/bin"))
99-
               #t))
100-
           (add-after 'install-bin 'wrap-program
101-
               (lambda* (#:key inputs outputs #:allow-other-keys)
102-
                 ;; Wrap the 'cuirass' command to refer to the right modules.
103-
                 (let* ((out    (assoc-ref outputs "out"))
104-
                        (commonmark (assoc-ref inputs "guile-commonmark"))
105-
                        (git    (assoc-ref inputs "guile-git"))
106-
                        (bytes  (assoc-ref inputs "guile-bytestructures"))
107-
                        (fibers (assoc-ref inputs "guile-fibers"))
108-
                        (gcrypt (assoc-ref inputs "guile-gcrypt"))
109-
			(syntax-highlight (assoc-ref inputs "guile-syntax-highlight"))
110-
                        (deps   (list out commonmark git bytes fibers gcrypt
111-
				      syntax-highlight))
112-
                        (guile  (assoc-ref %build-inputs "guile"))
113-
                        (effective (read-line
114-
                                    (open-pipe* OPEN_READ
115-
                                                (string-append guile "/bin/guile")
116-
                                                "-c" "(display (effective-version))")))
117-
                        (mods   (string-drop-right  ;drop trailing colon
118-
                                 (string-join deps
119-
                                              (string-append "/share/guile/site/"
120-
                                                             effective ":")
121-
                                              'suffix)
122-
                                 1))
123-
                        (objs   (string-drop-right
124-
                                 (string-join deps
125-
                                              (string-append "/lib/guile/" effective
126-
                                                             "/site-ccache:")
127-
                                              'suffix)
128-
                                 1)))
129-
                   (wrap-program (string-append out "/bin/gitile")
130-
                     `("GUILE_LOAD_PATH" ":" prefix (,mods))
131-
                     `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,objs)))
132-
                   #t))))))
133-
      (native-inputs
134-
       `(("autoconf" ,autoconf)
135-
         ("automake" ,automake)
136-
         ("guile" ,guile-3.0)
137-
         ("pkg-config" ,pkg-config)))
138-
      (inputs
139-
       `(("guile" ,guile-3.0)
140-
	 ("guile-commonmark" ,guile-commonmark)
141-
         ("guile-fibers" ,guile-fibers)
142-
         ("guile-gcrypt" ,guile-gcrypt)
143-
         ("guile-git" ,my-guile-git)
144-
	 ("guile-syntax-highlight" ,my-guile-syntax-highlight)
145-
         ("gnutls" ,gnutls)))
146-
      (home-page "")
147-
      (synopsis "")
148-
      (description "")
149-
      (license gpl3+))))
115+
       ("libtool" ,libtool)
116+
       ("pkg-config" ,pkg-config)
117+
       ("guile" ,guile-3.0)))
118+
    (home-page "https://git.lepiller.eu")
119+
    (synopsis "Simple git forge written in Guile")
120+
    (description "Gitile is a git forge written in Guile that lets you
121+
visualize your public Git repositories on a web interface.")
122+
    (license agpl3+)))
150123
151124
gitile

modules/services/gitile.scm

11
;;; GNU Guix --- Functional package management for GNU
2-
;;; Copyright ?? 2020 Julien Lepiller <julien@lepiller.eu>
2+
;;; Copyright ?? 2020, 2021 Julien Lepiller <julien@lepiller.eu>
33
;;;
44
;;; This file is part of GNU Guix.
55
;;;

2323
  #:use-module (gnu services base)
2424
  #:use-module (gnu services configuration)
2525
  #:use-module (gnu services shepherd)
26+
  #:use-module (gnu services web)
2627
  #:use-module (gnu system pam)
2728
  #:use-module (gnu system shadow)
2829
  #:use-module (gnu packages admin)

4445
  (database gitile-configuration-database
4546
            (default "/var/lib/gitile/gitile-db.sql"))
4647
  (repositories gitile-configuration-repositories
47-
                (default "/var/lib/gitolite/repositories")))
48+
                (default "/var/lib/gitolite/repositories"))
49+
  (base-git-url gitile-configuration-base-git-url)
50+
  (index-title gitile-configuration-index-title
51+
               (default "Index"))
52+
  (intro gitile-configuration-intro
53+
         (default '()))
54+
  (footer gitile-configuration-footer
55+
          (default '()))
56+
  (nginx gitile-configuration-nginx))
4857
49-
(define (gitile-config-file host port database repositories)
58+
(define (gitile-config-file host port database repositories base-git-url
59+
                            index-title intro footer)
5060
  (define build
5161
    #~(write `(config
5262
                (port #$port)
5363
                (host #$host)
5464
                (database #$database)
55-
                (repositories #$repositories))
65+
                (repositories #$repositories)
66+
                (base-git-url #$base-git-url)
67+
                (index-title #$index-title)
68+
                (intro #$intro)
69+
                (footer #$footer))
5670
             (open-output-file #$output)))
5771
5872
  (computed-file "gitile.conf" build))
5973
74+
(define gitile-nginx-server-block
75+
  (match-lambda
76+
    (($ <gitile-configuration> package host port database repositories
77+
        base-git-url index-title intro footer nginx)
78+
     (list (nginx-server-configuration
79+
             (inherit nginx)
80+
             (locations
81+
               (append
82+
                 (list
83+
                   (nginx-location-configuration
84+
                            (uri "/")
85+
                            (body
86+
                              (list
87+
                                #~(string-append "proxy_pass http://" #$host
88+
                                                 ":" (number->string #$port)
89+
                                                 "/;")))))
90+
                 (map
91+
                   (lambda (loc)
92+
                     (nginx-location-configuration
93+
                       (uri loc)
94+
                       (body
95+
                         (list
96+
                           #~(string-append "root " #$package "/share/gitile/assets;")))))
97+
                   '("/css" "/js" "/images"))
98+
                 (nginx-server-configuration-locations nginx))))))))
99+
60100
(define gitile-shepherd-service
61101
  (match-lambda
62-
    (($ <gitile-configuration> package host port database repositories)
102+
    (($ <gitile-configuration> package host port database repositories
103+
        base-git-url index-title intro footer nginx)
63104
     (list (shepherd-service
64105
             (provision '(gitile))
65106
             (requirement '(loopback))

68109
                          #~(make-forkexec-constructor
69110
                              `(,#$gitile "-c" #$(gitile-config-file
70111
                                                   host port database
71-
                                                   repositories))
112+
                                                   repositories
113+
                                                   base-git-url index-title
114+
                                                   intro footer))
72115
                              #:user "gitile"
73116
                              #:group "git")))
74117
             (stop #~(make-kill-destructor)))))))

89132
      (list (service-extension account-service-type
90133
                               (const %gitile-accounts))
91134
            (service-extension shepherd-root-service-type
92-
                               gitile-shepherd-service)))
93-
    (default-value
94-
      (gitile-configuration))))
135+
                               gitile-shepherd-service)
136+
            (service-extension nginx-service-type
137+
                               gitile-nginx-server-block)))))