daml/dev-env/lib/ensure-nix
Moritz Kiefer 2c1d4cb805
Fix nix installation (#6400)
Nix now requires -L, I’ve gone ahead and just normalized everything to
use -sfL which we were already using in one place.

changelog_begin
changelog_end
2020-06-18 10:34:08 +02:00

26 lines
659 B
Bash

#!/usr/bin/env bash
# source this file to check that nix is installed
#
# if nix is installed as a user profile, it will also load the nix profile
ensure_nix() {
local nix_profile=$HOME/.nix-profile/etc/profile.d/nix.sh
if type -p nix &>/dev/null; then
return
fi
# shellcheck disable=SC1090
[[ -f "$nix_profile" ]] && source "$nix_profile"
if type -p nix &>/dev/null; then
return
fi
echo "[dev-env] Nix is not installed on your machine." >&2
echo "[dev-env] Run \`bash <(curl -sSfL https://nixos.org/nix/install)\`" >&2
return 1
}
: "${MANPATH:=}" # Nix 2.x profile fails if `set -e` is active otherwise.
ensure_nix || exit 1