status-react/nix/bootstrapped-shell.nix
Pedro Pombeiro 9594552102
nix: Apply some nixfmt suggestions and fix macOS status-go buildInputs
Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
2019-07-29 18:01:07 +02:00

34 lines
951 B
Nix

#
# This Nix expression appends/modifies an existing attribute set in order to run scripts/setup if needed,
# as well as define STATUS_REACT_HOME
#
{ stdenv, mkShell, target-os, git }:
let
shell' = shellAttr:
shellAttr // {
nativeBuildInputs = (shellAttr.nativeBuildInputs or [ ]) ++ [ git ];
TARGET_OS = target-os;
shellHook = ''
set -e
export STATUS_REACT_HOME=$(git rev-parse --show-toplevel)
${shellAttr.shellHook or ""}
if [ "$IN_NIX_SHELL" != 'pure' ] && [ ! -f $STATUS_REACT_HOME/.ran-setup ]; then
$STATUS_REACT_HOME/scripts/setup
touch $STATUS_REACT_HOME/.ran-setup
fi
set +e
'';
};
# Declare a specialized mkShell function which adds some bootstrapping
# so that e.g. STATUS_REACT_HOME is automatically available in the shell
mkShell' = shellAttr:
(mkShell.override { inherit stdenv; }) (shell' shellAttr);
in mkShell'