;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2017, 2019-2021, 2023 Efraim Flashner ;;; Copyright © 2016 David Craven ;;; Copyright © 2016, 2017 Thomas Danckaert ;;; Copyright © 2017, 2018 Mark Meyer ;;; Copyright © 2017–2021 Tobias Geerinckx-Rice ;;; Copyright © 2018 Gábor Boskovits ;;; Copyright © 2019 Nicolas Goaziou ;;; Copyright © 2018, 2019, 2020 Hartmut Goebel ;;; Copyright © 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2020 Marius Bakke ;;; Copyright © 2020, 2021, 2022 Michael Rohleder ;;; Copyright © 2020 Prafulla Giri ;;; Copyright © 2020, 2021, 2022, 2023 Zheng Junjie <873216071@qq.com> ;;; Copyright © 2021 Alexandros Theodotou ;;; Copyright © 2021 la snesne ;;; Copyright © 2021, 2022, 2023
aboutsummaryrefslogtreecommitdiff
blob: d0f0bbe4cb60abb12b755d6e42fb10e2b3cd1bf8 (about) (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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.org>
;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;; Copyright © 2022 Matthew James Kraai <kraai@ftbfs.org>
;;; Copyright © 2022 Ricardo Wurmus <rekado@elephly.net>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu machine digital-ocean)
  #:use-module (gnu machine ssh)
  #:use-module (gnu machine)
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (gnu services networking)
  #:use-module (gnu system)
  #:use-module (gnu system pam)
  #:use-module (guix base32)
  #:use-module (guix derivations)
  #:use-module (guix i18n)
  #:use-module ((guix diagnostics) #:select (formatted-message))
  #:use-module (guix import json)
  #:use-module (guix monads)
  #:use-module (guix records)
  #:use-module (guix ssh)
  #:use-module (guix store)
  #:use-module (ice-9 format)
  #:use-module (ice-9 iconv)
  #:use-module (ice-9 string-fun)
  #:use-module (json)
  #:use-module (rnrs bytevectors)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-2)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-35)
  #:use-module (ssh key)
  #:use-module (ssh sftp)
  #:use-module (ssh shell)
  #:use-module (web client)
  #:use-module (web request)
  #:use-module (web response)
  #:use-module (web uri)
  #:export (digital-ocean-configuration
            digital-ocean-configuration?

            digital-ocean-configuration-ssh-key
            digital-ocean-configuration-tags
            digital-ocean-configuration-region
            digital-ocean-configuration-size
            digital-ocean-configuration-enable-ipv6?

            digital-ocean-environment-type))

;;; Commentary:
;;;
;;; This module implements a high-level interface for provisioning "droplets"
;;; from the Digital Ocean virtual private server (VPS) service.
;;;
;;; Code:

(define %api-base "https://api.digitalocean.com")

(define %digital-ocean-token
  (make-parameter (getenv "GUIX_DIGITAL_OCEAN_TOKEN")))

