r-darwish / topgrade

Upgrade everything
GNU General Public License v3.0
3.35k stars 160 forks source link

Nix-darwin was detected as NixOS #965

Open XYenon opened 2 years ago

XYenon commented 2 years ago

What did you expect to happen?

Do not run nixos-rebuild switch or run darwin-rebuild switch

What actually happened?

image

https://github.com/r-darwish/topgrade/blob/f390f2edbe74d1f1c635564efdf61a1dd4dd654b/src/steps/os/unix.rs#L268-L275

Additional details

 2022-07-01T06:32:56.800Z DEBUG topgrade::config > Configuration at /Users/xyenon/.config/topgrade.toml
 2022-07-01T06:32:56.800Z DEBUG topgrade::config > Loaded configuration: ConfigFile { pre_commands: Some({}), post_commands: None, commands: Some({}), git_repos: None, predefined_git_repos: None, disable: Some([Pip3, Node]), ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, git_arguments: None, tmux_arguments: None, set_title: None, assume_yes: None, yay_arguments: None, no_retry: None, run_in_tmux: None, cleanup: Some(true), notify_each_step: None, accept_all_windows_updates: None, bashit_branch: None, only: None, composer: Some(Composer { self_update: None }), brew: Some(Brew { greedy_cask: None }), linux: Some(Linux { yay_arguments: None, arch_package_manager: None, show_arch_news: None, trizen_arguments: None, dnf_arguments: None, apt_arguments: None, enable_tlmgr: None, redhat_distro_sync: None, rpm_ostree: None, emerge_sync_flags: None, emerge_update_flags: None }), git: Some(Git { max_concurrency: None, arguments: None, repos: None, pull_predefined: None }), windows: Some(Windows { accept_all_updates: None, self_rename: None, open_remotes_in_new_terminal: None }), npm: Some(NPM { use_sudo: None }), vim: None, firmware: Some(Firmware { upgrade: None }), vagrant: None, flatpak: Some(Flatpak { use_sudo: None }) }
 2022-07-01T06:32:56.800Z DEBUG topgrade         > Version: 8.1.2
 2022-07-01T06:32:56.800Z DEBUG topgrade         > OS: x86_64-apple-darwin
 2022-07-01T06:32:56.800Z DEBUG topgrade         > Args { inner: ["topgrade", "-v"] }
 2022-07-01T06:32:56.800Z DEBUG topgrade         > Binary path: Ok("/run/current-system/sw/bin/topgrade")
 2022-07-01T06:32:56.800Z DEBUG topgrade         > Self Update: false
 2022-07-01T06:32:56.801Z DEBUG topgrade::utils  > Detected "/usr/bin/git" as "git"
 2022-07-01T06:32:56.801Z DEBUG topgrade::utils  > Cannot find "doas"
 2022-07-01T06:32:56.802Z DEBUG topgrade::utils  > Detected "/usr/bin/sudo" as "sudo"
 2022-07-01T06:32:56.802Z DEBUG topgrade::utils  > Cannot find "pwsh"
 2022-07-01T06:32:56.802Z DEBUG topgrade::utils  > Cannot find "powershell"
 2022-07-01T06:32:56.802Z DEBUG topgrade::runner > Step "Brew (ARM)"
 2022-07-01T06:32:56.803Z DEBUG topgrade::runner > Step "Brew (Intel)"
 2022-07-01T06:32:56.803Z DEBUG topgrade::utils  > Detected "/usr/local/bin/brew" as "/usr/local/bin/brew"

―― 14:32:56 - Brew ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
 2022-07-01T06:32:56.804Z DEBUG topgrade::executor > Running "/usr/local/bin/brew" "update"
Already up-to-date.
 2022-07-01T06:33:03.293Z DEBUG topgrade::executor > Running "/usr/local/bin/brew" "upgrade" "--ignore-pinned" "--formula"
 2022-07-01T06:33:07.571Z DEBUG topgrade::executor > Running "/usr/local/bin/brew" "cleanup"
 2022-07-01T06:33:18.173Z DEBUG topgrade::runner   > Step "Brew Cask (ARM)"
 2022-07-01T06:33:18.174Z DEBUG topgrade::runner   > Step "Brew Cask (Intel)"
 2022-07-01T06:33:18.174Z DEBUG topgrade::utils    > Detected "/usr/local/bin/brew" as "/usr/local/bin/brew"

―― 14:33:18 - Brew - Cask ――――――――――――――――――――――――――――――――――――――――――――――――――――――
 2022-07-01T06:33:22.110Z DEBUG topgrade::executor > Running "/usr/local/bin/brew" "upgrade" "--cask"
 2022-07-01T06:33:26.244Z DEBUG topgrade::executor > Running "/usr/local/bin/brew" "cleanup"
 2022-07-01T06:33:37.128Z DEBUG topgrade::runner   > Step "MacPorts"
 2022-07-01T06:33:37.129Z DEBUG topgrade::runner   > Step "yadm"
 2022-07-01T06:33:37.129Z DEBUG topgrade::runner   > Step "nix"
 2022-07-01T06:33:37.130Z DEBUG topgrade::utils    > Detected "/run/current-system/sw/bin/nix" as "nix"
 2022-07-01T06:33:37.130Z DEBUG topgrade::utils    > Detected "/run/current-system/sw/bin/nix-channel" as "nix-channel"
 2022-07-01T06:33:37.130Z DEBUG topgrade::utils    > Detected "/run/current-system/sw/bin/nix-env" as "nix-env"

―― 14:33:37 - Nix ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
 2022-07-01T06:33:37.130Z DEBUG topgrade::steps::os::unix > Multi user nix: true
 2022-07-01T06:33:37.130Z DEBUG topgrade::executor        > Running "/usr/bin/sudo" "-i" "nix" "upgrade-nix"
error: Nix on NixOS must be upgraded via 'nixos-rebuild'
 2022-07-01T06:33:37.465Z DEBUG topgrade::runner          > Step "nix" failed: exit status: 1
 2022-07-01T06:33:37.465Z DEBUG topgrade::terminal        > Desktop notification: nix failed

Retry? (y)es/(N)o/(s)hell
XYenon commented 2 years ago

I found that this error was raised by nix when running sudo -i nix upgrade-nix. So I think maybe topgrade should do the same thing, just skip this step, on NixOS and nix-darwin.