Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow access to the nixpkgs overlay in the sandbox #352

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions nixpkgs_review/nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def nix_shell(
build_graph: str,
nix_path: str,
nixpkgs_config: Path,
nixpkgs_overlay: Path,
run: Optional[str] = None,
sandbox: bool = False,
) -> None:
Expand All @@ -58,7 +59,9 @@ 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, nix_path, nixpkgs_config)
args = _nix_shell_sandbox(
nix_shell, shell, nix_path, nixpkgs_config, nixpkgs_overlay
)
else:
args = [nix_shell, str(shell), "--nix-path", nix_path]
if run:
Expand All @@ -67,7 +70,11 @@ def nix_shell(


def _nix_shell_sandbox(
nix_shell: str, shell: Path, nix_path: str, nixpkgs_config: Path
nix_shell: str,
shell: Path,
nix_path: str,
nixpkgs_config: Path,
nixpkgs_overlay: Path,
) -> List[str]:
if platform != "linux":
raise RuntimeError("Sandbox mode is only available on Linux platforms.")
Expand Down Expand Up @@ -126,6 +133,7 @@ def tmpfs(path: Union[Path, str], dir: bool = True) -> List[str]:
*tmpfs("/tmp"),
# Required for evaluation
*bind(nixpkgs_config),
*bind(nixpkgs_overlay),
# /run (also cover sockets for wayland/pulseaudio and pipewires)
*bind(Path("/run/user").joinpath(uid), dev=True, try_=True),
# HOME
Expand Down
1 change: 1 addition & 0 deletions nixpkgs_review/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def start_review(
self.build_graph,
self.builddir.nix_path,
self.nixpkgs_config,
self.builddir.overlay.path,
self.run,
self.sandbox,
)
Expand Down