Skip to content
Closed
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
13 changes: 12 additions & 1 deletion pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,18 @@ def build_flake(
flake.to_attr(attr),
*dict_to_flags(flake_build_flags),
]
r = run_wrapper(run_args, stdout=PIPE, stderr=PIPE if quiet else None)
r = run_wrapper(
run_args,
stdout=PIPE,
stderr=PIPE if quiet else None,
# Running build inside tmpdir thanks to this nasty bug from `nix`
# that happens when `nix build` is run from a symlink pointing to the
# nix store (e.g., /run/opengl-driver/lib)
# See:
# - https://github.com/NixOS/nix/issues/13367
# - https://github.com/NixOS/nixpkgs/issues/144811
cwd=tmpdir.TMPDIR_PATH,
)
return Path(r.stdout.strip())


Expand Down
2 changes: 2 additions & 0 deletions pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import subprocess
from collections.abc import Sequence
from dataclasses import dataclass
from pathlib import Path
from typing import Final, Self, TypedDict, Unpack

from . import tmpdir
Expand Down Expand Up @@ -67,6 +68,7 @@ def _validate_opts(opts: list[str], ask_sudo_password: bool | None) -> None:
# Not exhaustive, but we can always extend it later.
class RunKwargs(TypedDict, total=False):
capture_output: bool
cwd: str | Path | None
stderr: int | None
stdout: int | None

Expand Down
5 changes: 5 additions & 0 deletions pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pytest import MonkeyPatch

import nixos_rebuild as nr
from nixos_rebuild import tmpdir

from .helpers import get_qualified_name

Expand Down Expand Up @@ -409,6 +410,7 @@ def run_side_effect(args: list[str], **kwargs: Any) -> CompletedProcess[str]:
check=True,
stdout=PIPE,
stderr=None,
cwd=tmpdir.TMPDIR_PATH,
**DEFAULT_RUN_KWARGS,
),
call(
Expand Down Expand Up @@ -477,6 +479,7 @@ def run_side_effect(args: list[str], **kwargs: Any) -> CompletedProcess[str]:
check=True,
stdout=PIPE,
stderr=None,
cwd=tmpdir.TMPDIR_PATH,
**DEFAULT_RUN_KWARGS,
),
call(
Expand Down Expand Up @@ -768,6 +771,7 @@ def run_side_effect(args: list[str], **kwargs: Any) -> CompletedProcess[str]:
check=True,
stdout=PIPE,
stderr=None,
cwd=tmpdir.TMPDIR_PATH,
**DEFAULT_RUN_KWARGS,
),
call(
Expand Down Expand Up @@ -1076,6 +1080,7 @@ def run_side_effect(args: list[str], **kwargs: Any) -> CompletedProcess[str]:
check=True,
stdout=PIPE,
stderr=None,
cwd=tmpdir.TMPDIR_PATH,
**DEFAULT_RUN_KWARGS,
),
call(
Expand Down
2 changes: 2 additions & 0 deletions pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def test_build_flake(mock_run: Mock, monkeypatch: MonkeyPatch, tmpdir: Path) ->
],
stdout=PIPE,
stderr=None,
cwd=ANY,
)

assert n.build_flake(
Expand All @@ -98,6 +99,7 @@ def test_build_flake(mock_run: Mock, monkeypatch: MonkeyPatch, tmpdir: Path) ->
],
stdout=PIPE,
stderr=PIPE,
cwd=ANY,
)


Expand Down