package: return from shellHook correctly
If our shellHook is being run from a nested nix-shell (see 7a12bc200¹), then (I think) it is run from a bash function due to the nesting, then `return` is correct. If its `eval`'d though, then there isn't really a correct way to early exit. So we can just unconditionally be executed in a function. Basically, we have IIFE at home. [1]:7a12bc2007
Change-Id:Iacad25cbbf66cde2911604e6061e56ad6212af7e
This commit is contained in:
parent
68937f2b64
commit
eac3546d50
48
package.nix
48
package.nix
|
@ -441,32 +441,36 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
# don't re-run the hook in (other) nested nix-shells
|
# don't re-run the hook in (other) nested nix-shells
|
||||||
if [[ $name != lix-shell-env ]]; then
|
function lixShellHook() {
|
||||||
return;
|
if [[ $name != lix-shell-env ]]; then
|
||||||
fi
|
return;
|
||||||
|
fi
|
||||||
|
|
||||||
PATH=$prefix/bin:$PATH
|
PATH=$prefix/bin:$PATH
|
||||||
unset PYTHONPATH
|
unset PYTHONPATH
|
||||||
export MANPATH=$out/share/man:$MANPATH
|
export MANPATH=$out/share/man:$MANPATH
|
||||||
|
|
||||||
# Make bash completion work.
|
# Make bash completion work.
|
||||||
XDG_DATA_DIRS+=:$out/share
|
XDG_DATA_DIRS+=:$out/share
|
||||||
|
|
||||||
${lib.optionalString (pre-commit-checks ? shellHook) pre-commit-checks.shellHook}
|
${lib.optionalString (pre-commit-checks ? shellHook) pre-commit-checks.shellHook}
|
||||||
# Allow `touch .nocontribmsg` to turn this notice off.
|
# Allow `touch .nocontribmsg` to turn this notice off.
|
||||||
if ! [[ -f .nocontribmsg ]]; then
|
if ! [[ -f .nocontribmsg ]]; then
|
||||||
cat ${contribNotice}
|
cat ${contribNotice}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install the Gerrit commit-msg hook.
|
# Install the Gerrit commit-msg hook.
|
||||||
# (git common dir is the main .git, including for worktrees)
|
# (git common dir is the main .git, including for worktrees)
|
||||||
if gitcommondir=$(git rev-parse --git-common-dir 2>/dev/null) && [[ ! -f "$gitcommondir/hooks/commit-msg" ]]; then
|
if gitcommondir=$(git rev-parse --git-common-dir 2>/dev/null) && [[ ! -f "$gitcommondir/hooks/commit-msg" ]]; then
|
||||||
echo 'Installing Gerrit commit-msg hook (adds Change-Id to commit messages)' >&2
|
echo 'Installing Gerrit commit-msg hook (adds Change-Id to commit messages)' >&2
|
||||||
mkdir -p "$gitcommondir/hooks"
|
mkdir -p "$gitcommondir/hooks"
|
||||||
curl -s -Lo "$gitcommondir/hooks/commit-msg" https://gerrit.lix.systems/tools/hooks/commit-msg
|
curl -s -Lo "$gitcommondir/hooks/commit-msg" https://gerrit.lix.systems/tools/hooks/commit-msg
|
||||||
chmod u+x "$gitcommondir/hooks/commit-msg"
|
chmod u+x "$gitcommondir/hooks/commit-msg"
|
||||||
fi
|
fi
|
||||||
unset gitcommondir
|
unset gitcommondir
|
||||||
|
}
|
||||||
|
|
||||||
|
lixShellHook
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue