summaryrefslogtreecommitdiffstats
path: root/vesktop.scm
blob: 070f4aece383656c358b2e48a505b8d73be6f375 (plain) (blame)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
(define-module (vesktop)
               #:use-module (gnu packages base)
               #:use-module (gnu packages bash)
               #:use-module (gnu packages compression)
               #:use-module (gnu packages cups)
               #:use-module (gnu packages fontutils)
               #:use-module (gnu packages gcc)
               #:use-module (gnu packages gl)
               #:use-module (gnu packages glib)
               #:use-module (gnu packages gnome)
               #:use-module (gnu packages gtk)
               #:use-module (gnu packages kerberos)
               #:use-module (gnu packages linux)
               #:use-module (gnu packages nss)
               #:use-module (gnu packages pulseaudio)
               #:use-module (gnu packages video)
               #:use-module (gnu packages xdisorg)
               #:use-module (gnu packages commencement)
               #:use-module (gnu packages xml)
               #:use-module (gnu packages xorg)
               #:use-module (gnu packages elf)
               #:use-module (gnu packages bash)
               #:use-module (gnu packages databases)
               #:use-module (guix download)
               #:use-module (guix gexp)
               #:use-module (guix build-system)
               #:use-module (guix build-system gnu)
               #:use-module (guix utils)
               #:use-module ((guix licenses) #:prefix license:)  
               #:use-module (guix packages)
               #:use-module (guix transformations)
               #:use-module (nonguix build-system binary)
               #:use-module (nonguix build-system chromium-binary)
               #:use-module (nonguix licenses)
               #:use-module (ice-9 match)
               #:use-module (ice-9 session)
               #:use-module (srfi srfi-1)
               )

