+# Steps
+class NixShellCommand(steps.ShellCommand):
+ def __init__(self, command=None, pure=True, nixfile=None, **kwargs):
+ assert(isinstance(command, str))
+ oldpath = kwargs.get("env", {}).get("PATH", None)
+ if which("nix-shell", path=oldpath) is None:
+ kwargs["env"] = kwargs.get("env", {})
+ if isinstance(oldpath, str):
+ kwargs["env"]["PATH"] = "/run/current-system/sw/bin:" + oldpath
+ elif isinstance(oldpath, list):
+ kwargs["env"]["PATH"] = ["/run/current-system/sw/bin"] + oldpath
+ nixcommand = ["nix-shell"]
+ if pure:
+ nixcommand.append("--pure")
+ nixcommand.append("--run")
+ nixcommand.append(command)
+ if nixfile is not None:
+ nixcommand.append(nixfile)
+ super().__init__(command=nixcommand, **kwargs)
+