From 5f63bea6672f889f79ccde289273187bb0dc085a Mon Sep 17 00:00:00 2001 From: swaphb Date: Thu, 13 Mar 2025 22:05:42 -0400 Subject: [PATCH] update --- README.md | 107 +++------ flake.lock | 222 ++++++++++++++++++ flake.nix | 14 +- manage.sh | 44 ++++ modules/darwin/apps/homebrew.nix | 25 +- modules/darwin/apps/nixpackages.nix | 18 +- modules/darwin/apps/services.nix | 2 +- modules/darwin/security/default.nix | 2 +- modules/darwin/system/appearance.nix | 23 +- modules/darwin/system/system.nix | 2 +- modules/home/stephen/default.nix | 28 +++ modules/home/stephen/dotfiles.nix | 148 ------------ modules/home/stephen/terminal/default.nix | 68 ++++++ .../stephen/terminal/starship/default.nix | 185 +++++++++++++++ .../home/userB/{dotfiles.nix => default.nix} | 15 +- rebuild.sh | 2 - update.sh | 3 - 17 files changed, 644 insertions(+), 264 deletions(-) create mode 100644 flake.lock create mode 100755 manage.sh create mode 100644 modules/home/stephen/default.nix delete mode 100644 modules/home/stephen/dotfiles.nix create mode 100644 modules/home/stephen/terminal/default.nix create mode 100644 modules/home/stephen/terminal/starship/default.nix rename modules/home/userB/{dotfiles.nix => default.nix} (52%) delete mode 100644 rebuild.sh delete mode 100644 update.sh diff --git a/README.md b/README.md index fdb1b69..e1a1c47 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,6 @@ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file - [Building and Switching](#building-and-switching) - [Common Commands](#common-commands) - [Troubleshooting](#troubleshooting) -- [Dirty Git Tree](#dirty-git-tree) -- [Path Does Not Exist](#path-does-not-exist) - [References](#references) ## Overview @@ -42,35 +40,42 @@ By splitting the configuration into multiple files under `./modules/`, each file After installing Nix, you can install nix-darwin (one recommended approach is from the official Nix-Darwin docs). ## Modules -- **flake.nix**: The top-level file defining all inputs (nixpkgs, nix-darwin, home-manager, nix-homebrew) and outputs (your nix-darwin configuration). Imports each module (e.g., `./modules/darwin/homebrew.nix`) into `darwinConfigurations..modules`. + +- **flake.nix**: The top-level file defining all inputs (nixpkgs, nix-darwin, home-manager, nix-homebrew) and outputs. - **modules/darwin/apps/**: - `homebrew.nix`: Holds Homebrew-related configurations (brew packages, casks, etc.). - - `nixpackages.nix`: Holds your `environment.systemPackages`. - - `services.nix`: Configures system services (e.g., Tailscale, nix-daemon, security/pam). - - `default.nix`: Aggregates all .nix files in the directory for easier reference by the flake. + - `default.nix`: Aggregates all .nix files in the directory. - **modules/darwin/security/**: - `default.nix`: Consolidated configurations for security related settings. - **modules/darwin/system/**: - - `appearance.nix`: Appearance related settings (e.g., dock, interface, login window settings, etc ). - - `finder.nix`: Finder related customizations. - - `system.nix`: System configuration (e.g., trackpad, keyboard mapping, screenshot default location, etc...). - - `default.nix`: Aggregates all .nix files in directory for easier reference by the flake + - `system.nix`: System configuration (e.g., trackpad, keyboard mapping, screenshot default location, etc.). + - `default.nix`: Aggregates all .nix files in directory. - **modules/home/**: - - `/dotfiles.nix`: Holds user-level dotfiles managed by Home Manager (e.g., `~/.gitconfig`, `~/.ssh/config`). -- **rebuild.sh**: A convenience script that typically runs something like: - ```sh - #!/usr/bin/env bash - darwin-rebuild switch --flake .# - ``` + - `/`: User-specific configurations + - `/terminal/`: Terminal-related configurations including shell setup + - `/terminal/starship/`: Starship prompt configurations + +## Management Script + +The repository includes an interactive management script (`manage.sh`) that provides a unified interface for common tasks: + +```sh +./manage.sh +``` + +The script offers the following options: + +1. **Rebuild configuration**: Rebuilds the current configuration +2. **Update flakes and rebuild**: Updates all flake inputs and rebuilds +3. **Clean nix store**: Runs garbage collection on the Nix store +4. **Exit**: Exits the script + +For rebuild operations (options 1 and 2), the script will: +- Prompt for the hostname (defaults to "swaphb-mba" if not specified) +- Execute the appropriate commands ## How to Use -In the `flake.nix` file, you can define host-specific and user-specific variables using let-bindings. Examples shown in the `flake.nix` file. - -To add a new host or user, update the `hostVars` and `userVars` sections in the `flake.nix` file with the new configurations. Follow the existing structure to ensure consistency. - -Execution: - 1. **Clone the repository**: ```sh git clone https://github.com/your-username/nix-darwin-config.git @@ -81,76 +86,46 @@ Execution: Follow the instructions on the [Nix website](https://nixos.org/download.html) to install Nix. 3. **Enable Flakes**: - Ensure that flakes are enabled in your Nix configuration: ```sh mkdir -p ~/.config/nix echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf ``` 4. **Apply Configuration**: - To apply the configuration for a specific host, run: ```sh - nix build .#darwinConfigurations..system - ./result/sw/bin/darwin-rebuild switch --flake . + nix run nix-darwin --extra-experimental-features nix-command --extra-experimental-features flakes -- switch --flake .#swaphb-mba ``` - - Replace `` with the actual hostname defined in the `flake.nix` file (e.g., `swaphb-mba`). - -## Building and Switching - -1. Clone this repo (or ensure you have your local copy). -2. Install nix-darwin if you haven’t already. -3. From the root of this repository (where `flake.nix` resides), run: - ```sh - darwin-rebuild switch --flake .# - ``` - Replace `` with the actual name of your system defined in `flake.nix` (e.g., `swaphb-mba`). - -Alternatively, if you have a script `rebuild.sh`, run: - -```sh -./rebuild.sh -``` -which should do the same command under the hood. + Select option 1 to rebuild the configuration, and enter your hostname when prompted. ## Common Commands +All common commands are now available through the management script (`./manage.sh`). However, you can still run commands manually if needed: + - **Build without switching**: ```sh darwin-rebuild build --flake .# ``` - This only builds the configuration but doesn’t apply it. - **Show changes**: ```sh darwin-rebuild dry-activate --flake .# ``` - See what changes will be made without applying them. - **List available flake outputs**: ```sh nix flake show ``` -- **Build with switching** - ```sh - darwin-rebuild switch --flake .# - ``` -- **Update upstream flakes** - ```sh - nix flake update - ``` ## Troubleshooting ### Dirty Git Tree -If you see warnings like: +If you see warnings about a dirty Git tree: ``` warning: Git tree '/path/to/your/repo' is dirty ``` -It means you have uncommitted changes. -**Solution**: Either commit the changes or pass `--impure` (not recommended), or stage/commit the changes to keep the flake happy: +**Solution**: Commit your changes: ```sh git add -A git commit -m "Commit message" @@ -158,23 +133,19 @@ git commit -m "Commit message" ### Path Does Not Exist -If you get an error similar to: +If you get path-related errors: ``` error: path '/nix/store/...-source/modules/darwin/homebrew.nix' does not exist ``` -It usually means: -- You haven’t actually created or committed the file. -- There’s a typo or case mismatch in the file name. -- The file is in a different directory than you think. - -**Solution**: Make sure the file exists, check for correct spelling/capitalization, and commit it to Git. +**Solution**: +- Verify the file exists +- Check for correct spelling/capitalization +- Ensure the file is committed to Git ## References - [NixOS Wiki: Flakes](https://nixos.wiki/wiki/Flakes) - [nix-darwin](https://github.com/LnL7/nix-darwin) - [Home Manager](https://github.com/nix-community/home-manager) -- [nix-homebrew (zhaofengli-wip)](https://github.com/zhaofengli/nix-homebrew) - -With this multi-file approach, you can easily add, remove, or tweak individual modules without having a giant monolithic `flake.nix`. \ No newline at end of file +- [nix-homebrew (zhaofengli-wip)](https://github.com/zhaofengli/nix-homebrew) \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7924dc4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,222 @@ +{ + "nodes": { + "brew-src": { + "flake": false, + "locked": { + "lastModified": 1740943974, + "narHash": "sha256-2lRLfb6qwoUAsX/XtYmt/ETxtGid6/VaBeFiRsoVMtU=", + "owner": "Homebrew", + "repo": "brew", + "rev": "64efed206deeb9c2304d9e5b5910dcbf0a509c15", + "type": "github" + }, + "original": { + "owner": "Homebrew", + "ref": "4.4.23", + "repo": "brew", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1741217763, + "narHash": "sha256-g/TrltIjFHIjtzKY5CJpoPANfHQWDD43G5U1a/v5oVg=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "486b066025dccd8af7fbe5dd2cc79e46b88c80da", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "homebrew-argoproj": { + "flake": false, + "locked": { + "lastModified": 1727199309, + "narHash": "sha256-UQbNtVYRj7m1tGeZOBgEAHcO4xDWgk0GidwF38FM/h8=", + "owner": "argoproj", + "repo": "homebrew-tap", + "rev": "a10c19d3a860ada425733e89758216ba0ccb4c28", + "type": "github" + }, + "original": { + "owner": "argoproj", + "repo": "homebrew-tap", + "type": "github" + } + }, + "homebrew-bundle": { + "flake": false, + "locked": { + "lastModified": 1741269991, + "narHash": "sha256-eyHpMTues9/ulREwI46nIhokUzUv8TZgojnomMePsFg=", + "owner": "homebrew", + "repo": "homebrew-bundle", + "rev": "87fa1e63eacf38167aec56d1732d95109ec47d00", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-bundle", + "type": "github" + } + }, + "homebrew-cask": { + "flake": false, + "locked": { + "lastModified": 1741272426, + "narHash": "sha256-Q9Hl0ISJ8jnZaaq9gChAyK+rDIldcpVS92XGq/MN3xw=", + "owner": "homebrew", + "repo": "homebrew-cask", + "rev": "ad2cf2e0abe31180b9998ba12f53c87653588e63", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-cask", + "type": "github" + } + }, + "homebrew-core": { + "flake": false, + "locked": { + "lastModified": 1741272988, + "narHash": "sha256-tQB7HSTic31wUsktBr4jqGVAnF1nytFQBTjdb5qTrFY=", + "owner": "homebrew", + "repo": "homebrew-core", + "rev": "e7fba177e9e2b83d900aa600cb43231341865298", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-core", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1741229100, + "narHash": "sha256-0HwrTDXp9buEwal/1ymK9uQmzUD5ozIA7CJGqnT/gLs=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "adf5c88ba1fe21af5c083b4d655004431f20c5ab", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nix-darwin_2": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1716329735, + "narHash": "sha256-ap51w+VqG21vuzyQ04WrhI2YbWHd3UGz0e7dc/QQmoA=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "eac4f25028c1975a939c8f8fba95c12f8a25e01c", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nix-homebrew": { + "inputs": { + "brew-src": "brew-src", + "nix-darwin": "nix-darwin_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1741032878, + "narHash": "sha256-s9YOBz8vAxPlI4wORma3D7km8wZOEe/7Hg/u3brmwUQ=", + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "rev": "a82c55b07f670a01da5a72b7a07fe41c256a4380", + "type": "github" + }, + "original": { + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1687274257, + "narHash": "sha256-TutzPriQcZ8FghDhEolnHcYU2oHIG5XWF+/SUBNnAOE=", + "path": "/nix/store/22qgs3skscd9bmrxv9xv4q5d4wwm5ppx-source", + "rev": "2c9ecd1f0400076a4d6b2193ad468ff0a7e7fdc5", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1716330097, + "narHash": "sha256-8BO3B7e3BiyIDsaKA0tY8O88rClYRTjvAp66y+VBUeU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5710852ba686cc1fd0d3b8e22b3117d43ba374c2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1741037377, + "narHash": "sha256-SvtvVKHaUX4Owb+PasySwZsoc5VUeTf1px34BByiOxw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "02032da4af073d0f6110540c8677f16d4be0117f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "homebrew-argoproj": "homebrew-argoproj", + "homebrew-bundle": "homebrew-bundle", + "homebrew-cask": "homebrew-cask", + "homebrew-core": "homebrew-core", + "nix-darwin": "nix-darwin", + "nix-homebrew": "nix-homebrew", + "nixpkgs": "nixpkgs_3" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 5945220..dea42e9 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,10 @@ url = "github:homebrew/homebrew-bundle"; flake = false; }; + homebrew-argoproj = { + url = "github:argoproj/homebrew-tap"; + flake = false; + }; }; outputs = inputs@{ self, nix-darwin, home-manager, ... }: @@ -92,6 +96,11 @@ in nix-darwin.lib.darwinSystem { modules = [ + ({ pkgs, ... }: { + _module.args = { + username = "${userVars.userA.username}"; + }; + }) host1Base ./modules/darwin/default.nix inputs.nix-homebrew.darwinModules.nix-homebrew @@ -104,9 +113,10 @@ "homebrew/homebrew-core" = inputs.homebrew-core; "homebrew/homebrew-cask" = inputs.homebrew-cask; "homebrew/homebrew-bundle" = inputs.homebrew-bundle; + "argoproj/homebrew-tap" = inputs.homebrew-argoproj; }; autoMigrate = true; - mutableTaps = false; + mutableTaps = true; }; } home-manager.darwinModules.home-manager { @@ -121,7 +131,7 @@ programs.zsh.enable = (userVars.userA.shell == "zsh"); programs.fish.enable = (userVars.userA.shell == "fish"); imports = [ - ./modules/home/${userVars.userA.username}/dotfiles.nix + ./modules/home/${userVars.userA.username}/default.nix ]; }; } diff --git a/manage.sh b/manage.sh new file mode 100755 index 0000000..7113f7c --- /dev/null +++ b/manage.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Colors for better visibility +GREEN='\033[0;32m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Print the menu +echo -e "${BLUE}Nix Darwin Configuration Management${NC}" +echo "1) Rebuild configuration" +echo "2) Update flakes and rebuild" +echo "3) Clean nix store" +echo "4) Exit" +echo "" + +# Get user choice +read -p "Please select an option (1-4): " choice + +case $choice in + 1) + echo -e "${GREEN}Rebuilding configuration...${NC}" + read -p "Enter hostname (default: swaphb-mba): " hostname + hostname=${hostname:-swaphb-mba} + darwin-rebuild switch --flake .#$hostname + ;; + 2) + echo -e "${GREEN}Updating flakes and rebuilding...${NC}" + read -p "Enter hostname (default: swaphb-mba): " hostname + hostname=${hostname:-swaphb-mba} + nix flake update && darwin-rebuild switch --flake .#$hostname + ;; + 3) + echo -e "${GREEN}Cleaning nix store...${NC}" + nix-store --gc + ;; + 4) + echo "Exiting..." + exit 0 + ;; + *) + echo "Invalid option. Please select 1-4." + exit 1 + ;; +esac \ No newline at end of file diff --git a/modules/darwin/apps/homebrew.nix b/modules/darwin/apps/homebrew.nix index a97f99e..c07cbaf 100644 --- a/modules/darwin/apps/homebrew.nix +++ b/modules/darwin/apps/homebrew.nix @@ -6,29 +6,34 @@ enable = true; onActivation.cleanup = "uninstall"; - taps = []; brews = [ - "cowsay" + "argoproj/homebrew-tap/kubectl-argo-rollouts" + "gh" "git" - "k9s" "helm" - "podman" - "podman-compose" + "k9s" + "ansible" ]; casks = [ "1password" - "podman-desktop" + "cursor" + "elgato-wave-link" + "ghostty" + "joplin" + "localsend" + "logi-options+" + "orbstack" "teleport-connect" "utm" - "localsend" - "joplin" - "ghostty" + "vivaldi" ]; masApps = { "1Password for Safari" = 1569813296; + "pairvpn" = 1347012179; + "tailscale" = 1475387142; + "Windows App" = 1295203466; "wireguard" = 1451685025; "wipr" = 1320666476; - "tailscale" = 1475387142; }; }; } diff --git a/modules/darwin/apps/nixpackages.nix b/modules/darwin/apps/nixpackages.nix index 967fabb..7e0b7a3 100644 --- a/modules/darwin/apps/nixpackages.nix +++ b/modules/darwin/apps/nixpackages.nix @@ -2,22 +2,6 @@ { environment.systemPackages = with pkgs; [ - _1password-cli - awscli - azure-cli - brave - discord - go - google-cloud-sdk - kubectl - krew - lens - slack - spotify - starship - teleport - tenv - vim - vscode + ]; } diff --git a/modules/darwin/apps/services.nix b/modules/darwin/apps/services.nix index 1c3b173..851c7aa 100644 --- a/modules/darwin/apps/services.nix +++ b/modules/darwin/apps/services.nix @@ -2,6 +2,6 @@ { # Example: Tailscale, other system services - services.nix-daemon.enable = true; + # services.nix-daemon.enable = true; # services.tailscale.enable = false; } diff --git a/modules/darwin/security/default.nix b/modules/darwin/security/default.nix index 6c31d6b..4e8836f 100644 --- a/modules/darwin/security/default.nix +++ b/modules/darwin/security/default.nix @@ -1,7 +1,7 @@ { config, pkgs, ... }: { # Enable TouchID for PAM auth: you could also place security/pam or other service configs here: - security.pam.enableSudoTouchIdAuth = true; + security.pam.services.sudo_local.touchIdAuth = true; system.defaults.alf = { allowsignedenabled = 1; # Allows any signed Application to accept incoming requests. Default is true. 0 = disabled 1 = enabled diff --git a/modules/darwin/system/appearance.nix b/modules/darwin/system/appearance.nix index 72163cf..89c5677 100644 --- a/modules/darwin/system/appearance.nix +++ b/modules/darwin/system/appearance.nix @@ -1,13 +1,18 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, lib, username, ... }: +let + homeDirectory = "/Users/${username}"; +in { # If you also want to do e.g. Dock preferences from the same user-level file: system.defaults.dock = { autohide = true; orientation = "bottom"; persistent-apps = [ - /Applications/Safari.app - /Applications/Ghostty.app - "/${pkgs.vscode}/Applications/Visual Studio Code.app" # Use the nixpkgs path to the app for apps installed via nix. This will automatically use the latest nix store path. + "/Applications/Zen Browser.app" + "/Applications/Vivaldi.app" + "/Applications/Ghostty.app" + "/Applications/Cursor.app" + # Use the nixpkgs path to the app for apps installed via nix. This will automatically use the latest nix store path. "/${pkgs.lens}/Applications/Lens.app" "/${pkgs.slack}/Applications/Slack.app" "/${pkgs.discord}/Applications/Discord.app" @@ -16,16 +21,16 @@ # Add your persistent apps here ]; persistent-others = [ - "~/code" - "~/Downloads" + "${homeDirectory}/code" + "${homeDirectory}/Downloads" + "${homeDirectory}/Applications/Home Manager Apps" # Add your persistent others here ]; show-recents = false; tilesize = 36; # Set the icon size on the dock; default is 64 }; - -system.defaults.NSGlobalDomain = { + system.defaults.NSGlobalDomain = { AppleInterfaceStyle = "Dark"; # "Dark" or "Light" - Darkmode all the things # Add more NSGlobalDomain settings here }; @@ -34,5 +39,5 @@ system.defaults.NSGlobalDomain = { GuestEnabled = false; # Disable guest account LoginwindowText = "Super Awesome Mac"; # Set login window text # Add more loginwindow settings here - }; + }; } \ No newline at end of file diff --git a/modules/darwin/system/system.nix b/modules/darwin/system/system.nix index 2a3aae3..561e376 100644 --- a/modules/darwin/system/system.nix +++ b/modules/darwin/system/system.nix @@ -14,7 +14,7 @@ }; system.keyboard = { - swapLeftCtrlAndFn = true; # Swap left control and function keys + swapLeftCtrlAndFn = false; # Swap left control and function keys enableKeyMapping = true; # Enable key mapping # Set up your keyboard preferences here }; diff --git a/modules/home/stephen/default.nix b/modules/home/stephen/default.nix new file mode 100644 index 0000000..8f8faad --- /dev/null +++ b/modules/home/stephen/default.nix @@ -0,0 +1,28 @@ +{ config, pkgs, lib, ... }: +{ + imports = [ + ./terminal/default.nix + ]; + + home = { + packages = with pkgs; [ + _1password-cli + awscli2 + azure-cli + brave + discord + go + google-cloud-sdk + kubectl + krew + lens + ollama + slack + spotify + teleport + tenv + vim + vscode + ]; + }; +} diff --git a/modules/home/stephen/dotfiles.nix b/modules/home/stephen/dotfiles.nix deleted file mode 100644 index 53699e0..0000000 --- a/modules/home/stephen/dotfiles.nix +++ /dev/null @@ -1,148 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - # Some user-level dotfiles - 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 - ''; - - ".config/starship.toml".text = '' - 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 " - ''; - - ".zshrc".text = '' - eval "$(starship init zsh)" - ''; - }; -} \ No newline at end of file diff --git a/modules/home/stephen/terminal/default.nix b/modules/home/stephen/terminal/default.nix new file mode 100644 index 0000000..21a59fd --- /dev/null +++ b/modules/home/stephen/terminal/default.nix @@ -0,0 +1,68 @@ +{ config, pkgs, lib, ... }: + +{ + + imports = [ + ./starship/default.nix + ]; + + # Some user-level dotfiles + home.file = { + # Configure ssh + ".ssh/config".text = '' + Host * + IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" + ''; + + # Configure git + ".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 + ''; + + # Configure 1password agent.toml + ".config/1Password/ssh/agent.toml".text = '' + # Examples can be found here: + # https://developer.1password.com/docs/ssh/agent/config + + [[ssh-keys]] + item = "github-auth-key" + vault = "Private" + + [[ssh-keys]] + item = "github-sign-key" + vault = "Private" + + [[ssh-keys]] + item = "Github-swaphb" + vault = "Private" + + [[ssh-keys]] + vault = "Employee" + ''; + + # Configure zsh + ".zshrc".text = '' + eval "$(starship init zsh)" + export PATH="''${KREW_ROOT:-/Users/${config.home.username}/.krew}/bin:$PATH" + ''; + + # Configure ghostty + ".config/ghostty/config".text = '' + background-opacity = 0.9 + theme = "dracula" + ''; + + }; +} \ No newline at end of file diff --git a/modules/home/stephen/terminal/starship/default.nix b/modules/home/stephen/terminal/starship/default.nix new file mode 100644 index 0000000..c2917f9 --- /dev/null +++ b/modules/home/stephen/terminal/starship/default.nix @@ -0,0 +1,185 @@ +{ + 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)"; + }; + + cmd_duration = { + min_time = 500; + format = "took [$duration](bold yellow)"; + }; + + git_commit = { + tag_symbol = " tag "; + }; + + git_status = { + ahead = ">"; + behind = "<"; + diverged = "<>"; + renamed = "r"; + deleted = "x"; + }; + + 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 = { + format = "[$symbol]($style) "; # Display the OS symbol + disabled = false; # Enable the OS module + style = "bold green"; # Style for the OS symbol + }; + + 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 = " "; + 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 "; + }; + }; + }; +} diff --git a/modules/home/userB/dotfiles.nix b/modules/home/userB/default.nix similarity index 52% rename from modules/home/userB/dotfiles.nix rename to modules/home/userB/default.nix index 2c0d77b..fc55fd8 100644 --- a/modules/home/userB/dotfiles.nix +++ b/modules/home/userB/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, lib, username, ... }: { home.file.".gitconfig".text = '' @@ -10,4 +10,15 @@ home.file.".zshrc".text = '' # userA's custom zsh config ''; -} + + imports = [ + # User B's imports + ]; + + home = { + packages = with pkgs; [ + # User B's packages + ]; + + }; +} \ No newline at end of file diff --git a/rebuild.sh b/rebuild.sh deleted file mode 100644 index 2554ee4..0000000 --- a/rebuild.sh +++ /dev/null @@ -1,2 +0,0 @@ -#bin/bash -darwin-rebuild switch --flake .#swaphb-mba \ No newline at end of file diff --git a/update.sh b/update.sh deleted file mode 100644 index 11572b9..0000000 --- a/update.sh +++ /dev/null @@ -1,3 +0,0 @@ -#bin/bash -nix flake update -darwin-rebuild switch --flake .#swaphb-mba \ No newline at end of file