First Try

This commit is contained in:
Olaf Kolkman
2025-05-06 19:41:26 +02:00
commit fbd41a72f1
58 changed files with 7011 additions and 0 deletions

16
modules/shared/README.md Normal file
View File

@ -0,0 +1,16 @@
## Shared
Much of the code running on MacOS or NixOS is actually found here.
This configuration gets imported by both modules. Some configuration examples include `git`, `zsh`, `vim`, and `tmux`.
## Layout
```
.
├── config # Config files not written in Nix
├── cachix # Defines cachix, a global cache for builds
├── default.nix # Defines how we import overlays
├── files.nix # Non-Nix, static configuration files (now immutable!)
├── home-manager.nix # The goods; most all shared config lives here
├── packages.nix # List of packages to share
```

View File

@ -0,0 +1 @@
config.el

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,142 @@
;; -------------------------
;; Variable Declarations
;; -------------------------
(defvar org-config-file "~/.local/share/src/nixos-config/modules/shared/config/emacs/config.org")
(defvar default-config-file "~/.emacs.d/default-config.org")
(defvar default-config-url "https://raw.githubusercontent.com/dustinlyons/nixos-config/9ad810c818b895c1f67f4daf21bbef31d8b5e8cd/shared/config/emacs/config.org")
;; -------------------------
;; Package Manager Setup
;; -------------------------
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")))
(unless (assoc-default "melpa" package-archives)
(message "Warning: MELPA source not found. Adding MELPA to package-archives.")
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t))
(unless (assoc-default "org" package-archives)
(message "Warning: Org source not found. Adding Org to package-archives.")
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t))
(setq package-enable-at-startup nil)
;; -------------------------
;; Use-Package Setup
;; -------------------------
(unless (package-installed-p 'use-package)
(package-initialize)
(if (package-install 'use-package)
(message "use-package installed successfully.")
(error "Error: Failed to install use-package."))
(setq use-package-verbose t)
(setq use-package-always-ensure t)
(require 'use-package))
;; -------------------------
;; Environment Variables Setup
;; -------------------------
(use-package exec-path-from-shell
:if (memq window-system '(mac ns x))
:config
(setq exec-path-from-shell-variables '("PATH" "GOPATH" "PNPM_HOME"))
(if (exec-path-from-shell-initialize)
(message "Environment variables initialized successfully.")
(error "Error: Failed to initialize environment variables.")))
(when (daemonp)
(exec-path-from-shell-initialize))
;; -------------------------
;; Straight.el Setup
;; -------------------------
(setq straight-repository-branch "develop")
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(if (load bootstrap-file nil 'nomessage)
(message "Straight.el loaded successfully.")
(error "Error: Failed to load Straight.el.")))
(setq straight-use-package-by-default t)
(package-initialize)
;; -------------------------
;; Window and UI Setup
;; -------------------------
(defun dl/window-setup ()
(condition-case nil
(progn
(column-number-mode)
(scroll-bar-mode 0)
(menu-bar-mode -1)
(tool-bar-mode 0)
(winner-mode 1)
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . dark))
(setq ns-use-proxy-icon nil)
(setq frame-title-format nil)
(message "Window and UI setup completed successfully."))
(error (message "Error occurred in Window and UI setup."))))
(dl/window-setup)
;; -------------------------
;; Org Mode Setup
;; -------------------------
(defun dl/org-mode-setup ()
(condition-case nil
(progn
(org-indent-mode)
(variable-pitch-mode 1)
(auto-fill-mode 0)
(visual-line-mode 1)
(setq evil-auto-indent nil)
(message "Org mode setup completed successfully."))
(error (message "Error occurred in Org mode setup."))))
(use-package org
:defer t
:hook (org-mode . dl/org-mode-setup)
:config
(setq org-edit-src-content-indentation 2
org-ellipsis ""
org-hide-emphasis-markers t
org-hide-block-startup nil)
:bind (("C-c a" . org-agenda)))
;; -------------------------
;; Default Config Download
;; -------------------------
(defun dl/download-default-config ()
(condition-case nil
(progn
(unless (file-exists-p default-config-file)
(url-retrieve default-config-url
(lambda (_status)
;; delete-region removes the HTTP headers from the downloaded content.
(delete-region (point-min) (1+ url-http-end-of-headers))
;; save the contents of the buffer to the file.
(write-file default-config-file)))
(message "Default configuration downloaded successfully.")))
(error (message "Error occurred while downloading the default configuration."))))
;; -------------------------
;; Load Org Config or Default
;; -------------------------
(condition-case nil
(progn
(unless (file-exists-p org-config-file)
(dl/download-default-config))
(if (file-exists-p org-config-file)
(org-babel-load-file org-config-file)
(org-babel-load-file default-config-file))
(message "Configuration loaded successfully."))
(error (message "Error occurred while loading the configuration.")))

View File

@ -0,0 +1,288 @@
# Temporarily change options.
'builtin' 'local' '-a' 'p10k_config_opts'
[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases')
[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob')
[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
() {
emulate -L zsh
setopt no_unset
autoload -Uz is-at-least && is-at-least 5.1 || return
# Unset all configuration options.
unset -m 'POWERLEVEL9K_*'
# Left prompt segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
dir # current directory
vcs # git status
context # user@host
command_execution_time # previous command duration
virtualenv # python virtual environment
prompt_char # prompt symbol
)
# Right prompt segments.
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
nix_shell_with_name
)
# Defines character set used by powerlevel10k.
typeset -g POWERLEVEL9K_MODE=nerdfont-complete
# When set to `moderate`, some icons will have an extra space after them. This is meant to avoid
# icon overlap when using non-monospace fonts. When set to `none`, spaces are not added.
typeset -g POWERLEVEL9K_ICON_PADDING=none
# Basic style options that define the overall prompt look.
typeset -g POWERLEVEL9K_BACKGROUND= # transparent background
typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace
typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space
typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol
typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION= # no segment icons
# Add an empty line before each prompt except the first. This doesn't emulate the bug
# in Pure that makes prompt drift down whenever you use the ALT-C binding from fzf or similar.
typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
# Green prompt symbol if the last command succeeded.
typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=002
# Red prompt symbol if the last command failed.
typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=001
# Default prompt symbol.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION=''
# Prompt symbol in command vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION=''
# Prompt symbol in visual vi mode is the same as in command mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION=''
# Prompt symbol in overwrite vi mode is the same as in command mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=false
# Grey Python Virtual Environment.
typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=007
# Don't show Python version.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=
# Blue current directory.
typeset -g POWERLEVEL9K_DIR_FOREGROUND=blue
# Context format when root: user@host. The first part white, the rest grey.
typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%7F%n%f%007F@%m%f'
# Context format when not root: user@host. The whole thing grey.
typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%007F%n@%m%f'
# Don't show context unless root or in SSH.
typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_CONTENT_EXPANSION=
# Show previous command duration only if it's >= 5s.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=5
# Don't show fractional seconds. Thus, 7s rather than 7.3s.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
# Duration format: 1d 2h 3m 4s.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s'
# Yellow previous command duration.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=007
# Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon.
typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 '
# Untracked files icon. It's really a question mark, your font isn't broken.
# Change the value of this parameter to show a different icon.
typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?'
# Version control system colors.
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=2
typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=3
typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=2
typeset -g POWERLEVEL9K_VCS_CONFLICTED_FOREGROUND=3
typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=8
# Nix shell color.
typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=0
typeset -g POWERLEVEL9K_NIX_SHELL_BACKGROUND=4
# Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line.
typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION=
function prompt_nix_shell_with_name() {
if [[ -n "${IN_NIX_SHELL-}" ]]; then
if [[ "${name-nix-shell}" != nix-shell ]] && [ "${name-shell}" != shell ]; then
p10k segment -b 4 -f 15 -r -i NIX_SHELL_ICON -t "$name"
else
p10k segment -b 4 -f 15 -r -i NIX_SHELL_ICON
fi
fi
}
# VCS_STATUS_* parameters are set by gitstatus plugin. See reference:
# https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh.
function my_git_formatter() {
emulate -L zsh
if [[ -n $P9K_CONTENT ]]; then
# If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from
# gitstatus plugin). VCS_STATUS_* parameters are not available in this case.
typeset -g my_git_format=$P9K_CONTENT
return
fi
if (( $1 )); then
# Styling for up-to-date Git status.
local meta='%f' # default foreground
local clean='%002F' # green foreground
local modified='%003F' # yellow foreground
local untracked='%004F' # blue foreground
local conflicted='%001F' # red foreground
else
# Styling for incomplete and stale Git status.
local meta='%244F' # grey foreground
local clean='%244F' # grey foreground
local modified='%244F' # grey foreground
local untracked='%244F' # grey foreground
local conflicted='%244F' # grey foreground
fi
local res
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
local branch=${(V)VCS_STATUS_LOCAL_BRANCH}
# If local branch name is at most 32 characters long, show it in full.
# Otherwise show the first 12 … the last 12.
(( $#branch > 32 )) && branch[13,-13]="…" # <-- this line
if (( VCS_STATUS_HAS_CONFLICTED)); then
res+="${conflicted}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
else
if (( VCS_STATUS_HAS_STAGED || VCS_STATUS_HAS_UNSTAGED )); then
res+="${modified}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
else
if (( VCS_STATUS_HAS_UNTRACKED )); then
res+="${untracked}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
else
res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
fi
fi
fi
fi
if [[ -n $VCS_STATUS_TAG
# Show tag only if not on a branch.
&& -z $VCS_STATUS_LOCAL_BRANCH # <-- this line
]]; then
local tag=${(V)VCS_STATUS_TAG}
# If tag name is at most 32 characters long, show it in full.
# Otherwise show the first 12 … the last 12.
(( $#tag > 32 )) && tag[13,-13]="…" # <-- this line
res+="${meta}#${clean}${tag//\%/%%}"
fi
# Display the current Git commit if there is no branch and no tag.
# Tip: To always display the current Git commit, delete the next line.
[[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line
res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
# Show tracking branch name if it differs from local branch.
if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}"
fi
typeset -g my_git_format=$res
}
functions -M my_git_formatter 2>/dev/null
# Don't count the number of unstaged, untracked and conflicted files in Git repositories with
# more than this many files in the index. Negative value means infinity.
#
# If you are working in Git repositories with tens of millions of files and seeing performance
# sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output
# of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's
# config: `git config bash.showDirtyState false`.
typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1
# Don't show Git status in prompt for repositories whose workdir matches this pattern.
# For example, if set to '~', the Git repository at $HOME/.git will be ignored.
# Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
# Disable the default Git status formatting.
typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true
# Install our own Git status formatter.
typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}'
typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}'
# Enable counters for staged, unstaged, etc.
typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
# Icon color.
typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=007
typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=008
# Show status of repositories of these types. You can add svn and/or hg if you are
# using them. If you do, your prompt may become slow even when your current directory
# isn't in an svn or hg reposotiry.
typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
# These settings are used for repositories other than Git or when gitstatusd fails and
# Powerlevel10k has to fall back to using vcs_info.
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=002
typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=004
typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=003
##########################[ end git configuration ]###########################
# Don't wait for Git status even for a millisecond, so that prompt always updates
# asynchronously when Git state changes.
typeset -g POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS=0
# Cyan ahead/behind arrows.
typeset -g POWERLEVEL9K_VCS_{INCOMING,OUTGOING}_CHANGESFORMAT_FOREGROUND=cyan
# Don't show remote branch, current tag or stashes.
# typeset -g POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind)
# When in detached HEAD state, show @commit where branch normally goes.
typeset -g POWERLEVEL9K_VCS_COMMIT_ICON='@'
# Don't show staged, unstaged, untracked indicators.
# typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED}_ICON=$'\b'
# Show '*' when there are staged, unstaged or untracked files.
typeset -g POWERLEVEL9K_VCS_DIRTY_ICON='*'
# Show '⇣' if local branch is behind remote.
typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='⇣'
# Show '⇡' if local branch is ahead of remote.
typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='⇡'
# Don't show the number of commits next to the ahead/behind arrows.
typeset -g POWERLEVEL9K_VCS_{COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=1
# Remove space between '⇣' and '⇡'.
# typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${P9K_CONTENT/⇣* ⇡/⇣⇡}'
# Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt
# when accepting a command line. Supported values:
typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off
# Instant prompt mode.
typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose
# Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized.
# For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload
# can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you
# really need it.
typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true
# If p10k is already loaded, reload configuration.
# This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true.
(( ! $+functions[p10k] )) || p10k reload
}
(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]}
'builtin' 'unset' 'p10k_config_opts'

View File

@ -0,0 +1,29 @@
{ config, pkgs, ... }:
let
emacsOverlaySha256 = "06413w510jmld20i4lik9b36cfafm501864yq8k4vxl5r4hn0j0h";
in
{
nixpkgs = {
config = {
allowUnfree = true;
allowBroken = true;
allowInsecure = false;
allowUnsupportedSystem = true;
};
overlays =
# Apply each overlay found in the /overlays directory
let path = ../../overlays; in with builtins;
map (n: import (path + ("/" + n)))
(filter (n: match ".*\\.nix" n != null ||
pathExists (path + ("/" + n + "/default.nix")))
(attrNames (readDir path)))
++ [(import (builtins.fetchTarball {
url = "https://github.com/dustinlyons/emacs-overlay/archive/refs/heads/master.tar.gz";
sha256 = emacsOverlaySha256;
}))];
};
}

16
modules/shared/files.nix Normal file
View File

@ -0,0 +1,16 @@
{ pkgs, config, ... }:
# let
# githubPublicKey = "ssh-ed25519 AAAA...";
# in
{
# ".ssh/id_github.pub" = {
# text = githubPublicKey;
# };
# Initializes Emacs with org-mode so we can tangle the main config
".emacs.d/init.el" = {
text = builtins.readFile ../shared/config/emacs/init.el;
};
}

View File

@ -0,0 +1,370 @@
{ config, pkgs, lib, ... }:
let name = "%NAME%";
user = "%USER%";
email = "%EMAIL%"; in
{
# Shared shell configuration
zsh = {
enable = true;
autocd = false;
cdpath = [ "~/.local/share/src" ];
plugins = [
{
name = "powerlevel10k";
src = pkgs.zsh-powerlevel10k;
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
}
{
name = "powerlevel10k-config";
src = lib.cleanSource ./config;
file = "p10k.zsh";
}
];
initExtraFirst = ''
if [[ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]]; then
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
. /nix/var/nix/profiles/default/etc/profile.d/nix.sh
fi
# Define variables for directories
export PATH=$HOME/.pnpm-packages/bin:$HOME/.pnpm-packages:$PATH
export PATH=$HOME/.npm-packages/bin:$HOME/bin:$PATH
export PATH=$HOME/.local/share/bin:$PATH
# Remove history data we don't want to see
export HISTIGNORE="pwd:ls:cd"
# Ripgrep alias
alias search=rg -p --glob '!node_modules/*' $@
# Emacs is my editor
export ALTERNATE_EDITOR=""
export EDITOR="emacsclient -t"
export VISUAL="emacsclient -c -a emacs"
e() {
emacsclient -t "$@"
}
# nix shortcuts
shell() {
nix-shell '<nixpkgs>' -A "$1"
}
# pnpm is a javascript package manager
alias pn=pnpm
alias px=pnpx
# Use difftastic, syntax-aware diffing
alias diff=difft
# Always color ls and group directories
alias ls='ls --color=auto'
'';
};
git = {
enable = true;
ignores = [ "*.swp" ];
userName = name;
userEmail = email;
lfs = {
enable = true;
};
extraConfig = {
init.defaultBranch = "main";
core = {
editor = "vim";
autocrlf = "input";
};
commit.gpgsign = true;
pull.rebase = true;
rebase.autoStash = true;
};
};
vim = {
enable = true;
plugins = with pkgs.vimPlugins; [ vim-airline vim-airline-themes vim-startify vim-tmux-navigator ];
settings = { ignorecase = true; };
extraConfig = ''
"" General
set number
set history=1000
set nocompatible
set modelines=0
set encoding=utf-8
set scrolloff=3
set showmode
set showcmd
set hidden
set wildmenu
set wildmode=list:longest
set cursorline
set ttyfast
set nowrap
set ruler
set backspace=indent,eol,start
set laststatus=2
set clipboard=autoselect
" Dir stuff
set nobackup
set nowritebackup
set noswapfile
set backupdir=~/.config/vim/backups
set directory=~/.config/vim/swap
" Relative line numbers for easy movement
set relativenumber
set rnu
"" Whitespace rules
set tabstop=8
set shiftwidth=2
set softtabstop=2
set expandtab
"" Searching
set incsearch
set gdefault
"" Statusbar
set nocompatible " Disable vi-compatibility
set laststatus=2 " Always show the statusline
let g:airline_theme='bubblegum'
let g:airline_powerline_fonts = 1
"" Local keys and such
let mapleader=","
let maplocalleader=" "
"" Change cursor on mode
:autocmd InsertEnter * set cul
:autocmd InsertLeave * set nocul
"" File-type highlighting and configuration
syntax on
filetype on
filetype plugin on
filetype indent on
"" Paste from clipboard
nnoremap <Leader>, "+gP
"" Copy from clipboard
xnoremap <Leader>. "+y
"" Move cursor by display lines when wrapping
nnoremap j gj
nnoremap k gk
"" Map leader-q to quit out of window
nnoremap <leader>q :q<cr>
"" Move around split
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
"" Easier to yank entire line
nnoremap Y y$
"" Move buffers
nnoremap <tab> :bnext<cr>
nnoremap <S-tab> :bprev<cr>
"" Like a boss, sudo AFTER opening the file to write
cmap w!! w !sudo tee % >/dev/null
let g:startify_lists = [
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] }
\ ]
let g:startify_bookmarks = [
\ '~/.local/share/src',
\ ]
let g:airline_theme='bubblegum'
let g:airline_powerline_fonts = 1
'';
};
alacritty = {
enable = true;
settings = {
cursor = {
style = "Block";
};
window = {
opacity = 1.0;
padding = {
x = 24;
y = 24;
};
};
font = {
normal = {
family = "MesloLGS NF";
style = "Regular";
};
size = lib.mkMerge [
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux 10)
(lib.mkIf pkgs.stdenv.hostPlatform.isDarwin 14)
];
};
dynamic_padding = true;
decorations = "full";
title = "Terminal";
class = {
instance = "Alacritty";
general = "Alacritty";
};
colors = {
primary = {
background = "0x1f2528";
foreground = "0xc0c5ce";
};
normal = {
black = "0x1f2528";
red = "0xec5f67";
green = "0x99c794";
yellow = "0xfac863";
blue = "0x6699cc";
magenta = "0xc594c5";
cyan = "0x5fb3b3";
white = "0xc0c5ce";
};
bright = {
black = "0x65737e";
red = "0xec5f67";
green = "0x99c794";
yellow = "0xfac863";
blue = "0x6699cc";
magenta = "0xc594c5";
cyan = "0x5fb3b3";
white = "0xd8dee9";
};
};
};
};
ssh = {
enable = true;
includes = [
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux
"/home/${user}/.ssh/config_external"
)
(lib.mkIf pkgs.stdenv.hostPlatform.isDarwin
"/Users/${user}/.ssh/config_external"
)
];
matchBlocks = {
"github.com" = {
identitiesOnly = true;
identityFile = [
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux
"/home/${user}/.ssh/id_github"
)
(lib.mkIf pkgs.stdenv.hostPlatform.isDarwin
"/Users/${user}/.ssh/id_github"
)
];
};
};
};
tmux = {
enable = true;
plugins = with pkgs.tmuxPlugins; [
vim-tmux-navigator
sensible
yank
prefix-highlight
{
plugin = power-theme;
extraConfig = ''
set -g @tmux_power_theme 'gold'
'';
}
{
plugin = resurrect; # Used by tmux-continuum
# Use XDG data directory
# https://github.com/tmux-plugins/tmux-resurrect/issues/348
extraConfig = ''
set -g @resurrect-dir '$HOME/.cache/tmux/resurrect'
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-pane-contents-area 'visible'
'';
}
{
plugin = continuum;
extraConfig = ''
set -g @continuum-restore 'on'
set -g @continuum-save-interval '5' # minutes
'';
}
];
terminal = "screen-256color";
prefix = "C-x";
escapeTime = 10;
historyLimit = 50000;
extraConfig = ''
# Remove Vim mode delays
set -g focus-events on
# Enable full mouse support
set -g mouse on
# -----------------------------------------------------------------------------
# Key bindings
# -----------------------------------------------------------------------------
# Unbind default keys
unbind C-b
unbind '"'
unbind %
# Split panes, vertical or horizontal
bind-key x split-window -v
bind-key v split-window -h
# Move around panes with vim-like bindings (h,j,k,l)
bind-key -n M-k select-pane -U
bind-key -n M-h select-pane -L
bind-key -n M-j select-pane -D
bind-key -n M-l select-pane -R
# Smart pane switching with awareness of Vim splits.
# This is copy paste from https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
'';
};
}

View File

@ -0,0 +1,61 @@
{ pkgs }:
with pkgs; [
# General packages for development and system management
alacritty
aspell
aspellDicts.en
bash-completion
bat
btop
coreutils
killall
neofetch
openssh
sqlite
wget
zip
# Encryption and security tools
age
age-plugin-yubikey
gnupg
libfido2
# Cloud-related tools and SDKs
docker
docker-compose
# Media-related packages
emacs-all-the-icons-fonts
dejavu_fonts
ffmpeg
fd
font-awesome
hack-font
noto-fonts
noto-fonts-emoji
meslo-lgs-nf
# Node.js development tools
nodePackages.npm # globally install npm
nodePackages.prettier
nodejs
# Text and terminal utilities
htop
hunspell
iftop
jetbrains-mono
jq
ripgrep
tree
tmux
unrar
unzip
zsh-powerlevel10k
# Python packages
python3
virtualenv
]