From patchwork Thu Feb 16 15:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janneke Nieuwenhuizen X-Patchwork-Id: 10005 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DCC5216919; Thu, 16 Feb 2023 15:55:17 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 478641690B for ; Thu, 16 Feb 2023 15:55:16 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSgbB-0001ca-QV; Thu, 16 Feb 2023 10:55:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSgb9-0001bG-JQ for guix-patches@gnu.org; Thu, 16 Feb 2023 10:55:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSgb9-00022S-7N for guix-patches@gnu.org; Thu, 16 Feb 2023 10:55:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pSgb8-0007rE-UH for guix-patches@gnu.org; Thu, 16 Feb 2023 10:55:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61483] [PATCH v2 2/5] DRAFT gnu: home: services: Add home-ssh-agent-service-type. Resent-From: "Jan (janneke) Nieuwenhuizen" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 16 Feb 2023 15:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61483 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 61483@debbugs.gnu.org Received: via spool by 61483-submit@debbugs.gnu.org id=B61483.167656285130115 (code B ref 61483); Thu, 16 Feb 2023 15:55:02 +0000 Received: (at 61483) by debbugs.gnu.org; 16 Feb 2023 15:54:11 +0000 Received: from localhost ([127.0.0.1]:37442 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSgaI-0007pZ-Rs for submit@debbugs.gnu.org; Thu, 16 Feb 2023 10:54:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSgaC-0007oS-R5 for 61483@debbugs.gnu.org; Thu, 16 Feb 2023 10:54:08 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSga7-0001pO-JG; Thu, 16 Feb 2023 10:53:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=L+lo8S04XJBPLC5vtryLUI7wdCr9sa161XSGtkC+sn8=; b=sHpDL1LD4irO+NJXEJ/0 nTeLR5qsMdC6Bf/pNiMHEjIcabTSnloWer4Xwp3Qz3pWmQP3iFCQi2DsDi9rqC9tHpphAqyrE3Xin BplKiR3E73b7UMmvxHTDcADK2zY6J78aShwz2vE0p67qlVgihQE1awNhrDhYYDLLdY7uyJBXwVMrK eVvfnwL2l8rrt4tIpL6YaPTgtdSKd5b941JXGM1lWjKonzmC5EH3PurnJgKSzux9bVJWgNiIvJuH9 WkDmqnhakvh+2WMPgWPk6+UsTLw4M2u8MWtP9jDHCraSD1vQYWS8iaW/jePBRzTHdHnZS0RbNHrYR L04sTp2NgLar8g==; Received: from 2a02-a462-da03-1-2701-7f81-a736-4607.fixed6.kpn.net ([2a02:a462:da03:1:2701:7f81:a736:4607] helo=drakenpad.fritz.box) by fencepost.gnu.org with esmtpa (Exim 4.90_1) (envelope-from ) id 1pSga6-0005sK-Tn; Thu, 16 Feb 2023 10:53:59 -0500 From: "Jan (janneke) Nieuwenhuizen" Date: Thu, 16 Feb 2023 16:53:52 +0100 Message-Id: <20230216155355.11106-2-janneke@gnu.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230216155355.11106-1-janneke@gnu.org> References: <20230216155355.11106-1-janneke@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/home/services/shepherd-xyz.scm (): New type. (home-ssh-agent-services): New procedure. (home-ssh-agent-service-type): New variable. --- gnu/home/services/shepherd-xyz.scm | 60 +++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/gnu/home/services/shepherd-xyz.scm b/gnu/home/services/shepherd-xyz.scm index 4d84008dae..75f3770ffc 100644 --- a/gnu/home/services/shepherd-xyz.scm +++ b/gnu/home/services/shepherd-xyz.scm @@ -25,6 +25,7 @@ (define-module (gnu home services shepherd-xyz) #:use-module (gnu home services) #:use-module (gnu home services shepherd) + #:use-module (gnu packages ssh) #:use-module (gnu packages version-control) #:use-module (gnu services configuration) #:use-module (gnu services shepherd) @@ -32,7 +33,9 @@ (define-module (gnu home services shepherd-xyz) #:use-module (guix gexp) #:export (home-git-daemon-configuration - home-git-daemon-service-type)) + home-git-daemon-service-type + home-ssh-agent-configuration + home-ssh-agent-service-type)) ;;; Commentary: ;; @@ -46,6 +49,15 @@ (define-module (gnu home services shepherd-xyz) ;; (home-git-configuration ;; (root (string-append (getenv "HOME") "/src")))) ;; +;; Ssh-agent +;; +;; Add to your ~/.bash_profile: +;; +;; SSH_AUTH_SOCK=${XDG_RUNTIME_DIR-$HOME/.cache}/ssh-agent/socket +;; export SSH_AUTH_SOCK +;; +;; (service home-ssh-agent-service-type) +;; ;;; Code: ;;; @@ -120,3 +132,49 @@ (define home-git-daemon-service-type home-git-daemon-services))) (description "Install and configure the git-daemon as a shepherd service."))) + + +;;; +;;; Ssh-agent. +;;; +(define-record-type* + home-ssh-agent-configuration make-home-ssh-agent-configuration + home-ssh-agent-configuration? + (openssh home-ssh-agent-openssh ;file-like + (default openssh)) + (socket-dir home-ssh-agent-socket-dir ;string + (default (string-append %user-runtime-dir "/ssh-agent"))) + (extra-options home-ssh-agent-extra-options ;list of string + (default '()))) + +(define (home-ssh-agent-services config) + "Return a for an ssh-agent with CONFIG." + (match config + (($ + openssh socket-dir extra-options) + (let* ((ssh-agent (file-append openssh "/bin/ssh-agent")) + (socket-file (string-append socket-dir "/socket")) + (command `(,ssh-agent + "-D" + "-a" ,socket-file + ,@extra-options)) + (log-file (string-append %user-log-dir "/ssh-agent.log"))) + (list (shepherd-service + (documentation "Run the ssh-agent.") + (provision '(ssh-agent)) + (start #~(lambda _ + (unless (file-exists? #$socket-dir) + (mkdir-p #$socket-dir) + (chmod #$socket-dir #o700)) + (fork+exec-command '#$command #:log-file #$log-file))) + (stop #~(make-kill-destructor)))))))) + +(define home-ssh-agent-service-type + (service-type + (name 'home-ssh-agent) + (default-value (home-ssh-agent-configuration)) + (extensions + (list (service-extension home-shepherd-service-type + home-ssh-agent-services))) + (description + "Install and configure the ssh-agent as a shepherd service.")))