Giter VIP home page Giter VIP logo

Comments (6)

dustinlyons avatar dustinlyons commented on May 2, 2024 2

@oscarvarto you may look at this option if you ever get back to Nix

https://daiderd.com/nix-darwin/manual/index.html#opt-homebrew.onActivation.autoUpdate

from nixos-config.

dustinlyons avatar dustinlyons commented on May 2, 2024

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.

from nixos-config.

dustinlyons avatar dustinlyons commented on May 2, 2024

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

from nixos-config.

oscarvarto avatar oscarvarto commented on May 2, 2024

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

from nixos-config.

dustinlyons avatar dustinlyons commented on May 2, 2024

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?

from nixos-config.

oscarvarto avatar oscarvarto commented on May 2, 2024

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.

from nixos-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.