summaryrefslogtreecommitdiffstats
path: root/manifest.scm
blob: 53544d4ac3175a8c2223ccd51970627768410e79 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
(use-modules (guix packages)
	     (guix git-download)
	     (guix build-system cmake)
	     (guix build-system copy)
	     (guix utils)
	     (guix gexp)
	     (gnu packages racket)
	     (gnu packages emacs-xyz)
	     ((guix licenses) #:prefix license:))

(define paho-mqtt-c
  (package
    (name "paho-mqtt-c")
    (version "1.3.13")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/eclipse/paho.mqtt.c")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32 "1y5lsh41kszyjcrxrjshs838l23ncdyssxk848ij1bq0jix2g93l"))))
    (build-system cmake-build-system)
    (arguments
     '(#:tests? #f)) ;; Disable tests
    (synopsis "Eclipse Paho MQTT C client library")
    (description
     "Eclipse Paho MQTT C client library.")
    (home-page "https://www.eclipse.org/paho/")
    (license license:epl1.0)))

(define (make-racket! package-to-inherit)
  (package
    (inherit package-to-inherit)
    (arguments
     (substitute-keyword-arguments (package-arguments package-to-inherit)
       ((#:phases those-phases #~%standard-phases)
	#~(modify-phases #$those-phases
            (add-after 'install 'wrap-racket
              (lambda* (#:key outputs inputs #:allow-other-keys)
		(let* ((out (assoc-ref outputs "out"))
		       (bin (string-append out "/bin/racket"))
		       (libpaho (string-append (assoc-ref inputs "paho-mqtt-c")
					       "/lib")))
		  (wrap-program bin
                    `("LD_LIBRARY_PATH" ":" prefix
                      ,(list libpaho))))))))))
    (inputs
     (modify-inputs (package-inputs package-to-inherit)
		    (prepend paho-mqtt-c)))))

(define racket-minimal! (make-racket! racket-minimal))
(define racket! (make-racket! racket))

(define smart-relay
  (package
    (name "smart-relay")
    (version "0.1.0")
    (source
     (local-file "src" #:recursive? #t))
    (build-system copy-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
	 (add-before 'install 'change-paths
           (lambda* (#:key outputs #:allow-other-keys)
	     (let ((out  (assoc-ref outputs "out")))
               (substitute* "smart-relay.sh"
		 (("smart-relay.rkt")
                  (string-append out "/share/smart-relay.rkt"))))))
	 (add-before 'install 'move-files
	   (lambda* (#:key inputs outputs #:allow-other-keys)
	     (let* ((out  (assoc-ref outputs "out"))
		    (bin  (string-append out "/bin/"))
		    (share  (string-append out "/share/")))
	       (mkdir-p bin)
	       (mkdir-p share)
	       (chmod "smart-relay.sh" #o555)
	       (copy-recursively "smart-relay.sh"
				 (string-append bin "smart-relay"))
	       (copy-recursively "smart-relay.rkt"
				 (string-append share "smart-relay.rkt"))
	       (delete-file-recursively "smart-relay.sh")
	       (delete-file-recursively "smart-relay.rkt")))))))
    (synopsis "Lisp program to control usb relay over mqtt")
    (description "Lisp program to control usb relay over mqtt")
    (home-page "https://git.jdlugosz.com/hsp/smart-relay")
    (license license:unlicense)))

(define emacs-geiser-racket!
  (package
    (inherit emacs-geiser-racket)
    (inputs
     (modify-inputs (package-inputs emacs-geiser-racket)
		    (delete "racket")
		    (prepend racket!)))))


(if (getenv "DEV_SHELL")
    (concatenate-manifests
     (list (packages->manifest
	    (list racket!
		  emacs-geiser-racket!))
	   (specifications->manifest
            (list "racket"
		  "emacs-racket-mode"
		  "emacs"))))
    (concatenate-manifests
     (list (packages->manifest
	    (list racket!
		  smart-relay))
	   (specifications->manifest
            (list "bash"
		  "nss-certs")))))