blob: 2deb7bfa8cd4c4a5f8c1b680c78a8a614f9de0bb (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
(define-module (gn services gitea-container))
(use-modules (gnu)
(gn packages gitea)
(guix records)
(ice-9 match))
(use-service-modules base networking shepherd)
(define %GITEA_WORK_DIR "/var/lib/git/gitea")
(define-record-type* <gitea-configuration>
gitea-configuration
make-gitea-configuration
gitea-configuration?
(package gitea-configuration-package ; package
(default gitea))
(work-dir gitea-configuration-work-dir ; string
(default %GITEA_WORK_DIR))
(port gitea-configuration-port ; number
(default 3300)))
(define gitea-activation
(match-lambda
(($ <gitea-configuration> package work-dir port)
#~(begin
(use-modules (guix build utils))
(let ((%user (getpwnam "gitea")))
;; Prepare the environment for gitea:
;; https://docs.gitea.io/en-us/install-from-binary/
(unless (directory-exists? #$work-dir)
(mkdir-p #$work-dir)
;; These two are supposed to be recursive.
(chown #$work-dir (passwd:uid %user) (passwd:gid %user))
(chmod #$work-dir #o750)))))))
(define gitea-shepherd-service
(match-lambda
(($ <gitea-configuration> package work-dir port)
(list (shepherd-service
(documentation "Run the Gitea server.")
(requirement '(networking))
(provision '(gitea))
(start #~(make-forkexec-constructor
(list
#$(file-append package "/bin/gitea")
"--port" #$(number->string port))
#:environment-variables
(list (string-append "GITEA_WORK_DIR=" #$work-dir)
(string-append "HOME=" #$work-dir))
#:user "gitea"
#:group "git"))
(stop #~(make-kill-destructor)))))))
(define gitea-service-type
(service-type
(name 'gitea)
(extensions
(list (service-extension shepherd-root-service-type
gitea-shepherd-service)
(service-extension activation-service-type
gitea-activation)))
(description
"Run a Gitea server.")
(default-value (gitea-configuration))))
(operating-system
(host-name "gitea")
(timezone "Etc/UTC")
(locale "en_US.utf8")
(bootloader (bootloader-configuration
(bootloader grub-bootloader)
(target "does-not-matter")))
(file-systems %base-file-systems)
;; No firmware for VMs or containers.
(firmware '())
;; The user and group names aren't important, but the user uid and group id
;; NEED to match the directory outside of the container.
(users (cons (user-account
(name "gitea")
(group "gitea")
;(system? #t)
(uid 1021))
%base-user-accounts))
(groups (cons (user-group
(name "git")
;(system? #t)
(id 998))
%base-groups))
(services (list (service dhcp-client-service-type)
(service gitea-service-type))))
|