(define* (post-endpoint endpoint body)
  "Encode BODY as JSON and send it to the Digital Ocean API endpoint
ENDPOINT. This procedure is quite a bit more specialized than 'http-post', as
it takes care to set headers such as 'Content-Type', 'Content-Length', and
'Authorization' appropriately."
  (let* ((uri (string->uri (string-append %api-base endpoint)))
         (body (string->bytevector (scm->json-string body) "UTF-8"))
         (headers `((User-Agent . "Guix Deploy")
                    (Accept . "application/json")
                    (Content-Type . "application/json")
                    (Authorization . ,(format #f "Bearer ~a"
                                              (%digital-ocean-token)))
                    (Content-Length . ,(number->string
                                        (bytevector-length body)))))
         (port (open-socket-for-uri uri))
         (request (build-request uri
                                 #:method 'POST
                                 #:version '(1 . 1)
                                 #:headers headers
                                 #:port port))
         (request (write-request request port)))
    (write-request-body request body)
    (force-output (request-port request))
    (let* ((response (read-response port))
           (body (read-response-body response)))
      (unless (= 2 (floor/ (response-code response) 100))
        (raise
         (condition (&message
                     (message (format
                               #f
                               (G_ "~a: HTTP post failed: ~a (~s)")
                               (uri->string uri)
                               (response-code response)
                               (response-reason-phrase response)))))))
      (close-port port)
      (bytevector->string body "UTF-8"))))

(define (fetch-endpoint endpoint)
  "Return the contents of the Digital Ocean API endpoint ENDPOINT as an
alist. This procedure is quite a bit more specialized than 'json-fetch', as it
takes care to set headers such as 'Accept' and 'Authorization' appropriately."
  (define headers
    `((user-agent . "Guix Deploy")
      (Accept . "application/json")
      (Authorization . ,(format #f "Bearer ~a" (%digital-ocean-token)))))
  (json-fetch (string-append %api-base endpoint) #:headers headers))


;;;
;;; Parameters for droplet creation.
;;;

(define-record-type* <digital-ocean-configuration> digital-ocean-configuration
  make-digital-ocean-configuration
  digital-ocean-configuration?
  this-digital-ocean-configuration
  (ssh-key     digital-ocean-configuration-ssh-key)      ; string
  (tags        digital-ocean-configuration-tags)         ; list of strings
  (region      digital-ocean-configuration-region)       ; string
  (size        digital-ocean-configuration-size)         ; string
  (enable-ipv6? digital-ocean-configuration-enable-ipv6?)) ; boolean

(define (read-key-fingerprint file-name)
  "Read the private key at FILE-NAME and return the key's fingerprint as a hex
string."
  (let* ((privkey (private-key-from-file file-name))
         (pubkey (private-key->public-key privkey))
         (hash (get-public-key-hash pubkey 'md5)))
    (bytevector->hex-string hash)))

(define (machine-droplet machine)
  "Return an alist describing the droplet allocated to MACHINE."
  (let ((tags (digital-ocean-configuration-tags
               (machine-configuration machine))))
    (find (lambda (droplet)
            (equal? (assoc-ref droplet "tags") (list->vector tags)))
          (vector->list
           (assoc-ref (fetch-endpoint "/v2/droplets") "droplets")))))

(define (machine-public-ipv4-network machine)
  "Return the public IPv4 network interface of the droplet allocated to
MACHINE as an alist. The expected fields are 'ip_address', 'netmask', and
'gateway'."
  (and-let* ((droplet (machine-droplet machine))
             (networks (assoc-ref droplet "networks"))
             (network (find (lambda (network)
                              (string= "public" (assoc-ref network "type")))
                            (vector->list (assoc-ref networks "v4")))))
    network))


;;;
;;; Remote evaluation.
;;;

(define (digital-ocean-remote-eval target exp)
  "Internal implementation of 'machine-remote-eval' for MACHINE instances with
an environment type of 'digital-ocean-environment-type'."
  (let* ((network (machine-public-ipv4-network target))
         (address (assoc-ref network "ip_address"))
         (ssh-key (digital-ocean-configuration-ssh-key
                   (machine-configuration target)))
         (delegate (machine
                    (inherit target)
                    (environment managed-host-environment-type)
                    (configuration
                     (machine-ssh-configuration
                      (host-name address)
                      (identity ssh-key)
                      (system "x86_64-linux"))))))
    (machine-remote-eval delegate exp)))


;;;
;;; System deployment.
;;;

;; XXX Copied from (gnu services base)
(define* (ip+netmask->cidr ip netmask #:optional (family AF_INET))
  "Return the CIDR notation (a string) for @var{ip} and @var{netmask}, two
@var{family} address strings, where @var{family} is @code{AF_INET} or
@code{AF_INET6}."
  (let* ((netmask (inet-pton family netmask))
         (bits    (logcount netmask)))
    (string-append ip "/" (number->string bits))))

;; The following script was adapted from the guide available at
;; <https://wiki.pantherx.org/Installation-digital-ocean/>.
(define (guix-infect network)
  "Given NETWORK, an alist describing the Droplet's public IPv4 network
interface, return a Bash script that will install the Guix system."
  (define os
    `(operating-system
       (host-name "gnu-bootstrap")
       (timezone "Etc/UTC")
       (bootloader (bootloader-configuration
                    (bootloader grub-bootloader)
                    (targets '("/dev/vda"))
                    (terminal-outputs '(console))))
       (file-systems (cons (file-system
                             (mount-point "/")
                             (device "/dev/vda1")
                             (type "ext4"))
                           %base-file-systems))
       (services
        (append (list (service static-networking-service-type
                               (list (static-networking
                                      (addresses
                                       (list (network-address
                                              (device "eth0")
                                              (value ,(ip+netmask->cidr
                                                       (assoc-ref network "ip_address")
                                                       (assoc-ref network "netmask"))))))
                                      (routes
                                       (list (network-route
                                              (destination "default")
                                              (gateway ,(assoc-ref network "gateway")))))
                                      (name-servers '("84.200.69.80" "84.200.70.40")))))
                      (simple-service 'guile-load-path-in-global-env
                                      session-environment-service-type
                                      `(("GUILE_LOAD_PATH"
                                         . "/run/current-system/profile/share/guile/site/3.0")
                                        ("GUILE_LOAD_COMPILED_PATH"
                                         . ,(string-append "/run/current-system/profile/lib/guile/3.0/site-ccache:"
                                                           "/run/current-system/profile/share/guile/site/3.0"))))
                      (service openssh-service-type
                               (openssh-configuration
                                (log-level 'debug)
                                (permit-root-login 'prohibit-password))))
            %base-services))))
  (format #f "#!/bin/bash

apt-get update
apt-get install xz-utils -y
wget -nv https://ci.guix.gnu.org/search/latest/archive?query=spec:tarball+status:success+system:x86_64-linux+guix-binary.tar.xz -O guix-binary-nightly.x86_64-linux.tar.xz
cd /tmp
tar --warning=no-timestamp -xf ~~/guix-binary-nightly.x86_64-linux.tar.xz
mv var/guix /var/ && mv gnu /
mkdir -p ~~root/.config/guix
ln -sf /var/guix/profiles/per-user/root/current-guix ~~root/.config/guix/current
export GUIX_PROFILE=\"`echo ~~root`/.config/guix/current\" ;
source $GUIX_PROFILE/etc/profile
groupadd --system guixbuild
for i in `seq -w 1 10`; do
   useradd -g guixbuild -G guixbuild         \
           -d /var/empty -s `which nologin`  \
           -c \"Guix build user $i\" --system  \
           guixbuilder$i;
done;
cp ~~root/.config/guix/current/lib/systemd/system/guix-daemon.service /etc/systemd/system/
systemctl start guix-daemon && systemctl enable guix-daemon
mkdir -p /usr/local/bin
cd /usr/local/bin
ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
mkdir -p /usr/local/share/info
cd /usr/local/share/info
for i in /var/guix/profiles/per-user/root/current-guix/share/info/*; do
    ln -s $i;
done
guix archive --authorize < ~~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub
# guix pull
guix package -i glibc-utf8-locales
export GUIX_LOCPATH=\"$HOME/.guix-profile/lib/locale\"
guix package -i openssl
cat > /etc/bootstrap-config.scm << EOF
(use-modules (gnu))
(use-service-modules base networking ssh)

~a
EOF
# guix pull
guix system build /etc/bootstrap-config.scm
guix system reconfigure /etc/bootstrap-config.scm
mv /etc /old-etc
mkdir /etc
cp -r /old-etc/{passwd,group,shadow,gshadow,mtab,guix,bootstrap-config.scm} /etc/
guix system reconfigure /etc/bootstrap-config.scm"
          ;; Escape the bare backtick to avoid having it interpreted by Bash.
          (string-replace-substring
           (format #f "~y" os) "`" "\\`")))

(define (machine-wait-until-available machine)
  "Block until the initial Debian image has been installed on the droplet
named DROPLET-NAME."
  (and-let* ((droplet (machine-droplet machine))
             (droplet-id (assoc-ref droplet "id"))
             (endpoint (format #f "/v2/droplets/~a/actions" droplet-id)))
    (let loop ()
      (let ((actions (assoc-ref (fetch-endpoint endpoint) "actions")))
        (unless (every (lambda (action)
                         (string= "completed" (assoc-ref action "status")))
                       (vector->list actions))
          (sleep 5)
          (loop))))))

(define (wait-for-ssh address ssh-key)
  "Block until the an SSH session can be made as 'root' with SSH-KEY at ADDRESS."
  (let loop ()
    (catch #t
      (lambda ()
        (open-ssh-session address #:user "root" #:identity ssh-key))
      (lambda args
        (sleep 5)
        (loop)))))

(define (add-static-networking target network)
  "Return an <operating-system> based on TARGET with a static networking
configuration for the public IPv4 network described by the alist NETWORK."
  (operating-system
    (inherit (machine-operating-system target))
    (services (cons* (service static-networking-service-type
                              (list (static-networking
                                     (addresses
                                      (list (network-address
                                             (device "eth0")
                                             (value (ip+netmask->cidr
                                                     (assoc-ref network "ip_address")
                                                     (assoc-ref network "netmask"))))))
                                     (routes
                                      (list (network-route
                                             (destination "default")
                                             (gateway (assoc-ref network "gateway")))))
                                     (name-servers '("84.200.69.80" "84.200.70.40")))))
                    (simple-service 'guile-load-path-in-global-env
                                    session-environment-service-type
                                    `(("GUILE_LOAD_PATH"
                                       . "/run/current-system/profile/share/guile/site/3.0")
                                      ("GUILE_LOAD_COMPILED_PATH"
                                       . ,(string-append "/run/current-system/profile/lib/guile/3.0/site-ccache:"
                                                         "/run/current-system/profile/share/guile/site/3.0"))))
                    (operating-system-user-services
                     (machine-operating-system target))))))

(define (deploy-digital-ocean target)
  "Internal implementation of 'deploy-machine' for 'machine' instances with an
environment type of 'digital-ocean-environment-type'."
  (maybe-raise-missing-api-key-error)
  (maybe-raise-unsupported-configuration-error target)
  (let* ((config (machine-configuration target))
         (name (machine-display-name target))
         (region (digital-ocean-configuration-region config))
         (size (digital-ocean-configuration-size config))
         (ssh-key (digital-ocean-configuration-ssh-key config))
         (fingerprint (read-key-fingerprint ssh-key))
         (enable-ipv6? (digital-ocean-configuration-enable-ipv6? config))
         (tags (digital-ocean-configuration-tags config))
         (request-body `(("name" . ,name)
                         ("region" . ,region)
                         ("size" . ,size)
                         ("image" . "debian-9-x64")
                         ("ssh_keys" . ,(vector fingerprint))
                         ("backups" . #f)
                         ("ipv6" . ,enable-ipv6?)
                         ("user_data" . #nil)
                         ("private_networking" . #nil)
                         ("volumes" . #nil)
                         ("tags" . ,(list->vector tags))))
         (response (post-endpoint "/v2/droplets" request-body)))
    (machine-wait-until-available target)
    (let* ((network (machine-public-ipv4-network target))
           (address (assoc-ref network "ip_address")))
      (wait-for-ssh address ssh-key)
      (let* ((ssh-session (open-ssh-session address #:user "root" #:identity ssh-key))
             (sftp-session (make-sftp-session ssh-session)))
        (call-with-remote-output-file sftp-session "/tmp/guix-infect.sh"
                                      (lambda (port)
                                        (display (guix-infect network) port)))
        (rexec ssh-session "/bin/bash /tmp/guix-infect.sh")
        ;; Session will close upon rebooting, which will raise 'guile-ssh-error.
        (catch 'guile-ssh-error
          (lambda () (rexec ssh-session "reboot"))
          (lambda args #t)))
      (wait-for-ssh address ssh-key)
      (let ((delegate (machine
                       (operating-system (add-static-networking target network))
                       (environment managed-host-environment-type)
                       (configuration
                        (machine-ssh-configuration
                         (host-name address)
                         (identity ssh-key)
                         (system "x86_64-linux"))))))
        (deploy-machine delegate)))))


;;;
;;; Roll-back.
;;;

(define (roll-back-digital-ocean target)
  "Internal implementation of 'roll-back-machine' for MACHINE instances with an
environment type of 'digital-ocean-environment-type'."
  (let* ((network (machine-public-ipv4-network target))
         (address (assoc-ref network "ip_address"))
         (ssh-key (digital-ocean-configuration-ssh-key
                   (machine-configuration target)))
         (delegate (machine
                    (inherit target)
                    (environment managed-host-environment-type)
                    (configuration
                     (machine-ssh-configuration
                      (host-name address)
                      (identity ssh-key)
                      (system "x86_64-linux"))))))
    (roll-back-machine delegate)))


;;;
;;; Environment type.
;;;

(define digital-ocean-environment-type
  (environment-type
   (machine-remote-eval digital-ocean-remote-eval)
   (deploy-machine      deploy-digital-ocean)
   (roll-back-machine   roll-back-digital-ocean)
   (name                'digital-ocean-environment-type)
   (description         "Provisioning of \"droplets\": virtual machines
 provided by the Digital Ocean virtual private server (VPS) service.")))


(define (maybe-raise-missing-api-key-error)
  (unless (%digital-ocean-token)
    (raise (condition
            (&message
             (message (G_ "No Digital Ocean access token was provided. This \
may be fixed by setting the environment variable GUIX_DIGITAL_OCEAN_TOKEN to \
one procured from https://cloud.digitalocean.com/account/api/tokens.")))))))

(define (maybe-raise-unsupported-configuration-error machine)
  "Raise an error if MACHINE's configuration is not an instance of
<digital-ocean-configuration>."
  (let ((config (machine-configuration machine))
        (environment (environment-type-name (machine-environment machine))))
    (unless (and config (digital-ocean-configuration? config))
      (raise (formatted-message (G_ "unsupported machine configuration '~a' \
for environment of type '~a'")
                                config
                                environment)))))
b93m1snxm4046xihb")))) (build-system qt-build-system) (arguments (list #:phases #~(modify-phases %standard-phases (add-before 'check 'check-setup (lambda* (#:key inputs #:allow-other-keys) (setenv "QT_QPA_PLATFORM" "offscreen") (setenv "HOME" ".") (setenv "TZ" "Europe/Prague") (setenv "TZDIR" (search-input-directory inputs "share/zoneinfo"))))))) (native-inputs (list extra-cmake-modules pkg-config tzdata-for-tests)) ;; TODO: clipper and osmctools are not detected (inputs (list clipper osmctools protobuf qtdeclarative-5 zlib networkmanager-qt ki18n)) (home-page "https://api.kde.org/kdepim/kpublictransport/html/index.html") (synopsis "Library for accessing realtime public transport data") (description "This package provides a library for accessing realtime public transport data and for performing public transport journey queries.") (license (list license:lgpl2.0+)))) (define-public snorenotify (package (name "snorenotify") (version "0.7.0") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/snorenotify/" version "/src/snorenotify-" version ".tar.xz")) (sha256 (base32 "0jz6ivk90h7iwgyxar7xzzj8yvzn6s1my6cqs9bdnwqswfk1nhbd")))) (build-system cmake-build-system) (arguments `(#:tests? #f)) ; both tests fail, require display (inputs (list qtbase-5)) (native-inputs (list extra-cmake-modules qttools-5)) (home-page "https://techbase.kde.org/Projects/Snorenotify") (synopsis "Qt notification framework") (description "Snorenotify is a multi platform Qt notification framework. Using a plugin system it is possible to create notifications with many different notification systems.") (license license:lgpl3))) (define-public kdeconnect (package (name "kdeconnect") (version "23.04.3") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/release-service/" version "/src/kdeconnect-kde-" version ".tar.xz")) (sha256 (base32 "1gcmqqj752h3lmcpvc7cm6k6bpb158ha7i5ysp0kqvf8cmpi5ydz")))) (build-system qt-build-system) (arguments (list #:configure-flags #~'("-DBUILD_TESTING=ON" "-DKDE_INSTALL_LIBEXECDIR=libexec" ;; So kdeconnect.so isn't installed to lib/plugins "-DPLUGIN_INSTALL_DIR=lib/qt5/plugins") #:tests? #f)) ; tests fail hard in our build environment (native-inputs (list extra-cmake-modules kdoctools libxtst pkg-config python-wrapper wayland-protocols)) (inputs (list kcmutils kconfigwidgets kdbusaddons kguiaddons ki18n kiconthemes kio kirigami knotifications kpackage kpeople kpeoplevcard kwayland libfakekey plasma-wayland-protocols pulseaudio-qt qca qqc2-desktop-style qtbase-5 qtdeclarative-5 qtgraphicaleffects qtmultimedia-5 qtquickcontrols-5 qtquickcontrols2-5 qtx11extras qtwayland-5 wayland modemmanager-qt libxkbcommon)) (home-page "https://community.kde.org/KDEConnect") (synopsis "Enable your devices to communicate with each other") (description "KDE Connect is a project that enables all your devices to communicate with each other. Here's a few things KDE Connect can do: @enumerate @item Receive your phone notifications on your desktop computer and reply to messages @item Control music playing on your desktop from your phone @item Use your phone as a remote control for your desktop @item Run predefined commands on your PC from connected devices @item Check your phones battery level from the desktop @item Ring your phone to help finding it @item Share files and links between devices @item Browse your phone from the desktop @item Control the desktop's volume from the phone @end enumerate") (properties `((upstream-name . "kdeconnect-kde"))) (license (list license:gpl2 license:gpl3)))) ; dual licensed (define-public labplot (package (name "labplot") (version "2.9.0") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/labplot" "/" version "/labplot-" version ".tar.xz")) (sha256 (base32 "1wi19gj18yhrim1cb2dwgpnc2yvydm87h41fcg670ampy24i98z5")))) (build-system qt-build-system) (arguments `(#:configure-flags (list "-DENABLE_CANTOR=OFF" ;not packaged "-DENABLE_MQTT=OFF" ;not packaged (qtmqtt) ;; FIXME: readstat (optional dependency) is available in the ;; statistics module, but that module can't be used here. "-DENABLE_READSTAT=OFF" ;; This is a bundled library that is not packaged. "-DENABLE_LIBORIGIN=ON") #:phases (modify-phases %standard-phases (replace 'check (lambda* (#:key tests? #:allow-other-keys) (when tests? ;; This test fails, I don't know why. (invoke "ctest" "-E" "(ParserTest|ReadStatFilterTest)"))))))) (native-inputs (list bison extra-cmake-modules pkg-config python-wrapper qttools-5)) (inputs (list breeze ;for dark themes breeze-icons ;for icons gsl karchive kcompletion kconfig kconfigwidgets kcoreaddons kcrash kdoctools ki18n kiconthemes kio knewstuff kparts kservice ksyntaxhighlighting ktextwidgets kuserfeedback kwidgetsaddons kxmlgui qtbase-5 qtsvg-5 shared-mime-info ;; Optional. cfitsio fftw hdf5 libcerf lz4 netcdf qtserialport zlib)) (home-page "https://labplot.kde.org/") (synopsis "Interactive graphing and analysis of scientific data") (description "LabPlot is a tool for interactive graphing and analysis of scientific data. It provides an easy way to create, manage and edit plots and to perform data analysis.") (license (list license:gpl2+ ;labplot license:gpl3+)))) ;liborigin (define-public kdf (package (name "kdf") (version "23.04.3") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/release-service/" version "/src/kdf-" version ".tar.xz")) (sha256 (base32 "11ndcbfkq5fhb1lfij0mmm43fw49sh0z3nw644sll0smcwic76aa")))) (build-system qt-build-system) (native-inputs (list extra-cmake-modules kdoctools)) (inputs (list kcmutils kconfigwidgets kcoreaddons ki18n kiconthemes kio knotifications kwidgetsaddons kxmlgui qtbase-5)) (home-page "https://kde.org/applications/system/kdk") (synopsis "View Disk Usage") (description "KDiskFree displays the available file devices (hard drive partitions, floppy and CD drives, etc.) along with information on their capacity, free space, type and mount point. It also allows you to mount and unmount drives and view them in a file manager.") (license license:gpl2+))) (define-public ktimer (package (name "ktimer") (version "23.04.3") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/release-service/" version "/src/ktimer-" version ".tar.xz")) (sha256 (base32 "1n5az5cgb0q28lz5f7afqjlfga32q232g836nkl1sfq8n5whj5z5")))) (build-system qt-build-system) (native-inputs (list extra-cmake-modules kdoctools)) (inputs (list kdbusaddons ki18n kio knotifications)) (home-page "https://kde.org/applications/utilities/ktimer") (synopsis "Countdown Launcher") (description "KTimer is a little tool to execute programs after some time. It allows you to enter several tasks and to set a timer for each of them. The timers for each task can be started, stopped, changed, or looped.") (license license:gpl2+))) (define-public kcachegrind (package (name "kcachegrind") (version "23.04.3") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/release-service/" version "/src/kcachegrind-" version ".tar.xz")) (sha256 (base32 "175bag1mfidp7bdsjb3zinib76jy8h881rqxgmkn90gmv4fqy62b")))) (build-system cmake-build-system) (native-inputs (list extra-cmake-modules perl python qttools-5 kdoctools)) (inputs (list qtbase-5 karchive ki18n kio kdbusaddons)) ;; Note: The 'hotshot2calltree' and 'pprof2calltree' scripts depend on ;; Python and PHP, respectively. These are optional and we ignore them ;; for now. (home-page "https://kcachegrind.github.io/html/Home.html") (synopsis "Visualize profiles produces by Valgrind's Cachegrind tool") (description "The data files generated by the Callgrind of Valgrind, an application profiler, can be loaded into KCachegrind for browsing the performance results. There is also a command-line tool to get ASCII reports from data files without the need to use KCachegrind. The format of Callgrind output is documented. With conversion scripts, KCachegrind is able to visualize output of other profilers like OProfile, a system-wide profiler for Linux using statistical sampling with hardware performance counters. There also exist converters for profiling output of Python, PHP, and Perl.") (license license:gpl2))) (define-public libkdegames (package (name "libkdegames") (version "23.04.3") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/release-service/" version "/src/libkdegames-" version ".tar.xz")) (sha256 (base32 "1sicpfsrkxn5d0fdy71h7033rpkb94r5hjvv5ab7qbmzb1qa4awq")))) (build-system qt-build-system) (native-inputs (list extra-cmake-modules)) (inputs (list karchive kbookmarks kcodecs kcompletion kconfigwidgets kcrash kdbusaddons kdeclarative kdnssd kglobalaccel kguiaddons ki18n kiconthemes ;("kio" ,kio) kitemviews kjobwidgets knewstuff kservice ktextwidgets kwidgetsaddons kxmlgui libsndfile openal qtbase-5 qtdeclarative-5 qtsvg-5)) (home-page "https://apps.kde.org/categories/games/") (synopsis "Runtime library for kdegames") (description "Runtime library for kdegames") (license (list license:gpl2+ license:fdl1.2+)))) (define-public marble-qt (package (name "marble-qt") (version "23.04.3") (source (origin (method git-fetch) (uri (git-reference (url "https://invent.kde.org/education/marble.git/") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "02qv2mfga4jm5br9dr8g6kcqr93q2ssq06m383kh83lkvickxzc9")))) (build-system qt-build-system) (arguments ;; FIXME: libmarblewidget-qt5.so.28 not found. Also enable the ;; corresponding configure flag to build tests. (list #:tests? #f #:configure-flags #~(list "-DBUILD_MARBLE_TOOLS=YES" ; file conversion tools "-DBUILD_TOUCH=YES" "-DBUILD_MARBLE_TESTS=FALSE"))) (native-inputs (list extra-cmake-modules kdoctools qttools-5)) ;; One optional dependency missing: libwlocate. (inputs (list gpsd kcoreaddons kcrash ki18n kio knewstuff kparts krunner kwallet perl phonon protobuf qtbase-5 qtdeclarative-5 qtlocation qtserialport qtsvg-5 qtwebchannel-5 qtwebengine-5 shapelib shared-mime-info zlib)) (home-page "https://marble.kde.org/") (synopsis "Virtual globe and world atlas") (description "Marble is similar to a desktop globe. At closer scale it becomes a world atlas, while OpenStreetMap takes the user to street level. It supports searching for places of interest, viewing Wikipedia articles, creating routes by drag and drop and more.") (license license:lgpl2.1+))) (define-public okular (package (name "okular") (version "23.04.3") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/release-service/" version "/src/" name "-" version ".tar.xz")) (sha256 (base32 "1vgcqkq6mzd270hzabmdqqv105iv6kr6ah2h18b15al2n9rmg0bi")))) (build-system qt-build-system) (arguments (list #:phases #~(modify-phases %standard-phases (delete 'check) ;; use installed data to check. (add-after 'install 'check (lambda* (#:key tests? #:allow-other-keys) (when tests? (invoke "ctest" "--output-on-failure" "--rerun-failed" "-E" "(mainshelltest|parttest|chmgeneratortest)")))) (add-before 'check 'check-setup (lambda* (#:key outputs #:allow-other-keys) (let ((share (string-append (assoc-ref outputs "out") "/share"))) (setenv "QT_QPA_PLATFORM" "offscreen") (setenv "HOME" ".") (setenv "XDG_DATA_DIRS" (string-append share ":" (getenv "XDG_DATA_DIRS"))) (invoke "update-desktop-database" "-v" share))))))) (native-inputs (list extra-cmake-modules kdoctools pkg-config ;; for test desktop-file-utils)) (inputs (list ebook-tools breeze-icons discount djvulibre kactivities khtml chmlib kdegraphics-mobipocket karchive kbookmarks kcompletion kconfig qtbase-5 libjpeg-turbo libtiff kirigami purpose freetype kiconthemes kio kparts kpty qtspeech kwallet kwindowsystem libkexiv2 libspectre libzip phonon poppler-qt5 qca qtdeclarative-5 qtsvg-5 qtwayland-5 threadweaver kcrash kjs qtx11extras)) (home-page "https://apps.kde.org/okular/") (synopsis "Document viewer") (description "Okular is a document viewer developed for KDE. It can display files in a variety of formats, including PDF, PostScript, DejaVu, and EPub.") (license license:gpl2+))) (define-public poxml (package (name "poxml") (version "23.04.3") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/release-service/" version "/src/poxml-" version ".tar.xz")) (sha256 (base32 "11rqd7hhsy6f8qi0529cmy381bhskji6wf4fij7yjksmrsdvfw6d")))) (build-system cmake-build-system) (native-inputs (list extra-cmake-modules kdoctools)) (inputs (list gettext-minimal qtbase-5)) (home-page "https://apps.kde.org/development/") (synopsis "Tools for translating DocBook XML files with Gettext") (description "This is a collection of tools that facilitate translating DocBook XML files using Gettext message files (PO files). Also included are several command-line utilities for manipulating DocBook XML files, PO files and PO template files.") (license license:gpl2+))) (define-public kdegraphics-mobipocket (package (name "kdegraphics-mobipocket") (version "23.04.3") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/release-service/" version "/src/" name "-" version ".tar.xz")) (sha256 (base32 "13hn6dh5d4vsblvg6wyyvbmcyl0yyqr8srilik86wilp58qbsrdv")))) (build-system cmake-build-system) (native-inputs (list extra-cmake-modules)) (inputs (list kio qtbase-5)) (home-page "https://apps.kde.org/en/kdegraphics_mobipocket") (synopsis "KDE thumbnailer for Mobipocket files") (description "This package provides a KDE plugin that shows thumbnails of Mobipocket e-books in Dolphin and other KDE apps.") (license license:gpl2+))) (define-public libkexiv2 (package (name "libkexiv2") (version "23.04.3") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/release-service/" version "/src/" name "-" version ".tar.xz")) (sha256 (base32 "16cb7cab4pyarwwn2byyvanwlakcgq5h203hkysp44flszq515cl")))) (build-system cmake-build-system) (native-inputs (list extra-cmake-modules)) (inputs (list exiv2 qtbase-5)) (home-page "https://invent.kde.org/graphics/libkexiv2") (synopsis "Manipulate the metadata of images") (description "Libkexiv2 wraps the Exiv2 library, allowing to manipulate picture metadata as EXIF/IPTC and XMP.") (license license:gpl2+))) (define-public zeroconf-ioslave (package (name "zeroconf-ioslave") (version "22.04.3") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/release-service/" version "/src/zeroconf-ioslave-" version ".tar.xz")) (sha256 (base32 "0jbrdbphxn77dg2a4wzsm7q24455j4d1xhd4rj5iwhq4ywiig9i1")))) (build-system qt-build-system) (native-inputs (list extra-cmake-modules)) (inputs (list kdbusaddons kdnssd ki18n kio qtbase-5)) (home-page "https://apps.kde.org/kio_zeroconf/") (synopsis "DNS-SD Service Discovery Monitor") (description "Adds an entry to Dolphin's Network page to show local services such as printers which advertise themselves with DNSSD (called Avahi or Bonjour by other projects).") (license ;; GPL for programs, LGPL for libraries, FDL for documentation (list license:gpl2+ license:lgpl2.0+ license:fdl1.2+)))) (define-public kuserfeedback ;; FIXME: Try to reduce data collection and ensure transmission i disabled by default. ;; FIXME: Check https://www.reddit.com/r/kde/comments/f7ojg9 for insights (package (name "kuserfeedback") (version "1.2.0") (source (origin (method url-fetch) (uri (string-append "mirror://kde/stable/kuserfeedback/" "/kuserfeedback-" version ".tar.xz")) (sha256 (base32 "0r7jcc88n5b4rc0asjzh7m7g33i35k3z99l08qkrn92kn4ickakn")))) (build-system qt-build-system) (native-inputs (list extra-cmake-modules qttools-5 ;; For optional component "Survey target expression parser" bison flex ;; For syntax checking and unit tests of PHP server code ;;("php" ,php) ;;("phpunit" ,phpunit) )) (inputs (list qtbase-5 qtcharts qtdeclarative-5 qtsvg-5)) (arguments `(#:tests? #f)) ;; 4/17 fail (home-page "https://api.kde.org/frameworks/kuserfeedback/html/") (synopsis "Collect application feedback via telemetry and targeted surveys") (description "This framework consists of the following components: @itemize @item Libraries for use in applications. @item QML bindings for the above. @item A server application. @item A management and analytics application. @end itemize") (license license:expat)))