diff --git a/flake.lock b/flake.lock index a2abe0d..e8e9285 100644 --- a/flake.lock +++ b/flake.lock @@ -43,6 +43,23 @@ "type": "gitlab" } }, + "brew-src": { + "flake": false, + "locked": { + "lastModified": 1751910772, + "narHash": "sha256-jQNdIkq2iRDNWskd5f8kX6q9BO/CBSXhMH41WNRft8E=", + "owner": "Homebrew", + "repo": "brew", + "rev": "700d67a85e0129ab8a893ff69246943479e33df1", + "type": "github" + }, + "original": { + "owner": "Homebrew", + "ref": "4.5.9", + "repo": "brew", + "type": "github" + } + }, "crash": { "inputs": { "nixpkgs": [ @@ -248,6 +265,38 @@ "type": "github" } }, + "homebrew-cask": { + "flake": false, + "locked": { + "lastModified": 1753968895, + "narHash": "sha256-q8loYa7TQFtxs0gAKUGs+arGusXkaNTnMYJdOSLLups=", + "owner": "homebrew", + "repo": "homebrew-cask", + "rev": "d3cc45a4ab90edca625bb040823edac3c09feb11", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-cask", + "type": "github" + } + }, + "homebrew-core": { + "flake": false, + "locked": { + "lastModified": 1753967820, + "narHash": "sha256-KPrAcjKW3dXbCt0b8i+bgMwNSnpGgnAnYZS6tgX0IVs=", + "owner": "homebrew", + "repo": "homebrew-core", + "rev": "e64e128c3acca63c8cbb25a7e6896b78e214092c", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-core", + "type": "github" + } + }, "nil": { "inputs": { "nixpkgs": "nixpkgs_2" @@ -308,6 +357,24 @@ "type": "github" } }, + "nix-homebrew": { + "inputs": { + "brew-src": "brew-src" + }, + "locked": { + "lastModified": 1752160973, + "narHash": "sha256-BCC8KB7TEtwv7vZN1WDu870tRbXtzUcmF9xNr6ws5Wc=", + "owner": "zhaofengli", + "repo": "nix-homebrew", + "rev": "69c1aa2f136f3c3326d9b6770e0eb54f12832971", + "type": "github" + }, + "original": { + "owner": "zhaofengli", + "repo": "nix-homebrew", + "type": "github" + } + }, "nixos-mailserver": { "inputs": { "blobs": "blobs", @@ -450,9 +517,12 @@ "fenix": "fenix", "github2forgejo": "github2forgejo", "home-manager": "home-manager", + "homebrew-cask": "homebrew-cask", + "homebrew-core": "homebrew-core", "nil": "nil", "nix": "nix", "nix-darwin": "nix-darwin", + "nix-homebrew": "nix-homebrew", "nixos-mailserver": "nixos-mailserver", "nixpkgs": "nixpkgs_4", "themes": "themes" diff --git a/flake.nix b/flake.nix index 7e4fc13..ef8c264 100644 --- a/flake.nix +++ b/flake.nix @@ -44,6 +44,18 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + nix-homebrew.url = "github:zhaofengli/nix-homebrew"; + homebrew-core = { + url = "github:homebrew/homebrew-core"; + + flake = false; + }; + homebrew-cask = { + url = "github:homebrew/homebrew-cask"; + + flake = false; + }; + home-manager = { url = "github:nix-community/home-manager"; diff --git a/modules/common/agenix.nix b/modules/common/agenix.nix index 3c7b95e..8b142f2 100644 --- a/modules/common/agenix.nix +++ b/modules/common/agenix.nix @@ -1,5 +1,5 @@ { config, lib, pkgs, ... }: let - inherit (lib) attrNames filterAttrs hasPrefix head mkAliasOptionModule mkIf; + inherit (lib) mkAliasOptionModule mkIf; in { imports = [(mkAliasOptionModule [ "secrets" ] [ "age" "secrets" ])]; @@ -7,7 +7,7 @@ in { (if config.isLinux then "/root/.ssh/id" else - "/Users/${head <| attrNames <| filterAttrs (_: value: value.home != null && hasPrefix "/Users/" value.home) config.users.users}/.ssh/id") + "/Users/${config.system.primaryUser}/.ssh/id") ]; environment = mkIf config.isDesktop { diff --git a/modules/darwin/ghostty.nix b/modules/darwin/ghostty.nix new file mode 100644 index 0000000..ad488fd --- /dev/null +++ b/modules/darwin/ghostty.nix @@ -0,0 +1,3 @@ +{ + homebrew.casks = [ "ghostty" ]; +} diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix new file mode 100644 index 0000000..19dba2e --- /dev/null +++ b/modules/darwin/homebrew.nix @@ -0,0 +1,16 @@ +{ nix-homebrew, homebrew-core, homebrew-cask, config, lib, ... }: let + inherit (lib) enabled; +in { + imports = [ nix-homebrew.darwinModules.nix-homebrew ]; + + homebrew = enabled; + + nix-homebrew = enabled { + user = config.system.primaryUser; + + taps."homebrew/homebrew-core" = homebrew-core; + taps."homebrew/homebrew-cask" = homebrew-cask; + + mutableTaps = false; + }; +} diff --git a/modules/darwin/karabiner.nix b/modules/darwin/karabiner.nix index 5e55403..4724306 100644 --- a/modules/darwin/karabiner.nix +++ b/modules/darwin/karabiner.nix @@ -129,21 +129,7 @@ } ]; in { - # TODO: Install using Nix. Currently I'm doing it manually. - - # nixpkgs.overlays = [(self: super: { - # karabiner-elements = super.karabiner-elements.overrideAttrs (old: { - # version = "14.13.0"; - - # src = super.fetchurl { - # inherit (old.src) url; - - # hash = "sha256-gmJwoht/Tfm5qMecmq1N6PSAIfWOqsvuHU8VDJY8bLw="; - # }; - # }); - # })]; - - # services.karabiner-elements = enabled; + homebrew.casks = [ "karabiner-elements" ]; home-manager.sharedModules = [{ xdg.configFile."karabiner/karabiner.json".text = toJSON {