lol

erlang: fix rebar3-nix-bootstrap in Erlang < R18.

+13 -5
+13 -5
pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap
··· 180 180 erlang:halt(1) 181 181 end. 182 182 183 - -spec gather_required_data_from_the_environment(#data{}) -> {ok, map()}. 183 + -spec gather_required_data_from_the_environment(#data{}) -> {ok, #data{}}. 184 184 gather_required_data_from_the_environment(ArgData) -> 185 185 {ok, ArgData#data{ version = guard_env("version") 186 - , erl_libs = os:getenv("ERL_LIBS", []) 187 - , plugins = os:getenv("buildPlugins", []) 186 + , erl_libs = get_env("ERL_LIBS", []) 187 + , plugins = get_env("buildPlugins", []) 188 188 , root = code:root_dir() 189 189 , name = guard_env("name") 190 - , compile_ports = nix2bool(os:getenv("compilePorts", "")) 190 + , compile_ports = nix2bool(get_env("compilePorts", "")) 191 191 , registry_snapshot = guard_env("HEX_REGISTRY_SNAPSHOT")}}. 192 192 193 193 -spec nix2bool(any()) -> boolean(). ··· 196 196 nix2bool("") -> 197 197 false. 198 198 199 + get_env(Name) -> 200 + os:getenv(Name). 201 + get_env(Name, Def) -> 202 + case get_env(Name) of 203 + false -> Def; 204 + Val -> Val 205 + end. 206 + 199 207 -spec guard_env(string()) -> string(). 200 208 guard_env(Name) -> 201 - case os:getenv(Name) of 209 + case get_env(Name) of 202 210 false -> 203 211 stderr("Expected Environment variable ~s! Are you sure you are " 204 212 "running in a Nix environment? Either a nix-build, "