Merge branch 'staging-nixos' into staging-next

This commit is contained in:
Vladimír Čunát
2026-07-30 19:29:12 +02:00
9 changed files with 38 additions and 36 deletions

View File

@@ -14,7 +14,6 @@ let
concatStringsSep
mapAttrsToList
toLower
optionalString
literalExpression
match
mkRenamedOptionModule
@@ -34,11 +33,12 @@ let
osReleaseContents =
let
isNixos = cfg.distroId == "nixos";
optionalAttr = cond: attr: if cond then attr else null;
in
{
NAME = "${cfg.distroName}";
ID = "${cfg.distroId}";
ID_LIKE = optionalString (!isNixos) "nixos";
${optionalAttr (!isNixos) "ID_LIKE"} = "nixos";
VENDOR_NAME = cfg.vendorName;
VERSION = "${cfg.release} (${cfg.codeName})";
VERSION_CODENAME = toLower cfg.codeName;
@@ -47,17 +47,16 @@ let
PRETTY_NAME = "${cfg.distroName} ${cfg.release} (${cfg.codeName})";
CPE_NAME = "cpe:/o:${cfg.vendorId}:${cfg.distroId}:${cfg.release}";
LOGO = "nix-snowflake";
HOME_URL = optionalString isNixos "https://nixos.org/";
VENDOR_URL = optionalString isNixos "https://nixos.org/";
DOCUMENTATION_URL = optionalString isNixos "https://nixos.org/learn.html";
SUPPORT_URL = optionalString isNixos "https://nixos.org/community.html";
BUG_REPORT_URL = optionalString isNixos "https://github.com/NixOS/nixpkgs/issues";
ANSI_COLOR = optionalString isNixos "0;38;2;126;186;228";
IMAGE_ID = optionalString (config.system.image.id != null) config.system.image.id;
${if config.system.image.version != null then "IMAGE_VERSION" else null} =
config.system.image.version;
VARIANT = optionalString (cfg.variantName != null) cfg.variantName;
VARIANT_ID = optionalString (cfg.variant_id != null) cfg.variant_id;
${optionalAttr isNixos "HOME_URL"} = "https://nixos.org/";
${optionalAttr isNixos "VENDOR_URL"} = "https://nixos.org/";
${optionalAttr isNixos "DOCUMENTATION_URL"} = "https://nixos.org/learn.html";
${optionalAttr isNixos "SUPPORT_URL"} = "https://nixos.org/community.html";
${optionalAttr isNixos "BUG_REPORT_URL"} = "https://github.com/NixOS/nixpkgs/issues";
${optionalAttr isNixos "ANSI_COLOR"} = "0;38;2;126;186;228";
${optionalAttr (config.system.image.id != null) "IMAGE_ID"} = config.system.image.id;
${optionalAttr (config.system.image.version != null) "IMAGE_VERSION"} = config.system.image.version;
${optionalAttr (cfg.variantName != null) "VARIANT"} = cfg.variantName;
${optionalAttr (cfg.variant_id != null) "VARIANT_ID"} = cfg.variant_id;
DEFAULT_HOSTNAME = config.system.nixos.distroId;
}
// cfg.extraOSReleaseArgs;

View File

@@ -212,8 +212,6 @@ def run(
)
print(
f"systemd-nspawn's PID is {cp.pid}",
# Need to flush stdout before systemd-nspawn gets exec-ed.
flush=True,
)
try:

View File

