Skip to main content

Invoke reproducible Nix shells from Python.

Project description

py-nix-shell

Invoke commands sourced from Nix. This is mainly intended for those who vend cli tools inside environments that often support Nix and need to be able to reproducibly invoke those tools.

If folks don't have Nix, it will attempt to run the command anyways, and then provide an information install-error style message (either packages to install or a suggestion to install Nix).

This is a drop-in replacement for subprocess -- so you can substitute your calls from subprocess.<method> to nix_shell.<method>.

If Nix is not installed, this (by default) falls back to a non-Nix shell.

Installation

pip install nix-shell

Usage

import nix_shell

# nix_shell supports existing subprocess commands

# if the command name matches the nixpkgs name, use that
# see https://search.nixos.org/packages for a list of packages
nix_shell.run(["curl", "https://google.com"])

# you can also specify the nix packages to install
nix_shell.run(["curl", "https://google.com"], packages=["curlMinimal"])

# you can also use a dev environment from a flake
nix_shell.run(["curl", "https://google.com"], flake="github:chadac/py-nix-shell#sample-curl-env")

# this supports

It is also possible to specify a common environment to run commands under:

import nix_shell

nix = nix_shell.from_flake("/path/to/my/flake.nix")

nix.run(["curl", "https://google.com"])
nix_shell.mk_shell(packages=["git"])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nix_shell-0.0.3.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nix_shell-0.0.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file nix_shell-0.0.3.tar.gz.

File metadata

  • Download URL: nix_shell-0.0.3.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nix_shell-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c8665b0dd2a11d152422ead7c1618398ffc9d1433202b3f2b2499a67074dff72
MD5 cdf4fae0d1882c0647f1c74d6538b86e
BLAKE2b-256 c9a8d9e6fea35e5bb2d7b49086eb1556f98b587c204d5b518868c4e11019d144

See more details on using hashes here.

Provenance

The following attestation bundles were made for nix_shell-0.0.3.tar.gz:

Publisher: publish.yaml on chadac/py-nix-shell

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nix_shell-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: nix_shell-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nix_shell-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fb86eb690fdc4a3918b151f4d030d8f47890f377fece2d64ec8f56b59034156c
MD5 1af683702dc025f569b4517e8c8888be
BLAKE2b-256 61de8239c0e01c4393bdf3cb7a942c96358fd64569c167ee65ffbd244b74fbde

See more details on using hashes here.

Provenance

The following attestation bundles were made for nix_shell-0.0.3-py3-none-any.whl:

Publisher: publish.yaml on chadac/py-nix-shell

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page