commit d18f18fc29bdd26246610d95c56545a195a45c6b Author: foehammer127 Date: Fri May 16 18:11:06 2025 -0500 Initial Commit diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..6adf7d3 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +use flake + +eval "$shellHook" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09bd556 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# direnv: +.direnv/ + +# result: +result/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ac5cb62 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Lorenzo Good + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/common/bash.nix b/common/bash.nix new file mode 100644 index 0000000..61bb267 --- /dev/null +++ b/common/bash.nix @@ -0,0 +1,105 @@ +{lib, ...}: { + programs.bash = { + enable = true; + + initExtra = '' + source /etc/profile + + export PATH=$PATH:/usr/local/bin:/usr/bin:/bin + ''; + }; + + home = { + sessionVariables = { + EDITOR = "nvim"; + GOPATH = "$HOME/tmp/go"; + }; + + shellAliases = { + vi = "nvim"; + vim = "nvim"; + tl = "tmux list-sessions"; + ta = "tmux attach"; + rfc_date = "date --rfc-3339='seconds'"; + }; + }; + + programs.starship = { + enable = true; + + settings = { + format = lib.concatStrings [ + "[\\[](green)" + "$username" + "[@](blue)" + "$hostname" + ":" + "$directory" + "[$git_branch$git_status](yellow)" + "$nix_shell" + "[\\]\\$](green) " + ]; + + username = { + style_root = "red"; + style_user = "green"; + format = "[$user]($style)"; + show_always = true; + aliases = { + foehammer = "foe"; + }; + }; + + hostname = { + ssh_only = false; + ssh_symbol = "!"; + trim_at = "."; + style = "green"; + format = "[$hostname]($style)[$ssh_symbol](red)"; + }; + + directory = { + truncation_length = 3; + truncate_to_repo = true; + style = "green"; + read_only = "(ro)"; + read_only_style = "red"; + home_symbol = "~"; + use_os_path_sep = true; + + format = "[$path]($style)[$read_only]($read_only_style)"; + }; + + git_branch = { + symbol = ""; + always_show_remote = false; + truncation_symbol = ".."; + ignore_branches = []; + truncation_length = 7; + + format = "\\(g-$branch"; + }; + + nix_shell = { + format = "[\\($symbol$pure_msg$impure_msg\\)]($style)"; + symbol = "n"; + style = "blue"; + impure_msg = " - \\(impure\\)"; + pure_msg = "p"; + }; + + git_status = { + style = "white"; + format = "$ahead_behind$conflicted$modified\\)"; + ahead = ">"; + behind = "<"; + diverged = "%"; + up_to_date = ""; + conflicted = "[!c](red)"; + modified = "*"; + }; + }; + + enableBashIntegration = true; + }; +} diff --git a/common/default.nix b/common/default.nix new file mode 100644 index 0000000..1ed190c --- /dev/null +++ b/common/default.nix @@ -0,0 +1,31 @@ +{ + pkgs, + lib, + ... +}: let + inherit (lib) mkOption types; +in { + options.home.uid = mkOption { + type = with types; nullOr int; + default = null; + description = '' + The account UID. If the UID is null, a free UID is picked on + activation. + ''; + }; + + config = { + programs.home-manager.enable = true; + + home = { + packages = with pkgs; [ + wget + curl + htop + doggo + jq + tree + ]; + }; + }; +} diff --git a/common/direnv.nix b/common/direnv.nix new file mode 100644 index 0000000..ac77d07 --- /dev/null +++ b/common/direnv.nix @@ -0,0 +1,9 @@ +{...}: { + programs.direnv = { + enable = true; + + enableBashIntegration = true; + + nix-direnv.enable = true; + }; +} diff --git a/common/git.nix b/common/git.nix new file mode 100644 index 0000000..d49be51 --- /dev/null +++ b/common/git.nix @@ -0,0 +1,32 @@ +{...}: { + programs.git = { + enable = true; + lfs.enable = true; + userName = "foehammer127"; + userEmail = "foehammer@disroot.org"; + + signing = { + key = "A972C2063F4F2554"; + signByDefault = true; + }; + + extraConfig = { + init = {defaultBranch = "main";}; + pull = {rebase = true;}; + rebase = {verify = false;}; + }; + + # Git aliases to use + aliases = { + c = "commit"; + cc = "commit"; + co = "checkout"; + cb = "checkout -b"; + aa = "add -A"; + a = "add"; + ca = "commit --amend"; + l = "log"; + lo = "log --oneline"; + }; + }; +} diff --git a/common/gpg/default.nix b/common/gpg/default.nix new file mode 100644 index 0000000..477c0ea --- /dev/null +++ b/common/gpg/default.nix @@ -0,0 +1,84 @@ +{ + config, + lib, + pkgs, + ... +}: { + services.gpg-agent = lib.mkIf pkgs.stdenv.isLinux { + enable = true; + enableScDaemon = true; + enableExtraSocket = true; + defaultCacheTtl = 34560000; + maxCacheTtl = 34560000; + pinentryPackage = pkgs.pinentry.tty; + enableSshSupport = true; + + extraConfig = '' + extra-socket /run/user/${toString config.home.uid}/gnupg/S.gpg-agent.extra + ''; + }; + + programs.gpg = { + enable = true; + + scdaemonSettings = { + disable-ccid = true; + }; + + # Basically Ripped From Yubikey-Guide + settings = { + personal-cipher-preferences = "AES256 AES192 AES"; + + personal-digest-preferences = "SHA512 SHA384 SHA256"; + + personal-compress-preferences = "ZLIB BZIP2 ZIP Uncompressed"; + + default-preference-list = "SHA512 SHA384 SHA256 AES256 AES192 AES ZLIB BZIP2 ZIP Uncompressed"; + + cert-digest-algo = "SHA512"; + + s2k-digest-algo = "SHA512"; + + s2k-cipher-algo = "AES256"; + + charset = "utf-8"; + + no-comments = ""; + + no-emit-version = ""; + + no-greeting = ""; + + keyid-format = "0xlong"; + + list-options = "show-uid-validity"; + + with-fingerprint = ""; + + require-cross-certification = ""; + + no-symkey-cache = ""; + + armor = ""; + + use-agent = ""; + + throw-keyids = ""; + + default-key = "A972C2063F4F2554"; + + trusted-key = "A972C2063F4F2554"; + }; + + publicKeys = [ + # Personal Yubikey. + { + source = ./pubkey.txt; + trust = "ultimate"; + } + ]; + + mutableTrust = false; + mutableKeys = false; + }; +} diff --git a/common/gpg/pubkey.txt b/common/gpg/pubkey.txt new file mode 100644 index 0000000..7069826 --- /dev/null +++ b/common/gpg/pubkey.txt @@ -0,0 +1,23 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: SKS 1.1.6 +Comment: Hostname: pgp.mit.edu + +mDMEZhmo/hYJKwYBBAHaRw8BAQdA5KtBDUHqW0HmTNZPx8AixJLu0f5Sn9hO9YKp6VP4cPe0 +JExvcmVuem8gR29vZCA8Zm9laGFtbWVyQGRpc3Jvb3Qub3JnPoiOBBMWCgA2FiEE2nCZLbIg +Jb/DvyDQqXLCBj9PJVQFAmYZqP4CGwEECwkIBwQVCgkIBRYCAwEAAh4FAheAAAoJEKlywgY/ +TyVUJQsBAPt5wWxJjY7aR7i4JW9GeGhXpi9ybRPulRAS+KZDdNuLAP0Sh03lJzV4D+jWG2z8 +vtq2iLkJyufs1Pz0VTTQfxAPD7gzBGYZqYcWCSsGAQQB2kcPAQEHQP76alk6Ei6ep4Mxhr9b +dwJkWvd5xr89W2PWWPBTnaEAiO8EGBYKACAWIQTacJktsiAlv8O/INCpcsIGP08lVAUCZhmp +hwIbAgCBCRCpcsIGP08lVHYgBBkWCgAdFiEE3fCObmGYe/Mi43lOf81kvYEYDtAFAmYZqYcA +CgkQf81kvYEYDtCBiQEA9y8tM4pdirGdoHXb6GlHcMG1JfIJf22UbW1KfyFskmUA/2lPJsfC +DNlkciqn7UIfNo4nKgZmr+Y2UcXq7hFjnKsLIAoBAIlUjngd17+kNA4iKs6hUuHc9SO8P4gc +iCAF67OH5uydAQD/Epq+qu59AWgKn+1pFZkvaPrGDONasDHptr2oOZLUBrgzBGYZqZ0WCSsG +AQQB2kcPAQEHQKtCcKS1jN/WSb4Ggvpz11pkUdE4kMgrN0xwptXLgSBXiHgEGBYKACAWIQTa +cJktsiAlv8O/INCpcsIGP08lVAUCZhmpnQIbIAAKCRCpcsIGP08lVLf1AP0VOdfnzaNQFd9m +IjcO0PTzYS8HV2Ku9I5iJQhGozhj1wEAuLT28hEDfkKrmELLu0aTzCZLUMOTnvAulFaTA+zF +VQu4OARmGamREgorBgEEAZdVAQUBAQdA/Zugq1SwUUdLqkkPnDFukfz/fAr7HAoIyooDukW2 +HDkDAQgHiHgEGBYKACAWIQTacJktsiAlv8O/INCpcsIGP08lVAUCZhmpkQIbDAAKCRCpcsIG +P08lVPrjAQDbhPJ7BGXwBIWh4cksS+gapFc5JGilL5O4cz5iPJkQKAEAk3yNx9hU6iNlGD21 +2Er+ZgBoyJo6eqD6XeBF9vS3dgo= +=nZ4q +-----END PGP PUBLIC KEY BLOCK----- diff --git a/common/k9s/default.nix b/common/k9s/default.nix new file mode 100644 index 0000000..aeef153 --- /dev/null +++ b/common/k9s/default.nix @@ -0,0 +1,13 @@ +{...}: { + programs.k9s = { + enable = true; + + settings = { + skin = "gruvbox-foehammer"; + }; + + skins = { + gruvbox-foehammer = builtins.fromJSON (builtins.readFile ./gruvbox.json); + }; + }; +} diff --git a/common/k9s/gruvbox.json b/common/k9s/gruvbox.json new file mode 100644 index 0000000..ada4560 --- /dev/null +++ b/common/k9s/gruvbox.json @@ -0,0 +1 @@ +{"foreground":"#ebdbb2","background":"#282828","current_line":"#ebdbb2","selection":"#3c3735","comment":"#bdad93","cyan":"#689D6A","green":"#98971a","orange":"#FABD2F","magenta":"#b16286","blue":"#83A598","red":"#cc241D","k9s":{"body":{"fgColor":"#ebdbb2","bgColor":"#282828","logoColor":"#83A598"},"prompt":{"fgColor":"#ebdbb2","bgColor":"#282828","suggestColor":"#FABD2F"},"info":{"fgColor":"#b16286","sectionColor":"#ebdbb2"},"help":{"fgColor":"#ebdbb2","bgColor":"#282828","keyColor":"#b16286","numKeyColor":"#83A598","sectionColor":"#98971a"},"dialog":{"fgColor":"#ebdbb2","bgColor":"#282828","buttonFgColor":"#ebdbb2","buttonBgColor":"#b16286","buttonFocusFgColor":"white","buttonFocusBgColor":"#689D6A","labelFgColor":"#FABD2F","fieldFgColor":"#ebdbb2"},"frame":{"border":{"fgColor":"#3c3735","focusColor":"#ebdbb2"},"menu":{"fgColor":"#ebdbb2","keyColor":"#b16286","numKeyColor":"#b16286"},"crumbs":{"fgColor":"#ebdbb2","bgColor":"#bdad93","activeColor":"#83A598"},"status":{"newColor":"#689D6A","modifyColor":"#83A598","addColor":"#98971a","errorColor":"#cc241D","highlightColor":"#FABD2F","killColor":"#bdad93","completedColor":"#bdad93"},"title":{"fgColor":"#ebdbb2","bgColor":"#282828","highlightColor":"#FABD2F","counterColor":"#83A598","filterColor":"#b16286"}},"views":{"charts":{"bgColor":"background","defaultDialColors":["#83A598","#cc241D"],"defaultChartColors":["#83A598","#cc241D"]},"table":{"fgColor":"#ebdbb2","bgColor":"#282828","cursorFgColor":"#ebdbb2","cursorBgColor":"#ebdbb2","header":{"fgColor":"#ebdbb2","bgColor":"#282828","sorterColor":"#3c3735"}},"xray":{"fgColor":"#ebdbb2","bgColor":"#282828","cursorColor":"#ebdbb2","graphicColor":"#83A598","showIcons":false},"yaml":{"keyColor":"#b16286","colonColor":"#83A598","valueColor":"#ebdbb2"},"logs":{"fgColor":"#ebdbb2","bgColor":"#282828","indicator":{"fgColor":"#ebdbb2","bgColor":"#282828","toggleOnColor":"#b16286","toggleOffColor":"#83A598"}}}}} diff --git a/common/tmux/default.nix b/common/tmux/default.nix new file mode 100644 index 0000000..729bc1d --- /dev/null +++ b/common/tmux/default.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + pkgs, + ... +}: { + programs.tmux = { + enable = true; + + baseIndex = 1; + clock24 = true; + keyMode = "vi"; + newSession = true; + + resizeAmount = 10; + shortcut = "b"; + terminal = "screen-256color"; + + plugins = with pkgs.tmuxPlugins; [ + ]; + + extraConfig = builtins.readFile ./tmux.conf; + + customPaneNavigationAndResize = true; + }; +} diff --git a/common/tmux/tmux.conf b/common/tmux/tmux.conf new file mode 100644 index 0000000..30ac2bb --- /dev/null +++ b/common/tmux/tmux.conf @@ -0,0 +1,49 @@ +set -g status-position top +set -g renumber-windows on +set -g set-clipboard on + +## Bindings: +bind -N "Split Horizontally" s split-window -v +bind -N "Split Vertically" v split-window -h +bind -N "Reload Source File" R source-file ~/.config/tmux/tmux.conf +bind -N "Change Session Root Dir" E attach-session -c "#{pane_current_path}" + +## COLORSCHEME: gruvbox dark (medium) +set-option -g status "on" + +# default statusbar color +set-option -g status-style bg="#282828",fg="#928374" # bg=bg1, fg=fg1 + +# default window title colors +set-window-option -g window-status-style bg="#282828",fg="#EBDBB2" # bg=yellow, fg=bg1 + +# default window with an activity alert +set-window-option -g window-status-activity-style bg="#282828",fg="#CC241D" # bg=bg1, fg=fg3 + +# active window title colors +set-window-option -g window-status-current-style bg="#EBDBB2",fg="#282828" # fg=bg1 + +# pane border +set-option -g pane-active-border-style fg="#928374" #fg2 +set-option -g pane-border-style fg="#928374" #bg1 + +# message infos +set-option -g message-style bg="#282828",fg="#FABD2F" # bg=bg2, fg=fg1 + +# writing commands inactive +set-option -g message-command-style bg="#282828",fg="#D3869B" # bg=fg3, fg=bg1 + +# pane number display +set-option -g display-panes-active-colour colour250 #fg2 +set-option -g display-panes-colour colour237 #bg1 + +# clock +set-window-option -g clock-mode-colour colour109 #blue + +# bell +set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg + + +set-option -sg escape-time 0 + +set-option -a terminal-features 'xterm-256-color:RGB' diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..79edc18 --- /dev/null +++ b/flake.lock @@ -0,0 +1,178 @@ +{ + "nodes": { + "alejandra": { + "inputs": { + "fenix": "fenix", + "flakeCompat": "flakeCompat", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660592437, + "narHash": "sha256-xFumnivtVwu5fFBOrTxrv6fv3geHKF04RGP23EsDVaI=", + "owner": "kamadorueda", + "repo": "alejandra", + "rev": "e7eac49074b70814b542fee987af2987dd0520b5", + "type": "github" + }, + "original": { + "owner": "kamadorueda", + "ref": "3.0.0", + "repo": "alejandra", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "alejandra", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1657607339, + "narHash": "sha256-HaqoAwlbVVZH2n4P3jN2FFPMpVuhxDy1poNOR7kzODc=", + "owner": "nix-community", + "repo": "fenix", + "rev": "b814c83d9e6aa5a28d0cf356ecfdafb2505ad37d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flakeCompat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747020534, + "narHash": "sha256-D/6rkiC6w2p+4SwRiVKrWIeYzun8FBg7NlMKMwQMxO0=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "b4bbdc6fde16fc2051fcde232f6e288cd22007ca", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-24.11", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1746957726, + "narHash": "sha256-k9ut1LSfHCr0AW82ttEQzXVCqmyWVA5+SHJkS5ID/Jo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a39ed32a651fdee6842ec930761e31d1f242cb94", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1743296961, + "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "alejandra": "alejandra", + "flake-parts": "flake-parts", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1657557289, + "narHash": "sha256-PRW+nUwuqNTRAEa83SfX+7g+g8nQ+2MMbasQ9nt6+UM=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "caf23f29144b371035b864a1017dbc32573ad56d", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..70ba78f --- /dev/null +++ b/flake.nix @@ -0,0 +1,89 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + + flake-parts.url = "github:hercules-ci/flake-parts"; + + home-manager = { + url = "github:nix-community/home-manager/release-24.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + alejandra = { + url = "github:kamadorueda/alejandra/3.0.0"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + systems.url = "github:nix-systems/default"; + }; + + outputs = inputs @ {self, ...}: + inputs.flake-parts.lib.mkFlake {inherit inputs;} (toplevel @ {withSystem, ...}: let + getPackages = system: + import inputs.nixpkgs { + localSystem = system; + config = { + allowUnfree = true; + allowAliases = true; + }; + + overlays = [ + ]; + }; + in { + systems = ["aarch64-linux" "aarch64-linux" "x86_64-linux"]; + + perSystem = { + config, + self', + inputs', + pkgs, + system, + ... + }: { + _module.args.pkgs = getPackages system; + + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [inputs'.home-manager.packages.default]; + }; + + formatter = inputs'.alejandra.packages.default; + }; + + flake = { + lib = import ./lib; + + homeConfigurations.default = inputs.home-manager.lib.homeManagerConfiguration { + pkgs = getPackages "x86_64-linux"; + modules = [ + self.homeModules.default + self.homeModules.nvim + self.homeModules.graphical + { + home = { + username = "foehammer"; + uid = 1000; + + homeDirectory = "/home/foehammer"; + stateVersion = "24.11"; + }; + } + ]; + }; + + homeModules = { + default = {...}: { + imports = self.lib.utils.findNixFiles ./common; + }; + + nvim = {...}: { + imports = [./nvim/default.nix]; + }; + + graphical = {...}: { + imports = self.lib.utils.findNixFiles ./graphical; + }; + }; + }; + }); +} diff --git a/graphical/wezterm/default.nix b/graphical/wezterm/default.nix new file mode 100644 index 0000000..add3947 --- /dev/null +++ b/graphical/wezterm/default.nix @@ -0,0 +1,50 @@ +{pkgs, ...}: { + programs.wezterm = { + enable = true; + enableBashIntegration = true; + + package = pkgs.runCommand "wezterm-config-only" {} '' + mkdir -p $out/etc/profile.d + cp ${pkgs.wezterm}/etc/profile.d/wezterm.sh $out/etc/profile.d + ''; + + extraConfig = builtins.readFile ./wezterm.lua; + + colorSchemes = { + gbox = rec { + background = "#282828"; + foreground = "#ebdbb2"; + + cursor_bg = foreground; + cursor_fg = background; + + cursor_border = foreground; + + selection_fg = background; + selection_bg = foreground; + + ansi = [ + "#282828" + "#cc241d" + "#98971a" + "#d79921" + "#458588" + "#B16286" + "#689D6A" + "#A89984" + ]; + + brights = [ + "#928374" + "#FB4934" + "#B8BB26" + "#FABD2F" + "#83A598" + "#D3869B" + "#8EC07C" + "#EBDBB2" + ]; + }; + }; + }; +} diff --git a/graphical/wezterm/wezterm.lua b/graphical/wezterm/wezterm.lua new file mode 100644 index 0000000..49fe88d --- /dev/null +++ b/graphical/wezterm/wezterm.lua @@ -0,0 +1,12 @@ +return { + color_scheme = 'gbox', + enable_tab_bar = false, + font_size = 10.0, + -- font = wezterm.font('ComicShanns Mono Nerd Font'), + keys = { + { + key = "F11", + action = wezterm.action.ToggleFullScreen, + }, + }, +} diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..258beb6 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,3 @@ +{ + utils = import ./utils.nix; +} diff --git a/lib/utils.nix b/lib/utils.nix new file mode 100644 index 0000000..aa06bc0 --- /dev/null +++ b/lib/utils.nix @@ -0,0 +1,47 @@ +rec { + findNixFiles = dir: let + inherit (builtins) attrNames readDir pathExists concatMap; + + # Helper function to build full paths + fullPath = name: dir + "/${name}"; + + # Get directory contents + contents = readDir dir; + + # Convert contents attrset to list of names + names = attrNames contents; + + # Filter and process each item + processItem = name: let + path = fullPath name; + type = contents.${name}; + in + if type == "regular" && hasSuffix "nix" name + then [path] + else if type == "directory" && pathExists path + then findNixFiles path + else []; + in + concatMap processItem names; + + getName = filename: let + parts = builtins.split "\\." filename; + base = builtins.head (builtins.split "\\." filename); + in + if builtins.length parts == 1 + then filename + else base; + + getSuffix = filename: let + parts = builtins.split "\\." filename; + end = builtins.tail (builtins.split "\\." filename); + in + if builtins.length parts == 1 + then filename + else builtins.elemAt end (builtins.length end - 1); + + hasSuffix = suffix: filename: + if (getSuffix filename) == suffix + then true + else false; +} diff --git a/nvim/config/init.lua b/nvim/config/init.lua new file mode 100755 index 0000000..d045b2e --- /dev/null +++ b/nvim/config/init.lua @@ -0,0 +1 @@ +require 'FoehammerVim'.init() diff --git a/nvim/config/lua/.luarc.json b/nvim/config/lua/.luarc.json new file mode 100755 index 0000000..23b9ee2 --- /dev/null +++ b/nvim/config/lua/.luarc.json @@ -0,0 +1,3 @@ +{ + "workspace.checkThirdParty": false +} \ No newline at end of file diff --git a/nvim/config/lua/FoehammerVim/init.lua b/nvim/config/lua/FoehammerVim/init.lua new file mode 100755 index 0000000..2a677be --- /dev/null +++ b/nvim/config/lua/FoehammerVim/init.lua @@ -0,0 +1,10 @@ +local function init() + require 'FoehammerVim.vim'.init() + require 'FoehammerVim.theme'.init() + require 'FoehammerVim.languages'.init() + require 'FoehammerVim.telescope'.init() +end + +return { + init = init, +} diff --git a/nvim/config/lua/FoehammerVim/languages.lua b/nvim/config/lua/FoehammerVim/languages.lua new file mode 100755 index 0000000..4859423 --- /dev/null +++ b/nvim/config/lua/FoehammerVim/languages.lua @@ -0,0 +1,239 @@ +local lspconfig = require 'lspconfig' +local treesitter = require 'nvim-treesitter.configs' +local treesitter_context = require 'treesitter-context' +local cmp = require 'cmp' +local luasnip = require 'luasnip' +local cmp_lsp = require 'cmp_nvim_lsp' +local rust_tools = require 'rust-tools' + +local function autocmd(args) + local event = args[1] + local group = args[2] + local callback = args[3] + + vim.api.nvim_create_autocmd(event, { + group = group, + buffer = args[4], + callback = function() + callback() + end, + once = args.once, + }) +end + +local function on_attach(client, buffer) + local augroup_highlight = vim.api.nvim_create_augroup("custom-lsp-references", { clear = true }) + local autocmd_clear = vim.api.nvim_clear_autocmds + + local opts = { buffer = buffer, remap = false } + + vim.bo[buffer].omnifunc = 'v:lua.vim.lsp.omnifunc' + + + -- Enable completion triggered by + vim.bo[buffer].omnifunc = 'v:lua.vim.lsp.omnifunc' + + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', 'wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, opts) + + vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format({ async = false })]] + + if client.server_capabilities.documentHighlightProvider then + autocmd_clear { group = augroup_highlight, buffer = buffer } + autocmd { "CursorHold", augroup_highlight, vim.lsp.buf.document_highlight, buffer } + autocmd { "CursorMoved", augroup_highlight, vim.lsp.buf.clear_references, buffer } + end +end + +local function init() + rust_tools.setup { + server = { + settings = { + ['rust-analyzer'] = { + cargo = { + buildScripts = { + enable = true, + }, + }, + diagnostics = { + enable = false, + }, + files = { + excludeDirs = { ".direnv", ".git" }, + watcherExclude = { ".direnv", ".git" }, + }, + }, + }, + on_attach = on_attach, + }, + } + + + + local language_servers = { + astro = {}, + clangd = {}, + cssls = {}, + dagger = {}, + diagnosticls = { + filetypes = { "python" }, + init_options = { + filetypes = { + python = "black" + }, + formatFiletypes = { + python = { "black" } + }, + formatters = { + black = { + command = "black", + args = { "--quiet", "-" }, + rootPatterns = { "pyproject.toml" }, + }, + }, + } + }, + elixirls = { + cmd = { "elixir-ls" }, + }, + gopls = { + settings = { + gopls = { + gofumpt = true, + }, + }, + }, + html = { + filetypes = { "html", "htmldjango" }, + }, + jsonls = {}, + lua_ls = { + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + runtime = { + version = 'LuaJIT', + }, + telemetry = { + enable = false, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + } + + + } + + }, + nil_ls = { + settings = { + ['nil'] = { + formatting = { command = { 'alejandra' } }, + } + + } + }, + pyright = {}, + tsserver = {}, + tailwindcss = { + filetypes = { "templ", "astro", "typescriptreact", "react", "html", "heex" }, + settings = { + tailwindCSS = { + includeLanguages = { + templ = "html", + }, + }, + }, + }, + yamlls = { + settings = { + yaml = { + keyOrdering = false, + }, + }, + }, + zls = {}, + } + + local capabilities = cmp_lsp.default_capabilities() + + -- Initialize servers + for server, server_config in pairs(language_servers) do + local config = { on_attach = on_attach, capabilities = capabilities } + + if server_config then + for k, v in pairs(server_config) do + config[k] = v + end + end + + lspconfig[server].setup(config) + end + + vim.keymap.set('n', 'e', vim.diagnostic.open_float) + vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) + vim.keymap.set('n', ']d', vim.diagnostic.goto_next) + vim.keymap.set('n', 'q', vim.diagnostic.setloclist) + + + treesitter.setup { + auto_install = false, + ignore_install = {}, + ensure_installed = {}, + highlight = { enable = true }, + indent = { enable = true }, + modules = {}, + rainbow = { enable = true }, + sync_install = false, + } + + treesitter_context.setup() + + + cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, -- For luasnip users. + }, { + { name = 'buffer' }, + }) + }) + + vim.g.vimtex_view_method = "zathura" +end + + +return { + init = init, +} diff --git a/nvim/config/lua/FoehammerVim/telescope.lua b/nvim/config/lua/FoehammerVim/telescope.lua new file mode 100755 index 0000000..639962c --- /dev/null +++ b/nvim/config/lua/FoehammerVim/telescope.lua @@ -0,0 +1,45 @@ +local telescope = require 'telescope' +local actions = require 'telescope.actions' + +local function init() + telescope.setup { + defaults = { + file_ignore_patterns = { + "node_modules/.*", + "%.pem" + }, + layout_strategy = "flex", + layout_config = { + horizontal = { + prompt_position = "bottom", + preview_width = 0.55, + }, + vertical = { mirror = false }, + width = 0.87, + height = 0.8, + preview_cutoff = 125, + }, + mappings = { + i = { + [""] = actions.close, + [""] = false, + [""] = actions.delete_buffer + actions.move_to_top, + }, + }, + } + } + + telescope.load_extension('notify') + + local options = { noremap = true, silent = true } + + vim.keymap.set('n', 'ff', 'lua require ("telescope.builtin").find_files()', options) + vim.keymap.set('n', 'fg', 'lua require ("telescope.builtin").live_grep()', options) + vim.keymap.set('n', 'cd', 'lua require ("telescope.builtin").diagnostics()', options) + + vim.keymap.set('n', 'b', 'lua require ("telescope.builtin").buffers()', options) +end + +return { + init = init, +} diff --git a/nvim/config/lua/FoehammerVim/theme.lua b/nvim/config/lua/FoehammerVim/theme.lua new file mode 100755 index 0000000..a2c8ba0 --- /dev/null +++ b/nvim/config/lua/FoehammerVim/theme.lua @@ -0,0 +1,162 @@ +local gitsigns = require 'gitsigns' +local lualine = require 'lualine' +local noice = require 'noice' +local notify = require 'notify' +local gruvbox = require 'gruvbox' + +local function setup_lualine() + local colors = { + black = '#282828', + white = '#ebdbb2', + red = '#fb4934', + green = '#b8bb26', + blue = '#459588', + yellow = '#faBD2f', + gray = '#928374', + darkgray = '#3c3836', + lightgray = '#504945', + inactivegray = '#7c6f64', + } + + local theme = { + normal = { + a = { bg = colors.gray, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.darkgray, fg = colors.gray }, + }, + insert = { + a = { bg = colors.blue, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.lightgray, fg = colors.white }, + }, + visual = { + a = { bg = colors.yellow, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.inactivegray, fg = colors.black }, + }, + replace = { + a = { bg = colors.red, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.black, fg = colors.white }, + }, + command = { + a = { bg = colors.green, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.inactivegray, fg = colors.black }, + }, + inactive = { + a = { bg = colors.darkgray, fg = colors.gray, gui = 'bold' }, + b = { bg = colors.darkgray, fg = colors.gray }, + c = { bg = colors.darkgray, fg = colors.gray }, + }, + } + + lualine.setup({ + options = { + icons_enabled = true, + theme = theme, + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = '' }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = vim.go.laststatus == 3, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { 'filename' }, + lualine_x = { 'encoding', { + 'fileformat', + symbols = { + unix = "", + mac = "󰀶", + } + }, + 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { 'filename' }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {}, + }, + }) +end + +local function init() + gitsigns.setup {} + + setup_lualine() + + notify.setup({ + render = "compact", + timeout = 1000, + }) + + noice.setup({ + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + }) + + gruvbox.setup { + terminal_colors = true, + undercurl = true, + underline = true, + bold = true, + italic = { + strings = true, + emphasis = true, + comments = true, + operators = false, + folds = true, + }, + strikethrough = true, + invert_selection = false, + invert_signs = false, + invert_tabline = false, + invert_intend_guides = false, + inverse = true, -- invert background for search, diffs, statuslines and errors + contrast = "", -- can be "hard", "soft" or empty string + palette_overrides = {}, + overrides = {}, + dim_inactive = false, + transparent_mode = false, + } + + + + vim.o.background = "dark" + vim.cmd [[colorscheme gruvbox]] +end + + +return { + init = init, +} diff --git a/nvim/config/lua/FoehammerVim/vim.lua b/nvim/config/lua/FoehammerVim/vim.lua new file mode 100755 index 0000000..c0056b8 --- /dev/null +++ b/nvim/config/lua/FoehammerVim/vim.lua @@ -0,0 +1,72 @@ +local function set_vim_g() + vim.g.mapleader = ' ' + vim.g.maplocalleader = ' ' +end + +local function set_vim_opt() + local settings = { + relativenumber = true, + number = true, + showmode = false, + clipboard = 'unnamedplus', + breakindent = true, + undofile = true, + ignorecase = true, + smartcase = true, + signcolumn = 'yes', + updatetime = 250, + timeoutlen = 300, + splitright = true, + splitbelow = true, + inccommand = 'split', + cursorline = true, + scrolloff = 10, + hlsearch = true, + termguicolors = true, + tabstop = 4, + shiftwidth = 4 + } + + for k, v in pairs(settings) do + vim.opt[k] = v + end +end + +local function set_vim_keymaps() + local options = { noremap = false, silent = true } + + vim.keymap.set('n', 'h', 'wincmd h', options) + vim.keymap.set('n', 'j', 'wincmd j', options) + vim.keymap.set('n', 'k', 'wincmd k', options) + vim.keymap.set('n', 'l', 'wincmd l', options) + vim.keymap.set('n', '', 'nohlsearch') + + -- Bandaid Peel + vim.keymap.set('n', '', '') + vim.keymap.set('n', '', '') + vim.keymap.set('n', '', '') + vim.keymap.set('n', '', 'ta", ":$tabnew", { noremap = true }) + vim.api.nvim_set_keymap("n", "tc", ":tabclose", { noremap = true }) + vim.api.nvim_set_keymap("n", "to", ":tabonly", { noremap = true }) + vim.api.nvim_set_keymap("n", "tn", ":tabn", { noremap = true }) + vim.api.nvim_set_keymap("n", "tp", ":tabp", { noremap = true }) + -- move current tab to previous position + vim.api.nvim_set_keymap("n", "tmp", ":-tabmove", { noremap = true }) + -- move current tab to next position + vim.api.nvim_set_keymap("n", "tmn", ":+tabmove", { noremap = true }) +end + + +local function init() + vim.loader.enable() + set_vim_g() + set_vim_opt() + set_vim_keymaps() +end + +return { + init = init, +} diff --git a/nvim/default.nix b/nvim/default.nix new file mode 100644 index 0000000..a28b7e9 --- /dev/null +++ b/nvim/default.nix @@ -0,0 +1,91 @@ +{pkgs, ...}: let + plugins = let + inherit (pkgs) vimPlugins; + in + with vimPlugins; [ + # Languages + nvim-lspconfig + nvim-treesitter.withAllGrammars + nvim-cmp + luasnip + cmp_luasnip + cmp-nvim-lsp + cmp-buffer + rust-tools-nvim + + # Telescope Stuff + telescope-nvim + plenary-nvim + + # Extra Stuff + gitsigns-nvim + lualine-nvim + noice-nvim + nvim-notify + gruvbox-nvim + nui-nvim + nvim-treesitter-context + nvim-web-devicons + vimtex + ]; + + packages = let + inherit (pkgs) nodePackages; + in + with pkgs; [ + #LSPs + cuelsp + elixir-ls + gopls + lua-language-server + rust-analyzer + tailwindcss-language-server + nil + nodePackages."@astrojs/language-server" + nodePackages."typescript-language-server" + nodePackages."diagnostic-languageserver" + nodePackages."vscode-langservers-extracted" + nodePackages."yaml-language-server" + pyright + zls + + #Formatters + gofumpt + alejandra + rustfmt + python3Packages.black + + # Telescope Stuff + ripgrep + fd + ]; + + vimPlugin = let + inherit (pkgs.vimUtils) buildVimPlugin; + in + buildVimPlugin { + name = "FoehammerVim"; + src = ./config; + }; + + extraConfig = '' + lua << EOF + require 'FoehammerVim'.init() + EOF + ''; +in { + home.packages = with pkgs; [ripgrep fd]; + + programs.neovim = { + inherit extraConfig; + plugins = plugins ++ [vimPlugin]; + extraPackages = packages; + + enable = true; + defaultEditor = true; + + withNodeJs = true; + withPython3 = true; + withRuby = true; + }; +} diff --git a/x b/x new file mode 100755 index 0000000..c84f6e4 --- /dev/null +++ b/x @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +function switch() { + home-manager switch --flake .#$1 +} + +if [[ -n $1 ]]; then + switch $1 +else + switch default +fi