dustinlyons / nixos-config

General purpose Nix configuration for macOS / NixOS with starter templates + step-by-step guides ✨
BSD 3-Clause "New" or "Revised" License
1.78k stars 113 forks source link

Suggestion on Migrating from Existing Install? #77

Closed Mick235711 closed 6 months ago

Mick235711 commented 6 months ago

Hi there, thanks for providing this incredible Nix config file on macOS! I have always wanted to try Nix on my Mac (aarch64), but I am a bit afraid of the steep learning curve, and this config will go a long way in alleviating that concern. However, the instructions in the README seem tailored to install the configuration on a brand-new MacOS installation. Is migrating from an in-use-for-years config supported now? For context, my computer currently has ~400 Homebrew core packages and ~100 Casks installed. Ideally, all the core packages should be migrated to use the Nixpkgs version, but the Casks should remain untouched. How should I approach the installation?

Thanks for the hard work in advance!

dustinlyons commented 6 months ago

So under the hood, the Nix homebrew abstractions are managed by nix-darwin.

I found this:

options.homebrew = {
    enable = mkEnableOption ''
      {command}`nix-darwin` to manage installing/updating/upgrading Homebrew taps, formulae,
      and casks, as well as Mac App Store apps and Docker containers, using Homebrew Bundle.

      Note that enabling this option does not install Homebrew, see the Homebrew
      [website](https://brew.sh) for installation instructions.

      Use the [](#opt-homebrew.brews), [](#opt-homebrew.casks),
      [](#opt-homebrew.masApps), and [](#opt-homebrew.whalebrews) options
      to list the Homebrew formulae, casks, Mac App Store apps, and Docker containers you'd like to
      install. Use the [](#opt-homebrew.taps) option, to make additional formula
      repositories available to Homebrew. This module uses those options (along with the
      [](#opt-homebrew.caskArgs) options) to generate a Brewfile that
      {command}`nix-darwin` passes to the {command}`brew bundle` command during
      system activation.

      The default configuration of this module prevents Homebrew Bundle from auto-updating Homebrew
      and all formulae, as well as upgrading anything that's already installed, so that repeated
      invocations of {command}`darwin-rebuild switch` (without any change to the
      configuration) are idempotent. You can modify this behavior using the options under
      [](#opt-homebrew.onActivation).

      This module also provides a few options for modifying how Homebrew commands behave when
      you manually invoke them, under [](#opt-homebrew.global)'';

Here is the module for reference.

My understanding is that it's just generating a brewfile. The apps aren't stored in the Nix Store, they sit where they normally would (Applications on my machine).

nix-homebrew on the other hand, manages the actual homebrew installation.

Here is information relevant to updating. Note the autoMigrate flag is already true in this config (and your template).

Mick235711 commented 6 months ago

Here is information relevant to updating. Note the autoMigrate flag is already true in this config (and your template).

Oh that's really good to hear, seems like nix-homebrew will automatically takes in the existing /opt/homebrew and /usr/local (for arch -x86_64 brew installs), and since the project is using Brewfile all the core packages and casks will still live where they are.

Thanks for the clarification!