(define (use-modern-gcc-on-chromium-binary bs)
"Based on guix build-system build-system-with-c-toolchain"
  
  (define lower
    (build-system-lower bs))

  (define (lower* . args)
    (let ((lowered (apply lower args)))
      (bag
        (inherit lowered)
        (host-inputs
     `(
      ("source" , mesa) ;For some reason requires a "source" decleration, or else will fail. This is a placeholder value. TODO: Find a way to remove this without breakage.
      ("alsa-lib" ,alsa-lib)
      ("atk" ,atk)
      ("at-spi2-atk" ,at-spi2-atk)
      ("at-spi2-core" ,at-spi2-core)
      ("bash-minimal" ,bash-minimal)
      ("cairo" ,cairo)
      ("cups" ,cups)
      ("dbus" ,dbus)
      ("eudev" ,eudev)
      ("expat" ,expat)
      ("fontconfig" ,fontconfig)
      ("freetype" ,freetype)
      ("gcc:lib" ,gcc-13 "lib")
      ("gcc-toolchain" ,gcc-toolchain-13)
      ("glib" ,glib)
      ("gtk+" ,gtk+)
      ("libdrm" ,libdrm)
      ("libnotify" ,libnotify)
      ("librsvg" ,librsvg)
      ("libsecret" ,libsecret)
      ("libx11" ,libx11)
      ("libxcb" ,libxcb)
      ("libxcomposite" ,libxcomposite)
      ("libxcursor" ,libxcursor)
      ("libxdamage" ,libxdamage)
      ("libxext" ,libxext)
      ("libxfixes" ,libxfixes)
      ("libxi" ,libxi)
      ("libxkbcommon" ,libxkbcommon)
      ("libxkbfile" ,libxkbfile)
      ("libxrandr" ,libxrandr)
      ("libxrender" ,libxrender)
      ("libxshmfence" ,libxshmfence)
      ("libxtst" ,libxtst)
      ("mesa" ,mesa)
      ("mit-krb5" ,mit-krb5)
      ("nspr" ,nspr)
      ("nss" ,nss)
      ("pango" ,pango)
      ("pulseaudio" ,pulseaudio)
      ("pipewire", pipewire)
      ("sqlcipher" ,sqlcipher)
      ("xcb-util" ,xcb-util)
      ("xcb-util-image" ,xcb-util-image)
      ("xcb-util-keysyms" ,xcb-util-keysyms)
      ("xcb-util-renderutil" ,xcb-util-renderutil)
      ("xcb-util-wm" ,xcb-util-wm)
      ("zlib" ,zlib)

      ;; Keep the standard inputs of 'gnu-build-system'.
      ,@(standard-packages))))))

  (lambda _
    (display (lower* (host-inputs))))
  
  (build-system
    (inherit bs)
    (lower lower*))
  )

(define-public vesktop
               (package
                 (name "vesktop-bin")
                 (version "1.5.2")
                 (source
                   (origin
                     (method url-fetch)
                     (uri
                       (string-append
                         "https://github.com/Vencord/Vesktop/releases/download/v" version "/vesktop_" version "_amd64.deb"))
                     (sha256
                       (base32 "01di0vdzb1svdw7mchicg3i7if0is6jdhrsbbs5icp9hdhbdq8qa"))))
                 (supported-systems '("x86_64-linux"))
                 (build-system (use-modern-gcc-on-chromium-binary chromium-binary-build-system))
                 (arguments
                   (list 
                         #:validate-runpath? #f ; TODO: fails on wrapped binary and included other files
                         #:wrapper-plan
                         #~'(
                             "lib/Vesktop/vesktop"
                             )
                         #:phases
                         #~(modify-phases %standard-phases
                                          (replace 'unpack
                                                   (lambda _
                                                     (invoke "ar" "x" #$source)
                                                     (invoke "tar" "xvf" "data.tar.xz")
                                                     ;; Fix the .desktop file binary location.
                                                     (substitute* '("usr/share/applications/vesktop.desktop")
                                                                  (("/opt/Vesktop/") (string-append #$output "/bin/")))
                                                     (copy-recursively "usr/" ".")
                                                     ;; Use the more standard lib directory for everything.
                                                     (rename-file "opt/" "lib")
                                                     ;; Remove unneeded files.
                                                     (delete-file-recursively "usr")
                                                     (delete-file "control.tar.gz")
                                                     (delete-file "data.tar.xz")
                                                     (delete-file "debian-binary")))

                                          (add-after 'install 'symlink-binary-file-and-cleanup
                                                     (lambda _
                                                       (delete-file (string-append #$output "/environment-variables"))
                                                       (mkdir-p (string-append #$output "/bin"))
                                                       (symlink (string-append #$output "/lib/Vesktop/vesktop")
                                                                (string-append #$output "/bin/discord"))
                                                       (symlink (string-append #$output "/lib/Vesktop/vesktop")
                                                                (string-append #$output "/bin/vencord"))
                                                       ))

                                          (add-after 'install 'wrap-where-patchelf-does-not-work
                                                     (lambda _
                                                       (wrap-program (string-append #$output "/lib/Vesktop/vesktop")
                                                                     `("LD_LIBRARY_PATH" ":" prefix
                                                                       (,(string-join
                                                                           (list
                                                                             (string-append #$(this-package-input "pipewire") "/lib")
                                                                             (string-append #$output "/lib/Vesktop")
                                                                             ;(string-append #$(this-package-input "gcc-toolchain") "/lib")
                                                                             )
                                                                           ":"))))))
                                          )))
(inputs (list pipewire gcc-toolchain-13 gcc-13))
(native-inputs (list tar xz patchelf))
(home-page "https://github.com/Vencord/Vesktop")
(synopsis "Discord experience with Vencord pre-installed")
(description "Vesktop is a cross platform desktop app aiming to give
             you a snappier Discord experience with Vencord pre-installed")
;; not working?
(properties
  '((release-monitoring-url . "https://github.com/Vencord/Vesktop/releases")))
(license license:gpl3)))