Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/constants.py +1 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ # Use strings to avoid breaking standalone (e.g.: `python -m nixos_rebuild`) # usage EXECUTABLE = "@executable@" # Use either `== "true"` if the default (e.g.: `python -m nixos_rebuld`) is # 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 = "@withNix218@" != "false" # type: ignore WITH_REEXEC = "@withReexec@" == "true" # type: ignore Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/models.py +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ type ImageVariants = dict[str, str] class NRError(Exception): "nixos-rebuild general error." def __init__(self, message: str): def __init__(self, message: str) -> None: self.message = message @override Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py +5 −5 Original line number Diff line number Diff line Loading @@ -433,14 +433,14 @@ def list_generations(profile: Profile) -> list[GenerationJson]: ) try: nixos_version = (generation_path / "nixos-version").read_text().strip() except IOError as ex: except OSError as ex: logger.debug("could not get nixos-version: %s", ex) nixos_version = "Unknown" try: kernel_version = next( (generation_path / "kernel-modules/lib/modules").iterdir() ).name except IOError as ex: except OSError as ex: logger.debug("could not get kernel version: %s", ex) kernel_version = "Unknown" specialisations = [ Loading @@ -451,7 +451,7 @@ def list_generations(profile: Profile) -> list[GenerationJson]: [generation_path / "sw/bin/nixos-version", "--configuration-revision"], capture_output=True, ).stdout.strip() except (CalledProcessError, IOError) as ex: except (OSError, CalledProcessError) as ex: logger.debug("could not get configuration revision: %s", ex) configuration_revision = "Unknown" Loading Loading @@ -583,7 +583,7 @@ def switch_to_configuration( ) def upgrade_channels(all: bool = False) -> None: def upgrade_channels(all_channels: bool = False) -> None: """Upgrade channels for classic Nix. It will either upgrade just the `nixos` channel (including any channel Loading @@ -591,7 +591,7 @@ def upgrade_channels(all: bool = False) -> None: """ for channel_path in Path("/nix/var/nix/profiles/per-user/root/channels/").glob("*"): if channel_path.is_dir() and ( all all_channels or channel_path.name == "nixos" or (channel_path / ".update-on-nixos-rebuild").exists() ): Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py +5 −4 Original line number Diff line number Diff line Loading @@ -3,9 +3,10 @@ import logging import os import shlex import subprocess from collections.abc import Sequence from dataclasses import dataclass from getpass import getpass from typing import Final, Self, Sequence, TypedDict, Unpack from typing import Final, Self, TypedDict, Unpack from . import tmpdir Loading Loading @@ -91,7 +92,7 @@ def run_wrapper( ) -> subprocess.CompletedProcess[str]: "Wrapper around `subprocess.run` that supports extra functionality." env = None input = None process_input = None if remote: if extra_env: extra_env_args = [f"{env}={value}" for env, value in extra_env.items()] Loading @@ -99,7 +100,7 @@ def run_wrapper( if sudo: if remote.sudo_password: args = ["sudo", "--prompt=", "--stdin", *args] input = remote.sudo_password + "\n" process_input = remote.sudo_password + "\n" else: args = ["sudo", *args] args = [ Loading Loading @@ -132,7 +133,7 @@ def run_wrapper( args, check=check, env=env, input=input, input=process_input, # Hope nobody is using NixOS with non-UTF8 encodings, but "surrogateescape" # should still work in those systems. text=True, Loading pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/utils.py +3 −3 Original line number Diff line number Diff line import logging from collections.abc import Mapping, Sequence from typing import Any, assert_never, override from typing import Any, ClassVar, assert_never, override type Arg = bool | str | list[str] | list[list[str]] | int | None type Args = dict[str, Arg] class LogFormatter(logging.Formatter): formatters = { formatters: ClassVar = { logging.INFO: logging.Formatter("%(message)s"), logging.DEBUG: logging.Formatter("%(levelname)s: %(name)s: %(message)s"), "DEFAULT": logging.Formatter("%(levelname)s: %(message)s"), Loading Loading @@ -37,7 +37,7 @@ def dict_to_flags(d: Args | None) -> list[str]: case int() if len(key) == 1: flags.append(f"-{key * value}") case int(): for i in range(value): for _ in range(value): flags.append(flag) case str(): flags.append(flag) Loading Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/constants.py +1 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ # Use strings to avoid breaking standalone (e.g.: `python -m nixos_rebuild`) # usage EXECUTABLE = "@executable@" # Use either `== "true"` if the default (e.g.: `python -m nixos_rebuld`) is # 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 = "@withNix218@" != "false" # type: ignore WITH_REEXEC = "@withReexec@" == "true" # type: ignore Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/models.py +1 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ type ImageVariants = dict[str, str] class NRError(Exception): "nixos-rebuild general error." def __init__(self, message: str): def __init__(self, message: str) -> None: self.message = message @override Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/nix.py +5 −5 Original line number Diff line number Diff line Loading @@ -433,14 +433,14 @@ def list_generations(profile: Profile) -> list[GenerationJson]: ) try: nixos_version = (generation_path / "nixos-version").read_text().strip() except IOError as ex: except OSError as ex: logger.debug("could not get nixos-version: %s", ex) nixos_version = "Unknown" try: kernel_version = next( (generation_path / "kernel-modules/lib/modules").iterdir() ).name except IOError as ex: except OSError as ex: logger.debug("could not get kernel version: %s", ex) kernel_version = "Unknown" specialisations = [ Loading @@ -451,7 +451,7 @@ def list_generations(profile: Profile) -> list[GenerationJson]: [generation_path / "sw/bin/nixos-version", "--configuration-revision"], capture_output=True, ).stdout.strip() except (CalledProcessError, IOError) as ex: except (OSError, CalledProcessError) as ex: logger.debug("could not get configuration revision: %s", ex) configuration_revision = "Unknown" Loading Loading @@ -583,7 +583,7 @@ def switch_to_configuration( ) def upgrade_channels(all: bool = False) -> None: def upgrade_channels(all_channels: bool = False) -> None: """Upgrade channels for classic Nix. It will either upgrade just the `nixos` channel (including any channel Loading @@ -591,7 +591,7 @@ def upgrade_channels(all: bool = False) -> None: """ for channel_path in Path("/nix/var/nix/profiles/per-user/root/channels/").glob("*"): if channel_path.is_dir() and ( all all_channels or channel_path.name == "nixos" or (channel_path / ".update-on-nixos-rebuild").exists() ): Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/process.py +5 −4 Original line number Diff line number Diff line Loading @@ -3,9 +3,10 @@ import logging import os import shlex import subprocess from collections.abc import Sequence from dataclasses import dataclass from getpass import getpass from typing import Final, Self, Sequence, TypedDict, Unpack from typing import Final, Self, TypedDict, Unpack from . import tmpdir Loading Loading @@ -91,7 +92,7 @@ def run_wrapper( ) -> subprocess.CompletedProcess[str]: "Wrapper around `subprocess.run` that supports extra functionality." env = None input = None process_input = None if remote: if extra_env: extra_env_args = [f"{env}={value}" for env, value in extra_env.items()] Loading @@ -99,7 +100,7 @@ def run_wrapper( if sudo: if remote.sudo_password: args = ["sudo", "--prompt=", "--stdin", *args] input = remote.sudo_password + "\n" process_input = remote.sudo_password + "\n" else: args = ["sudo", *args] args = [ Loading Loading @@ -132,7 +133,7 @@ def run_wrapper( args, check=check, env=env, input=input, input=process_input, # Hope nobody is using NixOS with non-UTF8 encodings, but "surrogateescape" # should still work in those systems. text=True, Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/nixos_rebuild/utils.py +3 −3 Original line number Diff line number Diff line import logging from collections.abc import Mapping, Sequence from typing import Any, assert_never, override from typing import Any, ClassVar, assert_never, override type Arg = bool | str | list[str] | list[list[str]] | int | None type Args = dict[str, Arg] class LogFormatter(logging.Formatter): formatters = { formatters: ClassVar = { logging.INFO: logging.Formatter("%(message)s"), logging.DEBUG: logging.Formatter("%(levelname)s: %(name)s: %(message)s"), "DEFAULT": logging.Formatter("%(levelname)s: %(message)s"), Loading Loading @@ -37,7 +37,7 @@ def dict_to_flags(d: Args | None) -> list[str]: case int() if len(key) == 1: flags.append(f"-{key * value}") case int(): for i in range(value): for _ in range(value): flags.append(flag) case str(): flags.append(flag) Loading