Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup GNU Guix Reproducible Development Environment #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ You can also parse individual Org files using [[file:./laundry/cli.rkt]].
#+begin_src bash :results drawer
laundry/cli.rkt docs/thoughts.org laundry/test.org
#+end_src

* Reproducible Development Environment
To have a (GNU Guix) fully Reproducible Development Environment run
#+begin_src bash :results drawer
./guix-rde/run-rde.sh
#+end_src

* Status
Laundry can parse most of Org syntax, though there are still issues
with the correctness of the parse in a number of cases.
Expand Down
8 changes: 8 additions & 0 deletions guix-rde/.bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Setups system and user profiles and related variables
# /etc/profile will be sourced by bash automatically
# Setups home environment profile
if [ -f ~/.profile ]; then source ~/.profile; fi

# Honor per-interactive-shell startup file
if [ -f ~/.bashrc ]; then source ~/.bashrc; fi
export HISTFILE=$XDG_CACHE_HOME/.bash_history
68 changes: 68 additions & 0 deletions guix-rde/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Bash initialization for interactive non-login shells and
# for remote shells (info "(bash) Bash Startup Files").

# Export 'SHELL' to child processes. Programs such as 'screen'
# honor it and otherwise use /bin/sh.
export SHELL

inst () {
set -x
raco pkg install --deps search-auto laundry
{ retval="$?";
set +x; } 2>/dev/null
return $retval
}

test () {
set -x
raco test --package laundry
{ retval="$?";
set +x; } 2>/dev/null
return $retval
}

inst_test () {
inst && test
}

guix_prompt () {
cat << EOF
=========================================
____ _ _ _ _ ____ _
/ ___| \ | | | | | / ___|_ _(_)_ __
| | _| \| | | | | | | _| | | | \ \/ /
| |_| | |\ | |_| | | |_| | |_| | |> <
\____|_| \_|\___/ \____|\__,_|_/_/\_\\

Available commands: inst, test, inst_test
=========================================
EOF
}

if [[ $- != *i* ]]
then
# We are being invoked from a non-interactive shell. If this
# is an SSH session (as in "ssh host command"), source
# /etc/profile so we get PATH and other essential variables.
[[ -n "$SSH_CLIENT" ]] && guix_prompt

# Don't do anything else.
return
fi

# Source the system-wide file.
# source /etc/bashrc

guix_prompt

# Adjust the prompt depending on whether we're in 'guix environment'.
if [ -n "$GUIX_ENVIRONMENT" ]
then
PS1='\u@\h \w [env]\$ '
else
PS1='\u@\h \w\$ '
fi
alias ls='ls -p --color=auto'
alias ll='ls -l'
alias grep='grep --color=auto'
alias clear="printf '\e[2J\e[H'"
49 changes: 49 additions & 0 deletions guix-rde/run-rde.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
#
# GNU Guix Reproducible Development Environment

WD=$(pwd) # WD=$(dirname "$0") # i.e. path to this file

# --container run command within an isolated container
# --network allow containers to access the network
# --preserve preserve environment variables that match the REGEXP
# --expose expose read-only host file system according to SPEC
# The --preserve and --expose parameters are needed so that `raco test laundry`
# doesn't complain:
# raco test: (submod "~/.local/share/racket/8.3/pkgs/laundry/colorer.rkt" test)
# Unable to init server: Could not connect: Connection refused
# Gtk initialization failed for display ":0"
# ...
# raco test: "~/.local/share/racket/8.3/pkgs/laundry/perf.rkt"
# Unable to init server: Could not connect: Connection refused
# Gtk initialization failed for display ":0"

## Full freeze of Guix channels:
# cat << EOF >> /tmp/channels-lock.scm
# (list (channel
# (name 'guix)
# (url "https://git.savannah.gnu.org/git/guix.git")
# (branch "master")
# (commit
# "67817299808a03e2750cfb630dc09fe8eb99c468")
# (introduction
# (make-channel-introduction
# "9edb3f66fd807b096b48283debdcddccfea34bad"
# (openpgp-fingerprint
# "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
# EOF
# guix time-machine --channels=/tmp/channels-lock.scm -- shell \
# --container --network REST-OF-ARGS-OF-GUIX-SHELL

# xtrace: Print commands and their arguments as they are executed
set -x

guix shell \
--container --network \
racket bash grep coreutils which openssl nss-certs \
--preserve='^DISPLAY$' --preserve='^XAUTHORITY$' --expose=$XAUTHORITY \
--share=$WD/guix-rde/.bash_profile=$HOME/.bash_profile \
--share=$WD/guix-rde/.bashrc=$HOME/.bashrc \
--share=/etc/ssl/certs \
--share=$WD \
-- bash