Unverified Commit c06b4ae3 authored by Alyssa Ross's avatar Alyssa Ross Committed by GitHub
Browse files

staging-nixos merge for 2026-03-12 (#499398)

parents fda6d7e7 d518b888
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -104,7 +104,12 @@ in
        description = "Pre-Sleep Actions";
        wantedBy = [ "sleep.target" ];
        before = [ "sleep.target" ];
        script = cfg.powerDownCommands;
        script = ''
          # NixOS pre-sleep script

          # config.powerManagement.powerDownCommands
          ${cfg.powerDownCommands}
        '';
        serviceConfig.Type = "oneshot";
      };

@@ -114,8 +119,14 @@ in
        # Pulled in by post-resume.service above
        after = [ "sleep.target" ];
        script = ''
          # NixOS pre-resume script

          /run/current-system/systemd/bin/systemctl try-restart --no-block post-resume.target

          # config.powerManagement.resumeCommands
          ${cfg.resumeCommands}

          # config.powerManagement.powerUpCommands
          ${cfg.powerUpCommands}
        '';
        serviceConfig.Type = "oneshot";
@@ -130,7 +141,12 @@ in
        before = [
          "shutdown.target"
        ];
        script = cfg.powerDownCommands;
        script = ''
          # NixOS pre-shutdown script

          # config.powerManagement.powerDownCommands
          ${cfg.powerDownCommands}
        '';
        serviceConfig.Type = "oneshot";
        unitConfig.DefaultDependencies = false;
      };
@@ -143,7 +159,12 @@ in
        wantedBy = [ "multi-user.target" ];
        restartIfChanged = false;
        script = ''
          # NixOS post-boot script

          # config.powerManagement.bootCommands
          ${cfg.bootCommands}

          # config.powerManagement.powerUpCommands
          ${cfg.powerUpCommands}
        '';
        serviceConfig = {
+10 −0
Original line number Diff line number Diff line
@@ -852,6 +852,16 @@ in
      };
    };

    # Remove with systemd 259.4
    security.polkit.extraConfig = mkIf config.security.polkit.enable ''
      polkit.addRule(function(action, subject) {
          if (action.id == "org.freedesktop.machine1.register-machine" &&
              subject.user != "root") {
              return polkit.Result.AUTH_ADMIN_KEEP;
          }
      });
    '';

    # run0 is supposed to authenticate the user via polkit and then run a command. Without this next
    # part, run0 would fail to run the command even if authentication is successful and the user has
    # permission to run the command. This next part is only enabled if polkit is enabled because the
+18 −24
Original line number Diff line number Diff line
@@ -193,13 +193,7 @@ def copy_closure(
    Also supports copying a closure from a remote to another remote."""

    sshopts = os.getenv("NIX_SSHOPTS", "")
    # This command is always run locally and needs to keep its own environent
    # while merging NIX_SSHOPTS and SSH_DEFAULT_OPTS together.
    # E.g.: to preserve SSH_AUTH_SOCK
    env = {
        **os.environ,
        "NIX_SSHOPTS": " ".join(filter(lambda x: x, [sshopts, *SSH_DEFAULT_OPTS])),
    }
    env = {"NIX_SSHOPTS": " ".join(filter(lambda x: x, [sshopts, *SSH_DEFAULT_OPTS]))}

    def nix_copy_closure(host: Remote, to: bool) -> None:
        run_wrapper(
@@ -210,7 +204,7 @@ def copy_closure(
                host.host,
                closure,
            ],
            env=env,
            append_local_env=env,
        )

    def nix_copy(to_host: Remote, from_host: Remote) -> None:
@@ -226,7 +220,7 @@ def copy_closure(
                f"ssh://{to_host.host}",
                closure,
            ],
            env=env,
            append_local_env=env,
        )

    match (to_host, from_host):
@@ -724,11 +718,11 @@ def _run_action_with_systemd(

    try:
        _run_action(
            action,
            path_to_config,
            install_bootloader,
            target_host,
            sudo,
            action=action,
            path_to_config=path_to_config,
            install_bootloader=install_bootloader,
            target_host=target_host,
            sudo=sudo,
            prefix=[*SYSTEMD_RUN_CMD_PREFIX, f"--unit={unique_unit_name}"],
        )
    except KeyboardInterrupt:
@@ -767,11 +761,11 @@ def switch_to_configuration(

    if _has_systemd(target_host):
        _run_action_with_systemd(
            action,
            path_to_config,
            install_bootloader,
            target_host,
            sudo,
            action=action,
            path_to_config=path_to_config,
            install_bootloader=install_bootloader,
            target_host=target_host,
            sudo=sudo,
        )
    else:
        logger.debug(
@@ -779,11 +773,11 @@ def switch_to_configuration(
            "not working in target host"
        )
        _run_action(
            action,
            path_to_config,
            install_bootloader,
            target_host,
            sudo,
            action=action,
            path_to_config=path_to_config,
            install_bootloader=install_bootloader,
            target_host=target_host,
            sudo=sudo,
        )


+7 −1
Original line number Diff line number Diff line
@@ -235,6 +235,7 @@ def run_wrapper(
    *,
    check: bool = True,
    env: Mapping[str, EnvValue] | None = None,
    append_local_env: Mapping[str, str] | None = None,
    remote: Remote | None = None,
    sudo: bool = False,
    **kwargs: Unpack[RunKwargs],
@@ -245,12 +246,17 @@ def run_wrapper(
    )

    logger.debug(
        "calling run with args=%r, kwargs=%r, env=%r",
        "calling run with args=%r, kwargs=%r, env=%r, append_local_env=%r",
        _sanitize_env_run_args(list(final_args)),
        kwargs,
        env,
        append_local_env,
    )

    if append_local_env:
        popen_env = dict(os.environ) if popen_env is None else dict(popen_env)
        popen_env.update(append_local_env)

    try:
        r = subprocess.run(
            final_args,
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ nixos-rebuild = "nixos_rebuild:main"
nixos_rebuild = ["*.nix.template"]

[tool.mypy]
files = ["nixos_rebuild", "tests"]
# `--strict` config, but explicit options to avoid breaking build when mypy is
# updated
warn_unused_configs = true
Loading