(use-modules (guix scripts archive)
             (ice-9 match))

(define* (server #:optional (host "127.0.0.1") (port 2904))
  (let ((s (socket PF_INET SOCK_STREAM 0)))
    (setsockopt s SOL_SOCKET SO_REUSEPORT 1)
    (bind s AF_INET (inet-pton AF_INET host) port)
    (listen s 5)

    (simple-format #t "Listening for clients in pid: ~S" (getpid))
    (newline)

    (while #true
      (match (accept s)
        ((client . _)
         (let ((thing (read client)))
           (format (current-output-port) "sending `~a'~%" thing)
           (parameterize ((current-output-port client))
             (apply guix-archive (list "--recursive" "--export" thing))))
           (close client))))))

(server)

Generated by Ricardo Wurmus using scpaste at Tue Mar 23 12:33:10 2021. CET. (original)