Merge pull request #2946 from vmandela/proxy
installer: handle network proxy in systemd multi-user install
This commit is contained in:
commit
15ee2bc2fe
|
@ -67,5 +67,23 @@ $ sudo launchctl kickstart -k system/org.nixos.nix-daemon
|
||||||
</screen>
|
</screen>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-installer-proxy-settings">
|
||||||
|
|
||||||
|
<title>Proxy Environment Variables</title>
|
||||||
|
|
||||||
|
<para>The Nix installer has special handling for these proxy-related
|
||||||
|
environment variables:
|
||||||
|
<varname>http_proxy</varname>, <varname>https_proxy</varname>,
|
||||||
|
<varname>ftp_proxy</varname>, <varname>no_proxy</varname>,
|
||||||
|
<varname>HTTP_PROXY</varname>, <varname>HTTPS_PROXY</varname>,
|
||||||
|
<varname>FTP_PROXY</varname>, <varname>NO_PROXY</varname>.
|
||||||
|
</para>
|
||||||
|
<para>If any of these variables are set when running the Nix installer,
|
||||||
|
then the installer will create an override file at
|
||||||
|
<filename>/etc/systemd/system/nix-daemon.service.d/override.conf</filename>
|
||||||
|
so <command>nix-daemon</command> will use them.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
34
scripts/install-systemd-multi-user.sh
Normal file → Executable file
34
scripts/install-systemd-multi-user.sh
Normal file → Executable file
|
@ -9,6 +9,38 @@ readonly SERVICE_DEST=/etc/systemd/system/nix-daemon.service
|
||||||
readonly SOCKET_SRC=/lib/systemd/system/nix-daemon.socket
|
readonly SOCKET_SRC=/lib/systemd/system/nix-daemon.socket
|
||||||
readonly SOCKET_DEST=/etc/systemd/system/nix-daemon.socket
|
readonly SOCKET_DEST=/etc/systemd/system/nix-daemon.socket
|
||||||
|
|
||||||
|
|
||||||
|
# Path for the systemd override unit file to contain the proxy settings
|
||||||
|
readonly SERVICE_OVERRIDE=${SERVICE_DEST}.d/override.conf
|
||||||
|
|
||||||
|
create_systemd_override() {
|
||||||
|
header "Configuring proxy for the nix-daemon service"
|
||||||
|
_sudo "create directory for systemd unit override" mkdir -p "$(dirname $SERVICE_OVERRIDE)"
|
||||||
|
cat <<EOF | _sudo "create systemd unit override" tee "$SERVICE_OVERRIDE"
|
||||||
|
[Service]
|
||||||
|
$1
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# Gather all non-empty proxy environment variables into a string
|
||||||
|
create_systemd_proxy_env() {
|
||||||
|
vars="http_proxy https_proxy ftp_proxy no_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY NO_PROXY"
|
||||||
|
for v in $vars; do
|
||||||
|
if [ "x${!v:-}" != "x" ]; then
|
||||||
|
echo "Environment=${v}=${!v}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_network_proxy() {
|
||||||
|
# Create a systemd unit override with proxy environment variables
|
||||||
|
# if any proxy environment variables are not empty.
|
||||||
|
PROXY_ENV_STRING=$(create_systemd_proxy_env)
|
||||||
|
if [ -n "${PROXY_ENV_STRING}" ]; then
|
||||||
|
create_systemd_override "${PROXY_ENV_STRING}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
poly_validate_assumptions() {
|
poly_validate_assumptions() {
|
||||||
if [ "$(uname -s)" != "Linux" ]; then
|
if [ "$(uname -s)" != "Linux" ]; then
|
||||||
failure "This script is for use with Linux!"
|
failure "This script is for use with Linux!"
|
||||||
|
@ -47,6 +79,8 @@ poly_configure_nix_daemon_service() {
|
||||||
_sudo "to set up the nix-daemon socket service" \
|
_sudo "to set up the nix-daemon socket service" \
|
||||||
systemctl enable "/nix/var/nix/profiles/default$SOCKET_SRC"
|
systemctl enable "/nix/var/nix/profiles/default$SOCKET_SRC"
|
||||||
|
|
||||||
|
handle_network_proxy
|
||||||
|
|
||||||
_sudo "to load the systemd unit for nix-daemon" \
|
_sudo "to load the systemd unit for nix-daemon" \
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue