Merge branch 'master' into 'master'

Adds Discord

See merge request nonguix/nonguix!454
This commit is contained in:
Jack Faller 2025-02-15 13:19:21 +00:00
commit 4a1883a142

View File

@ -12,6 +12,7 @@
#:use-module (gnu packages compression)
#:use-module (gnu packages cups)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages gcc)
#:use-module (gnu packages gl)
#:use-module (gnu packages glib)
@ -19,8 +20,11 @@
#:use-module (gnu packages gtk)
#:use-module (gnu packages kerberos)
#:use-module (gnu packages linux)
#:use-module (gnu packages node)
#:use-module (gnu packages nss)
#:use-module (gnu packages pulseaudio)
#:use-module (gnu packages video)
#:use-module (gnu packages wget)
#:use-module (gnu packages xdisorg)
#:use-module (gnu packages xml)
#:use-module (gnu packages xorg)
@ -34,6 +38,114 @@
#:use-module ((nonguix licenses) :prefix license:)
#:use-module (ice-9 match))
(define discord-disable-breaking-updates
(with-extensions
(list (@ (gnu packages guile) guile-json-4))
(program-file
"disable-breaking-updates"
;; Based on Python script of the same name from Nix.
#~(begin
(use-modules (json))
(let* ((config-home (or (getenv "XDG_CONFIG_HOME")
(string-append (getenv "HOME") "/.config")))
(settings-path (string-append config-home
"/discord/settings.json"))
(settings-tmp (string-append settings-path ".tmp"))
(settings
(if (file-exists? settings-path)
(with-exception-handler
(lambda (_)
(display "Settings invalid")
(newline)
(exit 0))
(lambda () (with-input-from-file settings-path json->scm))
#:unwind? #t
#:unwind-for-type 'json-invalid)
(list))))
(if (assoc-ref settings "SKIP_HOST_UPDATE")
(begin (display "Updates already disabled")
(newline))
(begin
(with-output-to-file settings-tmp
(lambda ()
(scm->json (assoc-set! settings "SKIP_HOST_UPDATE" #t))))
(rename-file settings-tmp settings-path)
(display "Disabled updates")
(newline))))))))
(define-public discord
(package
(name "discord")
(version "0.0.51")
(source
(origin
(method url-fetch)
(uri (string-append "https://cdn.discordapp.com/apps/linux/" version
"/discord-" version ".tar.gz"))
(sha256
(base32 "12d5hghnn6a30szsdbay5rx5j31da8y51zxmxg4dcpc9m9wwpk63"))))
;; Use this build system to set XDG_DATA_DIRS and other variables.
(build-system chromium-binary-build-system)
(arguments
(list
#:patchelf-plan
#~`(("Discord") ("chrome_crashpad_handler") ("chrome-sandbox"))
#:install-plan
#~`(("." "opt/discord")
("discord.desktop" "/share/applications/")
("discord.sh" "bin/discord")
("discord.png" "share/icons/hicolor/256x256/apps/")
("discord.png" "share/pixmaps/"))
#:phases
(with-imported-modules '((guix build utils))
#~(modify-phases %standard-phases
(add-after 'binary-unpack 'setup-cwd
(lambda* (#:key outputs #:allow-other-keys)
(use-modules (guix build utils))
(define output (assoc-ref outputs "out"))
(substitute* "discord.desktop"
(("Exec=.*$")
(string-append "Exec=" output "/bin/discord\n"))
(("Path=.*$")
(string-append "Path=" output "/opt/discord\n")))
(with-output-to-file "discord.sh"
(lambda _
(define (line . args)
(display (apply string-append args)) (newline))
(line "#!/bin/sh")
(line #$discord-disable-breaking-updates)
(line "cd " output "/opt/discord")
(line "./Discord"
;; Always use Ozone on Wayland, not sure if this is a good idea.
" ${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-features=WebRTCPipeWireCapturer}"
" \"$@\"")))
(for-each
(lambda (f) (chmod f #o755))
'("Discord" "chrome_crashpad_handler" "chrome-sandbox"
"discord.sh" "postinst.sh"))))))))
(inputs (list ffmpeg
gdk-pixbuf
libappindicator
libdbusmenu
libglvnd
libxscrnsaver
util-linux
wayland
;; Not sure if all of these are needed.
gzip
libsm
node
pipewire
pulseaudio
unzip
wget
xdg-utils))
(synopsis "Discord chat client")
(description "All-in-one cross-platform voice and text chat for gamers.")
(license (license:nonfree "https://discord.com/terms"))
(home-page "https://discordapp.com")))
(define-public element-desktop
(package
(name "element-desktop")