#!/bin/bash

#set -u
#set -e

# Configuration
remote="141.80.xxx.xxx:9999"
guix_root="/gnu/remote"

# Avoid locale warnings.
export GUIX_LOCPATH="${guix_root}/locales/.guix-profile/lib/locale"

# find SSL certificates
export SSL_CERT_FILE=/etc/pki/tls/certs/ca-bundle.crt

test "$1" = "gc" && \
    (>&2 echo 'Please do not use "guix gc" (garbage collection) here.'; exit 1)

# Use guix with the given arguments
export GUIX_DAEMON_SOCKET=guix://${remote}

if [ "$1" == "load-profile" ]; then
  if [ $# -gt 1 ]; then
    if [ "$2" != "--help" ] && [ "$2" != "-h" ]; then
      arguments=("$@")
      profile_arguments=("${arguments[@]:1}")
      profile_arguments=("${profile_arguments[@]/--}")
      profiles=${profile_arguments[@]/%/"/etc/profile"}
      set_output=$(grep -h "^export" $profiles)
      sge_variables=$(export -p | grep "^declare -x SGE")
      env - bash --init-file <(echo "$sge_variables"; echo "$set_output") -i "${@:$(($# + 1))}"
    else
      printf "Usage:\n  $0 $1 /path/to/profile\n"
    fi
  else
    printf "Usage:\n  $0 $1 /path/to/profile\n"
  fi
else
    # Pick either the user's variant of Guix or the shared variant.
    if [ -e ${HOME}/.config/guix/current/bin/guix ]; then
        ${HOME}/.config/guix/current/bin/guix "$@"
    else
        >&2 echo 'NOTE: Please run "guix pull" to manage your own version of Guix.'
        >&2 echo '      You are now using the default version, which may change without notice.'
        >&2 echo '  '

        ${guix_root}/.guix-pull/bin/guix "$@"
    fi
fi

Generated by Ricardo Wurmus using scpaste at Wed Jun 9 16:26:33 2021. CEST. (original)