diff --git a/flake.nix b/flake.nix index c60d73c..76fbbe5 100644 --- a/flake.nix +++ b/flake.nix @@ -81,43 +81,29 @@ apps = nixpkgs.lib.genAttrs linuxSystems mkLinuxApps // nixpkgs.lib.genAttrs darwinSystems mkDarwinApps; - darwinConfigurations = nixpkgs.lib.genAttrs darwinSystems - (system: darwin.lib.darwinSystem { + darwinConfigurations = nixpkgs.lib.genAttrs darwinSystems ( + system: darwin.lib.darwinSystem { inherit system; specialArgs = { inherit variables inputs; }; modules = [ home-manager.darwinModules.home-manager nix-homebrew.darwinModules.nix-homebrew - { - # TODO: Move to dedicated homebrew module incl. casks - nix-homebrew = { - user = variables.userName; - enable = true; - taps = { - "homebrew/homebrew-core" = homebrew-core; - "homebrew/homebrew-cask" = homebrew-cask; - "homebrew/homebrew-bundle" = homebrew-bundle; - }; - mutableTaps = false; - autoMigrate = true; - }; - } ./hosts/darwin ]; } - ); + ); nixosConfigurations = let mkNixos = host: system: nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = { inherit variables inputs; }; - modules = [ - disko.nixosModules.disko - home-manager.nixosModules.home-manager - ./hosts/${host} - ]; - }; + inherit system; + specialArgs = { inherit variables inputs; }; + modules = [ + disko.nixosModules.disko + home-manager.nixosModules.home-manager + ./hosts/${host} + ]; + }; in { "nixos-x86_64" = mkNixos "nixos" "x86_64-linux"; diff --git a/hosts/darwin/default.nix b/hosts/darwin/default.nix index 5f520d7..d6d51da 100644 --- a/hosts/darwin/default.nix +++ b/hosts/darwin/default.nix @@ -8,6 +8,7 @@ in { imports = [ ../../modules/darwin/home-manager.nix + ../../modules/darwin/homebrew.nix ../../modules/shared/cachix ../../modules/shared ]; @@ -25,9 +26,8 @@ in # Turn off NIX_PATH warnings now that we're using flakes system.checks.verifyNixPath = false; - networking = { - inherit hostName localHostName; - }; + # inherit sets options to the variable with the same name + networking = { inherit hostName localHostName; }; environment.systemPackages = with pkgs; [ git ]; @@ -60,7 +60,9 @@ in tilesize = 48; }; - finder = { _FXShowPosixPathInTitle = false; }; + finder = { + _FXShowPosixPathInTitle = false; + }; trackpad = { Clicking = true; diff --git a/modules/darwin/casks.nix b/modules/darwin/casks.nix deleted file mode 100644 index e625d06..0000000 --- a/modules/darwin/casks.nix +++ /dev/null @@ -1,28 +0,0 @@ -_: - -[ - # Development Tools - # "homebrew/cask/docker" - # "visual-studio-code" - "visual-studio-code@insiders" - - # Communication Tools - # "discord" - # "notion" - # "slack" - # "telegram" - # "zoom" - - # Utility Tools - # "syncthing" - - # Entertainment Tools - # "iina" # Video player - - # Productivity Tools - "raycast" - - # Browsers - "google-chrome" - # "arc" # Arc browser -] diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix new file mode 100644 index 0000000..f3b5ae5 --- /dev/null +++ b/modules/darwin/homebrew.nix @@ -0,0 +1,122 @@ +{ variables, inputs, config, lib, ... }: +let + inherit (variables) userName; + inherit (inputs) homebrew-bundle homebrew-core homebrew-cask; + inherit (lib) mkIf mkEnableOption; + cfg = config.nix-homebrew; +in +{ + options = { + # Homebrew shell integration, may be merged into nix-homebrew + # https://github.com/zhaofengli/nix-homebrew/pull/39 + # + # TODO: PR merged, update and test using nix-darwin interactiveShellInit + # instead of home-manager shell config like in PR + # + nix-homebrew = { + enableZshIntegration = mkEnableOption "homebrew zsh integration" // { + default = false; + }; + enableBashIntegration = mkEnableOption "homebrew bash integration" // { + default = false; + }; + enableFishIntegration = mkEnableOption "homebrew fish integration" // { + default = false; + }; + enableNushellIntegration = mkEnableOption "homebrew nushell integration" // { + default = false; + }; + }; + }; + + config = { + # nix-homebrew homebrew module + # Manages homebrew installation + nix-homebrew = { + user = userName; + enable = true; + enableZshIntegration = true; + taps = { + "homebrew/homebrew-core" = homebrew-core; + "homebrew/homebrew-cask" = homebrew-cask; + "homebrew/homebrew-bundle" = homebrew-bundle; + }; + mutableTaps = false; + autoMigrate = true; + }; + + # Homebrew shell integration + home-manager.users.${userName}.programs = { + zsh.initExtra = mkIf cfg.enableZshIntegration '' + eval "$(${config.homebrew.brewPrefix}/brew shellenv)" + ''; + + bash.initExtra = mkIf cfg.enableBashIntegration '' + eval "$(${config.homebrew.brewPrefix}/brew shellenv)" + ''; + + fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' + eval "$(${config.homebrew.brewPrefix}/brew shellenv)" + ''; + + # https://www.nushell.sh/book/configuration.html#homebrew + # https://reimbar.org/dev/nushell/ + nushell.extraEnv = mkIf cfg.enableFishIntegration '' + # $env.PATH = ($env.PATH | split row (char esep) | prepend '/opt/homebrew/bin') + use std "path add" + path add /opt/homebrew/bin + ''; + }; + + # nix-darwin homebrew module + # Manages homebrew packages + homebrew = { + enable = true; + onActivation.cleanup = "uninstall"; + + # Fixes nix-darwin trying to untap nix-homebrew taps when uninstall is set + # https://github.com/zhaofengli/nix-homebrew/issues/5 + taps = builtins.attrNames config.nix-homebrew.taps; + + casks = [ + # Development Tools + # "homebrew/cask/docker" + # "visual-studio-code" + "visual-studio-code@insiders" + + # Communication Tools + # "discord" + # "notion" + # "slack" + # "telegram" + # "zoom" + + # Utility Tools + # "syncthing" + + # Entertainment Tools + # "iina" # Video player + + # Productivity Tools + "raycast" + + # Browsers + "google-chrome" + # "arc" # Arc browser + ]; + + # Mac App Store Apps + # These app IDs are from using the mas CLI app + # $ nix shell nixpkgs#mas + # $ mas search + # + # If you have previously added these apps to your Mac App Store profile (but not installed them on this system), + # you may receive an error message "Redownload Unavailable with This Apple ID". + # This message is safe to ignore. (https://github.com/dustinlyons/nixos-config/issues/83) + # masApps = { + # "1password" = 1333542190; + # "wireguard" = 1451685025; + # }; + }; + }; +}