Skip to content

Commit

Permalink
Merge pull request #52 from imincik/prepare-shell
Browse files Browse the repository at this point in the history
modules: add internal prepareShell option
  • Loading branch information
imincik authored May 29, 2024
2 parents 8f5bd1e + 27c6773 commit 7662e05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules/languages/python.nix
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ in
POETRY_VIRTUALENVS_PATH = "/var/empty";
};

enterShell = lib.concatStringsSep "\n" ([
prepareShell = lib.concatStringsSep "\n" ([
''
export PYTHONPATH="$DEVENV_PROFILE/${cfg.package.sitePackages}''${PYTHONPATH:+:$PYTHONPATH}"
''
Expand Down
19 changes: 12 additions & 7 deletions modules/top-level.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ in
default = [ ];
};

prepareShell = lib.mkOption {
type = types.lines;
internal = true;
description = ''
This option allows modules to execute bash code when entering the shell,
but this code runs before any user defined `enterShell` code is
executed.
'';
default = "";
};

shell = lib.mkOption {
type = types.package;
internal = true;
Expand Down Expand Up @@ -181,12 +192,6 @@ in
export DIRENV_ACTIVE="$PWD:''${DIRENV_ACTIVE-}"
fi
# devenv helper
if [ ! type -p direnv &>/dev/null && -f .envrc ]; then
echo "You have .envrc but direnv command is not installed."
echo "Please install direnv: https://direnv.net/docs/installation.html"
fi
mkdir -p .devenv
rm -f .devenv/profile
ln -s ${profile} .devenv/profile
Expand All @@ -197,7 +202,7 @@ in
name = "devenv-shell";
env = config.env;
profile = profile;
shellHook = config.enterShell;
shellHook = config.prepareShell + config.enterShell;
debug = config.devenv.debug;
}
);
Expand Down

0 comments on commit 7662e05

Please sign in to comment.