From f66b0186dc9764b83ad76f9dcaec341b0f6f83a0 Mon Sep 17 00:00:00 2001 From: Gleb Peregud Date: Sun, 18 Jun 2017 16:17:40 +0200 Subject: [PATCH] erlang: fix rebar3-nix-bootstrap in Erlang < R18. --- .../build-managers/rebar3/rebar3-nix-bootstrap | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap b/pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap index 81257dd8c0c..b839a4a3b09 100755 --- a/pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap +++ b/pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap @@ -180,14 +180,14 @@ make_sure_registry_snapshot_exists(RegistrySnapshot) -> erlang:halt(1) end. --spec gather_required_data_from_the_environment(#data{}) -> {ok, map()}. +-spec gather_required_data_from_the_environment(#data{}) -> {ok, #data{}}. gather_required_data_from_the_environment(ArgData) -> {ok, ArgData#data{ version = guard_env("version") - , erl_libs = os:getenv("ERL_LIBS", []) - , plugins = os:getenv("buildPlugins", []) + , erl_libs = get_env("ERL_LIBS", []) + , plugins = get_env("buildPlugins", []) , root = code:root_dir() , name = guard_env("name") - , compile_ports = nix2bool(os:getenv("compilePorts", "")) + , compile_ports = nix2bool(get_env("compilePorts", "")) , registry_snapshot = guard_env("HEX_REGISTRY_SNAPSHOT")}}. -spec nix2bool(any()) -> boolean(). @@ -196,9 +196,17 @@ nix2bool("1") -> nix2bool("") -> false. +get_env(Name) -> + os:getenv(Name). +get_env(Name, Def) -> + case get_env(Name) of + false -> Def; + Val -> Val + end. + -spec guard_env(string()) -> string(). guard_env(Name) -> - case os:getenv(Name) of + case get_env(Name) of false -> stderr("Expected Environment variable ~s! Are you sure you are " "running in a Nix environment? Either a nix-build, "