Unverified Commit c70c79dd authored by Wolfgang Walther's avatar Wolfgang Walther Committed by GitHub
Browse files

nixos-rebuild-ng: remove conditionals for Nix < 2.18 (#433056)

parents 392a06f5 febce22a
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -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,
@@ -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
+4 −4
Original line number Diff line number Diff line
@@ -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.
+0 −8
Original line number Diff line number Diff line
@@ -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,
@@ -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}

+1 −4
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ from subprocess import CalledProcessError, run
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
@@ -270,9 +270,6 @@ def parse_args(
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"])
+0 −1
Original line number Diff line number Diff line
@@ -6,6 +6,5 @@ from typing import Final
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"
Loading