Merge pull request #2181 from grahamc/nix-install-behind-mitm-proxy
Install Nix behind MITM proxy
This commit is contained in:
commit
0a830ef12d
3 changed files with 75 additions and 5 deletions
|
@ -21,4 +21,51 @@ in your <filename>~/.profile</filename> (or similar), like this:</para>
|
||||||
<screen>
|
<screen>
|
||||||
source <replaceable>prefix</replaceable>/etc/profile.d/nix.sh</screen>
|
source <replaceable>prefix</replaceable>/etc/profile.d/nix.sh</screen>
|
||||||
|
|
||||||
</chapter>
|
<section xml:id="sec-nix-ssl-cert-file">
|
||||||
|
|
||||||
|
<title><envar>NIX_SSL_CERT_FILE</envar></title>
|
||||||
|
|
||||||
|
<para>If you need to specify a custom certificate bundle to account
|
||||||
|
for an HTTPS-intercepting man in the middle proxy, you must specify
|
||||||
|
the path to the certificate bundle in the environment variable
|
||||||
|
<envar>NIX_SSL_CERT_FILE</envar>.</para>
|
||||||
|
|
||||||
|
|
||||||
|
<para>If you don't specify a <envar>NIX_SSL_CERT_FILE</envar>
|
||||||
|
manually, Nix will install and use its own certificate
|
||||||
|
bundle.</para>
|
||||||
|
|
||||||
|
<procedure>
|
||||||
|
<step><para>Set the environment variable and install Nix</para>
|
||||||
|
<screen>
|
||||||
|
$ export NIX_SSL_CERT_FILE=/etc/ssl/my-certificate-bundle.crt
|
||||||
|
$ curl https://nixos.org/nix/install | sh
|
||||||
|
</screen></step>
|
||||||
|
|
||||||
|
<step><para>In the shell profile and rc files (for example,
|
||||||
|
<filename>/etc/bashrc</filename>, <filename>/etc/zshrc</filename>),
|
||||||
|
add the following line:</para>
|
||||||
|
<programlisting>
|
||||||
|
export NIX_SSL_CERT_FILE=/etc/ssl/my-certificate-bundle.crt
|
||||||
|
</programlisting>
|
||||||
|
</step>
|
||||||
|
</procedure>
|
||||||
|
|
||||||
|
<note><para>You must not add the export and then do the install, as
|
||||||
|
the Nix installer will detect the presense of Nix configuration, and
|
||||||
|
abort.</para></note>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<title><envar>NIX_SSL_CERT_FILE</envar> with macOS and the Nix daemon</title>
|
||||||
|
|
||||||
|
<para>On macOS you must specify the environment variable for the Nix
|
||||||
|
daemon service, then restart it:</para>
|
||||||
|
|
||||||
|
<screen>
|
||||||
|
$ sudo launchctl setenv NIX_SSL_CERT_FILE /etc/ssl/my-certificate-bundle.crt
|
||||||
|
$ sudo launchctl kickstart -k system/org.nixos.nix-daemon
|
||||||
|
</screen>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
</chapter>
|
||||||
|
|
|
@ -727,11 +727,17 @@ setup_default_profile() {
|
||||||
_sudo "to installing a bootstrapping Nix in to the default Profile" \
|
_sudo "to installing a bootstrapping Nix in to the default Profile" \
|
||||||
HOME="$ROOT_HOME" "$NIX_INSTALLED_NIX/bin/nix-env" -i "$NIX_INSTALLED_NIX"
|
HOME="$ROOT_HOME" "$NIX_INSTALLED_NIX/bin/nix-env" -i "$NIX_INSTALLED_NIX"
|
||||||
|
|
||||||
_sudo "to installing a bootstrapping SSL certificate just for Nix in to the default Profile" \
|
if [ -z "$NIX_SSL_CERT_FILE" ] || ! [ -f "$NIX_SSL_CERT_FILE" ]; then
|
||||||
HOME="$ROOT_HOME" "$NIX_INSTALLED_NIX/bin/nix-env" -i "$NIX_INSTALLED_CACERT"
|
_sudo "to installing a bootstrapping SSL certificate just for Nix in to the default Profile" \
|
||||||
|
HOME="$ROOT_HOME" "$NIX_INSTALLED_NIX/bin/nix-env" -i "$NIX_INSTALLED_CACERT"
|
||||||
|
export NIX_SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Have to explicitly pass NIX_SSL_CERT_FILE as part of the sudo call,
|
||||||
|
# otherwise it will be lost in environments where sudo doesn't pass
|
||||||
|
# all the environment variables by default.
|
||||||
_sudo "to update the default channel in the default profile" \
|
_sudo "to update the default channel in the default profile" \
|
||||||
HOME="$ROOT_HOME" NIX_SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt "$NIX_INSTALLED_NIX/bin/nix-channel" --update nixpkgs
|
HOME="$ROOT_HOME" NIX_SSL_CERT_FILE="$NIX_SSL_CERT_FILE" "$NIX_INSTALLED_NIX/bin/nix-channel" --update nixpkgs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,23 @@ if test -w $HOME; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export NIX_SSL_CERT_FILE="@localstatedir@/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"
|
|
||||||
|
# Set $NIX_SSL_CERT_FILE so that Nixpkgs applications like curl work.
|
||||||
|
if [ ! -z "$NIX_SSL_CERT_FILE" ]; then
|
||||||
|
: # Allow users to override the NIX_SSL_CERT_FILE
|
||||||
|
elif [ -e /etc/ssl/certs/ca-certificates.crt ]; then # NixOS, Ubuntu, Debian, Gentoo, Arch
|
||||||
|
export NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
|
||||||
|
elif [ -e /etc/ssl/ca-bundle.pem ]; then # openSUSE Tumbleweed
|
||||||
|
export NIX_SSL_CERT_FILE=/etc/ssl/ca-bundle.pem
|
||||||
|
elif [ -e /etc/ssl/certs/ca-bundle.crt ]; then # Old NixOS
|
||||||
|
export NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt
|
||||||
|
elif [ -e /etc/pki/tls/certs/ca-bundle.crt ]; then # Fedora, CentOS
|
||||||
|
export NIX_SSL_CERT_FILE=/etc/pki/tls/certs/ca-bundle.crt
|
||||||
|
elif [ -e "$NIX_USER_PROFILE_DIR/etc/ssl/certs/ca-bundle.crt" ]; then # fall back to cacert in the user's Nix profile
|
||||||
|
export NIX_SSL_CERT_FILE=$NIX_USER_PROFILE_DIR/etc/ssl/certs/ca-bundle.crt
|
||||||
|
elif [ -e "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt" ]; then # fall back to cacert in the default Nix profile
|
||||||
|
export NIX_SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
|
||||||
|
fi
|
||||||
|
|
||||||
export NIX_PATH="nixpkgs=@localstatedir@/nix/profiles/per-user/root/channels/nixpkgs:@localstatedir@/nix/profiles/per-user/root/channels"
|
export NIX_PATH="nixpkgs=@localstatedir@/nix/profiles/per-user/root/channels/nixpkgs:@localstatedir@/nix/profiles/per-user/root/channels"
|
||||||
export PATH="$HOME/.nix-profile/bin:$HOME/.nix-profile/lib/kde4/libexec:@localstatedir@/nix/profiles/default/bin:@localstatedir@/nix/profiles/default:@localstatedir@/nix/profiles/default/lib/kde4/libexec:$PATH"
|
export PATH="$HOME/.nix-profile/bin:$HOME/.nix-profile/lib/kde4/libexec:@localstatedir@/nix/profiles/default/bin:@localstatedir@/nix/profiles/default:@localstatedir@/nix/profiles/default/lib/kde4/libexec:$PATH"
|
||||||
|
|
Loading…
Reference in a new issue