diff --git a/.config/atuin/config.toml b/.config/atuin/config.toml deleted file mode 100644 index c7ec384..0000000 --- a/.config/atuin/config.toml +++ /dev/null @@ -1,232 +0,0 @@ -## where to store your database, default is your system data directory -## linux/mac: ~/.local/share/atuin/history.db -## windows: %USERPROFILE%/.local/share/atuin/history.db -# db_path = "~/.history.db" - -## where to store your encryption key, default is your system data directory -## linux/mac: ~/.local/share/atuin/key -## windows: %USERPROFILE%/.local/share/atuin/key -# key_path = "~/.key" - -## where to store your auth session token, default is your system data directory -## linux/mac: ~/.local/share/atuin/session -## windows: %USERPROFILE%/.local/share/atuin/session -# session_path = "~/.session" - -## date format used, either "us" or "uk" -# dialect = "us" - -## default timezone to use when displaying time -## either "l", "local" to use the system's current local timezone, or an offset -## from UTC in the format of "<+|->H[H][:M[M][:S[S]]]" -## for example: "+9", "-05", "+03:30", "-01:23:45", etc. -# timezone = "local" - -## enable or disable automatic sync -# auto_sync = true - -## enable or disable automatic update checks -# update_check = true - -## address of the sync server -# sync_address = "https://api.atuin.sh" - -## how often to sync history. note that this is only triggered when a command -## is ran, so sync intervals may well be longer -## set it to 0 to sync after every command -# sync_frequency = "10m" - -## which search mode to use -## possible values: prefix, fulltext, fuzzy, skim -# search_mode = "fuzzy" - -## which filter mode to use -## possible values: global, host, session, directory -# filter_mode = "global" - -## With workspace filtering enabled, Atuin will filter for commands executed -## in any directory within a git repository tree (default: false) -# workspaces = false - -## which filter mode to use when atuin is invoked from a shell up-key binding -## the accepted values are identical to those of "filter_mode" -## leave unspecified to use same mode set in "filter_mode" -# filter_mode_shell_up_key_binding = "global" - -## which search mode to use when atuin is invoked from a shell up-key binding -## the accepted values are identical to those of "search_mode" -## leave unspecified to use same mode set in "search_mode" -# search_mode_shell_up_key_binding = "fuzzy" - -## which style to use -## possible values: auto, full, compact -style = "compact" - -## the maximum number of lines the interface should take up -## set it to 0 to always go full screen -inline_height = 20 - -## Invert the UI - put the search bar at the top , Default to `false` -# invert = false - -## enable or disable showing a preview of the selected command -## useful when the command is longer than the terminal width and is cut off -# show_preview = true - -## what to do when the escape key is pressed when searching -## possible values: return-original, return-query -# exit_mode = "return-original" - -## possible values: emacs, subl -# word_jump_mode = "emacs" - -## characters that count as a part of a word -# word_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - -## number of context lines to show when scrolling by pages -# scroll_context_lines = 1 - -## use ctrl instead of alt as the shortcut modifier key for numerical UI shortcuts -## alt-0 .. alt-9 -# ctrl_n_shortcuts = false - -## default history list format - can also be specified with the --format arg -# history_format = "{time}\t{command}\t{duration}" - -## prevent commands matching any of these regexes from being written to history. -## Note that these regular expressions are unanchored, i.e. if they don't start -## with ^ or end with $, they'll match anywhere in the command. -## For details on the supported regular expression syntax, see -## https://docs.rs/regex/latest/regex/#syntax -# history_filter = [ -# "^secret-cmd", -# "^innocuous-cmd .*--secret=.+", -# ] - -## prevent commands run with cwd matching any of these regexes from being written -## to history. Note that these regular expressions are unanchored, i.e. if they don't -## start with ^ or end with $, they'll match anywhere in CWD. -## For details on the supported regular expression syntax, see -## https://docs.rs/regex/latest/regex/#syntax -# cwd_filter = [ -# "^/very/secret/area", -# ] - -## Configure the maximum height of the preview to show. -## Useful when you have long scripts in your history that you want to distinguish -## by more than the first few lines. -# max_preview_height = 4 - -## Configure whether or not to show the help row, which includes the current Atuin -## version (and whether an update is available), a keymap hint, and the total -## amount of commands in your history. -# show_help = true - -## Configure whether or not to show tabs for search and inspect -# show_tabs = true - -## Defaults to true. This matches history against a set of default regex, and will not save it if we get a match. Defaults include -## 1. AWS key id -## 2. Github pat (old and new) -## 3. Slack oauth tokens (bot, user) -## 4. Slack webhooks -## 5. Stripe live/test keys -# secrets_filter = true - -## Defaults to true. If enabled, upon hitting enter Atuin will immediately execute the command. Press tab to return to the shell and edit. -# This applies for new installs. Old installs will keep the old behaviour unless configured otherwise. -enter_accept = true - -## Defaults to "emacs". This specifies the keymap on the startup of `atuin -## search`. If this is set to "auto", the startup keymap mode in the Atuin -## search is automatically selected based on the shell's keymap where the -## keybinding is defined. If this is set to "emacs", "vim-insert", or -## "vim-normal", the startup keymap mode in the Atuin search is forced to be -## the specified one. -# keymap_mode = "auto" - -## Cursor style in each keymap mode. If specified, the cursor style is changed -## in entering the cursor shape. Available values are "default" and -## "{blink,steady}-{block,underline,bar}". -# keymap_cursor = { emacs = "blink-block", vim_insert = "blink-block", vim_normal = "steady-block" } - -# network_connect_timeout = 5 -# network_timeout = 5 - -## Timeout (in seconds) for acquiring a local database connection (sqlite) -# local_timeout = 5 - -## Set this to true and Atuin will minimize motion in the UI - timers will not update live, etc. -## Alternatively, set env NO_MOTION=true -# prefers_reduced_motion = false - -[stats] -## Set commands where we should consider the subcommand for statistics. Eg, kubectl get vs just kubectl -# common_subcommands = [ -# "apt", -# "cargo", -# "composer", -# "dnf", -# "docker", -# "git", -# "go", -# "ip", -# "kubectl", -# "nix", -# "nmcli", -# "npm", -# "pecl", -# "pnpm", -# "podman", -# "port", -# "systemctl", -# "tmux", -# "yarn", -# ] - -## Set commands that should be totally stripped and ignored from stats -# common_prefix = ["sudo"] - -## Set commands that will be completely ignored from stats -# ignored_commands = [ -# "cd", -# "ls", -# "vi" -# ] - -[keys] -# Defaults to true. If disabled, using the up/down key won't exit the TUI when scrolled past the first/last entry. -# scroll_exits = false - -[sync] -# Enable sync v2 by default -# This ensures that sync v2 is enabled for new installs only -# In a later release it will become the default across the board -records = true - -[preview] -## which preview strategy to use to calculate the preview height (respects max_preview_height). -## possible values: auto, static -## auto: length of the selected command. -## static: length of the longest command stored in the history. -# strategy = "auto" - -[daemon] -## Enables using the daemon to sync. Requires the daemon to be running in the background. Start it with `atuin daemon` -# enabled = false - -## How often the daemon should sync in seconds -# sync_frequency = 300 - -## The path to the unix socket used by the daemon (on unix systems) -## linux/mac: ~/.local/share/atuin/atuin.sock -## windows: Not Supported -# socket_path = "~/.local/share/atuin/atuin.sock" - -## Use systemd socket activation rather than opening the given path (the path must still be correct for the client) -## linux: false -## mac/windows: Not Supported -# systemd_socket = false - -## The port that should be used for TCP on non unix systems -# tcp_port = 8889 diff --git a/.config/home-manager/common-flake.nix b/.config/home-manager/common-flake.nix deleted file mode 100644 index 1a6a750..0000000 --- a/.config/home-manager/common-flake.nix +++ /dev/null @@ -1,190 +0,0 @@ -{ config, pkgs, lib, inputs, ... }: - -let - # Get GPG signing key from host configuration, with fallback - gpgSigningKey = config.myConfig.gpgSigningKey or null; -in - -{ - # Allow unfree packages (like some proprietary tools) - nixpkgs.config.allowUnfree = true; - - home.packages = [ - pkgs.ack - pkgs.act - pkgs.awscli2 - pkgs.dive - pkgs.fd - pkgs.fzf - pkgs.gh - pkgs.git - pkgs.gnupg - pkgs.jq - pkgs.kind - pkgs.k9s - pkgs.kubectl - pkgs.kubernetes-helm - pkgs.lazydocker - pkgs.lazygit - pkgs.neovim - pkgs.pinentry-curses # For GPG password prompts in terminal - pkgs.ripgrep - pkgs.terraform - pkgs.terraform-docs - pkgs.tmux - pkgs.yq - pkgs.yt-dlp - ]; - - home.file = { - ".ackrc".text = '' - --pager=less -R - --ignore-case - ''; - - ".tmux.conf".source = ../../tmux.conf; - - ".config/atuin".source = ../atuin; - ".config/ghostty".source = ../ghostty; - ".config/k9s".source = ../k9s; - ".config/nvim".source = ../nvim; - }; - - # Common session variables - home.sessionVariables = { - AWS_CLI_AUTO_PROMPT = "on-partial"; - EDITOR = "nvim"; - PAGER = "less"; - LESS = "-R"; - }; - - # Direnv integration - programs.direnv = { - enable = true; - nix-direnv.enable = true; - }; - - # Fish shell configuration - # https://nixos.wiki/wiki/Fish - programs.fish = { - enable = true; - - shellInit = '' - # Set up direnv if available - if command -v direnv >/dev/null - direnv hook fish | source - end - - fish_vi_key_bindings - ''; - - functions = { - # AWS profile switcher - aws-ps = { - description = "Switch AWS profiles"; - body = '' - set -l profile $argv[1] - if test -z "$profile" - echo "Available profiles:" - aws configure list-profiles - return - end - set -gx AWS_PROFILE $profile - echo "Switched to AWS profile: $profile" - ''; - }; - }; - - shellAliases = { - # Modern replacements - cat = "bat --style=plain"; - find = "fd"; - grep = "rg"; - - # Nix flake aliases - nfc = "nix flake check"; - nfu = "nix flake update"; - nfs = "nix flake show"; - }; - - plugins = [ - { - name = "pure"; - src = pkgs.fishPlugins.pure.src; - } - ]; - }; - - # Git configuration - programs.git = { - enable = true; - userName = "Mike Priscella"; - userEmail = "mpriscella@gmail.com"; - - extraConfig = { - init.defaultBranch = "main"; - pull.rebase = false; - push.autoSetupRemote = true; - core.editor = "nvim"; - - # GPG signing configuration (conditional) - user.signingkey = lib.mkIf (gpgSigningKey != null) gpgSigningKey; - commit.gpgsign = lib.mkIf (gpgSigningKey != null) true; - tag.gpgsign = lib.mkIf (gpgSigningKey != null) true; - }; - - ignores = [ - ".DS_Store" - "*.swp" - "*.swo" - "*~" - ".direnv/" - "result" - "result-*" - ]; - - aliases = { - st = "status"; - co = "checkout"; - br = "branch"; - ci = "commit"; - di = "diff"; - unstage = "reset HEAD --"; - last = "log -1 HEAD"; - visual = "!gitk"; - graph = "log --oneline --graph --decorate --all"; - # Show files ignored by git - ign = "ls-files -o -i --exclude-standard"; - }; - }; - - # GPG configuration - programs.gpg = { - enable = true; - settings = { - # Use a long keyid format - keyid-format = "long"; - # Show fingerprints - with-fingerprint = true; - # Disable greeting message - no-greeting = true; - # Use the GPG agent - use-agent = true; - }; - }; - - # Home Manager needs a bit of information about you and the - # paths it should manage. - programs.home-manager.enable = true; - - # Enable man page support - programs.man.enable = true; - - services.gpg-agent = { - enable = true; - enableFishIntegration = true; - pinentry.package = pkgs.pinentry-curses; - defaultCacheTtl = 28800; # 8 hours - maxCacheTtl = 86400; # 24 hours - }; -} diff --git a/.config/home-manager/hosts/default-flake.nix b/.config/home-manager/hosts/default-flake.nix deleted file mode 100644 index e5edc77..0000000 --- a/.config/home-manager/hosts/default-flake.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, pkgs, inputs, ... }: - -{ - imports = [ - ../common-flake.nix - ../modules/machine-config-flake.nix - ]; - - # Custom configuration using our module - myConfig = { - configPath = "${config.home.homeDirectory}/.config/home-manager/hosts/default-flake.nix"; - gpgSigningKey = null; # No default GPG key - }; -} diff --git a/.config/home-manager/hosts/macbook-air-flake.nix b/.config/home-manager/hosts/macbook-air-flake.nix deleted file mode 100644 index d470e05..0000000 --- a/.config/home-manager/hosts/macbook-air-flake.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ config, pkgs, inputs, ... }: - -{ - imports = [ - ../common-flake.nix - ../modules/machine-config-flake.nix - ]; - - # Custom configuration using our module - myConfig = { - configPath = "${config.home.homeDirectory}/.config/home-manager/hosts/macbook-air-flake.nix"; - gpgSigningKey = null; # Set your personal GPG key here if needed - }; - - # You can add MacBook Air specific configurations here - home.packages = with pkgs; [ - # Add any MacBook Air specific tools here - ]; -} diff --git a/.config/home-manager/hosts/work-macbook-pro-flake.nix b/.config/home-manager/hosts/work-macbook-pro-flake.nix deleted file mode 100644 index b261671..0000000 --- a/.config/home-manager/hosts/work-macbook-pro-flake.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ config, pkgs, inputs, ... }: - -{ - imports = [ - ../common-flake.nix - ../modules/machine-config-flake.nix - ]; - - # Custom configuration using our module - myConfig = { - configPath = "${config.home.homeDirectory}/.config/home-manager/hosts/work-macbook-pro-flake.nix"; - gpgSigningKey = "799887D03FE96FD0"; # Work-specific GPG key - }; - - # You can add work-specific packages or configurations here - home.packages = with pkgs; [ - # Add any work-specific tools here - ]; -} diff --git a/.config/home-manager/modules/machine-config-flake.nix b/.config/home-manager/modules/machine-config-flake.nix deleted file mode 100644 index b5feb48..0000000 --- a/.config/home-manager/modules/machine-config-flake.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ config, lib, pkgs, inputs, ... }: - -with lib; - -{ - options.myConfig = { - configPath = mkOption { - type = types.str; - default = "${config.home.homeDirectory}/.config/home-manager/home.nix"; - description = "Path to the home-manager configuration file for this machine"; - }; - - gpgSigningKey = mkOption { - type = types.nullOr types.str; - default = null; - description = "GPG key ID for signing git commits on this machine"; - example = "ABC123DEF456"; - }; - }; - - config = { - # Use your custom options here - home.packages = with pkgs; [ - # Custom build script for flake - (writeShellScriptBin "home-manager-build" '' - echo "Building Home Manager flake configuration..." - echo "Using config: ${config.myConfig.configPath}" - cd ${config.home.homeDirectory}/.config/home-manager/../../.. - exec home-manager build --flake .#$(hostname -s || echo "default") "$@" - '') - - # Custom switch script for flake - (writeShellScriptBin "home-manager-switch" '' - echo "Switching Home Manager flake configuration..." - echo "Using config: ${config.myConfig.configPath}" - cd ${config.home.homeDirectory}/.config/home-manager/../../.. - exec home-manager switch --flake .#$(hostname -s || echo "default") "$@" - '') - - # Helper script to show available flake configurations - (writeShellScriptBin "home-manager-list" '' - echo "Available Home Manager flake configurations:" - cd ${config.home.homeDirectory}/.config/home-manager/../../.. - nix flake show . 2>/dev/null | grep homeConfigurations || echo "No configurations found" - '') - - # Update flake script - (writeShellScriptBin "home-manager-update" '' - echo "Updating Home Manager flake inputs..." - cd ${config.home.homeDirectory}/.config/home-manager/../../.. - nix flake update - echo "Flake inputs updated!" - '') - ]; - - # Add some useful shell aliases for flake management - programs.fish.shellAliases = lib.mkMerge [ - { - hmb = "home-manager-build"; - hms = "home-manager-switch"; - hml = "home-manager-list"; - hmu = "home-manager-update"; - } - ]; - }; -} diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json deleted file mode 100644 index a3d2b60..0000000 --- a/.config/nvim/lazy-lock.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "avante.nvim": { "branch": "main", "commit": "fdf4716ec04cf5d9f8f39a44b7d42ab37cc2bd40" }, - "blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" }, - "codesnap.nvim": { "branch": "main", "commit": "be6d6b9a3b5e6999edbda76b16dace03d9bfcd3d" }, - "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, - "copilot.lua": { "branch": "master", "commit": "c1bb86abbed1a52a11ab3944ef00c8410520543d" }, - "copilot.vim": { "branch": "release", "commit": "3955014c503b0cd7b30bc56c86c56c0736ca0951" }, - "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, - "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, - "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "fzf-lua": { "branch": "main", "commit": "d155cc9648ba391f64876888ea0ae09a7aff469d" }, - "gitsigns.nvim": { "branch": "main", "commit": "731b581428ec6c1ccb451b95190ebbc6d7006db7" }, - "hardtime.nvim": { "branch": "main", "commit": "145b930954a3146cfb5b8a73cdcad42eb7d2740c" }, - "img-clip.nvim": { "branch": "main", "commit": "d8b6b030672f9f551a0e3526347699985a779d93" }, - "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "bef29b653ba71d442816bf56286c2a686210be04" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" }, - "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, - "mini.pick": { "branch": "main", "commit": "fdb920aa92ed624a0447bc13ddac79d9d2653c24" }, - "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, - "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, - "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-dap": { "branch": "master", "commit": "40a8189b8a57664a1850b0823fdcb3ac95b9f635" }, - "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, - "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, - "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "7ad4a11cc5742774877c529fcfb2702f7caf75e4" }, - "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" }, - "nvim-surround": { "branch": "main", "commit": "8dd9150ca7eae5683660ea20cec86edcd5ca4046" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-treesitter-context": { "branch": "master", "commit": "1a1a7c5d6d75cb49bf64049dafab15ebe294a79f" }, - "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, - "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "render-markdown.nvim": { "branch": "main", "commit": "76f7ce56ccb913632745714f160faa53164c5574" }, - "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, - "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, - "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, - "toggleterm.nvim": { "branch": "main", "commit": "022ff5594acccc8d90d2e46dc43994f7722ebdf7" }, - "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, - "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, - "vim-helm": { "branch": "master", "commit": "cc5ac22444332381f38084a6c7f023c25eef6201" }, - "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } -} diff --git a/.config/nvim/lua/custom/plugins/avante.lua b/.config/nvim/lua/custom/plugins/avante.lua deleted file mode 100644 index 1eb59b0..0000000 --- a/.config/nvim/lua/custom/plugins/avante.lua +++ /dev/null @@ -1,59 +0,0 @@ -return { - 'yetone/avante.nvim', - event = 'VeryLazy', - version = false, -- Never set this value to "*"! Never! - opts = { - -- add any opts here - -- for example - provider = 'openai', - openai = { - endpoint = 'https://api.openai.com/v1', - model = 'gpt-4o', -- your desired model (or use gpt-4o, etc.) - timeout = 30000, -- Timeout in milliseconds, increase this for reasoning models - temperature = 0, - max_completion_tokens = 8192, -- Increase this to include reasoning tokens (for reasoning models) - --reasoning_effort = "medium", -- low|medium|high, only used for reasoning models - }, - }, - -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` - build = 'make', - -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows - dependencies = { - 'nvim-treesitter/nvim-treesitter', - 'stevearc/dressing.nvim', - 'nvim-lua/plenary.nvim', - 'MunifTanjim/nui.nvim', - --- The below dependencies are optional, - 'echasnovski/mini.pick', -- for file_selector provider mini.pick - 'nvim-telescope/telescope.nvim', -- for file_selector provider telescope - 'hrsh7th/nvim-cmp', -- autocompletion for avante commands and mentions - 'ibhagwan/fzf-lua', -- for file_selector provider fzf - 'nvim-tree/nvim-web-devicons', -- or echasnovski/mini.icons - 'zbirenbaum/copilot.lua', -- for providers='copilot' - { - -- support for image pasting - 'HakonHarnes/img-clip.nvim', - event = 'VeryLazy', - opts = { - -- recommended settings - default = { - embed_image_as_base64 = false, - prompt_for_file_name = false, - drag_and_drop = { - insert_mode = true, - }, - -- required for Windows users - use_absolute_path = true, - }, - }, - }, - { - -- Make sure to set this up properly if you have lazy=true - 'MeanderingProgrammer/render-markdown.nvim', - opts = { - file_types = { 'markdown', 'Avante' }, - }, - ft = { 'markdown', 'Avante' }, - }, - }, -} diff --git a/.config/nvim/lua/custom/plugins/hardline.lua b/.config/nvim/lua/custom/plugins/hardline.lua deleted file mode 100644 index 1119b6d..0000000 --- a/.config/nvim/lua/custom/plugins/hardline.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - 'm4xshen/hardtime.nvim', - lazy = false, - dependencies = { 'MunifTanjim/nui.nvim' }, - opts = {}, -} diff --git a/.config/nvim/lua/custom/plugins/helm.lua b/.config/nvim/lua/custom/plugins/helm.lua deleted file mode 100644 index dbf16e6..0000000 --- a/.config/nvim/lua/custom/plugins/helm.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'towolf/vim-helm', - ft = 'helm', -} diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..d65ad9a --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,62 @@ +# Copilot Instructions for `dotfiles` + +## Overview +This repository manages cross-platform dotfiles using Nix flakes, Home Manager, and nix-darwin (for macOS). It supports both user-level and system-level configuration, with host-specific overrides. The structure is optimized for reproducibility and multi-host management. + +## Architecture +- **flake.nix**: Entry point. Defines all flake inputs (nixpkgs, home-manager, nix-darwin, etc.) and outputs (darwinConfigurations for macOS, devShells, formatters, packages). +- **home/modules/**: Shared configuration modules (`darwin.nix`, `home-base.nix`) for reuse across hosts. +- **home/programs/**: Individual program configurations (git.nix, fish.nix, etc.) imported by `home-base.nix`. +- **nix-darwin**: Used for system-level configuration on macOS. Home Manager is included as a module within nix-darwin for unified management. + +## Key Workflows +- **System configuration (macOS):** + - Use `darwin-rebuild switch --flake .#` to apply both system and user configuration. + - Example: `darwin-rebuild switch --flake .#macbook-pro-m3` + - For new installs: `nix run nix-darwin -- switch --flake .#` +- **Development shell:** + - Enter with `nix develop` for a shell with all dev tools and commands. +- **Update dependencies:** + - Run `nix flake update` to update all flake inputs. +- **Format code:** + - Use `nix fmt flake.nix home/` to format Nix files (avoid recursive formatting due to cache dirs). +- **Neovim development:** + - Use `./nvim-dev.sh` for isolated Neovim environment with local config. + +## Project Conventions +- **All macOS configuration is managed via nix-darwin.** Do not use standalone `homeConfigurations` for macOS hosts; use `darwinConfigurations` instead. +- **User-level configuration is managed via Home Manager as a nix-darwin module.** +- **Host-specific logic** is currently defined inline in `flake.nix` but should be moved to `home/hosts/.nix` following the project's intended structure. +- **Packages** for each system are defined in `defaultPackages` function in `flake.nix`. +- **Program configurations** are modularized in `home/programs/` and imported via `home-base.nix`. + +## Current Structure vs. Intended Structure +- **Current**: Host configurations are defined inline in `flake.nix` +- **Intended**: Host configurations should be in `home/hosts/.nix` files +- **When adding new hosts**: Create `home/hosts/.nix` and import it in `flake.nix` modules list + +## Shell Configuration +- **Fish shell**: Enable via `programs.fish.enable = true` in nix-darwin config +- **Shell setup**: Set user shell with `users.users..shell = pkgs.fish` +- **Note**: nix-darwin automatically adds enabled shells to `/etc/shells` + +## GPG Configuration +- **Per-host GPG keys**: Use `gpgConfig.gpgSigningKey` option in Home Manager config +- **Git signing**: Automatically configured when `gpgSigningKey` is set +- **Example**: `gpgConfig = { gpgSigningKey = "799887D03FE96FD0"; };` + +## Integration Points +- **nix-darwin**: System-level macOS configuration, including Home Manager as a module. +- **Home Manager**: User-level configuration, dotfiles, and packages. +- **Nixpkgs**: Source of all packages and system tools. + +## Troubleshooting +- If a configuration fails, check the relevant host configuration and shared modules for errors. +- Use `nix flake check` to validate the flake. +- For macOS, always use `darwin-rebuild` for system changes, not `home-manager switch`. +- Format specific paths only: `nix fmt flake.nix home/` (not recursive due to nvim-cache directories). + +## References +- [nix-darwin](https://github.com/LnL7/nix-darwin) +- [home-manager](https://github.com/nix-community/home-manager) +- [Nix Flakes](https://nixos.wiki/wiki/Flakes) diff --git a/.github/workflows/test-home-manager.yml b/.github/workflows/test-home-manager.yml index 65b0656..e34c89c 100644 --- a/.github/workflows/test-home-manager.yml +++ b/.github/workflows/test-home-manager.yml @@ -5,14 +5,16 @@ on: branches: - main paths: - - '.config/home-manager/**' + - 'home-manager/**' + - 'nix-darwin/**' - 'flake.nix' - 'flake.lock' pull_request: branches: - main paths: - - '.config/home-manager/**' + - 'home-manager/**' + - 'nix-darwin/**' - 'flake.nix' - 'flake.lock' workflow_dispatch: @@ -26,42 +28,30 @@ jobs: fail-fast: false matrix: include: - # Test configurations from flake - - config: default - os: ubuntu-latest - platform: linux - system: x86_64-linux - - config: linux-user - os: ubuntu-latest - platform: linux - system: x86_64-linux - - config: work-macbook-pro - os: macos-latest - platform: darwin - system: aarch64-darwin - - config: macbook-air + # Test Home Manager configurations only + # nix-darwin configs are excluded as they require actual macOS system setup + - config: macbook-pro-m3 os: macos-latest platform: darwin system: aarch64-darwin + type: home-manager + - config: nixos-orbstack + os: ubuntu-latest + platform: linux + system: aarch64-linux + type: home-manager steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Nix - uses: cachix/install-nix-action@v24 + uses: cachix/install-nix-action@v31 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} extra_nix_config: | experimental-features = nix-command flakes - # - name: Setup Cachix (optional - speeds up builds) - # uses: cachix/cachix-action@v12 - # if: ${{ vars.CACHIX_NAME != '' }} - # with: - # name: ${{ vars.CACHIX_NAME }} - # authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: Set test environment variables run: | # Set test username for configurations that need it @@ -76,19 +66,23 @@ jobs: cd ${{ github.workspace }} echo "Testing flake configuration: ${{ matrix.config }}" - # Check that the flake is valid - nix flake check --show-trace + # Skip nix flake check entirely as it tries to evaluate nix-darwin configs + # which conflict with existing Nix installation on GitHub runners # Show available configurations echo "Available configurations:" nix flake show + # Test that our specific Home Manager configuration exists + echo "Verifying ${{ matrix.config }} exists in homeConfigurations..." + nix eval .#homeConfigurations.${{ matrix.config }} --apply "x: \"exists\"" --raw + - name: Test configuration build run: | cd ${{ github.workspace }} - echo "Building Home Manager configuration: ${{ matrix.config }}" + echo "Building ${{ matrix.type }} configuration: ${{ matrix.config }}" - # Build the specific configuration from the flake + # Build Home Manager configuration nix build .#homeConfigurations.${{ matrix.config }}.activationPackage \ --no-link \ --show-trace \ @@ -97,9 +91,9 @@ jobs: - name: Test configuration evaluation run: | cd ${{ github.workspace }} - echo "Evaluating configuration for detailed analysis..." + echo "Evaluating ${{ matrix.type }} configuration for detailed analysis..." - # Test that the configuration evaluates without errors + # Test Home Manager configuration evaluation nix eval .#homeConfigurations.${{ matrix.config }}.config.home.stateVersion \ --show-trace @@ -116,16 +110,27 @@ jobs: # Check if all imported files exist echo "Checking Nix syntax..." - if ! find .config/home-manager -name "*.nix" -exec nix-instantiate --parse {} \; > /dev/null; then - echo "❌ Syntax errors found in nix files" + if ! find home-manager -name "*.nix" -exec nix-instantiate --parse {} \; > /dev/null; then + echo "❌ Syntax errors found in home-manager nix files" exit 1 fi - # Check flake syntax - echo "Checking flake syntax..." - nix flake check + if ! find nix-darwin -name "*.nix" -exec nix-instantiate --parse {} \; > /dev/null; then + echo "❌ Syntax errors found in nix-darwin nix files" + exit 1 + fi - echo "✅ Basic checks passed" + # Test flake.nix syntax without full evaluation + echo "Checking flake.nix syntax..." + if ! nix-instantiate --parse flake.nix > /dev/null; then + echo "❌ Syntax errors found in flake.nix" + exit 1 + fi + + # Skip full flake check as it conflicts with existing Nix on GitHub runners + echo "⚠️ Skipping 'nix flake check' due to nix-darwin build user conflicts in CI" + + echo "✅ Basic syntax checks passed" - name: Generate build artifacts info if: always() @@ -133,6 +138,7 @@ jobs: cd ${{ github.workspace }} echo "## Configuration Test Results" >> $GITHUB_STEP_SUMMARY echo "- **Configuration**: ${{ matrix.config }}" >> $GITHUB_STEP_SUMMARY + echo "- **Type**: ${{ matrix.type }}" >> $GITHUB_STEP_SUMMARY echo "- **Platform**: ${{ matrix.platform }}" >> $GITHUB_STEP_SUMMARY echo "- **System**: ${{ matrix.system }}" >> $GITHUB_STEP_SUMMARY echo "- **OS**: ${{ matrix.os }}" >> $GITHUB_STEP_SUMMARY @@ -157,9 +163,11 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY if [[ "${{ needs.test-configs.result }}" == "success" ]]; then - echo "🎉 **All configurations passed!**" >> $GITHUB_STEP_SUMMARY + echo "🎉 **All Home Manager configurations passed!**" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "All Home Manager configurations build successfully and are ready for deployment." >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "All host configurations build successfully and are ready for deployment." >> $GITHUB_STEP_SUMMARY + echo "📝 **Note**: nix-darwin configurations are not tested in CI as they require actual macOS system setup." >> $GITHUB_STEP_SUMMARY else echo "⚠️ **Some configurations failed**" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY @@ -168,7 +176,5 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY echo "### Tested Configurations:" >> $GITHUB_STEP_SUMMARY - echo "- default (Linux)" >> $GITHUB_STEP_SUMMARY - echo "- linux-user (Linux)" >> $GITHUB_STEP_SUMMARY - echo "- work-macbook-pro (macOS)" >> $GITHUB_STEP_SUMMARY - echo "- macbook-air (macOS)" >> $GITHUB_STEP_SUMMARY + echo "- **Home Manager**: macbook-pro-m3 (macOS), nixos-orbstack (Linux)" >> $GITHUB_STEP_SUMMARY + echo "- **nix-darwin**: Not tested in CI (requires actual macOS system)" >> $GITHUB_STEP_SUMMARY diff --git a/.gitignore b/.gitignore index 2ea2a09..f3049f3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ .DS_Store result + +nvim-cache +nvim-data diff --git a/.tmux/modules/get_kubernetes_context.sh b/.tmux/modules/get_kubernetes_context.sh deleted file mode 100755 index 54ac84b..0000000 --- a/.tmux/modules/get_kubernetes_context.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -context=$(kubectl config view --minify -o jsonpath='{.current-context}') -namespace=$(kubectl config view --minify -o jsonpath='{.contexts[0].context.namespace}') - -echo "$context/$namespace" diff --git a/.tmux/modules/kubernetes.sh b/.tmux/modules/kubernetes.sh deleted file mode 100644 index a1bf6cc..0000000 --- a/.tmux/modules/kubernetes.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -show_kubernetes() { - local index icon color text module - - index=$1 - icon=$(get_tmux_option "@catppuccin_kubernetes_icon" "󱃾") - color=$(get_tmux_option "@catppuccin_kubernetes_color" "${thm_blue:?}") - text=$(get_tmux_option "@catppuccin_kubernetes_text" "#( $HOME/.tmux/modules/get_kubernetes_context.sh )") - - module=$(build_status_module "$index" "$icon" "$color" "$text") - - echo "$module" -} diff --git a/.tmux/modules/time.sh b/.tmux/modules/time.sh deleted file mode 100644 index f986882..0000000 --- a/.tmux/modules/time.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -show_time() { - local index icon color text module - - index=$1 - icon="$(get_tmux_option "@catppuccin_time_icon" "")" - color="$(get_tmux_option "@catppuccin_time_color" "${thm_yellow:?}")" - text="$(get_tmux_option "@catppuccin_time_text" "%H:%M")" - - module=$(build_status_module "$index" "$icon" "$color" "$text") - - echo "$module" -} diff --git a/.vimrc b/.vimrc deleted file mode 100644 index 168a862..0000000 --- a/.vimrc +++ /dev/null @@ -1,140 +0,0 @@ -" ~/.vimrc - -" Section: Bootstrap - -let g:config_dir = expand('~/.vim') -if has('nvim') - let g:config_dir = expand('~/.config/nvim') -endif - -" Create config directory if it doesn't exist. -if !isdirectory(g:config_dir) - call mkdir(g:config_dir) -endif - -" Create autoload directory if it doesn't exist. -if !isdirectory(g:config_dir . "/autoload") - call mkdir(g:config_dir . "/autoload") -endif - -" Load vim-plug (https://github.com/junegunn/vim-plug). -if !filereadable(g:config_dir . '/autoload/plug.vim') - let $PLUG_FILE = g:config_dir . '/autoload/plug.vim' - silent execute '!curl -fLo $PLUG_FILE https://raw.github.com/junegunn/vim-plug/master/plug.vim' -endif - -" Section: Load Plugins - -if executable('git') - call plug#begin(g:config_dir . '/plugged') - - Plug 'tpope/vim-sensible' - - " Syntax plugins. - Plug 'pangloss/vim-javascript', {'for': 'javascript'} - Plug 'fatih/vim-go', {'for': 'go'} - Plug 'fgsch/vim-varnish' - - " Git plugins. - Plug 'tpope/vim-fugitive' - Plug 'airblade/vim-gitgutter' - - Plug 'tpope/vim-commentary' - Plug 'junegunn/rainbow_parentheses.vim' " Is this still active? - Plug 'tpope/vim-surround' - Plug 'Raimondi/delimitMate' - let delimitMate_matchpairs = "(:),[:],{:}" - - Plug 'gcmt/taboo.vim' - let g:taboo_tab_format = '[%N| %f%m]' - let g:taboo_renamed_tab_format = '[%N| %l]' - - Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } - Plug 'junegunn/fzf.vim' - nmap :Files - - call plug#end() -else - echo "Warning:" - echo " - git must be installed to install plugins." -endif - -set relativenumber -set number -set showcmd -set hidden -set modelines=5 -set autoindent -set smartindent -set shiftwidth=2 -set softtabstop=2 -set tabstop=2 -set expandtab -set ignorecase -set nowrap -set linebreak -set clipboard^=unnamed,unnamedplus -set omnifunc=syntaxcomplete#Complete -set splitright -set splitbelow -if (exists('+colorcolumn')) - set colorcolumn=80 - highlight ColorColumn ctermbg=59 -endif - -" Search mappings: These will make it so that going to the next item in a -" search will center on the line it's found in. -nnoremap n nzzzv -nnoremap N Nzzzv - -" Remove trailing whitespace on save. -autocmd BufWritePre * :%s/\s\+$//e - -" Section: Tabs - -let mapleader = "," -nmap t :tabnew -nmap w :tabclose - -" Tabs. -nmap n :tabn -nmap p :tabp -nmap 1 1gt -nmap 2 2gt -nmap 3 3gt -nmap 4 4gt -nmap 5 5gt -nmap 6 6gt -nmap 7 7gt -nmap 8 8gt -nmap 9 9gt - -nmap m1 :tabm 0 -nmap m2 :tabm 1 -nmap m3 :tabm 2 -nmap m4 :tabm 3 -nmap m5 :tabm 4 -nmap m6 :tabm 5 -nmap m7 :tabm 6 -nmap m8 :tabm 7 -nmap m9 :tabm 8 - -nmap r :TabooRename - -" Navigate split windows. -noremap j -noremap k -noremap l -noremap h - -tnoremap ,, - -" Cursor modes. -let &t_SI.="\e[5 q" " Set INSERT mode cursor to 'blinking vertical bar'. -let &t_EI.="\e[1 q" " Set NORMAL mode cursor to 'blinking block'. -let &t_ti.="\e[1 q" -let &t_te.="\e[0 q" - -if filereadable(expand("~/.vimrc.local")) - source ~/.vimrc.local -endif diff --git a/.zshrc b/.zshrc deleted file mode 100644 index 7db9fac..0000000 --- a/.zshrc +++ /dev/null @@ -1,215 +0,0 @@ -######## zinit (https://github.com/zdharma-continuum/zinit) integration ######## - -ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" -[ ! -d "$ZINIT_HOME" ] && mkdir -p "$(dirname "$ZINIT_HOME")" -[ ! -d "$ZINIT_HOME"/.git ] && git clone --depth 1 https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" -source "${ZINIT_HOME}/zinit.zsh" - -zinit load atuinsh/atuin - -#################################### Theme ##################################### - -zinit load mafredri/zsh-async -zinit load sindresorhus/pure - -################################################################################ - -autoload bashcompinit && bashcompinit -autoload -Uz compinit && compinit - -export PATH=$HOME/.bin:$HOME/.nvim/bin:$PATH -export LANG="en_US.UTF-8" - -# (F)astly (Debug). -# Sends the Fastly-Debug header to an endpoint. -# Additional documentation: https://developer.fastly.com/reference/http/http-headers/Fastly-Debug/ -alias fdebug='curl -svo /dev/null -H "Fastly-Debug: true"' -# Enable colored output for default commands. -# TODO should work on both darwin(mac) and linux. -alias grep='grep --color=auto ' -# (H)eader C(url). -alias hurl='curl -sLD - -o /dev/null' -alias ls='ls --color=always' -alias reload='source ~/.zshrc' -# (T)ime (T)o (F)irst (B)yte. -alias ttfb='curl -o /dev/null -H "Cache-Control: no-cache" -s -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n"' - -##################################### brew ##################################### - -if [ -d "/opt/homebrew/bin" ]; then - export PATH="/opt/homebrew/bin:$PATH" - - if type "brew" >/dev/null; then - eval "$(/opt/homebrew/bin/brew shellenv)" - fi -fi - -###################################### go ###################################### - -if [ -d "/usr/local/go/bin" ]; then - export PATH="/usr/local/go/bin:$PATH" -fi - -##################################### AWS ###################################### - -if (type "aws" >/dev/null && type aws_completer >/dev/null); then - aws_completer_path=$(which aws_completer) - complete -C "$aws_completer_path" aws - - export AWS_CLI_AUTO_PROMPT=on-partial - - if [ -z "$AWS_PROFILE" ]; then - export AWS_PROFILE=default - fi - - ####################################### - # Switch between AWS Profiles. - # Arguments: - # None - ####################################### - function aws-ps { - profile=$(aws configure list-profiles | fzf --height=30% --layout=reverse) - if [ -n "$profile" ]; then - export AWS_PROFILE=$profile - echo "AWS profile \"$AWS_PROFILE\" now active." - fi - } - - ####################################### - # Log into ECR repositories. - # Arguments: - # None - ####################################### - function ecr-login { - if [[ $(aws sts get-caller-identity >/dev/null 2>&1) -ne 0 ]]; then - echo "Could not connect to AWS account. Please verify that your credentials are correct." - kill -INT $$ - fi - - region=$(aws configure get region) - name=$(aws ecr describe-repositories --output json --query "repositories[*].repositoryName" | jq -r '.[]' | fzf --height=30% --layout=reverse --border --margin=1 --padding=1) - uri=$(aws ecr describe-repositories --repository-names "$name" --output json --query "repositories[*].repositoryUri" | jq -r '.[]') - - echo "Logging into $uri..." - aws ecr get-login-password --region "$region" | docker login --username AWS --password-stdin "$uri" - } -fi - -#################################### Editor #################################### - -if type "nvim" >/dev/null; then - export EDITOR=nvim - export GIT_EDITOR=nvim - export KUBE_EDITOR=nvim - - alias vi="echo 'Use \"nvim\" instead of \"vi\"'" - alias vim="echo 'Use \"nvim\" instead of \"vim\"'" -else - export EDITOR=vim - export GIT_EDITOR=vim - export KUBE_EDITOR=vim - - alias vi="echo 'Use \"vim\" instead of \"vi\"'" -fi - -############## FZF (https://github.com/junegunn/fzf) integration ############### - -[ -f "$HOME"/.fzf.zsh ] && source "$HOME"/.fzf.zsh -export FZF_DEFAULT_COMMAND='find . -not -path "**/.git/**"' - -################################## Kubernetes ################################## - -if type "helm" >/dev/null; then - source <(helm completion zsh) -fi - -if type "kind" >/dev/null; then - source <(kind completion zsh) -fi - -if type "kubectl" >/dev/null; then - source <(kubectl completion zsh) -fi - -################################# Devcontainer ################################# - -if type "devcontainer" >/dev/null; then - alias devup="devcontainer up --workspace-folder . --dotfiles-repository https://github.com/mpriscella/dotfiles.git" - alias devexec="devcontainer exec --workspace-folder . zsh" -fi - -#################################### LazyGit ################################### - -if type "lazygit" >/dev/null; then - alias lg="lazygit" -fi - -#################################### GitHub #################################### - -if type "gh" >/dev/null; then - source <(gh completion --shell zsh) -fi - -################################### Functions ################################## - -if (type "helm" >/dev/null && type "kubectl" >/dev/null); then - [ -f "$HOME"/.kshell.sh ] && source "$HOME"/.kshell.sh -fi - -############################### Load Local zshrc ############################### - -# shellcheck source=/dev/null -[ -f "$HOME"/.zshrc.local ] && source "$HOME"/.zshrc.local - -####################################### -# Create a visual pill. -# Arguments: -# text -# pill_color -# text_color -####################################### -function create_pill { - icon=$1 - text=$2 - pill_color=$3 - text_color=${4:-"black"} - - pill_left="%{$fg[$pill_color]%}" - pill_right="%{$reset_color$fg[$pill_color]%}" - - pill="$pill_left%{$bg[$pill_color]$fg[$text_color]%}$icon $text$pill_right%{$reset_color%}" - echo $pill -} - -function kube_pill { - context=$(kubectl config view --minify -o jsonpath='{.current-context}') - namespace=$(kubectl config view --minify -o jsonpath='{.contexts[0].context.namespace}') - - echo "%{$fg[red]%}$context%{$fg[black]%}/%{$fg[white]%}$namespace" -} - -gen_prompt='' -if [ -n "$AWS_PROFILE" ]; then - gen_prompt='$(create_pill  $AWS_PROFILE "yellow")' -fi - -# If shell is running in tmux, don't add kubectl context info to prompt. -if [[ "$TERM_PROGRAM" != "tmux" ]]; then - if type "kubectl" >/dev/null && $(kubectl config current-context >/dev/null 2>&1); then - context=$(kube_pill) - gen_prompt="$gen_prompt $(create_pill 󱃾 $context 'blue')" - fi -fi - -export RPROMPT=$gen_prompt - -if [ -d "$HOME/.atuin" ]; then - . "$HOME/.atuin/bin/env" - eval "$(atuin init zsh)" -fi - -if [ -f "$HOME/.nvm/nvm.sh" ]; then - export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm - [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion -fi diff --git a/.config/ghostty/config b/config/ghostty/config similarity index 100% rename from .config/ghostty/config rename to config/ghostty/config diff --git a/.config/k9s/plugins.yaml b/config/k9s/plugins.yaml similarity index 100% rename from .config/k9s/plugins.yaml rename to config/k9s/plugins.yaml diff --git a/.config/nvim/after/ftplugin/terraform.lua b/config/nvim/ftplugin/terraform.lua similarity index 100% rename from .config/nvim/after/ftplugin/terraform.lua rename to config/nvim/ftplugin/terraform.lua diff --git a/.config/nvim/init.lua b/config/nvim/init.lua similarity index 100% rename from .config/nvim/init.lua rename to config/nvim/init.lua diff --git a/config/nvim/lazy-lock.json b/config/nvim/lazy-lock.json new file mode 100644 index 0000000..f24750c --- /dev/null +++ b/config/nvim/lazy-lock.json @@ -0,0 +1,38 @@ +{ + "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, + "codesnap.nvim": { "branch": "main", "commit": "be6d6b9a3b5e6999edbda76b16dace03d9bfcd3d" }, + "conform.nvim": { "branch": "master", "commit": "26ebdcfb4f3c9d33d6f81c9534037bd5172b6d65" }, + "copilot.vim": { "branch": "release", "commit": "f3d66c148aa60ad04c0a21d3e0a776459de09eb2" }, + "fidget.nvim": { "branch": "main", "commit": "2cb5edb2dd6700a958a446b20bb2be04d318da9d" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, + "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, + "luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "1ec4da522fa49dcecee8d190efda273464dd2192" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "86389a3dd687cfaa647b6f44731e492970034baa" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, + "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, + "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, + "nvim-dap": { "branch": "master", "commit": "a479e25ed5b5d331fb46ee4b9e160ff02ac64310" }, + "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, + "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, + "nvim-lint": { "branch": "master", "commit": "7ef127aaede2a4d5ad8df8321e2eb4e567f29594" }, + "nvim-lspconfig": { "branch": "master", "commit": "61fdd3a8609071ce44519e405f3424d84ec94d9d" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-notify": { "branch": "master", "commit": "397c7c1184745fca649e5104de659e6392ef5a4d" }, + "nvim-surround": { "branch": "main", "commit": "d56752df477ebd808cb82cea2fc68cf7455abb21" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-treesitter-context": { "branch": "master", "commit": "dca8726fea2c14e1ce6adbaa76a04816fbfaff61" }, + "nvim-web-devicons": { "branch": "master", "commit": "c2599a81ecabaae07c49ff9b45dcd032a8d90f1a" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, + "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, + "toggleterm.nvim": { "branch": "main", "commit": "022ff5594acccc8d90d2e46dc43994f7722ebdf7" }, + "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } +} diff --git a/.config/nvim/lua/custom/plugins/autocompletion.lua b/config/nvim/lua/custom/plugins/autocompletion.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/autocompletion.lua rename to config/nvim/lua/custom/plugins/autocompletion.lua diff --git a/.config/nvim/lua/custom/plugins/autoformat.lua b/config/nvim/lua/custom/plugins/autoformat.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/autoformat.lua rename to config/nvim/lua/custom/plugins/autoformat.lua diff --git a/.config/nvim/lua/custom/plugins/autopairs.lua b/config/nvim/lua/custom/plugins/autopairs.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/autopairs.lua rename to config/nvim/lua/custom/plugins/autopairs.lua diff --git a/config/nvim/lua/custom/plugins/avante.lua b/config/nvim/lua/custom/plugins/avante.lua new file mode 100644 index 0000000..2c58a62 --- /dev/null +++ b/config/nvim/lua/custom/plugins/avante.lua @@ -0,0 +1,59 @@ +return { + -- 'yetone/avante.nvim', + -- event = 'VeryLazy', + -- version = false, -- Never set this value to "*"! Never! + -- opts = { + -- -- add any opts here + -- -- for example + -- provider = 'openai', + -- openai = { + -- endpoint = 'https://api.openai.com/v1', + -- model = 'gpt-4o', -- your desired model (or use gpt-4o, etc.) + -- timeout = 30000, -- Timeout in milliseconds, increase this for reasoning models + -- temperature = 0, + -- max_completion_tokens = 8192, -- Increase this to include reasoning tokens (for reasoning models) + -- --reasoning_effort = "medium", -- low|medium|high, only used for reasoning models + -- }, + -- }, + -- -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + -- build = 'make', + -- -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + -- dependencies = { + -- 'nvim-treesitter/nvim-treesitter', + -- 'stevearc/dressing.nvim', + -- 'nvim-lua/plenary.nvim', + -- 'MunifTanjim/nui.nvim', + -- --- The below dependencies are optional, + -- 'echasnovski/mini.pick', -- for file_selector provider mini.pick + -- 'nvim-telescope/telescope.nvim', -- for file_selector provider telescope + -- 'hrsh7th/nvim-cmp', -- autocompletion for avante commands and mentions + -- 'ibhagwan/fzf-lua', -- for file_selector provider fzf + -- 'nvim-tree/nvim-web-devicons', -- or echasnovski/mini.icons + -- 'zbirenbaum/copilot.lua', -- for providers='copilot' + -- { + -- -- support for image pasting + -- 'HakonHarnes/img-clip.nvim', + -- event = 'VeryLazy', + -- opts = { + -- -- recommended settings + -- default = { + -- embed_image_as_base64 = false, + -- prompt_for_file_name = false, + -- drag_and_drop = { + -- insert_mode = true, + -- }, + -- -- required for Windows users + -- use_absolute_path = true, + -- }, + -- }, + -- }, + -- { + -- -- Make sure to set this up properly if you have lazy=true + -- 'MeanderingProgrammer/render-markdown.nvim', + -- opts = { + -- file_types = { 'markdown', 'Avante' }, + -- }, + -- ft = { 'markdown', 'Avante' }, + -- }, + -- }, +} diff --git a/.config/nvim/lua/custom/plugins/codesnap.lua b/config/nvim/lua/custom/plugins/codesnap.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/codesnap.lua rename to config/nvim/lua/custom/plugins/codesnap.lua diff --git a/.config/nvim/lua/custom/plugins/copilot.lua b/config/nvim/lua/custom/plugins/copilot.lua similarity index 65% rename from .config/nvim/lua/custom/plugins/copilot.lua rename to config/nvim/lua/custom/plugins/copilot.lua index c4a31de..c073782 100644 --- a/.config/nvim/lua/custom/plugins/copilot.lua +++ b/config/nvim/lua/custom/plugins/copilot.lua @@ -3,10 +3,8 @@ return { config = function() vim.g.copilot_filetypes = { ['codecompanion'] = false, - ['helm'] = false, ['markdown'] = false, ['terraform'] = false, } - vim.g.copilot_settings = { selectedCompletionModel = 'gpt-4o-copilot' } end, } diff --git a/.config/nvim/lua/custom/plugins/debug.lua b/config/nvim/lua/custom/plugins/debug.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/debug.lua rename to config/nvim/lua/custom/plugins/debug.lua diff --git a/.config/nvim/lua/custom/plugins/gitsigns.lua b/config/nvim/lua/custom/plugins/gitsigns.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/gitsigns.lua rename to config/nvim/lua/custom/plugins/gitsigns.lua diff --git a/.config/nvim/lua/custom/plugins/icons.lua b/config/nvim/lua/custom/plugins/icons.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/icons.lua rename to config/nvim/lua/custom/plugins/icons.lua diff --git a/.config/nvim/lua/custom/plugins/lint.lua b/config/nvim/lua/custom/plugins/lint.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/lint.lua rename to config/nvim/lua/custom/plugins/lint.lua diff --git a/.config/nvim/lua/custom/plugins/lsp.lua b/config/nvim/lua/custom/plugins/lsp.lua similarity index 99% rename from .config/nvim/lua/custom/plugins/lsp.lua rename to config/nvim/lua/custom/plugins/lsp.lua index c4e2dab..fd712c9 100644 --- a/.config/nvim/lua/custom/plugins/lsp.lua +++ b/config/nvim/lua/custom/plugins/lsp.lua @@ -180,7 +180,7 @@ return { globals = { 'require', 'snacks', 'vim' }, }, workspace = { - library = { '/Users/michaelpriscella/.local/share/nvim' }, + library = { vim.loop.os_homedir() .. '/.local/share/nvim' }, }, }, }, diff --git a/.config/nvim/lua/custom/plugins/lualine.lua b/config/nvim/lua/custom/plugins/lualine.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/lualine.lua rename to config/nvim/lua/custom/plugins/lualine.lua diff --git a/.config/nvim/lua/custom/plugins/noice.lua b/config/nvim/lua/custom/plugins/noice.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/noice.lua rename to config/nvim/lua/custom/plugins/noice.lua diff --git a/.config/nvim/lua/custom/plugins/snacks.lua b/config/nvim/lua/custom/plugins/snacks.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/snacks.lua rename to config/nvim/lua/custom/plugins/snacks.lua diff --git a/.config/nvim/lua/custom/plugins/surround.lua b/config/nvim/lua/custom/plugins/surround.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/surround.lua rename to config/nvim/lua/custom/plugins/surround.lua diff --git a/.config/nvim/lua/custom/plugins/terminal.lua b/config/nvim/lua/custom/plugins/terminal.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/terminal.lua rename to config/nvim/lua/custom/plugins/terminal.lua diff --git a/.config/nvim/lua/custom/plugins/todo-comments.lua b/config/nvim/lua/custom/plugins/todo-comments.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/todo-comments.lua rename to config/nvim/lua/custom/plugins/todo-comments.lua diff --git a/.config/nvim/lua/custom/plugins/tokyonight.lua b/config/nvim/lua/custom/plugins/tokyonight.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/tokyonight.lua rename to config/nvim/lua/custom/plugins/tokyonight.lua diff --git a/.config/nvim/lua/custom/plugins/treesitter.lua b/config/nvim/lua/custom/plugins/treesitter.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/treesitter.lua rename to config/nvim/lua/custom/plugins/treesitter.lua diff --git a/.config/nvim/lua/custom/plugins/trouble.lua b/config/nvim/lua/custom/plugins/trouble.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/trouble.lua rename to config/nvim/lua/custom/plugins/trouble.lua diff --git a/.config/nvim/lua/custom/plugins/which-key.lua b/config/nvim/lua/custom/plugins/which-key.lua similarity index 100% rename from .config/nvim/lua/custom/plugins/which-key.lua rename to config/nvim/lua/custom/plugins/which-key.lua diff --git a/flake.lock b/flake.lock index 1e582b7..c7583d0 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1750304462, - "narHash": "sha256-Mj5t4yX05/rXnRqJkpoLZTWqgStB88Mr/fegTRqyiWc=", + "lastModified": 1755229570, + "narHash": "sha256-soZegto0xXzG2zYlu/zjknDHv0Z7tRS5EQs+Z/VRTBg=", "owner": "nix-community", "repo": "home-manager", - "rev": "863842639722dd12ae9e37ca83bcb61a63b36f6c", + "rev": "11626a4383b458f8dc5ea3237eaa04e8ab1912f3", "type": "github" }, "original": { @@ -20,18 +20,38 @@ "type": "github" } }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1755275010, + "narHash": "sha256-lEApCoWUEWh0Ifc3k1JdVjpMtFFXeL2gG1qvBnoRc2I=", + "owner": "nix-darwin", + "repo": "nix-darwin", + "rev": "7220b01d679e93ede8d7b25d6f392855b81dd475", + "type": "github" + }, + "original": { + "owner": "nix-darwin", + "repo": "nix-darwin", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1750365781, - "narHash": "sha256-XE/lFNhz5lsriMm/yjXkvSZz5DfvKJLUjsS6pP8EC50=", + "lastModified": 1755175540, + "narHash": "sha256-V0j2S1r25QnbqBLzN2Rg/dKKil789bI3P3id7bDPVc4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "08f22084e6085d19bcfb4be30d1ca76ecb96fe54", + "rev": "a595dde4d0d31606e19dcec73db02279db59d201", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -39,6 +59,7 @@ "root": { "inputs": { "home-manager": "home-manager", + "nix-darwin": "nix-darwin", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 4d12bf1..703ec79 100644 --- a/flake.nix +++ b/flake.nix @@ -1,144 +1,237 @@ { - description = "Personal dotfiles configuration with Home Manager"; + description = "Personal dotfiles with Home Manager and nix-darwin"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs = { + url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + }; + + nix-darwin = { + url = "github:nix-darwin/nix-darwin"; + inputs.nixpkgs.follows = "nixpkgs"; + }; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; - - # Optionally, you can pin to specific commits for reproducibility - # nixpkgs.url = "github:NixOS/nixpkgs/c16a6c8efedb65e10d565633e3f45f73bbbdf8ab"; }; - outputs = { self, nixpkgs, home-manager, ... }@inputs: - let - # Define supported systems - systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; - - # Helper to generate configurations for each system - forAllSystems = nixpkgs.lib.genAttrs systems; + outputs = { + self, + nixpkgs, + nix-darwin, + home-manager, + } @ inputs: let + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + forAllSystems = nixpkgs.lib.genAttrs systems; + + # Helper function to create a nix-darwin user configuration. + mkDarwinUser = { + username, + system, + }: { + environment.shells = ["/run/current-system/sw/bin/fish"]; + users.users.${username} = { + name = username; + home = "/Users/${username}"; + shell = "/run/current-system/sw/bin/fish"; + }; + }; - # Helper function to create home-manager configuration - mkHomeConfiguration = { system, username, homeDirectory, modules ? [], extraSpecialArgs ? {} }: + # Helper function to create home-manager configurations. + mkHomeConfiguration = { + system, + username, + homeDirectory ? null, + modules ? [], + extraSpecialArgs ? {}, + gpgSigningKey ? null, + isDarwinModule ? false, + }: let + calculatedHomeDirectory = + if homeDirectory != null + then homeDirectory + else if nixpkgs.lib.hasInfix "darwin" system + then "/Users/${username}" + else "/home/${username}"; + + baseModules = + [ + # Only set system metadata when not used as nix-darwin module + (nixpkgs.lib.optionalAttrs (!isDarwinModule) { + home.username = username; + home.homeDirectory = calculatedHomeDirectory; + home.stateVersion = "25.05"; + }) + ./home-manager/home.nix + ] + ++ modules; + + baseExtraSpecialArgs = + { + inherit inputs; + inherit gpgSigningKey; + inherit isDarwinModule; + } + // extraSpecialArgs; + in + if isDarwinModule + then + # When used as nix-darwin module, return module configuration directly + { + imports = baseModules; + _module.args = baseExtraSpecialArgs; + } + else + # When used standalone, wrap in homeManagerConfiguration home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.${system}; - - modules = [ - { - home.username = username; - home.homeDirectory = homeDirectory; - home.stateVersion = "25.05"; - } - ] ++ modules; - - extraSpecialArgs = { - inherit inputs; - } // extraSpecialArgs; - }; - in - { - # Home Manager configurations - homeConfigurations = { - # Default configuration for Linux (devcontainers, etc.) - "default" = mkHomeConfiguration { - system = "x86_64-linux"; - username = "vscode"; # Common devcontainer username - homeDirectory = "/home/vscode"; - modules = [ - ./.config/home-manager/hosts/default-flake.nix - ]; + modules = baseModules; + extraSpecialArgs = baseExtraSpecialArgs; }; + in { + darwinConfigurations = { + "macbook-pro-m3" = nix-darwin.lib.darwinSystem { + system = "aarch64-darwin"; + modules = [ + ./nix-darwin/determinate-nix.nix + (mkDarwinUser { + username = "michaelpriscella"; + system = "aarch64-darwin"; + }) + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.michaelpriscella = nixpkgs.lib.mkMerge [ + (mkHomeConfiguration { + system = "aarch64-darwin"; + username = "michaelpriscella"; + gpgSigningKey = "799887D03FE96FD0"; + isDarwinModule = true; + }) + { + home.stateVersion = "25.05"; + } + ]; + } + ]; + }; - # Work MacBook Pro configuration - "work-macbook-pro" = mkHomeConfiguration { - system = "aarch64-darwin"; # Apple Silicon - username = "michaelpriscella"; - homeDirectory = "/Users/michaelpriscella"; - modules = [ - ./.config/home-manager/hosts/work-macbook-pro-flake.nix - ]; - }; + "macbook-air-m4" = nix-darwin.lib.darwinSystem { + system = "aarch64-darwin"; + modules = [ + ./nix-darwin/official-nix.nix + (mkDarwinUser { + username = "mpriscella"; + system = "aarch64-darwin"; + }) + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.mpriscella = nixpkgs.lib.mkMerge [ + (mkHomeConfiguration { + system = "aarch64-darwin"; + username = "mpriscella"; + gpgSigningKey = "27301C740482A8B1"; + isDarwinModule = true; + }) + { + home.stateVersion = "25.05"; + } + ]; + } + ]; + }; + }; - # Generic MacBook Air configuration - "macbook-air" = mkHomeConfiguration { - system = "aarch64-darwin"; # Adjust if you have Intel MacBook Air - username = "user"; # Change this to your actual username - homeDirectory = "/Users/user"; # Change this to your actual home directory - modules = [ - ./.config/home-manager/hosts/macbook-air-flake.nix - ]; - }; + homeConfigurations = { + "macbook-pro-m3" = mkHomeConfiguration { + system = "aarch64-darwin"; + username = "michaelpriscella"; + gpgSigningKey = "799887D03FE96FD0"; + }; - # Alternative Linux configuration for different username - "linux-user" = mkHomeConfiguration { - system = "x86_64-linux"; - username = "user"; # Change this to your preferred username - homeDirectory = "/home/user"; - modules = [ - ./.config/home-manager/hosts/default-flake.nix - ]; - }; + "nixos-orbstack" = mkHomeConfiguration { + system = "aarch64-linux"; + username = "mpriscella"; }; + }; - # Development shells for each system - devShells = forAllSystems (system: { - default = nixpkgs.legacyPackages.${system}.mkShell { - buildInputs = with nixpkgs.legacyPackages.${system}; [ - home-manager.packages.${system}.default - git - nil # Nix language server - ]; - - shellHook = '' - echo "🏠 Home Manager Flake Development Shell" - echo "Available commands:" - echo " home-manager switch --flake .#" - echo " home-manager build --flake .#" - echo "" - echo "Available configurations:" - echo " default, work-macbook-pro, macbook-air, linux" - echo "" - echo "Example: home-manager switch --flake .#work-macbook-pro" - ''; + devShells = forAllSystems (system: { + default = nixpkgs.legacyPackages.${system}.mkShell { + buildInputs = [ + home-manager.packages.${system}.default + nix-darwin.packages.${system}.darwin-rebuild + nixpkgs.legacyPackages.${system}.cargo + nixpkgs.legacyPackages.${system}.python3 + nixpkgs.legacyPackages.${system}.nix-diff + nixpkgs.legacyPackages.${system}.nh + (nixpkgs.legacyPackages.${system}.writeShellScriptBin "nvim-dev" '' + XDG_CONFIG_HOME="config/" nvim "$@" + '') + ]; + + shellHook = '' + cat < # Build system config" + echo " sudo darwin-rebuild switch --flake .# # Apply system config" + echo " sudo darwin-rebuild switch --rollback # Rollback to previous config" + echo " nvim-dev [files] # Neovim with isolated config" + echo "" + echo "Available Nix Darwin configurations:" + echo " macbook-pro-m3, macbook-air-m4" + echo "" + echo "" + echo "Home Manager commands:" + echo " home-manager build --flake .# # Build home-manager config" + echo " home-manager switch --flake .# # Apply home-manager config" + echo " home-manager switch --rollback # Rollback to previous config" + echo "" + echo "Available Home Manager configurations:" + echo " macbook-pro-m3, nixos-orbstack" + echo "" + echo "" + echo "Nix commands:" + echo " nix flake check # Validate and test flake" + echo " nix flake update # Update dependencies" + echo " nix fmt flake.nix home-manager nix-darwin # Format code" + echo " nix upgrade-nix # Upgrade Nix" + ''; + }; + }); + + formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); + + checks = forAllSystems ( + system: let + macosChecks = nixpkgs.lib.optionalAttrs (nixpkgs.lib.hasInfix "darwin" system) { + home-manager-macbook-pro-m3 = self.homeConfigurations."macbook-pro-m3".activationPackage; + nix-darwin-macbook-pro-m3 = self.darwinConfigurations."macbook-pro-m3".system; + nix-darwin-macbook-air-m4 = self.darwinConfigurations."macbook-air-m4".system; }; - }); - - # Packages for each system (useful for CI/CD) - packages = forAllSystems (system: - let - # Only include packages that match the target system - linuxConfigs = nixpkgs.lib.optionalAttrs (nixpkgs.lib.hasInfix "linux" system) { - default = self.homeConfigurations.default.activationPackage; - linux-user = self.homeConfigurations.linux-user.activationPackage; - }; - darwinConfigs = nixpkgs.lib.optionalAttrs (nixpkgs.lib.hasInfix "darwin" system) { - work-macbook-pro = self.homeConfigurations.work-macbook-pro.activationPackage; - macbook-air = self.homeConfigurations.macbook-air.activationPackage; - }; - in - linuxConfigs // darwinConfigs - ); - - # Formatter for `nix fmt` - formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt); - - # Checks for `nix flake check` - checks = forAllSystems (system: - let - # Only include checks that match the target system - linuxChecks = nixpkgs.lib.optionalAttrs (nixpkgs.lib.hasInfix "linux" system) { - default = self.packages.${system}.default or null; - linux-user = self.packages.${system}.linux-user or null; - }; - darwinChecks = nixpkgs.lib.optionalAttrs (nixpkgs.lib.hasInfix "darwin" system) { - work-macbook-pro = self.packages.${system}.work-macbook-pro or null; - macbook-air = self.packages.${system}.macbook-air or null; - }; - in - nixpkgs.lib.filterAttrs (_: v: v != null) (linuxChecks // darwinChecks) - ); - }; + linuxChecks = nixpkgs.lib.optionalAttrs (nixpkgs.lib.hasInfix "linux" system) { + nixos-orbstack = self.homeConfigurations."nixos-orbstack".activationPackage; + }; + in + macosChecks // linuxChecks + ); + }; } diff --git a/home-manager/home.nix b/home-manager/home.nix new file mode 100644 index 0000000..936cc34 --- /dev/null +++ b/home-manager/home.nix @@ -0,0 +1,98 @@ +{ + config, + pkgs, + lib, + inputs, + gpgSigningKey ? null, + isDarwinModule ? false, + ... +}: { + imports = [ + ./programs/atuin.nix + ./programs/aws.nix + ./programs/direnv.nix + ./programs/fish.nix + ./programs/gh.nix + ( + import ./programs/git.nix { + inherit config pkgs lib inputs gpgSigningKey; + } + ) + ./programs/gpg.nix + ./programs/k9s.nix + ./programs/starship.nix + ./programs/tmux.nix + ./programs/yt-dlp.nix + ]; + + config = { + # Only set nix configuration when not used as nix-darwin module + # nix = lib.mkIf (!isDarwinModule) { + # package = pkgs.nix; + # settings = { + # experimental-features = [ "nix-command" "flakes" ]; + # }; + # }; + + home.file = { + ".ackrc".text = '' + --pager=less -R + --ignore-case + ''; + ".config/ghostty".source = ../config/ghostty; + ".config/nvim".source = config.lib.file.mkOutOfStoreSymlink "${inputs.self}/config/nvim"; + }; + + home.packages = [ + pkgs.ack + pkgs.act + pkgs.atuin + pkgs.bat + pkgs.delta + pkgs.dive + pkgs.fd + pkgs.fzf + pkgs.graphviz + pkgs.jq + pkgs.just + pkgs.kind + pkgs.kubectl + pkgs.kubernetes-helm + pkgs.lazydocker + pkgs.lazygit + pkgs.opencode + pkgs.neovim + pkgs.nil + pkgs.nodejs_24 + pkgs.ripgrep + pkgs.uv + pkgs.yq + ]; + + home.sessionVariables = { + EDITOR = "nvim"; + PAGER = "less"; + LESS = "-R"; + }; + + programs.man.enable = true; + programs.home-manager.enable = true; + + programs.fish.functions = { + clear-message-attachments = { + description = "Clear Local Message Attachments"; + body = '' + rm -rf ~/Library/Messages/Attachments/* + ''; + }; + dns-cache-flush = { + description = "Flush DNS Cache"; + body = '' + sudo dscacheutil -flushcache + sudo killall -HUP mDNSResponder + echo "DNS cache has been flushed." + ''; + }; + }; + }; +} diff --git a/home-manager/programs/atuin.nix b/home-manager/programs/atuin.nix new file mode 100644 index 0000000..33c75c2 --- /dev/null +++ b/home-manager/programs/atuin.nix @@ -0,0 +1,12 @@ +{ + config, + pkgs, + lib, + inputs, + ... +}: { + programs.atuin = { + enable = true; + enableFishIntegration = true; + }; +} diff --git a/home-manager/programs/aws.nix b/home-manager/programs/aws.nix new file mode 100644 index 0000000..29bc786 --- /dev/null +++ b/home-manager/programs/aws.nix @@ -0,0 +1,50 @@ +{ + config, + pkgs, + lib, + inputs, + ... +}: { + programs.awscli = { + enable = true; + }; + + home.sessionVariables = { + AWS_CLI_AUTO_PROMPT = "on-partial"; + }; + + programs.fish.functions.aws-ps = { + description = "Switch AWS profiles"; + body = '' + set -l profile $(aws configure list-profiles | fzf --height=30% --layout=reverse) + if set --query profile + set -gx AWS_PROFILE $profile + echo "Switched to AWS profile: $profile" + end + ''; + }; + + programs.fish.functions.ecr-login = { + description = "Login to ECR"; + body = '' + # Check if AWS credentials are valid + if not aws sts get-caller-identity >/dev/null 2>&1 + echo "Could not connect to AWS account. Please verify that your credentials are correct." + return + end + + # Get AWS region + set region (aws configure get region) + + # Select repository name using fzf + set name (aws ecr describe-repositories --output json --query "repositories[*].repositoryName" | jq -r '.[]' | fzf --height=30% --layout=reverse --border --margin=1 --padding=1) + + # Get repository URI + set uri (aws ecr describe-repositories --repository-names $name --output json --query "repositories[*].repositoryUri" | jq -r '.[]') + + # Log in to the repository + echo "Logging into $uri..." + aws ecr get-login-password --region $region | docker login --username AWS --password-stdin $uri + ''; + }; +} diff --git a/home-manager/programs/direnv.nix b/home-manager/programs/direnv.nix new file mode 100644 index 0000000..5ec3c0d --- /dev/null +++ b/home-manager/programs/direnv.nix @@ -0,0 +1,13 @@ +{ + config, + pkgs, + lib, + inputs, + ... +}: { + programs.direnv = { + enable = true; + nix-direnv.enable = true; + silent = true; + }; +} diff --git a/home-manager/programs/fish.nix b/home-manager/programs/fish.nix new file mode 100644 index 0000000..ceca136 --- /dev/null +++ b/home-manager/programs/fish.nix @@ -0,0 +1,16 @@ +{ + config, + pkgs, + lib, + inputs, + ... +}: { + programs.fish = { + enable = true; + + shellAliases = { + cat = "bat"; + lg = "lazygit"; + }; + }; +} diff --git a/home-manager/programs/gh.nix b/home-manager/programs/gh.nix new file mode 100644 index 0000000..2e7e921 --- /dev/null +++ b/home-manager/programs/gh.nix @@ -0,0 +1,12 @@ +{ + config, + pkgs, + lib, + inputs, + ... +}: { + programs.gh = { + enable = true; + extensions = [pkgs.gh-dash]; + }; +} diff --git a/home-manager/programs/git.nix b/home-manager/programs/git.nix new file mode 100644 index 0000000..2fad987 --- /dev/null +++ b/home-manager/programs/git.nix @@ -0,0 +1,66 @@ +{ + config, + pkgs, + lib, + inputs, + gpgSigningKey ? null, + ... +}: { + programs.git = { + enable = true; + userName = "Mike Priscella"; + userEmail = "mpriscella@gmail.com"; + + extraConfig = lib.mkMerge [ + { + init.defaultBranch = "main"; + pull.rebase = false; + push.autoSetupRemote = true; + core.editor = "nvim"; + + # Disable dirty worktree warnings for flake operations + flake.warn-dirty = false; + + # Better diff and merge tools + diff.tool = "vimdiff"; + merge.tool = "vimdiff"; + + # Performance optimizations + core.preloadindex = true; + core.fscache = true; + gc.auto = 256; + + # Delta + core.pager = "delta"; + interactive.diffFilter = "delta --color-only"; + delta = { + navigate = true; + }; + merge.conflictstyle = "zdiff3"; + } + + (lib.optionalAttrs (gpgSigningKey != null) { + user.signingkey = gpgSigningKey; + commit.gpgsign = true; + tag.gpgsign = true; + gpg.program = "${pkgs.gnupg}/bin/gpg"; + }) + ]; + + ignores = [ + ".DS_Store" + ".direnv/" + "*.log" + ".env" + ".env.local" + "node_modules/" + ".next/" + "dist/" + "build/" + ]; + + aliases = { + chb = "checkout -b"; + }; + }; +} diff --git a/home-manager/programs/gpg.nix b/home-manager/programs/gpg.nix new file mode 100644 index 0000000..ccbd8cb --- /dev/null +++ b/home-manager/programs/gpg.nix @@ -0,0 +1,29 @@ +{ + config, + pkgs, + lib, + ... +}: { + home.packages = with pkgs; [ + gnupg + pinentry-curses + ]; + + programs.gpg = { + enable = true; + settings = { + keyid-format = "long"; + with-fingerprint = true; + no-greeting = true; + use-agent = true; + }; + }; + + services.gpg-agent = { + enable = true; + enableFishIntegration = true; + pinentry.package = pkgs.pinentry-curses; + defaultCacheTtl = 28800; # 8 hours + maxCacheTtl = 86400; # 24 hours + }; +} diff --git a/home-manager/programs/k9s.nix b/home-manager/programs/k9s.nix new file mode 100644 index 0000000..da57183 --- /dev/null +++ b/home-manager/programs/k9s.nix @@ -0,0 +1,27 @@ +{ + config, + pkgs, + lib, + inputs, + ... +}: { + programs.k9s = { + enable = true; + + plugins = { + debug-container = { + shortCut = "d"; + description = "Add debug container"; + dangerous = true; + scopes = ["containers"]; + command = "bash"; + background = false; + confirm = true; + args = [ + "-c" + "kubectl debug -it --context $CONTEXT --namespace $NAMESPACE $POD --target=$NAME --image=ubuntu --share-processes -- bash" + ]; + }; + }; + }; +} diff --git a/home-manager/programs/starship.nix b/home-manager/programs/starship.nix new file mode 100644 index 0000000..8af7fcc --- /dev/null +++ b/home-manager/programs/starship.nix @@ -0,0 +1,39 @@ +{ + config, + pkgs, + lib, + inputs, + ... +}: { + programs.starship = { + enable = true; + enableFishIntegration = true; + settings = { + container = { + disabled = true; + }; + directory = { + truncate_to_repo = false; + }; + format = "$all$directory$character"; + git_status = { + format = ''([\[$ahead_behind\]]($style) )''; + }; + hostname = { + disabled = true; + }; + kubernetes = { + disabled = false; + }; + nix_shell = { + format = ''via [$symbol$name]($style) ''; + }; + terraform = { + disabled = true; + }; + username = { + disabled = true; + }; + }; + }; +} diff --git a/home-manager/programs/tmux.nix b/home-manager/programs/tmux.nix new file mode 100644 index 0000000..70ebf01 --- /dev/null +++ b/home-manager/programs/tmux.nix @@ -0,0 +1,12 @@ +{ + config, + pkgs, + lib, + inputs, + ... +}: { + programs.tmux = { + enable = true; + prefix = "C-a"; + }; +} diff --git a/home-manager/programs/yt-dlp.nix b/home-manager/programs/yt-dlp.nix new file mode 100644 index 0000000..0d1ce7e --- /dev/null +++ b/home-manager/programs/yt-dlp.nix @@ -0,0 +1,11 @@ +{ + config, + pkgs, + lib, + inputs, + ... +}: { + programs.yt-dlp = { + enable = true; + }; +} diff --git a/install.sh b/install.sh index 9a08b0b..cd513e8 100755 --- a/install.sh +++ b/install.sh @@ -1,23 +1,17 @@ #!/bin/bash -set -e # Exit on any error +set -e -# Check if dotfiles installation should be skipped -if [[ "${DEBUG_DOTFILES:-}" == "true" ]]; then - echo "🚫 DEBUG_DOTFILES is set to 'true' - skipping dotfiles installation" - echo " This is useful for debugging devcontainer setups without installing dotfiles" - echo " To install dotfiles, unset DEBUG_DOTFILES or set it to 'false'" - exit 0 -fi +####################################### +# Logging Functions. +####################################### -# Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' -NC='\033[0m' # No Color +NC='\033[0m' -# Helper functions log_info() { echo -e "${BLUE}[INFO]${NC} $1" } @@ -34,495 +28,93 @@ log_error() { echo -e "${RED}[ERROR]${NC} $1" } -# Detect operating system +####################################### +# Check prerequisites. +# Arguments: +# None +####################################### +check_prerequisites() { + if ! command -v curl >/dev/null 2>&1; then + log_error "curl is required but not installed" + exit 1 + fi + + if ! command -v xz >/dev/null 2>&1; then + log_error "xz is required but not installed" + exit 1 + fi +} + +####################################### +# Detect the host operating system. +# Arguments: +# None +####################################### detect_os() { case "$(uname -s)" in Darwin*) OS="macos" - log_info "Running on macOS" ;; Linux*) OS="linux" - log_info "Running on Linux" ;; *) log_error "Unsupported operating system: $(uname -s)" - log_error "This script supports macOS and Linux only" exit 1 ;; esac + log_info "$OS detected." +} - # Detect if we're in a container environment +####################################### +# Determine whether host system is a container. +# Arguments: +# None +####################################### +detect_container() { + IN_CONTAINER=false if [[ -f /.dockerenv ]] || [[ -n "${CODESPACES:-}" ]] || [[ -n "${DEVCONTAINER:-}" ]] || grep -qi 'docker\|lxc\|container' /proc/1/cgroup 2>/dev/null; then IN_CONTAINER=true log_info "Container environment detected" - else - IN_CONTAINER=false - fi -} - -# Check prerequisites based on OS -check_prerequisites() { - if ! command -v curl >/dev/null 2>&1; then - log_error "curl is required but not installed" - exit 1 fi } -# Install Nix if not already installed -# TODO: -# - If this script is run and nix is installed, then the script is run again, it's failing because path is not updated. install_nix() { - # Check for permission issues in devcontainer first - if command -v nix >/dev/null 2>&1 && [[ "$IN_CONTAINER" == true ]]; then - # Test if we can actually use nix commands that require write access to both db and store - write_test_failed=false - - if [[ ! -w /nix/var/nix/db/big-lock ]] 2>/dev/null || ! touch /nix/var/nix/test-write 2>/dev/null; then - write_test_failed=true - fi - rm -f /nix/var/nix/test-write 2>/dev/null # Clean up test file - - # Also test if we can write to the store (where the real issues often occur) - if ! touch /nix/store/test-write 2>/dev/null; then - write_test_failed=true - fi - rm -f /nix/store/test-write 2>/dev/null # Clean up test file - - if [[ "$write_test_failed" == true ]]; then - log_warning "Detected Nix permission issues in devcontainer" - log_error "Nix database permissions issue detected" - log_info "This usually happens when Nix was installed as root in devcontainer" - log_info "" - log_info "Solutions:" - echo " 1. Fix database permissions (quick fix):" - echo " sudo chown -R $(whoami):$(whoami) /nix/var/nix/" - echo "" - echo " 2. Reinstall as single-user (recommended for devcontainers):" - echo " sudo rm -rf /nix /etc/nix" - echo " curl -L https://nixos.org/nix/install | sh -s -- --no-daemon" - echo " source ~/.bashrc" - - read -p "Choose option (1/2) or cancel (N): " -n 1 -r - echo - if [[ $REPLY == "1" ]]; then - log_info "Attempting to fix Nix database permissions..." - if sudo chown -R "$(whoami):$(whoami)" /nix/var/nix/ 2>/dev/null; then - log_success "Fixed Nix database permissions!" - log_warning "Note: You may still encounter issues with /nix/store. Consider option 2 for a complete fix." - else - log_error "Failed to fix permissions." - exit 1 - fi - elif [[ $REPLY == "2" ]]; then - log_info "Reinstalling Nix as single-user..." - if sudo rm -rf /nix /etc/nix /etc/profile.d/nix.sh 2>/dev/null; then - log_info "Removed existing Nix installation" - # Fall through to the installation section below - else - log_error "Failed to remove existing Nix installation" - exit 1 - fi - else - log_error "Cannot continue with permission issues. Please fix manually." - exit 1 - fi - fi - fi - if command -v nix >/dev/null 2>&1; then - log_success "Nix is already installed: $(nix --version)" - - # Even if Nix is installed, ensure it's sourced in current session - if [[ -z "${NIX_PATH:-}" ]]; then - log_info "Sourcing Nix environment for current session..." - # Try to source Nix profile for current session - if [[ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]]; then - # shellcheck source=/dev/null - source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' - log_info "Sourced Nix daemon profile" - elif [[ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]]; then - # shellcheck source=/dev/null - source "$HOME/.nix-profile/etc/profile.d/nix.sh" - log_info "Sourced Nix single-user profile" - fi - else - log_info "Nix environment already sourced (NIX_PATH is set)" - fi - - log_success "Nix is ready to use" - return 0 - fi - - log_info "Installing Nix..." - - case "$OS" in - macos) - if [[ "$IN_CONTAINER" == true ]]; then - log_info "Container detected on macOS - using single-user installation" - install_args="--no-daemon" - else - # Use the official Nix installer for macOS with daemon support - install_args="--daemon" - fi - ;; - linux) - # In containers, always use single-user to avoid permission issues - if [[ "$IN_CONTAINER" == true ]]; then - log_info "Container environment detected - using single-user installation" - install_args="--no-daemon" - # Check if we should use multi-user or single-user install on bare metal - elif command -v systemctl >/dev/null 2>&1 && [[ "$EUID" -ne 0 ]]; then - log_info "Using multi-user installation (recommended)" - install_args="--daemon" - else - log_info "Using single-user installation" - install_args="--no-daemon" - fi - ;; - esac - - # Download and run the installer - if curl -L https://nixos.org/nix/install | sh -s -- "$install_args"; then - log_success "Nix installation completed" - - # Source nix profile to make nix available in current session - case "$OS" in - macos | linux) - # Try daemon profile first (multi-user install) - if [[ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]]; then - # shellcheck source=/dev/null - source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' - log_info "Sourced Nix daemon profile" - # Fallback to single-user profile - elif [[ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]]; then - # shellcheck source=/dev/null - source "$HOME/.nix-profile/etc/profile.d/nix.sh" - log_info "Sourced Nix single-user profile" - else - log_warning "Could not find Nix profile to source" - fi - ;; - esac - - # Verify installation - if command -v nix >/dev/null 2>&1; then - log_success "Nix is now available: $(nix --version)" - else - log_warning "Nix installed but not available in current session." - log_info "You may need to restart your terminal or manually source the Nix profile." - # Don't exit here - continue with the script - fi - else - log_error "Failed to install Nix" - log_info "You can try installing Nix manually from: https://nixos.org/download.html" - exit 1 - fi -} - -# Install home-manager -install_home_manager() { - # Check if home-manager is already installed. - if command -v home-manager >/dev/null 2>&1; then - log_success "home-manager is already installed: $(home-manager --version)" - return 0 - fi - - # Ensure nix-channel command is available. - if ! command -v nix-channel >/dev/null 2>&1; then - log_error "nix-channel command not found. Nix may not be properly installed or sourced." - log_info "Try restarting your terminal or manually sourcing Nix profile." - return 1 - fi - - log_info "Installing home-manager..." - - # Check if home-manager channel already exists - if nix-channel --list | grep -q "home-manager"; then - log_info "home-manager channel already exists" - else - # Add home-manager channel - if nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager; then - log_success "Added home-manager channel" - else - log_error "Failed to add home-manager channel" - log_info "You can try adding it manually: nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager" - return 1 - fi - fi - - # Update channels - log_info "Updating Nix channels..." - if nix-channel --update; then - log_success "Updated Nix channels" - else - log_warning "Failed to update Nix channels, but continuing..." - log_info "You may need to run 'nix-channel --update' manually later" - fi - - # Install home-manager - log_info "Installing home-manager package..." - if nix-shell '' -A install; then - log_success "home-manager installation completed" - - # Verify installation - if command -v home-manager >/dev/null 2>&1; then - log_success "home-manager is now available: $(home-manager --version)" - else - log_warning "home-manager installed but not available in current session." - log_info "You may need to restart your terminal or source your shell profile." - # Don't exit here - continue with the script - fi - else - log_error "Failed to install home-manager" - log_info "You can try installing it manually:" - echo " 1. nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager" - echo " 2. nix-channel --update" - echo " 3. nix-shell '' -A install" - return 1 - fi -} - -# Setup initial home-manager configuration -setup_home_manager() { - local config_dir="$HOME/.config/home-manager" - local dotfiles_config_dir - dotfiles_config_dir="$(pwd)/.config/home-manager" - local config_file - - if [[ -d "$config_dir" ]]; then - log_info "home-manager config directory already exists" - else - log_info "Creating home-manager config directory..." - mkdir -p "$config_dir" - fi - - # Check if we have a dotfiles home-manager config - if [[ -d "$dotfiles_config_dir" ]]; then - log_info "Dotfiles home-manager configuration found" - - # Suggest appropriate configuration file based on OS - case "$OS" in - macos) - config_file="work-macbook-pro.nix" - # log_info "You can now run: home-manager switch --file .config/home-manager/hosts/work-macbook-pro.nix" - ;; - linux) - config_file="default.nix" - # log_info "You can now run: home-manager switch --file .config/home-manager/hosts/linux-machine.nix" - ;; - esac - log_info "You can now run: home-manager switch --file .config/home-manager/hosts/$config_file" + log_info "Nix is already installed: $(nix --version)" + log_info "Skipping Nix installation." else - log_warning "No home-manager configuration found in dotfiles" - log_info "You may need to create a home-manager configuration" - fi -} - -# Test and apply home-manager configuration -test_and_apply_config() { - local config_file=".config/home-manager/hosts/default.nix" - local dotfiles_config_dir - dotfiles_config_dir="$(pwd)/.config/home-manager" - - # Check if we're in the dotfiles directory - if [[ ! -d "$dotfiles_config_dir" ]]; then - log_error "Not in dotfiles directory or home-manager config not found" - log_info "Please run this script from your dotfiles directory" - return 1 - fi - - # Check if default.nix exists - if [[ ! -f "$config_file" ]]; then - log_warning "Default configuration file not found: $config_file" - log_info "Skipping automatic configuration application" - return 1 - fi - - log_info "Testing home-manager configuration: $config_file" - - # Test the configuration by building it - if home-manager build --file "$config_file" --no-out-link; then - log_success "Configuration test passed!" + log_info "Installing Nix..." - # Ask user if they want to apply it - echo - read -p "Do you want to apply this configuration now? (y/N): " -n 1 -r - echo + detect_os + detect_container - if [[ $REPLY =~ ^[Yy]$ ]]; then - log_info "Applying home-manager configuration..." + INSTALL_COMMAND="curl -fsSL https://install.determinate.systems/nix | sh -s -- install" - if home-manager switch --file "$config_file"; then - log_success "Home-manager configuration applied successfully!" - - # Show what was applied - log_info "Configuration details:" - echo " - User: $(whoami)" - echo " - Config: $config_file" - echo " - Home: $HOME" - echo " - Generation: $(home-manager generations | head -1 | awk '{print $5}' || echo 'Unknown')" - - return 0 - else - log_error "Failed to apply home-manager configuration" - log_info "You can try manually with: home-manager switch --file $config_file" - return 1 + if [[ "$OS" == "linux" ]]; then + if [[ $IN_CONTAINER ]]; then + INSTALL_COMMAND="curl -fsSL https://install.determinate.systems/nix | sh -s -- install linux --no-confirm --init none" fi - else - log_info "Configuration not applied. You can apply it later with:" - echo " home-manager switch --file $config_file" - return 0 fi - else - log_error "Configuration test failed!" - log_info "Please check your configuration file: $config_file" - log_info "Common issues:" - echo " - Check syntax errors in nix files" - echo " - Verify all imports exist" - echo " - Ensure username/home directory are correct" - echo " - Try: home-manager build --file $config_file --show-trace" - return 1 - fi -} - -# Check and fix Nix permissions in devcontainer -check_devcontainer_nix() { - if [[ "$IN_CONTAINER" != true ]]; then - return 0 - fi - # Check if Nix is installed but has permission issues - if [[ -d /nix ]] && ! nix-channel --list >/dev/null 2>&1; then - log_warning "Detected Nix permission issues in devcontainer" + if eval "$INSTALL_COMMAND"; then + log_success "✓ Nix installation completed successfully" - # Check if we're running as root - if [[ "$EUID" -eq 0 ]]; then - log_error "Running as root in devcontainer. This script should run as the target user." - log_info "To fix this, ensure your devcontainer runs this script as the 'vscode' user:" - echo " \"postCreateCommand\": \"su - vscode -c 'cd /workspaces/dotfiles && ./install.sh'\"" + # shellcheck source=/dev/null + source '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' # Does this change based off the OS? + else + log_error "✗ Nix installation failed" exit 1 fi - - # Check if big-lock file has permission issues - if [[ ! -w /nix/var/nix/db/big-lock ]] 2>/dev/null; then - log_error "Nix database permissions issue detected" - log_info "This usually happens when Nix was installed as root in devcontainer" - log_info "" - log_info "Solutions:" - echo " 1. Fix permissions (run as root):" - echo " sudo chown -R $(whoami):$(whoami) /nix/var/nix/" - echo "" - echo " 2. Or reinstall Nix as single-user:" - echo " sudo rm -rf /nix /etc/nix" - echo " curl -L https://nixos.org/nix/install | sh -s -- --no-daemon" - echo " source ~/.bashrc" - echo "" - echo " 3. Or run this script with sudo to fix ownership:" - echo " sudo ./install.sh" - - read -p "Would you like to automatically fix the permissions? (y/N): " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]]; then - log_info "Attempting to fix Nix permissions..." - if sudo chown -R "$(whoami):$(whoami)" /nix/var/nix/ 2>/dev/null; then - log_success "Fixed Nix permissions!" - else - log_error "Failed to fix permissions. You may need to reinstall Nix." - exit 1 - fi - else - log_error "Cannot continue with permission issues. Please fix manually." - exit 1 - fi - fi fi } -# Main installation process main() { log_info "Starting dotfiles installation..." - # Detect operating system - detect_os - - # Check devcontainer Nix setup - check_devcontainer_nix - - # Check prerequisites check_prerequisites - # Install Nix - log_info "Checking Nix installation..." install_nix - nix_install_result=$? - - if [[ $nix_install_result -ne 0 ]]; then - log_error "Nix installation failed. Cannot continue." - exit 1 - fi - - # Install home-manager - log_info "Checking home-manager installation..." - install_home_manager - hm_install_result=$? - - if [[ $hm_install_result -ne 0 ]]; then - log_warning "home-manager installation had issues, but continuing..." - log_info "You may need to install home-manager manually later." - fi - - # Setup home-manager - setup_home_manager - - # Test and apply configuration (only if home-manager is available) - if command -v home-manager >/dev/null 2>&1; then - log_info "Testing and applying home-manager configuration..." - if test_and_apply_config; then - log_success "Installation and configuration completed!" - echo - log_info "Your dotfiles are now active!" - echo - log_info "Useful commands:" - echo " - Update packages: nix-channel --update && home-manager switch" - echo " - Rebuild config: home-manager switch --file .config/home-manager/hosts/default.nix" - echo " - List generations: home-manager generations" - echo " - Rollback: home-manager switch --switch-generation " - echo " - Check system: nix-info -m" - else - log_warning "Configuration test/apply step had issues" - log_success "Base installation completed!" - echo - log_info "Manual next steps:" - - case "$OS" in - macos | linux) - echo " 1. Navigate to your dotfiles directory" - echo " 2. Test config: home-manager build --file .config/home-manager/hosts/default.nix --no-out-link" - echo " 3. Apply config: home-manager switch --file .config/home-manager/hosts/default.nix" - ;; - esac - - echo - log_info "Useful commands:" - echo " - Update packages: nix-channel --update && home-manager switch" - echo " - List generations: home-manager generations" - echo " - Rollback: home-manager switch --switch-generation " - echo " - Check system: nix-info -m" - fi - else - log_warning "home-manager not available. Skipping configuration application." - log_success "Nix installation completed!" - echo - log_info "Next steps:" - echo " 1. Install home-manager manually:" - echo " nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager" - echo " nix-channel --update" - echo " nix-shell '' -A install" - echo " 2. Apply your configuration:" - echo " home-manager switch --file .config/home-manager/hosts/default.nix" - fi } -# Run main function main "$@" diff --git a/nix-darwin/base.nix b/nix-darwin/base.nix new file mode 100644 index 0000000..bf4530f --- /dev/null +++ b/nix-darwin/base.nix @@ -0,0 +1,20 @@ +{ + config, + pkgs, + ... +}: { + programs.fish.enable = true; + + system.stateVersion = 6; + + environment.systemPackages = [ + pkgs._1password-gui + pkgs.bruno + pkgs.dbeaver-bin + pkgs.discord + pkgs.firefox + pkgs.obsidian + pkgs.shottr + pkgs.vscode + ]; +} diff --git a/nix-darwin/determinate-nix.nix b/nix-darwin/determinate-nix.nix new file mode 100644 index 0000000..f8f5814 --- /dev/null +++ b/nix-darwin/determinate-nix.nix @@ -0,0 +1,14 @@ +{ + config, + pkgs, + ... +}: { + imports = [ + ./base.nix + ]; + + # Nix daemon configuration + nix = { + enable = false; + }; +} diff --git a/nix-darwin/official-nix.nix b/nix-darwin/official-nix.nix new file mode 100644 index 0000000..c9ec8dd --- /dev/null +++ b/nix-darwin/official-nix.nix @@ -0,0 +1,30 @@ +{ + config, + pkgs, + ... +}: { + imports = [ + ./base.nix + ]; + + nix = { + enable = true; + + linux-builder = { + enable = true; + }; + + settings = { + experimental-features = [ + "nix-command" + "flakes" + ]; + }; + }; + + nixpkgs = { + config = { + allowUnfree = true; + }; + }; +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 9d3fd10..0000000 --- a/shell.nix +++ /dev/null @@ -1,14 +0,0 @@ -let - pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/c16a6c8efedb65e10d565633e3f45f73bbbdf8ab.tar.gz") { - config = { - allowUnfree = true; - }; - overlays = []; - }; -in - pkgs.mkShellNoCC { - buildInputs = [ - pkgs.gh - pkgs.shellcheck - ]; - }