status-react/nix/bootstrapped-shell.nix

33 lines
946 B
Nix
Raw Normal View History

#
# This Nix expression appends/modifies an existing attribute set in order to run scripts/setup if needed,
# as well as define STATUS_REACT_HOME
#
2019-07-19 18:40:03 +00:00
{ stdenv, mkShell, target-os, git }:
let
shell' = shellAttr:
shellAttr // {
nativeBuildInputs = (shellAttr.nativeBuildInputs or []) ++ [ git ];
2019-07-19 18:40:03 +00:00
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'