Skip to content
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
7 changes: 3 additions & 4 deletions pkgs/by-name/ni/nixos-rebuild-ng/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ not possible to fix, please open an issue and we can discuss a solution.
your password wrong, it will fail during activation (this can be improved
though)
- When `--build-host` and `--target-host` are used together, we will use `nix
copy` (or 2 `nix-copy-closure` if you're using Nix <2.18) instead of SSH'ing
to build host and using `nix-copy-closure --to target-host`. The reason for
this is documented in PR
copy` instead of SSH'ing to build host and using
`nix-copy-closure --to target-host`. The reason for this is documented in PR
[#364698](https://github.com/NixOS/nixpkgs/pull/364698). If you do need the
previous behavior, you can simulate it using `ssh build-host --
nixos-rebuild-ng switch --target-host target-host`. If that is not the case,
Expand Down Expand Up @@ -119,7 +118,7 @@ not possible to fix, please open an issue and we can discuss a solution.
and there was a need to bootstrap a new version of Nix before evaluating the
configuration (otherwise the new Nixpkgs version may have code that is only
compatible with a newer version of Nix). Nixpkgs now has a policy to be
compatible with Nix 2.3, and even if this is bumped as long we don't do
compatible with Nix 2.18, and even if this is bumped as long we don't do
drastic minimum version changes this should not be an issue. Also, the daemon
itself always run with the previous version since even we can replace Nix in
`PATH` (so Nix client), but we can't replace the daemon without switching to
Expand Down
8 changes: 4 additions & 4 deletions pkgs/by-name/ni/nixos-rebuild-ng/nixos-rebuild.8.scd
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ It must be one of the following:

*--use-substitutes*
When set, nixos-rebuild will add *--use-substitutes* to each invocation
of _nix-copy-closure_/_nix copy_. This will only affect the behavior of
nixos-rebuild if *--target-host* or *--build-host* is also set. This is
useful when the target-host connection to cache.nixos.org is faster than
the connection between hosts.
of _nix copy_. This will only affect the behavior of nixos-rebuild if
*--target-host* or *--build-host* is also set. This is useful when the
target-host connection to cache.nixos.org is faster than the connection
between hosts.

*--sudo*
When set, *nixos-rebuild* prefixes activation commands with sudo.
Expand Down
8 changes: 0 additions & 8 deletions pkgs/by-name/ni/nixos-rebuild-ng/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
# Very long tmp dirs lead to "too long for Unix domain socket"
# SSH ControlPath errors. Especially macOS sets long TMPDIR paths.
withTmpdir ? if stdenv.hostPlatform.isDarwin then "/tmp" else null,
# This version is kind of arbitrary, we use some features that were
# implemented in newer versions of Nix, but not necessary 2.18.
# However, Lix is a fork of Nix 2.18, so this looks like a good version
# to cut specific functionality.
# ATTN: This currently doesn't disambiguate between Nix and Lix, so using this
# in a conditional needs careful checking against both Nix implementations.
withNix218 ? lib.versionAtLeast nix.version "2.18",
# passthru.tests
nixosTests,
nixVersions,
Expand Down Expand Up @@ -62,7 +55,6 @@ python3Packages.buildPythonApplication rec {
postPatch = ''
substituteInPlace nixos_rebuild/constants.py \
--subst-var-by executable ${executable} \
--subst-var-by withNix218 ${lib.boolToString withNix218} \
--subst-var-by withReexec ${lib.boolToString withReexec} \
--subst-var-by withShellFiles ${lib.boolToString withShellFiles}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Final, assert_never

from . import nix, services
from .constants import EXECUTABLE, WITH_NIX_2_18, WITH_REEXEC, WITH_SHELL_FILES
from .constants import EXECUTABLE, WITH_REEXEC, WITH_SHELL_FILES
from .models import Action, BuildAttr, Flake, Profile
from .process import Remote
from .utils import LogFormatter
Expand Down Expand Up @@ -270,9 +270,6 @@ def parser_warn(msg: str) -> None:
def execute(argv: list[str]) -> None:
args, args_groups = parse_args(argv)

if not WITH_NIX_2_18:
logger.warning("you're using Nix <2.18, some features will not work correctly")

common_flags = vars(args_groups["common_flags"])
common_build_flags = common_flags | vars(args_groups["common_build_flags"])
build_flags = common_build_flags | vars(args_groups["classic_build_flags"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
EXECUTABLE: Final[str] = "@executable@"
# Use either `== "true"` if the default (e.g.: `python -m nixos_rebuild`) is
# `False` or `!= "false"` if the default is `True`
WITH_NIX_2_18: Final[bool] = "@withNix218@" != "false"
WITH_REEXEC: Final[bool] = "@withReexec@" == "true"
WITH_SHELL_FILES: Final[bool] = "@withShellFiles@" == "true"
14 changes: 1 addition & 13 deletions pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from typing import Final, Literal

from . import tmpdir
from .constants import WITH_NIX_2_18
from .models import (
Action,
BuildAttr,
Expand Down Expand Up @@ -228,18 +227,7 @@ def nix_copy(to_host: Remote, from_host: Remote) -> None:
case (Remote(_) as host, None) | (None, Remote(_) as host):
nix_copy_closure(host, to=bool(to_host))
case (Remote(_), Remote(_)):
if WITH_NIX_2_18:
# With newer Nix, use `nix copy` instead of `nix-copy-closure`
# since it supports `--to` and `--from` at the same time
# TODO: once we drop Nix 2.3 from nixpkgs, remove support for
# `nix-copy-closure`
nix_copy(to_host, from_host)
else:
# With older Nix, we need to copy from to local and local to
# host. This means it is slower and need additional disk space
# in local
nix_copy_closure(from_host, to=False)
nix_copy_closure(to_host, to=True)
nix_copy(to_host, from_host)


def edit() -> None:
Expand Down
5 changes: 0 additions & 5 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 @@ -10,7 +10,6 @@
import pytest

import nixos_rebuild as nr
from nixos_rebuild.constants import WITH_NIX_2_18

from .helpers import get_qualified_name

Expand Down Expand Up @@ -450,10 +449,6 @@ def run_side_effect(args: list[str], **kwargs: Any) -> CompletedProcess[str]:
@patch("subprocess.run", autospec=True)
@patch("uuid.uuid4", autospec=True)
@patch(get_qualified_name(nr.services.cleanup_ssh), autospec=True)
@pytest.mark.skipif(
not WITH_NIX_2_18,
reason="Tests internal logic based on the assumption that Nix >= 2.18",
)
def test_execute_nix_switch_build_target_host(
mock_cleanup_ssh: Mock,
mock_uuid4: Mock,
Expand Down
17 changes: 0 additions & 17 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 @@ -254,7 +254,6 @@ def test_copy_closure(monkeypatch: MonkeyPatch) -> None:
)

monkeypatch.setenv("NIX_SSHOPTS", "--ssh build-target-opt")
monkeypatch.setattr(n, "WITH_NIX_2_18", True)
extra_env = {
"NIX_SSHOPTS": " ".join([*p.SSH_DEFAULT_OPTS, "--ssh build-target-opt"])
}
Expand All @@ -276,22 +275,6 @@ def test_copy_closure(monkeypatch: MonkeyPatch) -> None:
extra_env=extra_env,
)

monkeypatch.setattr(n, "WITH_NIX_2_18", False)
with patch(get_qualified_name(n.run_wrapper, n), autospec=True) as mock_run:
n.copy_closure(closure, target_host, build_host)
mock_run.assert_has_calls(
[
call(
["nix-copy-closure", "--from", "user@build.host", closure],
extra_env=extra_env,
),
call(
["nix-copy-closure", "--to", "user@target.host", closure],
extra_env=extra_env,
),
]
)


@patch(get_qualified_name(n.run_wrapper, n), autospec=True)
def test_edit(mock_run: Mock, monkeypatch: MonkeyPatch, tmpdir: Path) -> None:
Expand Down
Loading