From 09513b5c4e4babfaefdd06c592ef34c0908dc572 Mon Sep 17 00:00:00 2001 From: sadbeast Date: Thu, 30 May 2024 00:47:47 +0000 Subject: oh god what have i done --- home/sadbeast/features/desktop/default.nix | 21 +++ home/sadbeast/features/desktop/firefox.nix | 127 +++++++++++++++ home/sadbeast/features/desktop/foot.nix | 21 +++ home/sadbeast/features/desktop/sway.nix | 132 ++++++++++++++++ home/sadbeast/features/desktop/waybar.css | 70 +++++++++ home/sadbeast/features/desktop/waybar.nix | 57 +++++++ home/sadbeast/features/git.nix | 28 ++++ home/sadbeast/features/gpg.nix | 67 ++++++++ home/sadbeast/features/pass.nix | 17 ++ home/sadbeast/features/services.nix | 21 +++ home/sadbeast/features/ssh.nix | 26 +++ home/sadbeast/features/vim.nix | 245 +++++++++++++++++++++++++++++ home/sadbeast/features/zsh.nix | 67 ++++++++ home/sadbeast/global/default.nix | 211 +++++++++++++++++++++++++ home/sadbeast/joshua.nix | 26 +++ home/sadbeast/norad.nix | 11 ++ home/sadbeast/wopr.nix | 11 ++ home/sadbeast/work.nix | 64 ++++++++ 18 files changed, 1222 insertions(+) create mode 100644 home/sadbeast/features/desktop/default.nix create mode 100644 home/sadbeast/features/desktop/firefox.nix create mode 100644 home/sadbeast/features/desktop/foot.nix create mode 100644 home/sadbeast/features/desktop/sway.nix create mode 100644 home/sadbeast/features/desktop/waybar.css create mode 100644 home/sadbeast/features/desktop/waybar.nix create mode 100644 home/sadbeast/features/git.nix create mode 100644 home/sadbeast/features/gpg.nix create mode 100644 home/sadbeast/features/pass.nix create mode 100644 home/sadbeast/features/services.nix create mode 100644 home/sadbeast/features/ssh.nix create mode 100644 home/sadbeast/features/vim.nix create mode 100644 home/sadbeast/features/zsh.nix create mode 100644 home/sadbeast/global/default.nix create mode 100644 home/sadbeast/joshua.nix create mode 100644 home/sadbeast/norad.nix create mode 100644 home/sadbeast/wopr.nix create mode 100644 home/sadbeast/work.nix (limited to 'home/sadbeast') diff --git a/home/sadbeast/features/desktop/default.nix b/home/sadbeast/features/desktop/default.nix new file mode 100644 index 0000000..d393fff --- /dev/null +++ b/home/sadbeast/features/desktop/default.nix @@ -0,0 +1,21 @@ +{ + pkgs, + config, + lib, + ... +}: { + imports = [ + ./firefox.nix + ./foot.nix + ./sway.nix + ./waybar.nix + ]; + + home = { + packages = with pkgs; [ + galculator + pavucontrol + wine + ]; + }; +} diff --git a/home/sadbeast/features/desktop/firefox.nix b/home/sadbeast/features/desktop/firefox.nix new file mode 100644 index 0000000..08ec448 --- /dev/null +++ b/home/sadbeast/features/desktop/firefox.nix @@ -0,0 +1,127 @@ +{ + pkgs, + inputs, + lib, + config, + ... +}: let + addons = inputs.firefox-addons.packages.${pkgs.system}; +in { + programs.browserpass.enable = true; + programs.firefox = { + enable = true; + profiles.sadbeast = { + search = { + force = true; + default = "Google"; + privateDefault = "DuckDuckGo"; + order = ["Google" "DuckDuckGo"]; + }; + bookmarks = {}; + extensions = with addons; [ + ublock-origin + browserpass + ]; + bookmarks = {}; + settings = { + "browser.startup.homepage" = "about:home"; + + # Disable irritating first-run stuff + "browser.disableResetPrompt" = true; + "browser.download.panel.shown" = true; + "browser.feeds.showFirstRunUI" = false; + "browser.messaging-system.whatsNewPanel.enabled" = false; + "browser.rights.3.shown" = true; + "browser.shell.checkDefaultBrowser" = false; + "browser.shell.defaultBrowserCheckCount" = 1; + "browser.startup.homepage_override.mstone" = "ignore"; + "browser.uitour.enabled" = false; + "startup.homepage_override_url" = ""; + "trailhead.firstrun.didSeeAboutWelcome" = true; + "browser.bookmarks.restore_default_bookmarks" = false; + "browser.bookmarks.addedImportButton" = true; + + # Don't ask for download dir + "browser.download.useDownloadDir" = false; + + # Disable crappy home activity stream page + "browser.newtabpage.activity-stream.feeds.topsites" = false; + "browser.newtabpage.activity-stream.showSponsoredTopSites" = false; + "browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts" = false; + "browser.newtabpage.blocked" = lib.genAttrs [ + # Youtube + "26UbzFJ7qT9/4DhodHKA1Q==" + # Facebook + "4gPpjkxgZzXPVtuEoAL9Ig==" + # Wikipedia + "eV8/WsSLxHadrTL1gAxhug==" + # Reddit + "gLv0ja2RYVgxKdp0I5qwvA==" + # Amazon + "K00ILysCaEq8+bEqV/3nuw==" + # Twitter + "T9nJot5PurhJSy8n038xGA==" + ] (_: 1); + + # Disable some telemetry + "app.shield.optoutstudies.enabled" = false; + "browser.discovery.enabled" = false; + "browser.newtabpage.activity-stream.feeds.telemetry" = false; + "browser.newtabpage.activity-stream.telemetry" = false; + "browser.ping-centre.telemetry" = false; + "datareporting.healthreport.service.enabled" = false; + "datareporting.healthreport.uploadEnabled" = false; + "datareporting.policy.dataSubmissionEnabled" = false; + "datareporting.sessions.current.clean" = true; + "devtools.onboarding.telemetry.logged" = false; + "toolkit.telemetry.archive.enabled" = false; + "toolkit.telemetry.bhrPing.enabled" = false; + "toolkit.telemetry.enabled" = false; + "toolkit.telemetry.firstShutdownPing.enabled" = false; + "toolkit.telemetry.hybridContent.enabled" = false; + "toolkit.telemetry.newProfilePing.enabled" = false; + "toolkit.telemetry.prompted" = 2; + "toolkit.telemetry.rejected" = true; + "toolkit.telemetry.reportingpolicy.firstRun" = false; + "toolkit.telemetry.server" = ""; + "toolkit.telemetry.shutdownPingSender.enabled" = false; + "toolkit.telemetry.unified" = false; + "toolkit.telemetry.unifiedIsOptIn" = false; + "toolkit.telemetry.updatePing.enabled" = false; + + # Disable fx accounts + "identity.fxaccounts.enabled" = false; + # Disable "save password" prompt + "signon.rememberSignons" = false; + # Harden + "privacy.trackingprotection.enabled" = true; + "dom.security.https_only_mode" = true; + # Layout + "browser.uiCustomization.state" = builtins.toJSON { + currentVersion = 20; + newElementCount = 5; + dirtyAreaCache = ["nav-bar" "PersonalToolbar" "toolbar-menubar" "TabsToolbar" "widget-overflow-fixed-list"]; + placements = { + PersonalToolbar = ["personal-bookmarks"]; + TabsToolbar = ["tabbrowser-tabs" "new-tab-button" "alltabs-button"]; + nav-bar = ["back-button" "forward-button" "stop-reload-button" "urlbar-container" "downloads-button" "ublock0_raymondhill_net-browser-action" "browserpass_maximbaz_com-browser-action" "reset-pbm-toolbar-button" "unified-extensions-button"]; + toolbar-menubar = ["menubar-items"]; + unified-extensions-area = []; + widget-overflow-fixed-list = []; + }; + seen = ["save-to-pocket-button" "developer-button" "ublock0_raymondhill_net-browser-action" "browserpass_maximbaz_com-browser-action"]; + }; + }; + }; + }; + + # home = { + # persistence = { + # # Not persisting is safer + # "/persistent${config.home.homeDirectory}" = { + # directories = [ ".mozilla/firefox" ]; + # allowOther = true; + # }; + # }; + # }; +} diff --git a/home/sadbeast/features/desktop/foot.nix b/home/sadbeast/features/desktop/foot.nix new file mode 100644 index 0000000..d6bb965 --- /dev/null +++ b/home/sadbeast/features/desktop/foot.nix @@ -0,0 +1,21 @@ +{ + inputs, + outputs, + ... +}: { + programs.foot = { + enable = true; + + # server.enable = true; + + settings = { + main = { + font = "Iosevka-11:style=Medium,Regular, JoyPixels"; + font-bold = "Iosevka-11:style=Bold"; + font-italic = "Iosevka-11:style=Italic"; + + underline-offset = 1; + }; + }; + }; +} diff --git a/home/sadbeast/features/desktop/sway.nix b/home/sadbeast/features/desktop/sway.nix new file mode 100644 index 0000000..39e9834 --- /dev/null +++ b/home/sadbeast/features/desktop/sway.nix @@ -0,0 +1,132 @@ +{ + config, + lib, + pkgs, + ... +}: { + home.packages = with pkgs; [ + grim + iosevka + (nerdfonts.override {fonts = ["Iosevka"];}) + light + slurp + swayimg + wl-clipboard + dmenu-wayland + ]; + + fonts.fontconfig.enable = true; + + home.sessionVariables = { + XDG_CURRENT_DESKTOP = "sway"; + MOZ_ENABLE_WAYLAND = 1; + QT_QPA_PLATFORM = "wayland"; + LIBSEAT_BACKEND = "logind"; + SDL_VIDEODRIVER = "wayland"; + }; + + gtk = { + enable = true; + theme = { + package = pkgs.gnome-themes-extra; + # name = "Adwaita-dark"; + name = "Adwaita"; + }; + }; + + home.pointerCursor = { + gtk.enable = true; + package = pkgs.vanilla-dmz; + name = "Vanilla-DMZ"; + size = 22; + }; + + wayland.windowManager.sway = { + enable = true; + + config = { + modifier = "Mod4"; + + bars = []; + + fonts = { + names = ["Iosevka"]; + size = 11.0; + }; + + gaps = { + smartGaps = true; + outer = 0; + }; + + input = { + "*" = { + xkb_layout = "us"; + xkb_options = "ctrl:nocaps"; + tap = "enabled"; + }; + }; + + keybindings = let + modifier = config.wayland.windowManager.sway.config.modifier; + in + lib.mkOptionDefault { + "${modifier}+p" = "exec passmenu"; + "${modifier}+Shift+Return" = "exec qutebrowser"; + "${modifier}+y" = "exec grim ~/scrn-$(date +\"%Y-%m-%d-%H-%M-%S\").png"; + "${modifier}+Shift+y" = "exec slurp | grim -g - ~/scrn-$(date +\"%Y-%m-%d-%H-%M-%S\").png"; + "XF86AudioRaiseVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%+ && wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed 's/[^0-9]//g' > $XDG_RUNTIME_DIR/wob.sock"; + "XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%- && wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed 's/[^0-9]//g' > $XDG_RUNTIME_DIR/wob.sock"; + "XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && (wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q MUTED && echo 0 > $XDG_RUNTIME_DIR/wob.sock) || wpctl get-volume @DEFAULT_AUDIO_SINK@ > $XDG_RUNTIME_DIR/wob.sock"; + + "XF86MonBrightnessUp" = "exec light -A 5 && light -G | cut -d'.' -f1 > $XDG_RUNTIME_DIR/wob.sock"; + "XF86MonBrightnessDown" = "exec light -U 5 && light -G | cut -d'.' -f1 > $XDG_RUNTIME_DIR/wob.sock"; + }; + + startup = [ + { + command = "systemctl --user restart waybar"; + always = true; + } + ]; + + terminal = "${pkgs.foot}/bin/foot"; + }; + + extraConfig = '' + # Window borders + default_border pixel 1 + default_floating_border normal + hide_edge_borders smart + ''; + }; + + services = { + mako = { + enable = true; + + extraConfig = '' + [mode=do-not-disturb] + invisible=1 + ''; + }; + + swayidle = { + enable = true; + + events = [ + # { event = "timeout 300"; command = "${pkgs.swaylock}/bin/swaylock -fF -c 000000"; } + # { event = "timeout 600"; command = "swaymsg \"output * dpms off\""; } + { + event = "after-resume"; + command = "swaymsg \"output * dpms on\""; + } + { + event = "before-sleep"; + command = "${pkgs.swaylock}/bin/swaylock -fF -c 000000"; + } + ]; + }; + wob.enable = true; + }; +} diff --git a/home/sadbeast/features/desktop/waybar.css b/home/sadbeast/features/desktop/waybar.css new file mode 100644 index 0000000..725514c --- /dev/null +++ b/home/sadbeast/features/desktop/waybar.css @@ -0,0 +1,70 @@ +* { + border: none; + border-radius: 0; + font-family: Iosevka; + font-size: 13px; + min-height: 0; +} + +window#waybar { + background: rgba(43, 48, 59, 0.5); + border-bottom: 2px solid rgba(100, 114, 125, 0.5); + color: white; +} + +#workspaces { + margin-right: 5px; +} + +#workspaces button { + padding: 0 5px; + background: transparent; + color: white; + border-bottom: 2px solid transparent; +} + +#workspaces button.focused { + background: #64727D; + border-bottom: 2px solid white; +} + +#mode, #clock, #battery { + padding: 0 10px; + margin: 0 5px; +} + +#mode { + background: #64727D; + border-bottom: 2px solid white; +} + +#clock { + background-color: #64727D; +} + +#battery { + background-color: #ffffff; + color: black; +} + +#battery.charging { + color: white; + background-color: #26A65B; +} + +@keyframes blink { + to { + background-color: #ffffff; + color: black; + } +} + +#battery.warning:not(.charging) { + background: #f53c3c; + color: white; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} diff --git a/home/sadbeast/features/desktop/waybar.nix b/home/sadbeast/features/desktop/waybar.nix new file mode 100644 index 0000000..02410b4 --- /dev/null +++ b/home/sadbeast/features/desktop/waybar.nix @@ -0,0 +1,57 @@ +{ + programs.waybar = { + enable = true; + systemd.enable = true; + + settings = { + mainBar = { + layer = "bottom"; + position = "top"; + height = 20; + + modules-left = ["sway/workspaces" "sway/mode" "sway/window"]; + modules-right = ["tray" "battery" "clock"]; + + "sway/workspaces" = { + format = "{name}"; + disable-scroll = true; + }; + + "sway/mode" = { + format = " {}"; + }; + + "sway/window" = { + max-length = 80; + tooltip = false; + }; + + clock = { + format = "{:%a %d %I:%M}"; + tooltip = false; + }; + + battery = { + format = "{capacity}% {icon}"; + format-alt = "{time} {icon}"; + format-icons = ["" "" "" "" ""]; + format-charging = "{capacity}% "; + interval = 30; + + states = { + warning = 25; + critical = 10; + }; + + tooltip = false; + }; + + tray = { + icon-size = 18; + }; + }; + }; + + style = ./waybar.css; + }; +} diff --git a/home/sadbeast/features/git.nix b/home/sadbeast/features/git.nix new file mode 100644 index 0000000..477265b --- /dev/null +++ b/home/sadbeast/features/git.nix @@ -0,0 +1,28 @@ +{ + config, + lib, + ... +}: { + programs.git = { + enable = true; + userName = lib.mkDefault config.home.username; + userEmail = lib.mkDefault "sadbeast@sadbeast.com"; + + aliases = { + p = "pull --ff-only"; + ff = "merge --ff-only"; + graph = "log --decorate --oneline --graph"; + add-nowhitespace = "!git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero -"; + # for "last branch", shows the most recently accessed branches + lb = "!git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 15 | awk -F' ~ HEAD@{' '{printf(\" \\033[33m%s: \\033[37m %s\\033[0m\\n\", substr($2, 1, length($2)-1), $1)}'"; + }; + + extraConfig = { + init.defaultBranch = "main"; + push.autoSetupRemote = true; + # Reuse merge conflict fixes when rebasing + rerere.enabled = true; + }; + ignores = [".direnv"]; + }; +} diff --git a/home/sadbeast/features/gpg.nix b/home/sadbeast/features/gpg.nix new file mode 100644 index 0000000..5af4838 --- /dev/null +++ b/home/sadbeast/features/gpg.nix @@ -0,0 +1,67 @@ +{ + pkgs, + config, + lib, + ... +}: { + services.gpg-agent = { + enable = true; + # enableSshSupport = true; + # sshKeys = [""]; + enableExtraSocket = true; + pinentryPackage = + if config.gtk.enable + then pkgs.pinentry-gnome3 + else pkgs.pinentry-tty; + }; + + home.packages = lib.optional config.gtk.enable pkgs.gcr; + + programs = let + fixGpg = + /* + bash + */ + '' + gpgconf --launch gpg-agent + ''; + in { + # Start gpg-agent if it's not running or tunneled in + # SSH does not start it automatically, so this is needed to avoid having to use a gpg command at startup + # https://www.gnupg.org/faq/whats-new-in-2.1.html#autostart + bash.profileExtra = fixGpg; + zsh.loginExtra = fixGpg; + + gpg = { + enable = true; + settings = { + trust-model = "tofu+pgp"; + }; + # publicKeys = [ + # { + # source = ../../pgp.asc; + # trust = 5; + # } + # ]; + }; + }; + + systemd.user.services = { + # Link /run/user/$UID/gnupg to ~/.gnupg-sockets + # So that SSH config does not have to know the UID + link-gnupg-sockets = { + Unit = { + Description = "link gnupg sockets from /run to /home"; + }; + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.coreutils}/bin/ln -Tfs /run/user/%U/gnupg %h/.gnupg-sockets"; + ExecStop = "${pkgs.coreutils}/bin/rm $HOME/.gnupg-sockets"; + RemainAfterExit = true; + }; + Install.WantedBy = ["default.target"]; + }; + }; +} +# vim: filetype=nix + diff --git a/home/sadbeast/features/pass.nix b/home/sadbeast/features/pass.nix new file mode 100644 index 0000000..0a64f41 --- /dev/null +++ b/home/sadbeast/features/pass.nix @@ -0,0 +1,17 @@ +{ + pkgs, + config, + ... +}: { + programs.password-store = { + enable = true; + settings = { + PASSWORD_STORE_DIR = "$HOME/.password-store"; + }; + package = pkgs.pass.withExtensions (p: [p.pass-otp]); + }; + + # home.persistence = { + # "/persistent${config.home.homeDirectory}".directories = [".password-store"]; + # }; +} diff --git a/home/sadbeast/features/services.nix b/home/sadbeast/features/services.nix new file mode 100644 index 0000000..71ef7d8 --- /dev/null +++ b/home/sadbeast/features/services.nix @@ -0,0 +1,21 @@ +{pkgs, ...}: { + services = { + swayidle = { + enable = true; + + events = [ + # { event = "timeout 300"; command = "${pkgs.swaylock}/bin/swaylock -fF -c 000000"; } + # { event = "timeout 600"; command = "swaymsg \"output * dpms off\""; } + { + event = "after-resume"; + command = "swaymsg \"output * dpms on\""; + } + { + event = "before-sleep"; + command = "${pkgs.swaylock}/bin/swaylock -fF -c 000000"; + } + ]; + }; + wob.enable = true; + }; +} diff --git a/home/sadbeast/features/ssh.nix b/home/sadbeast/features/ssh.nix new file mode 100644 index 0000000..aeace3c --- /dev/null +++ b/home/sadbeast/features/ssh.nix @@ -0,0 +1,26 @@ +{ + programs.ssh = { + enable = true; + + matchBlocks = { + "falken" = { + hostname = "sadbeast.com"; + port = 6973; + }; + + "crystalpalace" = { + hostname = "192.168.0.2"; + port = 6973; + }; + + "joshua" = { + hostname = "192.168.0.3"; + }; + + "teamdraft" = { + hostname = "teamdraft.net"; + port = 6973; + }; + }; + }; +} diff --git a/home/sadbeast/features/vim.nix b/home/sadbeast/features/vim.nix new file mode 100644 index 0000000..173304d --- /dev/null +++ b/home/sadbeast/features/vim.nix @@ -0,0 +1,245 @@ +{pkgs, ...}: { + programs.vim = { + enable = true; + defaultEditor = true; + + plugins = with pkgs.vimPlugins; [ + # ale + asyncomplete-vim + asyncomplete-lsp-vim + base16-vim + copilot-vim + lightline-vim + # lightline-ale + lightline-lsp + fugitive + fzf-vim + vim-commentary + vim-dadbod + vim-dispatch + vim-dotenv + vim-eunuch + vim-lsp + # vim-lsp-ale + vim-lsp-settings + vim-mustache-handlebars + vim-rails + vim-signify + vim-wayland-clipboard + vim-vsnip + vim-vsnip-integ + zig-vim + ]; + + settings = { + hidden = true; + ignorecase = true; + # mouse = "a"; + number = true; + relativenumber = true; + smartcase = true; + }; + + extraConfig = '' + set nocompatible + set encoding=utf-8 + set wildmenu + set showcmd + set hlsearch + " Use visual bell instead of beeping when doing something wrong + set visualbell + + " And reset the terminal code for the visual bell. If visualbell is set, and + " this line is also included, vim will neither flash nor beep. If visualbell + " is unset, this does nothing. + set t_vb= + set backspace=indent,eol,start + set autoindent + set nostartofline + set ruler + set confirm + " Quickly time out on keycodes, but never time out on mappings + set notimeout ttimeout ttimeoutlen=200 + set pastetoggle= + " automatically leave paste mode so I don't forget + autocmd InsertLeave * set nopaste + " Indentation settings for using 4 spaces instead of tabs. + " Do not change 'tabstop' from its default value of 8 with this setup. + set shiftwidth=4 + set softtabstop=4 + set expandtab + " Don't update the screen when executing macros + set lazyredraw + + " Easier to reach than \ + let mapleader=" " + + " fzf + nmap p :Files + nmap bb :Buffers + + " dadbod + autocmd FileType sql let b:dispatch = 'pgcli %' + vnoremap d :DB + nmap d :DB + + set formatoptions=ctqrn1 + + " Show matching brackets. + set showmatch + + " Bracket blinking. + set matchtime=5 + + " start scrolling when we're 8 lines away from margins + set scrolloff=8 + set sidescrolloff=15 + set sidescroll=1 + + set noswapfile + set nobackup + set nowb + + " Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode. + "set fo+=o + " Do not automatically insert a comment leader after an enter + "set fo-=r + " Do no auto-wrap text using textwidth (does not apply to comments) + "set fo-=t + + set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/vendor/*,*/bin/*,*/node_modules/* + + " quicker async update time + set updatetime=100 + + " taller vertical bar for vsplits + set fillchars+=vert:│ + + set ttymouse = "sgr"; + + " Enable 24-bit colors + set termguicolors + let &t_8f = "\[38:2::%lu:%lu:%lum" + let &t_8b = "\[48:2::%lu:%lu:%lum" + + " Workaround bug in vim, where it incorrectly thinks modifyOtherKeys level 2 is + " enabled, even when it's not. The snippets below ensure modifyOtherKeys=2 is + " enabled. https://github.com/vim/vim/issues/9014 + let &t_TI = "\[>4;2m" + let &t_TE = "\[>4;m" + + set undodir=~/.vim/backups + set undofile + + " When opening a file, always jump to the last cursor position + autocmd BufReadPost * + \ if line("'\"") > 0 && line ("'\"") <= line("$") | + \ exe "normal g'\"" | + \ endif + + " remove annoying help window + inoremap + nnoremap + vnoremap + + " better window navigation + nnoremap j + nnoremap k + nnoremap h + nnoremap l + + " quickfix + nnoremap :cnext + nnoremap :cprevious + + " command line autocomplete + set wildchar= wildmenu wildmode=full + + " scroll through buffers + noremap :bp + noremap :bn + + " show menu to switch buffers + set wildcharm= + nnoremap :b + + " unhighlight search results + noremap / :nohls + + " reselect visual block after indent/outdent + vnoremap < >gv + + " force saving files that require root permission + cmap w!! %!sudo tee > /dev/null % + + " Close the current buffer and move to the previous one + " This replicates the idea of closing a tab + nmap bq :bp bd # + + colorscheme base16-default-dark + + let g:termdebug_popup = 0 + let g:termdebug_wide = 163 + + " vim-lsp + function! s:on_lsp_buffer_enabled() abort + setlocal omnifunc=lsp#complete + setlocal signcolumn=yes + if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif + nmap gd (lsp-definition) + nmap gs (lsp-document-symbol-search) + nmap gS (lsp-workspace-symbol-search) + nmap gr (lsp-references) + nmap gi (lsp-implementation) + nmap gt (lsp-type-definition) + nmap rn (lsp-rename) + nmap [g (lsp-previous-diagnostic) + nmap ]g (lsp-next-diagnostic) + nmap K (lsp-hover) + " nnoremap lsp#scroll(+4) + " nnoremap lsp#scroll(-4) + + let g:lsp_format_sync_timeout = 1000 + autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') + + " refer to doc to add more commands + endfunction + + augroup lsp_install + au! + " call s:on_lsp_buffer_enabled only for languages that has the server registered. + autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() + augroup END + + "if executable('solargraph') + " " gem install solargraph + " au User lsp_setup call lsp#register_server({ + " \ 'name': 'solargraph', + " \ 'cmd': {server_info->[&shell, &shellcmdflag, 'solargraph stdio']}, + " \ 'initialization_options': {"diagnostics": "true"}, + " \ 'whitelist': ['ruby'], + " \ }) + "endif + + " asyncomplete + inoremap pumvisible() ? "\" : "\" + inoremap pumvisible() ? "\" : "\" + inoremap pumvisible() ? asyncomplete#close_popup() : "\" + + imap (asyncomplete_force_refresh) + + " vim-vsnip + " Expand + imap vsnip#expandable() ? '(vsnip-expand)' : '' + smap vsnip#expandable() ? '(vsnip-expand)' : '' + + " Expand or jump + imap vsnip#available(1) ? '(vsnip-expand-or-jump)' : '' + smap vsnip#available(1) ? '(vsnip-expand-or-jump)' : '' + + " Copilot ugh + " let g:copilot_node_command = "/usr/bin/env node" + ''; + }; +} diff --git a/home/sadbeast/features/zsh.nix b/home/sadbeast/features/zsh.nix new file mode 100644 index 0000000..db568e6 --- /dev/null +++ b/home/sadbeast/features/zsh.nix @@ -0,0 +1,67 @@ +{ + pkgs, + config, + ... +}: { + programs.zsh = { + enable = true; + autocd = true; + enableCompletion = true; + enableVteIntegration = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + + loginExtra = '' + if [ "$(tty)" = "/dev/tty1" ]; then + exec sway + fi + ''; + + initExtra = '' + precmd() { + print -Pn "\e]133;A\e\\" + } + + function osc7-pwd() { + emulate -L zsh # also sets localoptions for us + setopt extendedglob + local LC_ALL=C + printf '\e]7;file://%s%s\e\' $HOST ''${PWD//(#m)([^@-Za-z&-;_~])/%''${(l:2::0:)$(([##16]#MATCH))}} + } + + function chpwd-osc7-pwd() { + (( ZSH_SUBSHELL )) || osc7-pwd + } + add-zsh-hook -Uz chpwd chpwd-osc7-pwd + ''; + + defaultKeymap = "emacs"; + + history = { + size = 10000; + path = "${config.xdg.dataHome}/zsh/zsh_history"; + }; + + shellAliases = { + ll = "ls -l"; + }; + + sessionVariables = { + EDITOR = "vim"; + }; + + # TODO: this causes a 2 second delay + # plugins = [ + # { + # name = "zsh-nix-shell"; + # file = "nix-shell.plugin.zsh"; + # src = pkgs.fetchFromGitHub { + # owner = "chisui"; + # repo = "zsh-nix-shell"; + # rev = "v0.8.0"; + # sha256 = "1lzrn0n4fxfcgg65v0qhnj7wnybybqzs4adz7xsrkgmcsr0ii8b7"; + # }; + # } + # ]; + }; +} diff --git a/home/sadbeast/global/default.nix b/home/sadbeast/global/default.nix new file mode 100644 index 0000000..e811b6f --- /dev/null +++ b/home/sadbeast/global/default.nix @@ -0,0 +1,211 @@ +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: { + # You can import other home-manager modules here + imports = [ + # If you want to use modules your own flake exports (from modules/home-manager): + # outputs.homeManagerModules.example + + # Or modules exported from other flakes (such as nix-colors): + # inputs.nix-colors.homeManagerModules.default + inputs.impermanence.nixosModules.home-manager.impermanence + + # You can also split up your configuration and import pieces of it here: + ../features/git.nix + ../features/gpg.nix + ../features/pass.nix + ../features/ssh.nix + ../features/vim.nix + ../features/zsh.nix + ]; + + nix = { + package = lib.mkDefault pkgs.nix; + settings = { + experimental-features = [ + "nix-command" + "flakes" + "ca-derivations" + ]; + warn-dirty = false; + }; + }; + + nixpkgs = { + overlays = [ + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.additions + # outputs.overlays.modifications + outputs.overlays.stable-packages + + # You can also add overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + + config = { + allowUnfree = true; + allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "joypixels" + ]; + joypixels.acceptLicense = true; + }; + }; + + home = { + username = "sadbeast"; + homeDirectory = "/home/${config.home.username}"; + }; + + programs = { + # browserpass = { + # enable = true; + # browsers = [ "firefox" ]; + # }; + + btop.enable = true; + fd.enable = true; + firefox = { + package = pkgs.wrapFirefox (pkgs.firefox-unwrapped.override {pipewireSupport = true;}) {}; + enable = true; + }; + gpg.enable = true; + home-manager.enable = true; + qutebrowser.enable = true; + ripgrep.enable = true; + starship.enable = true; + swaylock.enable = true; + + tmux = { + enable = true; + shortcut = "a"; + escapeTime = 0; + + plugins = with pkgs; [ + tmuxPlugins.better-mouse-mode + tmuxPlugins.pain-control + ]; + + extraConfig = '' + # https://old.reddit.com/r/tmux/comments/mesrci/tmux_2_doesnt_seem_to_use_256_colors/ + set -g default-terminal "xterm-256color" + set -ga terminal-overrides ",*256col*:Tc" + set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' + set-environment -g COLORTERM "truecolor" + + # Mouse works as expected + set-option -g mouse on + # easy-to-remember split pane commands + bind | split-window -h -c "#{pane_current_path}" + bind - split-window -v -c "#{pane_current_path}" + bind c new-window -c "#{pane_current_path}" + ''; + }; + + direnv = { + enable = true; + enableZshIntegration = true; + nix-direnv.enable = true; + }; + + fzf = { + enable = true; + defaultCommand = "fd -H -E .git --type f"; + changeDirWidgetCommand = "fd --type d"; + fileWidgetCommand = "fd --type f"; + historyWidgetOptions = [ + "--sort" + "--exact" + ]; + }; + + keychain = { + enable = true; + enableZshIntegration = true; + keys = ["id_ed25519"]; + extraFlags = ["--quiet"]; + }; + }; + + home = { + packages = with pkgs; [ + httpie + jq + joypixels + sops + unzip + uxn + zig + ]; + + # persistence = { + # "${config.home.homeDirectory}" = { + # directories = [ + # { + # directory = "docs"; + # method = "symlink"; + # } + # { + # directory = "projects"; + # method = "symlink"; + # } + # { + # directory = ".local/share/qutebrowser"; + # method = "symlink"; + # } + # { + # directory = ".local/share/vim-lsp-settings"; + # method = "symlink"; + # } + # ".password-store" + # ".local/share/direnv" + # ".local/share/zsh" + # ".gnupg" + # ".ssh" + # ]; + # allowOther = true; + # }; + # }; + }; + + xdg.userDirs = let + homeDir = config.home.homeDirectory; + in { + enable = true; + createDirectories = false; + + desktop = "${homeDir}"; + documents = "${homeDir}/docs"; + download = "${homeDir}/downloads"; + pictures = "${homeDir}/pics"; + }; + + xdg.mimeApps = { + enable = true; + + defaultApplications = { + "text/html" = "org.qutebrowser.qutebrowser.desktop"; + "x-scheme-handler/http" = "org.qutebrowser.qutebrowser.desktop"; + "x-scheme-handler/https" = "org.qutebrowser.qutebrowser.desktop"; + "x-scheme-handler/about" = "org.qutebrowser.qutebrowser.desktop"; + "x-scheme-handler/unknown" = "org.qutebrowser.qutebrowser.desktop"; + }; + }; + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + home.stateVersion = "24.05"; +} diff --git a/home/sadbeast/joshua.nix b/home/sadbeast/joshua.nix new file mode 100644 index 0000000..44c3a47 --- /dev/null +++ b/home/sadbeast/joshua.nix @@ -0,0 +1,26 @@ +{ + pkgs, + config, + lib, + ... +}: { + imports = [ + ./global + ./features/desktop + ]; + + # ---------- --------- + # | HDMI-A-1 | | DVI-D-1 | + # ---------- --------- + + wayland.windowManager.sway.config.output = { + HDMI-A-1 = { + resolution = "1920x1080"; + position = "0,0"; + }; + DVI-D-1 = { + resolution = "1920x1080"; + position = "1920,0"; + }; + }; +} diff --git a/home/sadbeast/norad.nix b/home/sadbeast/norad.nix new file mode 100644 index 0000000..477930c --- /dev/null +++ b/home/sadbeast/norad.nix @@ -0,0 +1,11 @@ +{ + pkgs, + config, + lib, + ... +}: { + imports = [ + ./global + ./features/desktop + ]; +} diff --git a/home/sadbeast/wopr.nix b/home/sadbeast/wopr.nix new file mode 100644 index 0000000..477930c --- /dev/null +++ b/home/sadbeast/wopr.nix @@ -0,0 +1,11 @@ +{ + pkgs, + config, + lib, + ... +}: { + imports = [ + ./global + ./features/desktop + ]; +} diff --git a/home/sadbeast/work.nix b/home/sadbeast/work.nix new file mode 100644 index 0000000..5d253e8 --- /dev/null +++ b/home/sadbeast/work.nix @@ -0,0 +1,64 @@ +{ + pkgs, + config, + lib, + ... +}: { + imports = [ + ./global + ./features/desktop + ]; + + home = { + sessionVariables = { + BUNDLE_PATH = "vendor/bundle"; + }; + + packages = with pkgs; [ + aws-sam-cli + awscli2 + gcc + google-chrome + ruby + nodejs + slack + ruby-lsp + ssm-session-manager-plugin + ]; + }; + + programs = { + git = { + userName = "Kent Smith"; + userEmail = "kent.smith@andros.co"; + + extraConfig = { + core.sshCommand = "ssh -i ~/.ssh/id_rsa -o IdentitiesOnly=yes"; + }; + }; + + obs-studio = { + enable = true; + plugins = with pkgs.obs-studio-plugins; [ + wlrobs + obs-backgroundremoval + obs-pipewire-audio-capture + ]; + }; + }; + + wayland.windowManager.sway.config.output = { + eDP-1 = { + resolution = "1920x1080"; + position = "0,0"; + }; + HDMI-A-1 = { + resolution = "1920x1080"; + position = "0,1080"; + }; + DP-1 = { + resolution = "1920x1080"; + position = "1920,1080"; + }; + }; +} -- cgit v1.2.3