From patchwork Fri Aug 27 07:07:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Tropin X-Patchwork-Id: 32333 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 86FBB27BBE3; Fri, 27 Aug 2021 08:08:13 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 01D7227BBE1 for ; Fri, 27 Aug 2021 08:08:13 +0100 (BST) Received: from localhost ([::1]:54408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJVyG-0000Cd-4Z for patchwork@mira.cbaines.net; Fri, 27 Aug 2021 03:08:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJVy6-00008K-V2 for guix-patches@gnu.org; Fri, 27 Aug 2021 03:08:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mJVy6-0005kd-NJ for guix-patches@gnu.org; Fri, 27 Aug 2021 03:08:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mJVy6-0005Ab-IV for guix-patches@gnu.org; Fri, 27 Aug 2021 03:08:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50208] [PATCH 5/5] home: Add home-environment. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 27 Aug 2021 07:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50208 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Oleg Pykhalov Cc: 50208@debbugs.gnu.org Received: via spool by 50208-submit@debbugs.gnu.org id=B50208.163004806719845 (code B ref 50208); Fri, 27 Aug 2021 07:08:02 +0000 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 07:07:47 +0000 Received: from localhost ([127.0.0.1]:51175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVxq-0005A1-Dh for submit@debbugs.gnu.org; Fri, 27 Aug 2021 03:07:46 -0400 Received: from mail-lj1-f174.google.com ([209.85.208.174]:33431) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVxp-00059o-72 for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 03:07:45 -0400 Received: by mail-lj1-f174.google.com with SMTP id s12so9851407ljg.0 for <50208@debbugs.gnu.org>; Fri, 27 Aug 2021 00:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=LlG0vkpHel4BIBrogJDjIPYyNwcyYajjndC5aD91k7g=; b=JmOIFUWID3xO3XEQAdHawezvDJemOn+ZW2JLSqcyoIRXCPSbCRVV50nhpofl/nlgJ9 JLJ/y3AoMd8ZYwIsFyXjLOQdq4mXVOVrPzx6s4dzy5sp2i3i1sOi4WY3qcau02tFHJ4w ZvShlOKGfKlNSmv6hyE8d7mL5lHX9h2nRn8cJ8jouSKo57irrSpS52JIfI/8rH4O8o+0 HS08m+8xiJWJFsXvxxYjhHxVH1nArQBnlmv1DtPud2jhseamQDkmCe7yRn2QjCUiMWV8 9CXvjIV72yKXZk7BtcffuAPIl20QF/+fqJ4kakUeMPW8sdw3mqJ+Z+otNKVwGprzbz1V bmlQ== 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:in-reply-to:references:date :message-id:mime-version; bh=LlG0vkpHel4BIBrogJDjIPYyNwcyYajjndC5aD91k7g=; b=XQP1/XckIDPszUSLNpu/CnD6X09/wYHSqT42VOfCxbAVgLNT/13RByYdLXxWD+H7c2 ja//z76AaCzAplbrH9zE3THgFm3ljhcN1JBGqLwMYcn40VTWI/1f9cL4LvP+GQb9+K6F O5C/Zdtz4qbyI1zBGWVO5pmlR9ck2wEvm+Y/pNo1K7htfiFd4O2zjP5GJJE8FDhwbg7g P9ufPUS+el6CEbUK78EyYu+xgGvyX7+xXrJItcaQ7+PSxAShf5WuSjAN1J4xmgrvoUhi DHcU/z945clGGzD92snjKTfv5QeFxYFoJHvSVPDEiLZKjC1+kxNDGSFfTG96IJdSJo/K p+Rw== X-Gm-Message-State: AOAM5318Z950G8lYxKmcoINop6x7AKJz1cpa0UoPC+hnqlDv83MuSQJU Z481MWVdCezIwFjAY/Off9GJobxZGbo8Tg== X-Google-Smtp-Source: ABdhPJwH/aNNNuf9tDi1ZPVXXIqAXoak9kk1vXzBcu+oPw+ZHzTDODs81k6cw0x2n3bUxv5Dnu7NHg== X-Received: by 2002:a2e:97cf:: with SMTP id m15mr6367577ljj.125.1630048059129; Fri, 27 Aug 2021 00:07:39 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id f30sm509986lfj.219.2021.08.27.00.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 00:07:38 -0700 (PDT) From: Andrew Tropin In-Reply-To: <871r6ffklu.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> Date: Fri, 27 Aug 2021 10:07:35 +0300 Message-ID: <87lf4ne56w.fsf@trop.in> 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" X-getmail-retrieved-from-mailbox: Patches * gnu/home.scm (home-environment, home-environment?, this-home-environment) (home-environment-derivation, home-environment-user-services) (home-environment-essential-services, home-environment-services) (home-environment-location, home-environment-with-provenance): New variables. * gnu/local.mk (GNU_SYSTEM_MODULES): Add home.scm. --- gnu/home.scm | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 2 files changed, 98 insertions(+) create mode 100644 gnu/home.scm diff --git a/gnu/home.scm b/gnu/home.scm new file mode 100644 index 0000000000..220cc49846 --- /dev/null +++ b/gnu/home.scm @@ -0,0 +1,97 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Andrew Tropin +;;; +;;; 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 . + +(define-module (gnu home) + #:use-module (gnu home-services) + #:use-module (gnu home-services symlink-manager) + #:use-module (gnu home-services shells) + #:use-module (gnu home-services xdg) + #:use-module (gnu home-services fontutils) + #:use-module (gnu services) + #:use-module (guix records) + #:use-module (guix diagnostics) + + #:export (home-environment + home-environment? + this-home-environment + + home-environment-derivation + home-environment-user-services + home-environment-essential-services + home-environment-services + home-environment-location + + home-environment-with-provenance)) + +(define-record-type* home-environment + make-home-environment + home-environment? + this-home-environment + + (packages home-environment-packages ; list of (PACKAGE OUTPUT...) + (default '())) + + (essential-services home-environment-essential-services ; list of services + (thunked) + (default (home-environment-default-essential-services + this-home-environment))) + (services home-environment-user-services + (default '())) + + (location home-environment-location ; + (default (and=> (current-source-location) + source-properties->location)) + (innate))) + +(define (home-environment-default-essential-services he) + "Return the list of essential services for home environment." + (list + (service home-run-on-first-login-service-type) + (service home-activation-service-type) + (service home-environment-variables-service-type) + + (service home-symlink-manager-service-type) + + (service home-fontconfig-service-type) + (service home-xdg-base-directories-service-type) + (service home-shell-profile-service-type) + + (service home-service-type) + (service home-profile-service-type (home-environment-packages he)))) + +(define* (home-environment-services he) + "Return all the services of home environment." + (instantiate-missing-services + (append (home-environment-user-services he) + (home-environment-essential-services he)))) + +(define* (home-environment-derivation he) + "Return a derivation that builds OS." + (let* ((services (home-environment-services he)) + (home (fold-services services + #:target-type home-service-type))) + (service-value home))) + +(define* (home-environment-with-provenance he config-file) + "Return a variant of HE that stores its own provenance information, +including CONFIG-FILE, if available. This is achieved by adding an instance +of HOME-PROVENANCE-SERVICE-TYPE to its services." + (home-environment + (inherit he) + (services (cons (service home-provenance-service-type config-file) + (home-environment-user-services he))))) diff --git a/gnu/local.mk b/gnu/local.mk index 8c44c143af..bbaee51140 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -72,6 +72,7 @@ GNU_SYSTEM_MODULES = \ %D%/bootloader/u-boot.scm \ %D%/bootloader/depthcharge.scm \ %D%/ci.scm \ + %D%/home.scm \ %D%/home-services.scm \ %D%/home-services/symlink-manager.scm \ %D%/home-services/fontutils.scm \