diff --git a/README.org b/README.org index a496415..ec51a2d 100644 --- a/README.org +++ b/README.org @@ -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. diff --git a/guix-rde/.bash_profile b/guix-rde/.bash_profile new file mode 100644 index 0000000..384ef2a --- /dev/null +++ b/guix-rde/.bash_profile @@ -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 diff --git a/guix-rde/.bashrc b/guix-rde/.bashrc new file mode 100644 index 0000000..fb9d5ef --- /dev/null +++ b/guix-rde/.bashrc @@ -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'" diff --git a/guix-rde/run-rde.sh b/guix-rde/run-rde.sh new file mode 100755 index 0000000..ab930c5 --- /dev/null +++ b/guix-rde/run-rde.sh @@ -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