From unknown Mon Jun 23 07:53:06 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#42820] [PATCH] doc: cookbook: Add chapter about Guix environment. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 12 Aug 2020 06:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42820 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 42820@debbugs.gnu.org Cc: Oleg Pykhalov X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.159721242014907 (code B ref -1); Wed, 12 Aug 2020 06:07:01 +0000 Received: (at submit) by debbugs.gnu.org; 12 Aug 2020 06:07:00 +0000 Received: from localhost ([127.0.0.1]:42700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k5jud-0003sN-Uo for submit@debbugs.gnu.org; Wed, 12 Aug 2020 02:07:00 -0400 Received: from lists.gnu.org ([209.51.188.17]:36216) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k5jua-0003sD-U4 for submit@debbugs.gnu.org; Wed, 12 Aug 2020 02:06:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5jua-00086x-Pm for guix-patches@gnu.org; Wed, 12 Aug 2020 02:06:56 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:36908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k5juY-0006zG-UK for guix-patches@gnu.org; Wed, 12 Aug 2020 02:06:56 -0400 Received: by mail-lj1-x22f.google.com with SMTP id w14so928296ljj.4 for ; Tue, 11 Aug 2020 23:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SbKzDRUBlkmD9wi40d1GTNL43sd8MsdghpCfefFugFo=; b=HhKhP2sjRe9zJON20jAcxIWQ/pbnN+hIRABXPk9v+UjczMvAYtGSwHbMshckE0ZDX0 gcrxCNwye7dfjVf5kfmLl73q/whE7aUfVxs+1AgrXwJ/qVVCFTVJh/yj+z0H9BHBqzbF +QEVJ7+EEFL1NHOwFqxPtz/5XbkQgUxtMO2lGWbto98CbchXGOHH5ITxzuNN0DTbt3Wi U5aVtzFwuMbdHinfoEUsQwFhzA3jvt89i1oGLmbFZRWekkwH6b5HTTPjR3QlONnQT5ic sb1Rf+uC7H4waqdw8txnyS6FEVPtvVZMpFYOhRaa7nClEN7rgHDesevWsqxtXVZs4UPc +opA== 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:mime-version :content-transfer-encoding; bh=SbKzDRUBlkmD9wi40d1GTNL43sd8MsdghpCfefFugFo=; b=bQ/8QI9Izqq8sVnslvxSEgVSjECs/yuXwURq/0QRMYdS8BjzkWaW9GWjjCO+FbLdhO mmZXHHZb3Op0qS4b5ZxkFyPFahfsVawObW0cX8kysvd3GsBIwmTvzkAunKsp3H4ijJq1 7Qgu3+TZGCk1G7oc2/D3T6aXimhoAWwVHIcF28vK501PRvG9NlFOJULl92b38AkgNDFD nHSkV7M5GK857ZcsHsJql/LVDPuZzRhahh8sLPUoHLfsIfvuQmhlvqk70TvKEpuu7goD Zzx2OB1nqqJGgBd0UkGcGoaFrvwYt77p5aB7bG3oEOtxZGCgebG7OqPCft/qIkUlSq+t OTbw== X-Gm-Message-State: AOAM532jL9ygfergdqY3x8MAPS7EnX40RhsOi5HjU5yAS6vIBPwV++zn j/jCdj+5vh2osUZTdDbqy1DSWNK7 X-Google-Smtp-Source: ABdhPJzL2e2lNdEnxIi/D3k6zT2KUKYk9cIwxSYOTofffumPx8YNF2Acolxhpy2t1knPxc0GLh+EHw== X-Received: by 2002:a2e:b814:: with SMTP id u20mr4390971ljo.202.1597212412268; Tue, 11 Aug 2020 23:06:52 -0700 (PDT) Received: from localhost.localdomain (ppp91-122-98-213.pppoe.avangarddsl.ru. [91.122.98.213]) by smtp.gmail.com with ESMTPSA id a2sm215455ljj.40.2020.08.11.23.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 23:06:51 -0700 (PDT) From: Oleg Pykhalov Date: Wed, 12 Aug 2020 09:06:13 +0300 Message-Id: <20200812060613.15094-1-go.wigust@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=go.wigust@gmail.com; helo=mail-lj1-x22f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.1 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * doc/guix-cookbook.texi (Environment management): New chapter. --- doc/guix-cookbook.texi | 125 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index f541592d13..326675c48b 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -64,6 +64,7 @@ Translation Project}. * Packaging:: Packaging tutorials * System Configuration:: Customizing the GNU System * Advanced package management:: Power to the users! +* Environment management:: Control environment * Acknowledgments:: Thanks! * GNU Free Documentation License:: The license of this document. @@ -2268,6 +2269,130 @@ mkdir -p "$GUIX_EXTRA_PROFILES/my-project" It's safe to delete the Guix channel profile you've just installed with the channel specification, the project profile does not depend on it. +@c ********************************************************************* +@node Environment management +@chapter Environment management + +Guix provides multiple tools to manage environment. This chapter +demonstrate such utilities. + +@menu +* Guix environment via direnv:: Setup Guix environment with direnv +@end menu + +@node Guix environment via direnv +@section Guix environment via direnv + +Guix provides a @samp{direnv} package, which could extend shell after +directory change. This tool could be used to prepare a pure Guix +environment. + +The following example provides a shell function for @file{~/.direnvrc} +file, which could be used from Guix Git repository in +@file{~/src/guix/.envrc} file to setup a build environment similar to +described in @pxref{Building from Git,,, guix, GNU Guix Reference +Manual}. + +Create a @file{~/.direnvrc} with a Bash code: + +@example +# Thanks +export_function() +@{ + local name=$1 + local alias_dir=$PWD/.direnv/aliases + mkdir -p "$alias_dir" + PATH_add "$alias_dir" + local target="$alias_dir/$name" + if declare -f "$name" >/dev/null; then + echo "#!$SHELL" > "$target" + declare -f "$name" >> "$target" 2>/dev/null + # Notice that we add shell variables to the function trigger. + echo "$name \$*" >> "$target" + chmod +x "$target" + fi +@} + +use_guix() +@{ + # Set GitHub token. + export GUIX_GITHUB_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + + # Unset 'GUIX_PACKAGE_PATH'. + export GUIX_PACKAGE_PATH="" + + # Recreate a garbage collector root. + gcroots="$HOME/.config/guix/gcroots" + mkdir -p "$gcroots" + gcroot="$gcroots/guix" + if [ -L "$gcroot" ] + then + rm -v "$gcroot" + fi + + # Miscellaneous packages. + PACKAGES_MAINTENANCE=( + direnv + git + git:send-email + git-cal + gnupg + guile-colorized + guile-readline + less + ncurses + openssh + xdot + ) + + # Environment packages. + PACKAGES=(help2man guile-sqlite3 guile-gcrypt) + + # Thanks + eval "$(guix environment --search-paths --root="$gcroot" --pure guix --ad-hoc $@{PACKAGES[@@]@} $@{PACKAGES_MAINTENANCE[@@]@} "$@@")" + + # Predefine configure flags. + configure() + @{ + ./configure --localstatedir=/var --prefix= + @} + export_function configure + + # Run make and optionally build something. + build() + @{ + make -j 2 + if [ $# -gt 0 ] + then + ./pre-inst-env guix build "$@@" + fi + @} + export_function build + + # Predefine push Git command. + push() + @{ + git push --set-upstream origin + @} + export_function push + + clear # Clean up the screen. + git-cal # Show contributions calendar. + + # Show commands help. + echo " +build build a package or just a project if no argument provided +configure run ./configure with predefined parameters +push push to upstream Git repository +" +@} +@end example + +Every project containing @file{.envrc} with a string @code{use guix} +will have predefined environment variables and procedures. + +Run @command{direnv allow} to setup the environment for the first time. + @c ********************************************************************* @node Acknowledgments @chapter Acknowledgments -- 2.28.0 From unknown Mon Jun 23 07:53:06 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#42820] [PATCH] doc: cookbook: Add chapter about Guix environment. Resent-From: Leo Famulari Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 22 Aug 2020 18:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42820 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Oleg Pykhalov Cc: 42820@debbugs.gnu.org Received: via spool by 42820-submit@debbugs.gnu.org id=B42820.15981223023083 (code B ref 42820); Sat, 22 Aug 2020 18:52:01 +0000 Received: (at 42820) by debbugs.gnu.org; 22 Aug 2020 18:51:42 +0000 Received: from localhost ([127.0.0.1]:51467 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9YcA-0000ne-Bv for submit@debbugs.gnu.org; Sat, 22 Aug 2020 14:51:42 -0400 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:38191) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9Yc9-0000nT-9D for 42820@debbugs.gnu.org; Sat, 22 Aug 2020 14:51:41 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 6B05D187; Sat, 22 Aug 2020 14:51:35 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 22 Aug 2020 14:51:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=famulari.name; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=mesmtp; bh=TL8Y0BDCr6vKfYdxFck7f41s H1ZJLHhyHNH5tCfSQGg=; b=iem2haxVYvR5Oz+zX3ksnystMxJ9yiz/0EU4ym5C eI638pLhcDPGANU5CxmE0DAC9gYakh10TR/bgZN8Cpir75HHj0RzKW1fPoH2DtIJ g1wfqYJeFLCCSnq1Wwp8aQWOvXaTjCU/Kz+4RoHWRjNfBW3lYlJGP2B9i1GWtD2r dAM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=TL8Y0B DCr6vKfYdxFck7f41sH1ZJLHhyHNH5tCfSQGg=; b=pd50f/wx1CRfW46BSGggAe hTaNJfNPqjIcXwNHJtUFgJJuECjM+OX8OUNckOkLXW+MiQLOD5JpjL00lZmBsl0j wT/kugs2lw0V7Efm5lveqyo7xy3sb2OGTVkCyPuLBWSI1Ldq81A8FOKOTQ1KfFc9 KDoB3lmt7MYtXAGfFjrbLS0U0RoFyIS9OigzKudOXLz/M2iy0JPkrad21/1DMJjD HUcwjhycv7/wRCkS/POzDMvsvszd//KXTZNSAI/3zDZNdELByuYJfUPmWgZHtbSz C3UFkJ4gCBALOgsegsSj1cCvPA3/JWzv2QZf3y7cV6eK+o3vH0xgHj/KleLVxHbw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddugedgudeffecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehttd ertddttddvnecuhfhrohhmpefnvghoucfhrghmuhhlrghrihcuoehlvghosehfrghmuhhl rghrihdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeeukeektdffvddtudegjeegtdevhf eufeeivdejiedtieegtdevjedvjeehffevgfenucfkphepjeefrddugedurdduvdejrddu geeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplh gvohesfhgrmhhulhgrrhhirdhnrghmvg X-ME-Proxy: Received: from localhost (c-73-141-127-146.hsd1.pa.comcast.net [73.141.127.146]) by mail.messagingengine.com (Postfix) with ESMTPA id BE57730600A6; Sat, 22 Aug 2020 14:51:34 -0400 (EDT) Date: Sat, 22 Aug 2020 14:51:33 -0400 From: Leo Famulari Message-ID: <20200822185133.GA20524@jasmine.lan> References: <20200812060613.15094-1-go.wigust@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200812060613.15094-1-go.wigust@gmail.com> X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Wed, Aug 12, 2020 at 09:06:13AM +0300, Oleg Pykhalov wrote: > * doc/guix-cookbook.texi (Environment management): New chapter. If it's useful for you, please go ahead and push! From unknown Mon Jun 23 07:53:06 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Oleg Pykhalov Subject: bug#42820: closed (Re: [bug#42820] [PATCH] doc: cookbook: Add chapter about Guix environment.) Message-ID: References: <877dtpvly7.fsf@gmail.com> <20200812060613.15094-1-go.wigust@gmail.com> X-Gnu-PR-Message: they-closed 42820 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 42820@debbugs.gnu.org Date: Sun, 23 Aug 2020 07:53:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1598169181-12998-1" This is a multi-part message in MIME format... ------------=_1598169181-12998-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #42820: [PATCH] doc: cookbook: Add chapter about Guix environment. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 42820@debbugs.gnu.org. --=20 42820: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D42820 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1598169181-12998-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 42820-done) by debbugs.gnu.org; 23 Aug 2020 07:52:14 +0000 Received: from localhost ([127.0.0.1]:52015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9knW-0003Md-3O for submit@debbugs.gnu.org; Sun, 23 Aug 2020 03:52:14 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:38325) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k9knT-0003MQ-O8 for 42820-done@debbugs.gnu.org; Sun, 23 Aug 2020 03:52:12 -0400 Received: by mail-lj1-f194.google.com with SMTP id m22so6226625ljj.5 for <42820-done@debbugs.gnu.org>; Sun, 23 Aug 2020 00:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ozDn1tVANHM6bnZuITGL4ZAPyVtTthuSyRex5Dceksg=; b=D1vgIAlpA3ynoSRBG50TM8B6XH00U19yAb9o4Ux/Ym4S6bensU8aaw0x/Enl9BELOP pyOKqPuF3npR8OIBi85Jt7CPLhFxoBTFodQv89QuOj0rkN86V/FkK4vAyEYxlpOzaR1N NqL5OiG9UVvcsspjkQWyuq4qXeXOQcmCUhu6JfsRYq9IzaRkWGlrzvxbv6MsRi3uMzee 8/fQiFnvbyHU+Es0Acwavh0tv7AI0rFWuax4lFCSgWiFOafdzhgTgxVqSpHEnbFzqTA0 X41hHyzxm0WvJTs78dA/hAOBeaz5HLvvNlrEkrTLFG1oDrhI3qmmFMVHs4Irh+gZToJh vB0g== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=ozDn1tVANHM6bnZuITGL4ZAPyVtTthuSyRex5Dceksg=; b=jMQksTEvBUgLnIsqYLwwaK4qM0Sw0u6wLndbCp/OyBub+4D7ZjRBCQPw6pqhyrCATf sTwpiYfFAkCAcfMFhMEIiDLcI0UCTiiIApnq5zm8mY7WHN9Iz15VB1tm0XEaFeSpWE5v dLUPQPFsTiSZFlZFDf3CVWCafYchPfKU9KrDUXfqgk5n2h/jT6qbQo1HWLxbIFX9cK9r xOATPkzkkMo4pUDTuJ5I/7WNc+cwFjtaWfggmUDKI/9ioH8j9krdywYeurKR6pjrs2YK 9Bml5kRI4M6l+Ageq2U0jkcDfh+Hzwt1dQOhVzNf+ObnWbrOfNmmD6xK72NJ60dAz+XM XLGQ== X-Gm-Message-State: AOAM530de1RDG6rWItp4pCAIOhjlWTiTKB8nO4xzWtsix9opOiP8iuMr nv7PKUXpoAuFZTSGzIwI8ddT4Ls4L8E= X-Google-Smtp-Source: ABdhPJyqZTpvI2+yVr0O9XplA4YSCffZiB8zW6jWYk4wTc8sVb3vFAW76+hT8krpQHqftOwhDoVuGA== X-Received: by 2002:a2e:7a03:: with SMTP id v3mr202630ljc.350.1598169125239; Sun, 23 Aug 2020 00:52:05 -0700 (PDT) Received: from guixsd (95-55-4-176.dynamic.avangarddsl.ru. [95.55.4.176]) by smtp.gmail.com with ESMTPSA id v14sm1441164ljk.10.2020.08.23.00.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 00:52:04 -0700 (PDT) From: Oleg Pykhalov To: Leo Famulari Subject: Re: [bug#42820] [PATCH] doc: cookbook: Add chapter about Guix environment. References: <20200812060613.15094-1-go.wigust@gmail.com> <20200822185133.GA20524@jasmine.lan> Date: Sun, 23 Aug 2020 10:52:00 +0300 In-Reply-To: <20200822185133.GA20524@jasmine.lan> (Leo Famulari's message of "Sat, 22 Aug 2020 14:51:33 -0400") Message-ID: <877dtpvly7.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 42820-done Cc: 42820-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) --=-=-= Content-Type: text/plain Hi, Leo Famulari writes: >> * doc/guix-cookbook.texi (Environment management): New chapter. > > If it's useful for you, please go ahead and push! Thanks for bumping the thread, pushed to master. Oleg. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAl9CICAACgkQFn+OpQAa +pyDkQ/+IKKSnTMbbqSl/g/q5ZeULfBqq93QOtYdRKYN1exZAEGmwWrm08fIxj5z t5X75eQOdggCKAzN5Eq1y7YJ5cpGekunT0+knnoxzX7VKu3gK/oeu3BiNXVGnLAP 62MrVlQUo1umu7GqL9b54ji90uWX3KTGEeGS+kUEY09s1SzS1gjhbcja+DIxHwrO vbw/qtJQS37XF6XhurVyMsgZPPzEJOX7CA0c3zZO6SFcFyf28llAuNW8eONRmYZJ 3bZEl3l/vZ6SDxgRmE286mimfGUfq63A62jq0idemItFW6iwQCOTP45EglHLxbpf 4ltIcjVwRPv/NSx/t1qZZTycikl/Hj/ZFoc9B7oxya60HoDcuxPLy3Vy0Eqd42Lx Ma3e+hGmnciE7CV1jMcypVe8gApubdAUKlmDpaK4irInGSPWU6h5/xlu2a3bhS8k gLpeFJSDBTEIx4/uSqGcQqnW5/kNfJ3eC88OqWsK1y8m6GWFmuMcWGyXCflidUYf KY+GYRTeX5vekgYyBbJNhtwcjUnRkRVTaHT09/lKYDKRNsrzMxWOMvThQUZS/3+G 8D6r9cB2SJ8uj/cUdFtXT0EqZgnVAu8K5kTBya1ZDyUVZQ7gEHsWFQBDQ+Q/py7K vFN7m+zQadUaguO4eOX67e83NSBMPLN0xNuaPajVOA2L/5s94jI= =athU -----END PGP SIGNATURE----- --=-=-=-- ------------=_1598169181-12998-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 12 Aug 2020 06:07:00 +0000 Received: from localhost ([127.0.0.1]:42700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k5jud-0003sN-Uo for submit@debbugs.gnu.org; Wed, 12 Aug 2020 02:07:00 -0400 Received: from lists.gnu.org ([209.51.188.17]:36216) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k5jua-0003sD-U4 for submit@debbugs.gnu.org; Wed, 12 Aug 2020 02:06:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5jua-00086x-Pm for guix-patches@gnu.org; Wed, 12 Aug 2020 02:06:56 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:36908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k5juY-0006zG-UK for guix-patches@gnu.org; Wed, 12 Aug 2020 02:06:56 -0400 Received: by mail-lj1-x22f.google.com with SMTP id w14so928296ljj.4 for ; Tue, 11 Aug 2020 23:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SbKzDRUBlkmD9wi40d1GTNL43sd8MsdghpCfefFugFo=; b=HhKhP2sjRe9zJON20jAcxIWQ/pbnN+hIRABXPk9v+UjczMvAYtGSwHbMshckE0ZDX0 gcrxCNwye7dfjVf5kfmLl73q/whE7aUfVxs+1AgrXwJ/qVVCFTVJh/yj+z0H9BHBqzbF +QEVJ7+EEFL1NHOwFqxPtz/5XbkQgUxtMO2lGWbto98CbchXGOHH5ITxzuNN0DTbt3Wi U5aVtzFwuMbdHinfoEUsQwFhzA3jvt89i1oGLmbFZRWekkwH6b5HTTPjR3QlONnQT5ic sb1Rf+uC7H4waqdw8txnyS6FEVPtvVZMpFYOhRaa7nClEN7rgHDesevWsqxtXVZs4UPc +opA== 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:mime-version :content-transfer-encoding; bh=SbKzDRUBlkmD9wi40d1GTNL43sd8MsdghpCfefFugFo=; b=bQ/8QI9Izqq8sVnslvxSEgVSjECs/yuXwURq/0QRMYdS8BjzkWaW9GWjjCO+FbLdhO mmZXHHZb3Op0qS4b5ZxkFyPFahfsVawObW0cX8kysvd3GsBIwmTvzkAunKsp3H4ijJq1 7Qgu3+TZGCk1G7oc2/D3T6aXimhoAWwVHIcF28vK501PRvG9NlFOJULl92b38AkgNDFD nHSkV7M5GK857ZcsHsJql/LVDPuZzRhahh8sLPUoHLfsIfvuQmhlvqk70TvKEpuu7goD Zzx2OB1nqqJGgBd0UkGcGoaFrvwYt77p5aB7bG3oEOtxZGCgebG7OqPCft/qIkUlSq+t OTbw== X-Gm-Message-State: AOAM532jL9ygfergdqY3x8MAPS7EnX40RhsOi5HjU5yAS6vIBPwV++zn j/jCdj+5vh2osUZTdDbqy1DSWNK7 X-Google-Smtp-Source: ABdhPJzL2e2lNdEnxIi/D3k6zT2KUKYk9cIwxSYOTofffumPx8YNF2Acolxhpy2t1knPxc0GLh+EHw== X-Received: by 2002:a2e:b814:: with SMTP id u20mr4390971ljo.202.1597212412268; Tue, 11 Aug 2020 23:06:52 -0700 (PDT) Received: from localhost.localdomain (ppp91-122-98-213.pppoe.avangarddsl.ru. [91.122.98.213]) by smtp.gmail.com with ESMTPSA id a2sm215455ljj.40.2020.08.11.23.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 23:06:51 -0700 (PDT) From: Oleg Pykhalov To: guix-patches@gnu.org Subject: [PATCH] doc: cookbook: Add chapter about Guix environment. Date: Wed, 12 Aug 2020 09:06:13 +0300 Message-Id: <20200812060613.15094-1-go.wigust@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=go.wigust@gmail.com; helo=mail-lj1-x22f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.1 (/) X-Debbugs-Envelope-To: submit Cc: Oleg Pykhalov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * doc/guix-cookbook.texi (Environment management): New chapter. --- doc/guix-cookbook.texi | 125 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi index f541592d13..326675c48b 100644 --- a/doc/guix-cookbook.texi +++ b/doc/guix-cookbook.texi @@ -64,6 +64,7 @@ Translation Project}. * Packaging:: Packaging tutorials * System Configuration:: Customizing the GNU System * Advanced package management:: Power to the users! +* Environment management:: Control environment * Acknowledgments:: Thanks! * GNU Free Documentation License:: The license of this document. @@ -2268,6 +2269,130 @@ mkdir -p "$GUIX_EXTRA_PROFILES/my-project" It's safe to delete the Guix channel profile you've just installed with the channel specification, the project profile does not depend on it. +@c ********************************************************************* +@node Environment management +@chapter Environment management + +Guix provides multiple tools to manage environment. This chapter +demonstrate such utilities. + +@menu +* Guix environment via direnv:: Setup Guix environment with direnv +@end menu + +@node Guix environment via direnv +@section Guix environment via direnv + +Guix provides a @samp{direnv} package, which could extend shell after +directory change. This tool could be used to prepare a pure Guix +environment. + +The following example provides a shell function for @file{~/.direnvrc} +file, which could be used from Guix Git repository in +@file{~/src/guix/.envrc} file to setup a build environment similar to +described in @pxref{Building from Git,,, guix, GNU Guix Reference +Manual}. + +Create a @file{~/.direnvrc} with a Bash code: + +@example +# Thanks +export_function() +@{ + local name=$1 + local alias_dir=$PWD/.direnv/aliases + mkdir -p "$alias_dir" + PATH_add "$alias_dir" + local target="$alias_dir/$name" + if declare -f "$name" >/dev/null; then + echo "#!$SHELL" > "$target" + declare -f "$name" >> "$target" 2>/dev/null + # Notice that we add shell variables to the function trigger. + echo "$name \$*" >> "$target" + chmod +x "$target" + fi +@} + +use_guix() +@{ + # Set GitHub token. + export GUIX_GITHUB_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + + # Unset 'GUIX_PACKAGE_PATH'. + export GUIX_PACKAGE_PATH="" + + # Recreate a garbage collector root. + gcroots="$HOME/.config/guix/gcroots" + mkdir -p "$gcroots" + gcroot="$gcroots/guix" + if [ -L "$gcroot" ] + then + rm -v "$gcroot" + fi + + # Miscellaneous packages. + PACKAGES_MAINTENANCE=( + direnv + git + git:send-email + git-cal + gnupg + guile-colorized + guile-readline + less + ncurses + openssh + xdot + ) + + # Environment packages. + PACKAGES=(help2man guile-sqlite3 guile-gcrypt) + + # Thanks + eval "$(guix environment --search-paths --root="$gcroot" --pure guix --ad-hoc $@{PACKAGES[@@]@} $@{PACKAGES_MAINTENANCE[@@]@} "$@@")" + + # Predefine configure flags. + configure() + @{ + ./configure --localstatedir=/var --prefix= + @} + export_function configure + + # Run make and optionally build something. + build() + @{ + make -j 2 + if [ $# -gt 0 ] + then + ./pre-inst-env guix build "$@@" + fi + @} + export_function build + + # Predefine push Git command. + push() + @{ + git push --set-upstream origin + @} + export_function push + + clear # Clean up the screen. + git-cal # Show contributions calendar. + + # Show commands help. + echo " +build build a package or just a project if no argument provided +configure run ./configure with predefined parameters +push push to upstream Git repository +" +@} +@end example + +Every project containing @file{.envrc} with a string @code{use guix} +will have predefined environment variables and procedures. + +Run @command{direnv allow} to setup the environment for the first time. + @c ********************************************************************* @node Acknowledgments @chapter Acknowledgments -- 2.28.0 ------------=_1598169181-12998-1--