@@ -86,7 +86,7 @@ def get_parser() -> tuple[argparse.ArgumentParser, dict[str, argparse.ArgumentPa
main_parser = argparse.ArgumentParser(
prog="nixos-rebuild",
parents=list(sub_parsers.values()),
parents=sub_parsers.values(),
description="Reconfigure a NixOS machine",
add_help=False,
allow_abbrev=False,
@@ -260,7 +260,6 @@ def parse_args(
if args.v or args.debug:
logger.setLevel(logging.DEBUG)
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh#L56
if args.action == Action.DRY_RUN.value:
args.action = Action.DRY_BUILD.value

View File

@@ -30,6 +30,8 @@ from .models import (
from .process import run_wrapper, ssh_default_opts
from .utils import Args, dict_to_flags
local_tz: Final = datetime.now().astimezone().tzinfo
FLAKE_FLAGS: Final = ["--extra-experimental-features", "nix-command flakes"]
FLAKE_REPL_TEMPLATE: Final = "repl.nix.template"
SWITCH_TO_CONFIGURATION_CMD_PREFIX: Final = [
@@ -433,9 +435,10 @@ def get_generations(profile: Profile) -> list[Generation]:
def parse_path(path: Path, profile: Profile) -> Generation:
entry_id = path.name.split("-")[1]
current = path.name == profile.path.readlink().name
timestamp = datetime.fromtimestamp(path.stat().st_ctime).strftime(
"%Y-%m-%d %H:%M:%S"
)
timestamp = datetime.fromtimestamp(
timestamp=path.stat().st_ctime,
tz=local_tz,
).strftime("%Y-%m-%d %H:%M:%S")
return Generation(
id=int(entry_id),

View File

@@ -46,8 +46,7 @@ def dict_to_flags(d: Args | None) -> list[str]:
for vs in value:
flags.append(flag)
if isinstance(vs, list):
for v in vs:
flags.append(v)
flags.extend(vs)
else:
flags.append(vs)
case _:

View File

@@ -82,6 +82,10 @@ extend-select = [
# allow Any type
"ANN401"
]
"nixos_rebuild/constants.py" = [
# allow constant comparison since the values are replaced at build-time
"PLR0133"
]
[tool.pytest.ini_options]
pythonpath = ["."]

View File

@@ -993,9 +993,9 @@ def test_execute_nix_switch_flake_build_host(
config_path.touch()
def run_side_effect(args: list[str], **kwargs: Any) -> CompletedProcess[str]:
if args[0] == "nix" and "eval" in args:
return CompletedProcess([], 0, str(config_path))
elif args[0] == "ssh" and "nix" in args:
if (args[0] == "nix" and "eval" in args) or (
args[0] == "ssh" and "nix" in args
):
return CompletedProcess([], 0, str(config_path))
elif args[0] == "nix-instantiate":
return CompletedProcess([], 1)
@@ -1316,9 +1316,7 @@ def test_execute_test_flake(mock_run: Mock, tmp_path: Path) -> None:
def run_side_effect(args: list[str], **kwargs: Any) -> CompletedProcess[str]:
if args[0] == "nix":
return CompletedProcess([], 0, str(config_path))
elif args[0] == "nix-instantiate":
return CompletedProcess([], 1)
elif args[0] == "test":
elif args[0] == "nix-instantiate" or args[0] == "test":
return CompletedProcess([], 1)
else:
return CompletedProcess([], 0)
@@ -1386,9 +1384,9 @@ def test_execute_test_rollback(
2084 2024-11-07 23:54:17 (current)
"""),
)
elif args[0] == "nix-instantiate" and "nixos-system" in args:
return CompletedProcess([], 1)
elif args[0] == "test":
elif (args[0] == "nix-instantiate" and "nixos-system" in args) or args[
0
] == "test":
return CompletedProcess([], 1)
else:
return CompletedProcess([], 0)

View File

@@ -29,8 +29,10 @@ def test_remote_env_shell_argv() -> None:
"sudo",
"/bin/sh",
"-c",
"""exec /usr/bin/env -i PATH="${PATH-}" LOCALE_ARCHIVE="${LOCALE_ARCHIVE-}" """
'''NIXOS_NO_CHECK="${NIXOS_NO_CHECK-}" NIXOS_INSTALL_BOOTLOADER=0 "$@"''',
(
"""exec /usr/bin/env -i PATH="${PATH-}" LOCALE_ARCHIVE="${LOCALE_ARCHIVE-}" """
'''NIXOS_NO_CHECK="${NIXOS_NO_CHECK-}" NIXOS_INSTALL_BOOTLOADER=0 "$@"'''
),
"sh",
"cmd",
"arg",

View File

@@ -17,7 +17,7 @@
rustPlatform.buildRustPackage (finalAttrs: {
pname = "ty";
version = "0.0.64";
version = "0.0.65";
__structuredAttrs = true;
src = fetchFromGitHub {
@@ -25,7 +25,7 @@ rustPlatform.buildRustPackage (finalAttrs: {
repo = "ty";
tag = finalAttrs.version;
fetchSubmodules = true;
hash = "sha256-Czk1MpUzWiSNynUtm+hO3NbU+HGLtBWrNnuo1jy4NvA=";
hash = "sha256-+P0mtnz/syeLk7E6GI5OdocjthDtrdMdCc0BrW+C8UQ=";
};
# For Darwin platforms, remove the integration test for file notifications,
@@ -39,7 +39,7 @@ rustPlatform.buildRustPackage (finalAttrs: {
cargoBuildFlags = [ "--package=ty" ];
cargoHash = "sha256-Jpm6te8+I0Qlq+wA7DIPpIlLoF38pwgChgntKYZY5uc=";
cargoHash = "sha256-dAfb5lDt5v7tuqJGbey1mRrLL+zI7eb8GH1DUAtaaT4=";
nativeBuildInputs = [ installShellFiles ];
buildInputs = [ rust-jemalloc-sys ];