about summary refs log tree commit diff
path: root/scripts/nix-profile.sh.in
blob: 6e70b81df46a51fc046916088cdf11b13d3d19d0 (plain) (blame)
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
if [ -n "$HOME" ]; then
    NIX_LINK="$HOME/.nix-profile"

    # Set the default profile.
    if ! [ -L "$NIX_LINK" ]; then
        echo "creating $NIX_LINK" >&2
        _NIX_DEF_LINK=@localstatedir@/nix/profiles/default
        @coreutils@/ln -s "$_NIX_DEF_LINK" "$NIX_LINK"
    fi

    export PATH=$NIX_LINK/bin:$NIX_LINK/sbin:$PATH

    # Subscribe the user to the Nixpkgs channel by default.
    if [ ! -e "$HOME/.nix-channels" ]; then
        echo "https://nixos.org/channels/nixpkgs-unstable nixpkgs" > "$HOME/.nix-channels"
    fi

    # Append ~/.nix-defexpr/channels/nixpkgs to $NIX_PATH so that
    # <nixpkgs> paths work when the user has fetched the Nixpkgs
    # channel.
    export NIX_PATH=${NIX_PATH:+$NIX_PATH:}nixpkgs=$HOME/.nix-defexpr/channels/nixpkgs

    # Set $SSL_CERT_FILE so that Nixpkgs applications like curl work.
    if [ -e /etc/ssl/certs/ca-certificates.crt ]; then # NixOS, Ubuntu, Debian, Gentoo, Arch
        export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
    elif [ -e /etc/ssl/certs/ca-bundle.crt ]; then # Old NixOS
        export SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt
    elif [ -e /etc/pki/tls/certs/ca-bundle.crt ]; then # Fedora, CentOS
        export SSL_CERT_FILE=/etc/pki/tls/certs/ca-bundle.crt
    elif [ -e "$NIX_LINK/etc/ssl/certs/ca-bundle.crt" ]; then # fall back to cacert in Nix profile
        export SSL_CERT_FILE="$NIX_LINK/etc/ssl/certs/ca-bundle.crt"
    elif [ -e "$NIX_LINK/etc/ca-bundle.crt" ]; then # old cacert in Nix profile
        export SSL_CERT_FILE="$NIX_LINK/etc/ca-bundle.crt"
    fi
fi