This repository has been archived by the owner on Mar 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
guix-pre-inst-env
executable file
·81 lines (58 loc) · 2.05 KB
/
guix-pre-inst-env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
set -e
if [ ! -n "$BASH" ] ; then
exec bash "$0" "$@"
fi
export GOVUK_GUIX_ROOT="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
export GUIX_PACKAGE_PATH="$GOVUK_GUIX_ROOT/.guix-package-path"
if [[ $# -eq 0 ]] ; then
cat <<EOF
Usage: ./guix-pre-inst-env COMMAND ARG...
Run COMMAND in a pre-installation environment. This involves first
generating a Guix environment containing the version of Guix contained
within this repository. Then, using this version of Guix, create the
environment in which to use. Only environment variables that are
explicitly passed through are used.
This script will use GNU Guix from the Guix store, if you want to use
Guix from another location, use the ./pre-inst-env script instead.
EOF
exit 1
fi
# Put the right version of guix on the path, and coreutils as env and
# cut are used by this script
GDS_GUIX_SEARCH_PATHS="$(guix environment --fallback --pure --ad-hoc coreutils guile guix-gds-no-tests git --search-paths)"
eval "$GDS_GUIX_SEARCH_PATHS"
# To avoid $XDG_CONFIG_HOME/guix/latest from being used
export GUIX_UNINSTALLED="true"
SEARCH_PATHS="$(guix environment --fallback --pure govuk-guix --ad-hoc less nss-certs guile-readline git --search-paths)"
INCLUDED_VARIABLES=(HOME USER LOGNAME DISPLAY TERM TZ PAGER GUIX_GITHUB_TOKEN GUIX_DAEMON_SOCKET)
for var in $(env -0 | tr -d '\n' | tr '\0' '\n' | cut -d '=' -f 1); do
if [[ $var == GDS_* ]]
then
continue
fi
if [[ $var == GOVUK_* ]]
then
continue
fi
if [[ $var == AWS_* ]]
then
continue
fi
for var_to_skip in "${INCLUDED_VARIABLES[@]}"
do
if [ "$var" == "$var_to_skip" ]
then
continue 2
fi
done
unset $var;
done
set -u
eval "$SEARCH_PATHS"
export PATH="$GOVUK_GUIX_ROOT/bin:$PATH"
export GUIX_ENVIRONMENT="$(dirname $(dirname $(type -p guix)))"
export SSL_CERT_FILE="$GUIX_ENVIRONMENT/etc/ssl/certs/ca-certificates.crt"
export SSL_CERT_DIR="$GUIX_ENVIRONMENT/etc/ssl/certs"
export GIT_SSL_CAINFO="$SSL_CERT_FILE"
exec bash "$GOVUK_GUIX_ROOT/pre-inst-env" "$@"