diff --git a/README.md b/README.md index bfb9ba8..c80ab22 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ nix flake init -t github:chrisvander/dotfiles#darwin-host The generated `flake.nix` selects modules from `homeManagerModules` and language-specific toolchains and LSPs from `languageModules`. +It also selects `darwinModules.homebrew`, which installs Homebrew itself. Add +formulae and casks separately if you want them declaratively managed. + Build it with the published dotfiles revision: ```sh diff --git a/flake.lock b/flake.lock index ab37218..7f58c76 100644 --- a/flake.lock +++ b/flake.lock @@ -79,7 +79,43 @@ "home-manager": "home-manager", "nix-darwin": "nix-darwin", "nixpkgs": "nixpkgs", - "nixpkgs-unstable": "nixpkgs-unstable" + "nixpkgs-unstable": "nixpkgs-unstable", + "nix-homebrew": "nix-homebrew" + } + }, + "brew-src": { + "flake": false, + "locked": { + "lastModified": 1786945682, + "narHash": "sha256-VBESSoJccikdhxh3vp3SQeG7cZXTOulMvVkoSqNDEhs=", + "owner": "Homebrew", + "repo": "brew", + "rev": "5b90e281d4e0c8fbd6ca4d8358276fb305b8d0bd", + "type": "github" + }, + "original": { + "owner": "Homebrew", + "ref": "6.0.18", + "repo": "brew", + "type": "github" + } + }, + "nix-homebrew": { + "inputs": { + "brew-src": "brew-src" + }, + "locked": { + "lastModified": 1787330919, + "narHash": "sha256-LslMncqN7uOOH5S88WZtO/EVt2HwD8ltUnfyANk+mC0=", + "owner": "zhaofengli", + "repo": "nix-homebrew", + "rev": "b00218e4aec0e5bf07d61a0bb13f842faa582d7b", + "type": "github" + }, + "original": { + "owner": "zhaofengli", + "repo": "nix-homebrew", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 80a564b..3457bbd 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,7 @@ nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nix-darwin.url = "github:nix-darwin/nix-darwin/nix-darwin-26.05"; nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + nix-homebrew.url = "github:zhaofengli/nix-homebrew"; home-manager.url = "github:nix-community/home-manager/release-26.05"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; }; @@ -17,6 +18,7 @@ inherit (inputs) home-manager nix-darwin + nix-homebrew nixpkgs nixpkgs-unstable ; @@ -42,6 +44,8 @@ typescript = ./modules/languages/typescript.nix; }; + darwinModules.homebrew = ./modules/darwin/homebrew.nix; + exampleUser = { username = "example"; homeDirectory = "/Users/example"; @@ -54,7 +58,7 @@ in { lib = dotfilesLib; - inherit homeManagerModules languageModules; + inherit darwinModules homeManagerModules languageModules; checks.aarch64-darwin = { example = @@ -65,6 +69,7 @@ user = exampleUser; vcs = exampleVcs; modules = exampleModules; + darwinModules = [ darwinModules.homebrew ]; }).system; }; diff --git a/lib/default.nix b/lib/default.nix index d0b15fc..9246e1e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,6 +1,7 @@ { home-manager, nix-darwin, + nix-homebrew, nixpkgs, nixpkgs-unstable, }: @@ -50,7 +51,10 @@ in }; in nix-darwin.lib.darwinSystem { - specialArgs = { inherit host nixpkgs-unstable; }; + specialArgs = { + inherit host nixpkgs-unstable; + nixHomebrew = nix-homebrew; + }; modules = [ home-manager.darwinModules.home-manager ../modules/darwin diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 78a6699..a07f7bc 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -10,6 +10,16 @@ shell = pkgs.fish; }; + system.primaryUser = host.user.username; + system.defaults.menuExtraClock = { + Show24Hour = false; + ShowAMPM = true; + ShowDate = 2; + ShowDayOfMonth = false; + ShowDayOfWeek = true; + ShowSeconds = false; + }; + security.pam.services.sudo_local = { # Enable Touch ID authentication for sudo touchIdAuth = true; diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix new file mode 100644 index 0000000..d7def3e --- /dev/null +++ b/modules/darwin/homebrew.nix @@ -0,0 +1,9 @@ +{ host, nixHomebrew, ... }: { + imports = [ nixHomebrew.darwinModules.nix-homebrew ]; + + nix-homebrew = { + enable = true; + user = host.user.username; + autoMigrate = true; + }; +} diff --git a/templates/darwin-host/flake.nix b/templates/darwin-host/flake.nix index 6908d84..65300cd 100644 --- a/templates/darwin-host/flake.nix +++ b/templates/darwin-host/flake.nix @@ -20,6 +20,8 @@ email = "example@example.invalid"; }; + darwinModules = with dotfiles.darwinModules; [ homebrew ]; + modules = with dotfiles.homeManagerModules; [