Skip to content

wrap-nix-shell - run a packaged Nix program with its dependencies installed

[Home | GitLab | PyPI | ReadTheDocs]

Overview

The wrap-nix-shell command-line tool runs nix-shell to install some packages and run a program. It is intended to be the target of a symbolic link, and it uses the name of the symlink as the name of the program to run and, unless otherwise configured, the name of the single package to install it from.

After wrap-nix-shell has been installed, set up a symbolic link pointing to it in a directory that is in the default search path:

ln -s -- /path/to/wrap-nix-shell "$HOME/bin/cargo"

Configuration

The wrap-nix-shell tool looks for a wrap-nix-shell.toml configuration file in the application's configuration directory (e.g. $HOME/.config/wrap-nix-shell/wrap-nix-shell.toml by default on Unix-like systems). The configuration file must contain a format.version section with major and minor fields; currently the only format supported is at version 1.0.

The wrap table in the configuration file contains per-program overrides; currently the pure, keep, and packages values may be overriden, and a command to override the program name may be specified:

[format.version]
major = 1
minor = 0

# Make sure Rust programs may be compiled and analyzed.
[wrap.cargo]
packages = ["cargo", "rustc", "rustfmt", "clippy"]

# A program called "something" that should have access to non-Nix
# environment settings, e.g. other programs in the search path.
[wrap.something]
pure = false

# Run a Python 3.10 interpreter if invoked as `py310`.
# Run in pure mode by default, but preserve the `PYTHONPATH` environment
# variable if specified.
[wrap.py310]
packages = ["python310"]
keep = ["PYTHONPATH"]
command = "python3"

Contact

The wrap-nix-shell library was written by Peter Pentchev. It is developed in a GitLab repository. This documentation is hosted at Ringlet with a copy at ReadTheDocs.