From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uGwuB7t/EWGKBgAAgWs5BA (envelope-from ) for ; Mon, 09 Aug 2021 21:19:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id UPrQArt/EWHjVgAA1q6Kng (envelope-from ) for ; Mon, 09 Aug 2021 19:19:23 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A147F2F28A for ; Mon, 9 Aug 2021 21:19:22 +0200 (CEST) Received: from localhost ([::1]:33040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDAnx-000344-LG for larch@yhetil.org; Mon, 09 Aug 2021 15:19:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDAng-0002Ks-Ap for guix-patches@gnu.org; Mon, 09 Aug 2021 15:19:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46305) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDAng-0000St-3h for guix-patches@gnu.org; Mon, 09 Aug 2021 15:19:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDAng-0004XM-0I for guix-patches@gnu.org; Mon, 09 Aug 2021 15:19:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49969] [PATCH 6/7] gnu: desktop: Add greetd-service-type Resent-From: muradm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 09 Aug 2021 19:19:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49969 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49969@debbugs.gnu.org Cc: muradm Received: via spool by 49969-submit@debbugs.gnu.org id=B49969.162853671317362 (code B ref 49969); Mon, 09 Aug 2021 19:19:03 +0000 Received: (at 49969) by debbugs.gnu.org; 9 Aug 2021 19:18:33 +0000 Received: from localhost ([127.0.0.1]:57844 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDAnB-0004Vs-6l for submit@debbugs.gnu.org; Mon, 09 Aug 2021 15:18:33 -0400 Received: from mail-ej1-f42.google.com ([209.85.218.42]:41918) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDAn5-0004Ug-99 for 49969@debbugs.gnu.org; Mon, 09 Aug 2021 15:18:27 -0400 Received: by mail-ej1-f42.google.com with SMTP id d11so6439616eja.8 for <49969@debbugs.gnu.org>; Mon, 09 Aug 2021 12:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=muradm-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZVxtLCxQv0YfqJRzYhcHPFN0ekGqAYGltUjBcgXQK9M=; b=UIfwDUNPgQwdBJIgoczAkVzwV3IA8s6dwmSklt/fhSQqXJ0JOR24NhR7qaGtIHm/hz 43paHaKyGiApLiq3u/mMUifvNsPMyTJOQxyMdQJWfz97sntJsCK2ISMczUoJ5HLnARhk +ILkztKyBWSYMiu3VEBCVXgeInK7R0DHZkIN6FeiS/N52/AJa1HF9ngjH8/EY6xWhx1R wbCOH/BFDALgxnx2agEXT2FpBSnsORi7Mc9WA31RAfX9EpLi6MjEn8R4RKqfqymmgGmz TF1Kr9l/CzOADJmx3wBU9VXhFZxNROVXUtuijDsZYQy2lwkjY215CZPSsmsAmA1Zkspj TPug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZVxtLCxQv0YfqJRzYhcHPFN0ekGqAYGltUjBcgXQK9M=; b=BjuOccK3KZ693Mwc6StA/5i9RUPTQDgbaaggORDLsqK/heBB8S+wS52XH4rCyA3PZ/ TBscCD5B8uw+gMSwgl0p3RtMLC6R7yp3Zc7Z+3fXtCsaMylZ7Xr4M+Ar3UyuAP9k+na0 7JP8nPWc7OKPIgt2/4xsU4TWle7bOnVmx+2HpKy/dQGI9h2rHOh+hH09csTdssPlERBt H2ethqcKqBsTgKt1eRUWgdw+vbr5Qpw2o2YU26EcNDReszL8GbK4hZXQhUxhBatNX7ky zct7ADcRNv2Z9YLGhuo9OOsuMIgIo5zn5+Dh4xgVWqyXMAaGrQfC8UcqM++6UB+6+ltp i01w== X-Gm-Message-State: AOAM531alfBNghApYgv7zfrjznBg2rC9Cn3aHEXPBE9+IB4WZkTlcosj jX2KCY/LouzoSr7uIPm4+Y2CldI4Y3AKFQ== X-Google-Smtp-Source: ABdhPJziM4u0tve4pjJAv43t3PGXjsDysubMcVEfRxIiCtk62x+LIvQilnvbqCXBDhShT3v7LRbBFg== X-Received: by 2002:a17:907:3d91:: with SMTP id he17mr24172685ejc.355.1628536701446; Mon, 09 Aug 2021 12:18:21 -0700 (PDT) Received: from localhost.localdomain ([31.142.122.131]) by smtp.gmail.com with ESMTPSA id gv7sm6167100ejc.5.2021.08.09.12.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 12:18:20 -0700 (PDT) From: muradm Date: Mon, 9 Aug 2021 22:18:02 +0300 Message-Id: <20210809191803.7833-6-mail@muradm.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210809190257.7280-1-mail@muradm.net> References: <20210809190257.7280-1-mail@muradm.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1628536762; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=mpuuvhbAAzRCICS8NjFDV1woyXDgpdkr+sMgezJtBYE=; b=XJsVyRHk+RmTBV0dEDkoqnaLPsowOb7bZ55N+KyCQNecy4MLTKqh47+aKbloFRJcxZXhhZ lR9pEJOVrD2GvC6Zr68gdr9w/kohGiqBTNoCBBYcB/KKNHx9kkG9SpV9YAdJFQqutKQJEJ NsY6GO9/7A78eE2fW5nL7DYj84y7icv21QyHLx4+tkMjwq6kT93HA+idMirGcQ4BOwUYvf R+spvLPR9dQ/wyttbDZB87hPT2RvOXBML+W8EU/1gzDlYEEQEtyij4aZWyPxPM9WRIN2Or kwObuIO9xIkr0QaO6G4CZeuy70Ib93OFDTu/6Tx+MC2iOWwLs87HpZZm6IwbQA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628536762; a=rsa-sha256; cv=none; b=ky3fnrEvJOSrabihpXu4rNNz9tQU+JjadBks5FBgas59UdAIPFr/scewpTtSCVOKnX4sgn aygy5LQ29kq2xYx/coTdJqDv0O04KgE5SdvvNHR5j9ytVba8Cs3ons90tOCX/mSaF8wYcW jnRK7drO9Zfdox/0fYN2WnYGzAsKxvTTHFbX6QKlbawHpggyXWFw5LL0Cd3aoTxMHPmRBd nUHUJiws0UceWFCIB5sJeA4MP2X+M7657vPAV1dqZ3R+sToDT4JPFpRF4/LLAuPw/x0fk2 ETMkOaXSUQBOEznk3ROGKvGO4RpJcfA3LmRZ5z+9p/MkO2IW8d/b3Pb7GavEcA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=muradm-net.20150623.gappssmtp.com header.s=20150623 header.b=UIfwDUNP; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 3.59 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=muradm-net.20150623.gappssmtp.com header.s=20150623 header.b=UIfwDUNP; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: A147F2F28A X-Spam-Score: 3.59 X-Migadu-Scanner: scn0.migadu.com X-TUID: 6UOOQUyZfYa5 greetd is a minimal and flexible login manager daemon that makes no assumptions about what you want to launch. Currently, only agreety configuration is provided. * gnu/services/desktop.scm: Add greetd-service-type --- gnu/services/desktop.scm | 139 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index cc13859532..601b9921a4 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -49,6 +49,7 @@ #:use-module (gnu system pam) #:use-module (gnu packages glib) #:use-module (gnu packages admin) + #:use-module (gnu packages bash) #:use-module (gnu packages cups) #:use-module (gnu packages freedesktop) #:use-module (gnu packages gnome) @@ -160,6 +161,11 @@ seatd-configuration seatd-service-type + greetd-configuration + greetd-agreety-tty-session + greetd-agreety-tty-xdg-session + greetd-service-type + %desktop-services)) ;;; Commentary: @@ -1297,6 +1303,139 @@ or setting its password with passwd."))) seatd-shepherd-service))) (default-value (seatd-configuration)))) + +;;; +;;; greetd-service-type -- minimal and flexible login manager daemon +;;; + +(define %greetd-accounts + (list (user-account (name "greeter") (group "wheel") (system? #t)))) + +(define-record-type* + greetd-agreety-session make-greetd-agreety-session + greetd-agreety-session? + (package greetd-agreety-command-package (default bash)) + (command-bin greetd-agreety-command-bin (default "/bin/bash")) + (command-args greetd-agreety-command-args (default '("-l"))) + (extra-env greetd-agreety-extra-env (default '())) + (command-generator greetd-agreety-command-generator)) + +(define greetd-agreety-tty-session-command + (match-lambda + (($ pkg command-bin command-args extra-env) + (program-file + "agreety-tty-session-command" + #~(begin + (use-modules (ice-9 match)) + (let* ((abs-cmd-bin #$(file-append pkg command-bin))) + (for-each + (match-lambda ((var . val) (setenv var val))) + (quote (#$@extra-env))) + (apply execl abs-cmd-bin abs-cmd-bin + (list #$@command-args)))))))) + +(define greetd-agreety-tty-xdg-session-command + (match-lambda + (($ package command-bin command-args extra-env) + (program-file + "agreety-tty-xdg-session-command" + #~(begin + (use-modules (ice-9 popen) (ice-9 rdelim) (ice-9 match)) + (let* + ((pmvarrun-bin #$(file-append seatd-pam-mount "/sbin/pmvarrun")) + (username (getenv "USER")) + (useruid (passwd:uid (getpwuid username))) + (useruid (number->string useruid)) + (pmvarrun-cmd (string-join (list pmvarrun-bin "-u" username "-o" "0") " ")) + (pmvarrun-port (open-input-pipe pmvarrun-cmd)) + (session-id (read-line pmvarrun-port)) + (session-id (string-append username "-" session-id)) + (abs-cmd-bin #$(file-append package command-bin))) + (close-pipe pmvarrun-port) + (setenv "XDG_SESSION_ID" session-id) + (setenv "XDG_SESSION_TYPE" "tty") + (setenv "XDG_RUNTIME_DIR" (string-append "/run/user/" useruid)) + (for-each + (match-lambda ((var . val) (setenv var val))) + (quote (#$@extra-env))) + (apply execl abs-cmd-bin abs-cmd-bin + (list #$@command-args)))))))) + +(define greetd-agreety-tty-session + (greetd-agreety-session + (command-generator greetd-agreety-tty-session-command))) + +(define greetd-agreety-tty-xdg-session + (greetd-agreety-session + (command-generator greetd-agreety-tty-xdg-session-command))) + +(define-record-type* greetd-configuration + make-greetd-configuration + greetd-configuration? + (greetd greetd-package (default greetd)) + (config-file-name greetd-config-file-name (thunked) + (default (default-config-file-name this-record))) + (terminal-vt greetd-terminal-vt (default "7")) + (default-session-user greetd-default-session-user (default "greeter")) + (default-session-command greetd-default-session-command + (default greetd-agreety-tty-session))) + +(define (default-config-file-name config) + (string-join (list "config-" (greetd-terminal-vt config) ".toml") "")) + +(define make-greetd-default-session-command + (match-lambda + (($ greetd _ _ _ default-session-command) + (cond ((greetd-agreety-session? default-session-command) + (let* + ((generator (greetd-agreety-command-generator + default-session-command)) + (command (apply generator (list default-session-command))) + (agreety-bin (file-append greetd "/bin/agreety"))) + (program-file + "agreety-command" + #~(execl #$agreety-bin #$agreety-bin "-c" #$command)))) + (else (program-file "agreety-command-exit" #~(exit #f))))))) + +(define (greetd-configuration-file config) + (let* + ((config-file-name (greetd-config-file-name config)) + (terminal-vt (greetd-terminal-vt config)) + (default-session-user (greetd-default-session-user config)) + (default-session-command (make-greetd-default-session-command config))) + (mixed-text-file + config-file-name + "[terminal]\n" + "vt = " terminal-vt "\n" + "[default_session]\n" + "user = " default-session-user "\n" + "command = " default-session-command "\n"))) + +(define (greetd-shepherd-service config) + (let* + ((greetd-bin (file-append (greetd-package config) "/sbin/greetd")) + (greetd-conf (greetd-configuration-file config))) + (list + (shepherd-service + (requirement '(user-processes host-name udev virtual-terminal)) + (provision (list (symbol-append + 'term-tty + (string->symbol (greetd-terminal-vt config))))) + (start #~(make-forkexec-constructor + (list #$greetd-bin "-c" #$greetd-conf))) + (stop #~(make-kill-destructor)))))) + +(define greetd-service-type + (service-type + (name 'greetd) + (extensions + (list + (service-extension shepherd-root-service-type + greetd-shepherd-service) + (service-extension account-service-type + (const %greetd-accounts)))) + (default-value (greetd-configuration)))) + ;;; ;;; The default set of desktop services. -- 2.32.0