Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Guix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
inf
Guix
Commits
d0fc1e83
Unverified
Commit
d0fc1e83
authored
4 years ago
by
Oleg Pykhalov
Browse files
Options
Downloads
Patches
Plain Diff
doc: cookbook: Add chapter about Guix environment.
* doc/guix-cookbook.texi (Environment management): New chapter.
parent
dc12a37a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/guix-cookbook.texi
+125
-0
125 additions, 0 deletions
doc/guix-cookbook.texi
with
125 additions
and
0 deletions
doc/guix-cookbook.texi
+
125
−
0
View file @
d0fc1e83
...
...
@@ -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 <https:
//
github.com
/
direnv
/
direnv
/
issues
/
73
#issuecomment
-
152284914
>
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 <https://lists.gnu.org/archive/html/guix-devel/2016-09/msg00859.html>
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
--
author
=
'Your Name' # 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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment