Add pastebin service

Evgeny PisemskySun Feb 23 14:25:35+0300 2025

0672c88

Add pastebin service

modules/cogd/packages/guile-xyz.scm

4646
      (license license:lgpl3+))))
4747
4848
(define-public guile-pastebin
49-
  (let ((commit "0cae302d520a171f2eda15e0f64781873cdc7a23")
49+
  (let ((commit "243961331e87c5134e08d5f4ffa5603f6f44d939")
5050
        (revision "0"))
5151
    (package
5252
      (name "guile-pastebin")

5959
               (commit commit)))
6060
         (file-name (git-file-name name version))
6161
         (sha256
62-
          (base32 "1m1bx3y0x4922brvwajr9h1yip4is3w57mb3y7r046c8dv6284mq"))))
62+
          (base32 "02xj7ia15qvfbkrdmn1i7vcby0ibqcqqxsdn3zsdzhrn3yksx9kj"))))
6363
      (build-system guile-build-system)
6464
      (arguments
6565
       (list

8787
      (native-inputs (list guile-3.0))
8888
      (inputs (list guile-3.0 bash-minimal))
8989
      (home-page "https://github.com/pisemsky/guile-pastebin")
90-
      (synopsis "Simple pastebin in Guile Scheme")
90+
      (synopsis "Simple pastebin written in Guile Scheme")
9191
      (description
9292
       "This package provides a very simple pastebin written in Guile Scheme.")
9393
      (license license:gpl3+))))

modules/cogd/services/pastebin.scm unknown status 1

1+
;;; SPDX-FileCopyrightText: 2025 Evgeny Pisemsky <mail@pisemsky.site>
2+
;;;
3+
;;; SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
(define-module (cogd services pastebin))
6+
7+
(use-modules (guix records)
8+
             (guix gexp)
9+
             (gnu packages admin)
10+
             (gnu system shadow)
11+
             (gnu services)
12+
             (gnu services shepherd)
13+
             (cogd packages guile-xyz))
14+
15+
(export pastebin-configuration
16+
        pastebin-configuration?
17+
        pastebin-configuration-requirement
18+
        pastebin-configuration-package
19+
        pastebin-configuration-data-dir
20+
        pastebin-configuration-addr
21+
        pastebin-configuration-port
22+
        pastebin-service-type)
23+
24+
(define-record-type* <pastebin-configuration>
25+
  pastebin-configuration
26+
  make-pastebin-configuration
27+
  pastebin-configuration?
28+
  (requirement pastebin-configuration-requirement
29+
               (default '(loopback)))
30+
  (package     pastebin-configuration-package
31+
               (default guile-pastebin))
32+
  (data-dir    pastebin-configuration-data-dir
33+
               (default "/var/lib/pastebin"))
34+
  (addr        pastebin-configuration-addr
35+
               (default "127.0.0.1"))
36+
  (port        pastebin-configuration-port
37+
               (default "8080")))
38+
39+
(define (pastebin-accounts config)
40+
  (list (user-group
41+
         (name "pastebin")
42+
         (system? #t))
43+
        (user-account
44+
         (name "pastebin")
45+
         (group "pastebin")
46+
         (system? #t)
47+
         (home-directory (pastebin-configuration-data-dir config))
48+
         (shell (file-append shadow "/sbin/nologin")))))
49+
50+
(define (pastebin-shepherd-service config)
51+
  (match-record
52+
      config <pastebin-configuration>
53+
      (package data-dir addr port requirement)
54+
    (list (shepherd-service
55+
           (documentation "Run the Pastebin.")
56+
           (provision '(pastebin))
57+
           (requirement requirement)
58+
           (start #~(make-forkexec-constructor
59+
                     (list #$(file-append package "/bin/pastebin")
60+
                           "--addr" #$addr
61+
                           "--port" #$port
62+
                           #$data-dir)
63+
                     #:user "pastebin"
64+
                     #:group "pastebin"))
65+
           (stop #~(make-kill-destructor))))))
66+
67+
(define pastebin-service-type
68+
  (service-type
69+
   (description "Run the Pastebin.")
70+
   (name 'pastebin)
71+
   (extensions
72+
    (list (service-extension account-service-type pastebin-accounts)
73+
          (service-extension shepherd-root-service-type pastebin-shepherd-service)))
74+
   (default-value (pastebin-configuration))))