From 66a49eb5135506b3e9b1805a396eda92cce23c1f Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 25 Jul 2025 00:08:22 +0200 Subject: [PATCH] feat: mac sack --- flake.lock | 58 ++++++++++++++++++++++++++++++++ flake.nix | 18 ++++++++++ hosts/mac/configuration.nix | 66 +++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 hosts/mac/configuration.nix diff --git a/flake.lock b/flake.lock index 90a6e5e..db74829 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,23 @@ "type": "github" } }, + "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" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -193,6 +210,45 @@ "type": "github" } }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1751313918, + "narHash": "sha256-HsJM3XLa43WpG+665aGEh8iS8AfEwOIQWk3Mke3e7nk=", + "owner": "nix-darwin", + "repo": "nix-darwin", + "rev": "e04a388232d9a6ba56967ce5b53a8a6f713cdfcf", + "type": "github" + }, + "original": { + "owner": "nix-darwin", + "ref": "master", + "repo": "nix-darwin", + "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-hardware": { "locked": { "lastModified": 1749195551, @@ -326,6 +382,8 @@ "agenix": "agenix", "home-manager": "home-manager_2", "mms": "mms", + "nix-darwin": "nix-darwin", + "nix-homebrew": "nix-homebrew", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs_4", "nixpkgs-stable": "nixpkgs-stable", diff --git a/flake.nix b/flake.nix index d6eb4bd..c57cfb3 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,9 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.05"; + nix-darwin.url = "github:nix-darwin/nix-darwin/master"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + nix-homebrew.url = "github:zhaofengli/nix-homebrew"; zen-browser.url = "github:0xc000022070/zen-browser-flake"; mms.url = "github:mkaito/nixos-modded-minecraft-servers"; agenix.url = "github:ryantm/agenix"; @@ -19,6 +22,8 @@ self, nixpkgs, nixpkgs-stable, + nix-darwin, + nix-homebrew, ... } @ inputs: { formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra; @@ -50,5 +55,18 @@ ./hosts/karasumaru/configuration.nix ]; }; + darwinConfigurations."mac" = nix-darwin.lib.darwinSystem { + specialArgs = {inherit inputs;}; + modules = [ + ./hosts/mac/configuration.nix + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + enable = true; + user = "admin"; + }; + } + ]; + }; }; } diff --git a/hosts/mac/configuration.nix b/hosts/mac/configuration.nix new file mode 100644 index 0000000..feff190 --- /dev/null +++ b/hosts/mac/configuration.nix @@ -0,0 +1,66 @@ + { + config, + pkgs, + ... + }: { + system.primaryUser = "admin"; + + environment.systemPackages = with pkgs; [ + vim + neovim + alacritty + element-desktop + mkalias + flutter + pass + ]; + + homebrew = { + enable = true; + casks = [ + ]; + brews = [ + ]; + #masApps = []; + onActivation.cleanup = "zap"; + onActivation.autoUpdate = true; + onActivation.upgrade = true; + }; + + # Necessary for using flakes on this system. + nix.settings.experimental-features = "nix-command flakes"; + programs.zsh.enable = true; + + # Enable alternative shell support in nix-darwin. + # programs.fish.enable = true; + + system.activationScripts.applications.text = let + env = pkgs.buildEnv { + name = "system-applications"; + paths = config.environment.systemPackages; + pathsToLink = "/Applications"; + }; + in + pkgs.lib.mkForce '' + # Set up applications. + echo "setting up /Applications..." >&2 + rm -rf /Applications/Nix\ Apps + mkdir -p /Applications/Nix\ Apps + find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + | + while read -r src; do + app_name=$(basename "$src") + echo "copying $src" >&2 + ${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name" + done + ''; + + # Set Git commit hash for darwin-version. + #system.configurationRevision = self.rev or self.dirtyRev or null; + + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 6; + + # The platform the configuration will be used on. + nixpkgs.hostPlatform = "x86_64-darwin"; +}