diff --git a/flake.nix b/flake.nix index dca83ae..13b239f 100644 --- a/flake.nix +++ b/flake.nix @@ -5,9 +5,8 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nix-darwin.url = "github:LnL7/nix-darwin"; nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; - nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; - # Optional: Declarative tap management + nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; homebrew-core = { url = "github:homebrew/homebrew-core"; flake = false; @@ -20,231 +19,111 @@ url = "github:homebrew/homebrew-bundle"; flake = false; }; + home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = inputs@{ self, nix-darwin, nix-homebrew, homebrew-core, homebrew-cask, homebrew-bundle, home-manager, ... }: - let - username = "stephen"; - hostname = "swaphb-mba"; - configuration = { pkgs, lib, inputs, ... }: { - # List packages installed in system profile. To search by name, run: - # $ nix-env -qaP | grep wget + outputs = inputs@{ self, nix-darwin, nix-homebrew, home-manager, ... }: + let + username = "stephen"; + hostname = "swaphb-mba"; - ##################### - ### Nix Packages ### - ##################### - environment.systemPackages = - [ - pkgs.vim - pkgs.lens - pkgs.vscode - pkgs.spotify - pkgs.slack - pkgs.kubectl - pkgs.discord - pkgs._1password-cli - pkgs.brave - pkgs.teleport - pkgs.tenv - pkgs.google-cloud-sdk - pkgs.awscli - pkgs.azure-cli - pkgs.go - pkgs.starship - ]; - - ################ - ### Homebrew ### - ################ - homebrew = { - enable = true; - onActivation.cleanup = "uninstall"; - - taps = []; - brews = [ - "cowsay" - "git" - "k9s" - "helm" - "podman" - "podman-compose" - ]; - casks = [ - "1password" - "podman-desktop" - "teleport-connect" - "utm" - "localsend" - ]; - masApps = { - "1Password for Safari" = 1569813296; - "wireguard" = 1451685025; - "wipr" = 1320666476; + # Minimal Darwin system config (minus environment.systemPackages/services) + configuration = { pkgs, lib, inputs, ... }: { + # Some general Darwin/Nix configuration + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; + + # This can stay here or move to modules/darwin/services.nix + # services.nix-daemon.enable = true; + + # Enable the nix-darwin module system. + nix.package = pkgs.nix; + + # Necessary for using flakes on this system. + nix.settings.experimental-features = "nix-command flakes"; + + # zsh, fish, etc. + programs.zsh.enable = true; + programs.bash.interactiveShellInit = '' + source /home/${username}/.config/op/plugins.sh + ''; + + system.configurationRevision = self.rev or self.dirtyRev or null; + + system.defaults = { + # ... + }; + + system.stateVersion = 4; + nixpkgs.hostPlatform = "aarch64-darwin"; + nixpkgs.config = { + allowUnfree = true; + allowBroken = true; }; }; - ################ - ### Nix-Darwin ### - ################ - nix.extraOptions = '' - experimental-features = nix-command flakes - ''; - # Auto upgrade nix package and the daemon service. - services.nix-daemon.enable = true; - services = { - tailscale = { - enable = true; - }; - }; + # Minimal home-manager config (minus dotfiles) + homeconfig = { pkgs, lib, ... }: { + home.stateVersion = "24.05"; + programs.home-manager.enable = true; - # Enable the darwin security.pam module for sudo Touch ID authentication. - security = { - pam = { - enableSudoTouchIdAuth = true; - }; - }; - - # Enable the nix-darwin module system. - nix.package = pkgs.nix; - - # Necessary for using flakes on this system. - nix.settings.experimental-features = "nix-command flakes"; - - # Create /etc/zshrc that loads the nix-darwin environment. - programs = { - fish = { - enable = false; - }; - zsh = { - enable = true; - }; - }; - # programs.fish.enable = true; - # Enable 1password plugins on interactive shell init - programs.bash.interactiveShellInit = '' - source /home/${username}/.config/op/plugins.sh - ''; - - # Set Git commit hash for darwin-version. - system.configurationRevision = self.rev or self.dirtyRev or null; - - system.defaults = { - dock = { - autohide = true; - mru-spaces = false; - }; - finder = { - AppleShowAllFiles = true; - AppleShowAllExtensions = true; - FXPreferredViewStyle = "clmv"; - }; - loginwindow.LoginwindowText = "${hostname}"; - screencapture.location = "~/Documents/Pictures/screenshots"; - screensaver.askForPasswordDelay = 10; - trackpad = { - # Click = "click"; - # DragLock = true; - # Dragging = true; - TrackpadThreeFingerDrag = true; - FirstClickThreshold = 1; - }; - NSGlobalDomain = { - AppleInterfaceStyle = "Dark"; - }; - }; - # Used for backwards compatibility, please read the changelog before changing. - # $ darwin-rebuild changelog - system.stateVersion = 4; - - # The platform the configuration will be used on. - nixpkgs.hostPlatform = "aarch64-darwin"; - nixpkgs.config = { - allowUnfree = true; - allowBroken = true; - }; - }; - - homeconfig = { pkgs, lib, ... }: { - # this is internal compatibility configuration - # for home-manager, don't change this! - home.stateVersion = "24.05"; - # Let home-manager install and manage itself. - programs.home-manager.enable = true; - - home.packages = with pkgs; [ ]; - - home.sessionVariables = { + home.packages = with pkgs; [ ]; + home.sessionVariables = { EDITOR = "nano"; + }; + home.homeDirectory = lib.mkForce "/Users/${username}"; + }; + in + { + darwinConfigurations."${hostname}" = nix-darwin.lib.darwinSystem { + modules = + [ + # Main Darwin config + configuration + + # The official nix-homebrew module from your flake inputs + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + enable = true; + enableRosetta = true; + user = "${username}"; + taps = { + "homebrew/homebrew-core" = inputs.homebrew-core; + "homebrew/homebrew-cask" = inputs.homebrew-cask; + "homebrew/homebrew-bundle" = inputs.homebrew-bundle; + }; + autoMigrate = true; + mutableTaps = false; + }; + } + + # Our own modules for Darwin-level configs + ./modules/darwin/homebrew.nix + ./modules/darwin/nixpackages.nix + ./modules/darwin/services.nix + + # Home Manager + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.verbose = true; + home-manager.users.${username} = { + imports = [ + homeconfig + ./modules/home/dotfiles.nix + ]; + }; + } + ]; }; - home.homeDirectory = lib.mkForce "/Users/${username}"; + darwinPackages = self.darwinConfigurations."${hostname}".pkgs; }; - in - { - # Build darwin flake using: - # $ darwin-rebuild build --flake .#${hostname} - darwinConfigurations."${hostname}" = nix-darwin.lib.darwinSystem { - modules = [ - configuration - nix-homebrew.darwinModules.nix-homebrew - { - nix-homebrew = { - enable = true; - enableRosetta = true; - user = "${username}"; - taps = { - "homebrew/homebrew-core" = homebrew-core; - "homebrew/homebrew-cask" = homebrew-cask; - "homebrew/homebrew-bundle" = homebrew-bundle; - }; - autoMigrate = true; # Automatically migrate from brewfile to flake if brew already exists. - mutableTaps = false; - }; - } - home-manager.darwinModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.verbose = true; - home-manager.users.${username} = { - imports = [ homeconfig ]; - home.file = { - ".ssh/config".text = '' - Host * - IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" - ''; - - ".gitconfig".text = '' - [user] - name = swaphb - email = s@swaphb.com - signingkey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx0WMlfx+AwcROXFO+/all/WkLvBKpEkjwRY15tjSiB - - [gpg] - format = ssh - - [gpg "ssh"] - program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign" - - [commit] - gpgSign = true - ''; - }; - }; - } - # { - # imports = [ ./modules/terminal/starship/default.nix ]; - # } - ]; - }; - - # Expose the package set, including overlays, for convenience. - darwinPackages = self.darwinConfigurations."${hostname}".pkgs; - }; } - - diff --git a/home.nix b/home.nix index 8b5f03b..b746a8d 100644 --- a/home.nix +++ b/home.nix @@ -12,6 +12,256 @@ # # This is to ensure programs are using ~/.config rather than # # /Users/&2 "Homebrew bundle..." -# if [ -f "${cfg.brewPrefix}/brew" ]; then -# PATH="${cfg.brewPrefix}":$PATH ${cfg.onActivation.brewBundleCmd} -# else -# echo -e "\e[1;31merror: Homebrew is not installed, skipping...\e[0m" >&2 -# fi -# ''; -# }; -# } \ No newline at end of file diff --git a/modules/terminal/default.nix b/modules/terminal/default.nix deleted file mode 100644 index 531b022..0000000 --- a/modules/terminal/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - imports = [ - ./terminal - ]; -} \ No newline at end of file diff --git a/modules/terminal/starship/default.nix b/modules/terminal/starship/default.nix deleted file mode 100644 index 069494e..0000000 --- a/modules/terminal/starship/default.nix +++ /dev/null @@ -1,152 +0,0 @@ -{ - programs.starship = { - enable = true; - settings = { - add_newline = false; - scan_timeout = 10; - format = "$all"; - character = { - success_symbol = "[>](bold green)"; - error_symbol = "[x](bold red)"; - vimcmd_symbol = "[<](bold green)"; - }; - - git_commit = { - tag_symbol = " tag "; - }; - git_status = { - ahead = ">"; - behind = "<"; - diverged = "<>"; - renamed = "r"; - deleted = "x"; - }; - cmd_duration = { - min_time = 500; - format = "took [$duration](bold yellow)"; - }; - aws = { - symbol = "aws "; - }; - azure = { - symbol = "az "; - }; - bun = { - symbol = "bun "; - }; - - cmake = { - symbol = "cmake "; - }; - deno = { - symbol = "deno "; - }; - directory = { - read_only = " ro"; - }; - docker_context = { - symbol = "docker "; - }; - git_branch = { - symbol = "git "; - }; - golang = { - symbol = "go "; - }; - hostname = { - ssh_only = false; - format = " on [$hostname](bold #FFA500)\n"; - disabled = false; - }; - lua = { - symbol = "lua "; - }; - nodejs = { - symbol = "nodejs "; - }; - memory_usage = { - symbol = "memory "; - }; - nim = { - symbol = "nim "; - }; - nix_shell = { - symbol = "nix "; - }; - os.symbols = { - Alpaquita = "alq "; - Alpine = "alp "; - Amazon = "amz "; - Android = "andr "; - Arch = "rch "; - Artix = "atx "; - CentOS = "cent "; - Debian = "deb "; - DragonFly = "dfbsd "; - Emscripten = "emsc "; - EndeavourOS = "ndev "; - Fedora = "fed "; - FreeBSD = "fbsd "; - Garuda = "garu "; - Gentoo = "gent "; - HardenedBSD = "hbsd "; - Illumos = "lum "; - Linux = "lnx "; - Mabox = "mbox "; - Macos = "mac "; - Manjaro = "mjo "; - Mariner = "mrn "; - MidnightBSD = "mid "; - Mint = "mint "; - NetBSD = "nbsd "; - NixOS = "nix "; - OpenBSD = "obsd "; - OpenCloudOS = "ocos "; - openEuler = "oeul "; - openSUSE = "osuse "; - OracleLinux = "orac "; - Pop = "pop "; - Raspbian = "rasp "; - Redhat = "rhl "; - RedHatEnterprise = "rhel "; - Redox = "redox "; - Solus = "sol "; - SUSE = "suse "; - Ubuntu = "ubnt "; - Unknown = "unk "; - Windows = "win "; - }; - package = { - symbol = "pkg "; - }; - purescript = { - symbol = "purs "; - }; - python = { - symbol = "py "; - }; - rust = { - symbol = "rs "; - }; - status = { - symbol = "[x](bold red) "; - }; - sudo = { - symbol = "sudo "; - }; - terraform = { - symbol = "terraform "; - }; - username = { - style_user = "blue bold"; - style_root = "orange bold"; - format = "[$user]($style)"; - disabled = false; - show_always = true; - }; - zig = { - symbol = "zig "; - }; - }; - }; -} \ No newline at end of file diff --git a/modules/terminal/zsh/default.nix b/modules/terminal/zsh/default.nix deleted file mode 100644 index a34653f..0000000 --- a/modules/terminal/zsh/default.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ pkgs, username, ... }: -{ - imports = [ - ./alacritty - # ./cava - ./fonts - ./foot - ./nvim - ./starship - ./tmux - ./yazi - ./zsh - ]; - - # ---- Home Configuration ---- - home-manager.users.${username} = { - programs.git.enable = true; - }; - - # ---- System Configuration ---- - programs = { - htop.enable = true; - mtr.enable = true; - }; - - environment.systemPackages = with pkgs; [ - alacritty - brightnessctl - btop - gh - ghostty - kubectl - kubernetes-helm - lens - mods - nitch - pavucontrol - playerctl - ripgrep - todoist - unzip - vhs - zoxide - ]; -} \ No newline at end of file