Open shackra opened 1 week ago
Invoke has a great way to override configuration which can be triggered by a file or an environment variable. You can run invoke with the -d
flag for debug information and you can determine where that file would be located in your nix environment or if your INVOKE_XXX_YYY variable is being picked.
Particularly for the shell, you can simply set the INVOKE_RUN_SHELL variable
I haven't found a way to run pip from nix-shell
to demonstrate this but you can use uv
to test this.
export INVOKE_RUN_SHELL=/run/current-system/sw/bin/bash
echo '
from invoke import task
from invoke.context import Context
from invoke.collection import Collection
from invoke.program import Program
import os
@task(default=True)
def show_me_config(ctx: Context):
for key, value in dict(ctx.config.run).items():
env_var = f'INVOKE_RUN_{key.upper()}'
changed = '✅' if env_var in os.environ else f'💡 change with {env_var}'
print(f"{key}={value} ({changed})")
ns = Collection()
ns.add_task(show_me_config)
p = Program("test", ns)
p.run()
' | uv run --with invoke -
The output should be something like:
asynchronous=False (💡 change with INVOKE_RUN_ASYNCHRONOUS)
disown=False (💡 change with INVOKE_RUN_DISOWN)
dry=False (💡 change with INVOKE_RUN_DRY)
echo=False (💡 change with INVOKE_RUN_ECHO)
echo_stdin=None (💡 change with INVOKE_RUN_ECHO_STDIN)
encoding=None (💡 change with INVOKE_RUN_ENCODING)
env=<DataProxy: {}> (💡 change with INVOKE_RUN_ENV)
err_stream=None (💡 change with INVOKE_RUN_ERR_STREAM)
fallback=True (💡 change with INVOKE_RUN_FALLBACK)
hide=None (💡 change with INVOKE_RUN_HIDE)
in_stream=None (💡 change with INVOKE_RUN_IN_STREAM)
out_stream=None (💡 change with INVOKE_RUN_OUT_STREAM)
echo_format={command} (💡 change with INVOKE_RUN_ECHO_FORMAT)
pty=False (💡 change with INVOKE_RUN_PTY)
replace_env=False (💡 change with INVOKE_RUN_REPLACE_ENV)
shell=/run/current-system/sw/bin/bash (✅)
warn=False (💡 change with INVOKE_RUN_WARN)
watchers=[] (💡 change with INVOKE_RUN_WATCHERS)
Note: Only primitive types can be overridden in this way (int
, bool
, str
, but not list
or dict
)
On NixOS this package is completely useless and also sabotages the usage of other packages that depend on it to function.
On NixOS bash is located here: