clan-core/pkgs/clan-cli/clan_cli/nix.py
Jörg Thalheim 83005a6795 cli: use nixpkgs in nix shell in pure mode
This avoids nixpkgs config and overlay provided by the user.
Also enables caching in nix.
2023-07-26 09:31:49 +02:00

11 lines
345 B
Python

import os
def nix_shell(packages: list[str], cmd: list[str]) -> list[str]:
nixpkgs = os.environ.get("CLAN_NIXPKGS")
# in unittest we will have all binaries provided
if nixpkgs is None:
return cmd
wrapped_packages = [f"path:{nixpkgs}#{p}" for p in packages]
return ["nix", "shell"] + wrapped_packages + ["-c"] + cmd