guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

16/22: services: Add hurd.


From: guix-commits
Subject: 16/22: services: Add hurd.
Date: Mon, 13 Apr 2020 09:20:49 -0400 (EDT)

janneke pushed a commit to branch wip-hurd-vm
in repository guix.

commit effb8a296b39d57d72bede18221fe7da64b0c20c
Author: Jan (janneke) Nieuwenhuizen <address@hidden>
AuthorDate: Sun Apr 12 22:17:03 2020 +0200

    services: Add hurd.
    
    * gnu/services/hurd.scm: New file.
    * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk          |   1 +
 gnu/services/hurd.scm | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 128 insertions(+)

diff --git a/gnu/local.mk b/gnu/local.mk
index 0d49838..0fc7a48 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -567,6 +567,7 @@ GNU_SYSTEM_MODULES =                                \
   %D%/services/games.scm                       \
   %D%/services/getmail.scm                             \
   %D%/services/guix.scm                        \
+  %D%/services/hurd.scm                                \
   %D%/services/kerberos.scm                    \
   %D%/services/linux.scm                       \
   %D%/services/lirc.scm                                \
diff --git a/gnu/services/hurd.scm b/gnu/services/hurd.scm
new file mode 100644
index 0000000..38add88
--- /dev/null
+++ b/gnu/services/hurd.scm
@@ -0,0 +1,127 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <address@hidden>
+;;;
+;;; 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 services hurd)
+  #:use-module (gnu packages ssh)
+  #:use-module (gnu services)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu system shadow)
+  #:use-module (guix gexp)
+  #:use-module (guix modules)
+  #:use-module (guix records)
+  #:use-module (srfi srfi-1)
+  #:use-module (ice-9 match)
+  #:export (hurd-service->shepherd-service
+            hurd-ssh-configuration
+            hurd-ssh-service-type))
+
+;;; Commentary:
+;;;
+;;; This module implements services for the Hurd.
+;;;
+;;; Code:
+
+;; XXX Gradually bootstrap (gnu services) framework.
+(define (hurd-service->shepherd-service service)
+  (let ((config (service-value service)))
+    (match config
+      (($ <openssh-configuration>) (hurd-ssh-shepherd-service config))
+      (_ '()))))
+
+
+;;;
+;;; Simplified OpenSSH.  This removes loopback, syslogd and PAM dependencies.
+;;; This package will be removed when the Hurd supports those.
+;;;
+
+(define <openssh-configuration>
+  (@@ (gnu services ssh) <openssh-configuration>))
+
+(define %openssh-accounts
+  (@@ (gnu services ssh) %openssh-accounts))
+
+(define openssh-activation
+  (@@ (gnu services ssh) openssh-activation))
+
+(define openssh-auto-start?
+  (@@ (gnu services ssh) openssh-auto-start?))
+
+(define openssh-config-file
+  (@@ (gnu services ssh) openssh-config-file))
+
+(define (hurd-ssh-configuration)
+  ((@@ (gnu services ssh) openssh-configuration)))
+
+(define openssh-configuration-openssh
+  (@@ (gnu services ssh) openssh-configuration-openssh))
+
+(define openssh-configuration-pid-file
+  (@@ (gnu services ssh) openssh-configuration-pid-file))
+
+(define extend-openssh-authorized-keys
+  (@@ (gnu services ssh) extend-openssh-authorized-keys))
+
+(define (hurd-ssh-shepherd-service config)
+  "Return a <shepherd-service> for openssh with CONFIG."
+
+  (define pid-file
+    (openssh-configuration-pid-file config))
+
+  (define openssh-command
+    #~(list
+       (string-append
+        #$(openssh-configuration-openssh config)
+        "/sbin/sshd")
+       "-D"
+       "-f" #$(openssh-config-file config)))
+
+  (list (shepherd-service
+         (documentation "OpenSSH server.")
+         (requirement '())
+         (provision '(ssh-daemon ssh sshd))
+         (start #~(make-forkexec-constructor
+                   #$openssh-command
+                   #:pid-file #$pid-file))
+         (stop #~(make-kill-destructor))
+         (auto-start? (openssh-auto-start? config)))))
+
+(define hurd-ssh-service-type
+  (service-type
+   (name 'openssh)
+   (description
+    "Run the OpenSSH secure shell (SSH) server, @command{sshd}.")
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             hurd-ssh-shepherd-service)
+          (service-extension activation-service-type
+                             openssh-activation)
+          (service-extension account-service-type
+                             (const %openssh-accounts))
+
+          ;; Install OpenSSH in the system profile.  That way,
+          ;; 'scp' is found when someone tries to copy to or from
+          ;; this machine.
+          (service-extension profile-service-type
+                             (lambda (config)
+                               (list (openssh-configuration-openssh
+                                      config))))))
+   (compose concatenate)
+   (extend  extend-openssh-authorized-keys)
+   (default-value (hurd-ssh-configuration))))
+
+;;; hurd.scm ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]