dustinlyons/nixos-config

How to upgrade everything installed (Mac OSX Sonoma)?

Closed this issue · 6 comments

Hi!

I have seen the video posted in the README about updating "dependencies" with one command. I am not sure the video is updated neither that this instruction will upgrade my installed packages.

  • I use to do a nix flake update, then I use git add . (if I changed anything in my config), followed by nix run .#build-switch.
  • I don't have a ./bin/ build file/directory. Is this somehow related to #40 ? Is the video oudated? I have a apps/aarch64-darwin/build and apps/aarch64-darwin/build-switch scripts though. Are these the ones that are supposed to upgrade my installed packages? It doesn't seem they are upgrading my packages (at least not the ones installed by using homebrew declaratively).
  • I did a brew upgrade && brew update && brew update --cask && brew cleanup and it DID upgraded a bunch of outdated packages, that I have installed via nix-homebrew and related.

Lastly, how can I clean up/collect some of the garbage that could be outdated in my installation, just like I would do in a NixOS installation?

Hi, the video is out of date. I just moved the script to run under nix run .#build-switch.

Nix is self-contained, it only knows about what is defined in flake.nix. So if you're running brew commands Nix will have no knowledge of those. Adversely, it will mutate your system in a way that is not conducive to Nix (being self contained, defined by a flake.nix declaration). So you'll see weird behavior.

If you want to use Nix and brew, let Nix manage brew for you (like this config).

There is a big "leap" in Nix in that you're moving from imperative commands (typing commands into your terminal to do something), to defining what you're configuration should be and letting Nix do it for you (nix flake update; nix run .#build-switch).

Over the past year, I only run nix flake update and nix run .#build-switch to alter my system, outside of a few throw away applications.

For example, I don't run brew commands. I run my main nix run .#build-switch command that runs brew for me.

See this link of where I define what brew package I want Nix to install for me:
https://github.com/dustinlyons/nixos-config/blob/main/modules/darwin/home-manager.nix#L26

I installed several (homebrew) things using your repo code. However, I didn't noticed that doing nix flake update then nix run .#build-switch upgraded my homebrew installed packages. For example, I have this in my modules/darwin/home-manager.nix:

  homebrew = {
    enable = true;
    brews = [
      {
        name = "d12frosted/emacs-plus/emacs-plus";
        args = [ "with-xwidgets" "with-native-comp" "with-poll" ];
        link = true;
      }
    ];
    casks = pkgs.callPackage ./casks.nix {};

    onActivation = {
      extraFlags = [ "--verbose" ];
    };

    masApps = {
      "Amazon Prime Video" = 545519333;
      "WhatsApp Messenger" = 310633997;
    };
  };

In a different (Mac OS X, intel Sonoma, no nix, used for work activities) computer with homebrew, I noticed my Emacs Plus formula was updated from 29.1 to 29.2. Even when I have been regularly "upgrading" (doing nix flake update then nix run .#build-switch) my nix installation, I never noticed that it tried to recompile my Emacs Plus installation, for example, until I manually executed brew upgrade && brew update && brew update --cask && brew cleanup today in the morning (CST time zone).

I have a section like this in my flake.nix:

             nix-homebrew = {
                enable = true;
                user = "${user}";
                taps = {
                  "homebrew/homebrew-core" = homebrew-core;
                  "homebrew/homebrew-cask" = homebrew-cask;
                  "homebrew/homebrew-cask-versions" = homebrew-cask-versions;
                  "homebrew/homebrew-bundle" = homebrew-bundle;
                  "d12frosted/homebrew-emacs-plus" = homebrew-emacs-plus;
                };
                mutableTaps = false;
                autoMigrate = true;
              };

Could I possibly be missing something @dustinlyons ?

Edit: Here is my current configuration, based on your code: https://github.com/oscarvarto/nixos-config

Okay, sorry I left some previous comments but I don't think I understood the problem. Now I see. You're saying there are updates available, but Nix can't see them; only if you run brew do you see them.

I honestly don't know much about the internals of nix-homebrew. If you run nix flake update, my understanding is that your flake lock file gets updated with the latest hash for brew packages, casks, etc. You might ask this question over there.

In general, I try not to use brew packages and keep things in Nix land. When I do use brew or mas, I generally let those packages update however they want (auto update, or not using Nix.) But your question still stands-- why doesn't nix flake update bring in the latest brew versions, but using brew update does?

Exactly, this is my actual question:
why doesn't nix flake update bring in the latest brew versions, but using brew update does?
However, I've decided to not use nix on Mac OSX, and use traditional installation of my stuff. Not worth the additional overhead/complexity for my use cases.