Skip to content

Commit

Permalink
Setup GNU Guix Reproducible Development Environment
Browse files Browse the repository at this point in the history
  • Loading branch information
BostX committed Feb 7, 2022
1 parent fa9e70a commit 759d4bc
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .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
34 changes: 34 additions & 0 deletions .bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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

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" ]] && source /etc/profile

# Don't do anything else.
return
fi

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

source /usr/etc/profile

# 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'"
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
./run.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
11 changes: 11 additions & 0 deletions channels-lock.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(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")))))
33 changes: 33 additions & 0 deletions etc/profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# /etc/profile

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

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

go () {
ri && rt
}

cat << EOF
=========================================
____ _ _ _ _ ____ _
/ ___| \ | | | | | / ___|_ _(_)_ __
| | _| \| | | | | | | _| | | | \ \/ /
| |_| | |\ | |_| | | |_| | |_| | |> <
\____|_| \_|\___/ \____|\__,_|_/_/\_\\
Available commands: ri rt go
=========================================
EOF
38 changes: 38 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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
# --no-cwd don't share current working directory with an isolated container
# --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:
# guix time-machine --channels=./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 --no-cwd \
racket bash grep coreutils which openssl nss-certs \
--preserve='^DISPLAY$' --preserve='^XAUTHORITY$' --expose=$XAUTHORITY \
--share=$WD/.bash_profile=$HOME/.bash_profile \
--share=$WD/.bashrc=$HOME/.bashrc \
--share=$WD/etc=/usr/etc \
--share=/etc/ssl/certs \
--share=$WD \
-- bash

0 comments on commit 759d4bc

Please sign in to comment.