about summary refs log tree commit diff
path: root/.guix/run64-release.scm
blob: 6a767a1f452b93f927630d47aba30cec83c88253 (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
;;; run64 --- SRFI-64 test runner
;;; Copyright © 2025 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This file is part of run64.
;;;
;;; run64 is free software: you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; run64 is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;; General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with run64.  If not, see <https://www.gnu.org/licenses/>.

(define-module (run64-release)
  #:use-module ((gnu packages base) #:select (gnu-make))
  #:use-module ((gnu packages compression) #:select (lzip))
  #:use-module ((gnu packages version-control) #:select (git-minimal))
  #:use-module (guix gexp))

(define run64-git-repo
  (local-file "../.git"
              "run64-git-repo"
              #:recursive? #t))

(define run64-release-gexp
  (with-imported-modules '((guix build utils))
    #~(begin
        (use-modules (guix build utils)
                     (ice-9 match)
                     (ice-9 popen)
                     (srfi srfi-26)
                     (rnrs io ports))

        (define (call-with-input-pipe command proc)
          "Call @var{proc} with input pipe to @var{command}. @var{command} is a list of
program arguments."
          (match command
            ((prog args ...)
             (let ((port #f))
               (dynamic-wind
                 (lambda ()
                   (set! port (apply open-pipe* OPEN_READ prog args)))
                 (cut proc port)
                 (cut close-pipe port))))))

        (define (git-version)
          (call-with-input-pipe (list "git" "tag" "--sort=-taggerdate" "--list" "v*")
            (compose (cut substring <> (string-length "v"))
                     get-line)))

        (set-path-environment-variable
         "PATH" '("bin") '(#$git-minimal #$gnu-make #$lzip))
        (invoke "git" "clone" (string-append "file://" #$run64-git-repo) (getcwd))
        (let ((version (git-version)))
          (invoke "make" "dist" (string-append "version=" version))
          (copy-file (string-append "run64-" version ".tar.lz")
                     #$output)))))

(define run64-release
  (computed-file "run64.tar.lz"
                 run64-release-gexp))

run64-release