Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions nixpkgs_review/nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def nix_shell(
shell = cache_directory.joinpath("shell.nix")
write_shell_expression(shell, attrs, system, nixpkgs_config)
if sandbox:
args = _nix_shell_sandbox(nix_shell, shell)
args = _nix_shell_sandbox(nix_shell, shell, nixpkgs_config)
else:
args = [nix_shell, str(shell)]
if run:
args.extend(["--run", run])
sh(args, cwd=cache_directory, check=False)


def _nix_shell_sandbox(nix_shell: str, shell: Path) -> List[str]:
def _nix_shell_sandbox(nix_shell: str, shell: Path, nixpkgs_config: Path) -> List[str]:
if platform != "linux":
raise RuntimeError("Sandbox mode is only available on Linux platforms.")

Expand Down Expand Up @@ -105,7 +105,7 @@ def tmpfs(path: Union[Path, str], dir: bool = True) -> List[str]:
home = Path.home()
current_dir = Path().absolute()
xdg_config_home = Path(os.environ.get("XDG_CONFIG_HOME", home.joinpath(".config")))
nixpkgs_config = xdg_config_home.joinpath("nixpkgs")
nixpkgs_config_dir = xdg_config_home.joinpath("nixpkgs")
xauthority = Path(os.environ.get("XAUTHORITY", home.joinpath(".Xauthority")))
hub_config = xdg_config_home.joinpath("hub")
gh_config = xdg_config_home.joinpath("gh")
Expand All @@ -121,13 +121,15 @@ def tmpfs(path: Union[Path, str], dir: bool = True) -> List[str]:
*bind("/"),
*bind("/dev", dev=True),
*tmpfs("/tmp"),
# Required for evaluation
*bind(nixpkgs_config),
# /run (also cover sockets for wayland/pulseaudio and pipewires)
*bind(Path("/run/user").joinpath(uid), dev=True, try_=True),
# HOME
*tmpfs(home),
*bind(current_dir, ro=False),
*bind(nixpkgs_review_pr, ro=False),
*bind(nixpkgs_config, try_=True),
*bind(nixpkgs_config_dir, try_=True),
# For X11 applications
*bind("/tmp/.X11-unix", try_=True),
*bind(xauthority, try_=True),
Expand Down