-
Notifications
You must be signed in to change notification settings - Fork 7
/
manifest.scm
57 lines (51 loc) · 1.89 KB
/
manifest.scm
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
(use-modules (ice-9 textual-ports)
(git bindings)
(git repository)
(git reference)
(guix packages)
(guix gexp)
((guix git-download) #:select (git-predicate))
(gnu packages certs)
(uio packages nivlheim))
(define %checkout (dirname (current-filename)))
(define version
(call-with-input-file (string-append %checkout "/VERSION")
(lambda (port)
(string-trim-right (get-string-all port)))))
(define ref
(or (getenv "GITHUB_REF_NAME")
(if (file-exists? (string-append %checkout "/.git"))
(begin
(libgit2-init!)
(let* ((repo (repository-open %checkout))
(head (repository-head repo))
(branch (reference-shorthand head)))
(repository-close! repo)
(libgit2-shutdown!)
branch))
"unknown")))
(define (ref-is-tag? ref)
(if (getenv "GITHUB_ACTIONS")
(string=? (getenv "GITHUB_REF_TYPE") "tag")
;; XXX: guile-git lacks bindings for git_reference_type,
;; so we instead rely on the fact that REF becomes "HEAD"
;; when not on a branch.
(string=? ref "HEAD")))
(define %nivlheim
(package
(inherit nivlheim)
;; Custom variant of Nivlheim that uses the local checkout as source,
;; and with "version" set to the contents of the VERSION file and
;; current branch.
(version (if (or (string=? ref "master") (ref-is-tag? ref))
version
(string-append version "-" ref)))
(source (local-file %checkout
#:recursive? #t
#:select? (git-predicate %checkout)))
;; Propagate nss-certs to ensure /etc/ssl/certs is available.
(propagated-inputs
(append (list nss-certs)
(package-propagated-inputs nivlheim)))))
(packages->manifest
(list %nivlheim))