summaryrefslogtreecommitdiffstats
path: root/vesktop.scm
blob: fe6feae5913e9de462dd976a0caaa7ff6d0f395b (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
(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 (guix download)
               #:use-module (guix gexp)
               #:use-module (guix build-system)
               #:use-module (guix utils)
               #:use-module (guix licenses)  
               #: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 (srfi srfi-1)
               )

(define (aggressively-purge-old-gcc bs toolchain)
"Based on guix build-system build-system-with-c-toolchain"
  
  (define lower
    (build-system-lower bs))

  (define toolchain-packages
    '("gcc" "gcc:lib" "binutils" "libc" "libc:static" "ld-wrapper"))

  (define (lower* . args)
    (let ((lowered (apply lower args)))
      (bag
        (inherit lowered)
        (host-inputs
         (append (fold alist-delete
                       (bag-build-inputs lowered)
                       toolchain-packages)
                 toolchain)))))

  (display lower*)
  (build-system
    (inherit bs)
    (lower lower*))
  )

(define-public vesktop
               (package
                 (name "vesktop-bin")
                 (version "1.5.1")
                 (source
                   (origin
                     (method url-fetch)
                     (uri
                       (string-append
                         "https://github.com/Vencord/Vesktop/releases/download/v" version "/vesktop_" version "_amd64.deb"))
                     (sha256
                       (base32 "03nnz0mvb1pdv12qdrh3vk243dk3f97dh3b5lh7kmmbbh2bxdhh7"))))
                 (supported-systems '("x86_64-linux"))
                 (build-system (aggressively-purge-old-gcc chromium-binary-build-system `(("gcc-toolchain-13" ,gcc-toolchain-13)) ))
                 (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 "nss") "/lib/nss")
                                                                             ;(string-append #$(this-package-input "eudev") "/lib")
                                                                             ;(string-append #$(this-package-input "libnotify") "/lib")
                                                                             ;(string-append #$(this-package-input "libxkbfile") "/lib")
                                                                             (string-append #$(this-package-input "pipewire") "/lib")
                                                                             ;(string-append #$(this-package-input "sqlcipher") "/lib")
                                                                             ;(string-append #$(this-package-input "zlib") "/lib")
                                                                             (string-append #$output "/lib/Vesktop")
                                                                             ;(string-append #$(this-package-input "gcc-toolchain") "/lib")
                                                                             )
                                                                           ":"))))))
                                          )))

(inputs (list pipewire))
(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 gpl3)))