blob: 7faa000fa095d3004d1144d6356998cf22393c38 (
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
|
;; Snarfed from David Wilson who I believe snarfed from Andrew Tropin.
(define-module (dthompson home pipewire)
#:use-module (guix build-system trivial)
#:use-module (guix packages)
#:use-module (gnu packages)
#:use-module (gnu packages bash)
#:use-module (gnu packages linux)
#:use-module (gnu services)
#:use-module (gnu services configuration)
#:use-module (gnu home services)
#:use-module (gnu home services shepherd)
#:use-module (guix gexp)
#:export (package-with-pw-jack
package-with-pw-wrapper))
(define (package-with-pw-jack pkg program)
(package
(name (package-name pkg))
(version (package-version pkg))
(source #f)
(build-system trivial-build-system)
(arguments
(list
#:modules '((guix build union)
(guix build utils))
#:builder
#~(begin
(use-modules (ice-9 match)
(guix build union)
(guix build utils))
(let* ((program (string-append #$output "/bin/" #$program))
(program* (string-append program ".real"))
(desktop (string-append #$output "/share/applications/"
#$program ".desktop")))
(union-build #$output (list #$pkg)
#:create-all-directories? #t)
(when (file-exists? desktop)
(substitute* desktop
(("Exec=.*")
(string-append "Exec=" program "\n"))))
(rename-file program program*)
(call-with-output-file program
(lambda (port)
(display "#!" port)
(display #$bash-minimal port)
(display "/bin/sh" port)
(newline port)
(display "exec " port)
(display #$pipewire port)
(display "/bin/pw-jack " port)
(display program* port)
(display " \"$@\"" port)
(newline port)))
(chmod program #x555)
#t))))
(synopsis (package-synopsis pkg))
(description (package-description pkg))
(home-page (package-home-page pkg))
(license (package-license pkg))))
(define* (package-with-pw-wrapper pkg #:optional (program (package-name pkg)))
(package
(name (package-name pkg))
(version (package-version pkg))
(source #f)
(build-system trivial-build-system)
(arguments
(list
#:modules '((guix build union)
(guix build utils))
#:builder
#~(begin
(use-modules (ice-9 match)
(guix build union)
(guix build utils))
(let* ((program (string-append #$output "/bin/" #$program))
(desktop (string-append #$output "/share/applications/"
#$program ".desktop"))
(pw-lib (string-append #$pipewire "/lib")))
(union-build #$output (list #$pkg)
#:create-all-directories? #t)
(when (file-exists? desktop)
(substitute* desktop
(("Exec=.*")
(string-append "Exec=" program "\n"))))
(wrap-program program
#:sh (string-append #$bash-minimal "/bin/sh")
`("LD_LIBRARY_PATH" ":" prefix (,pw-lib)))))))
(synopsis (package-synopsis pkg))
(description (package-description pkg))
(home-page (package-home-page pkg))
(license (package-license pkg))))
|