Files

577 lines
19 KiB
Nix

{
config,
pkgs,
lib,
home-manager,
llm-agents,
...
}:
let
user = "olaf";
# Define the content of your file as a derivation
myEmacsLauncher = pkgs.writeScript "emacs-launcher.command" ''
#!/bin/sh
emacs &
'';
additionalFiles = import ./files.nix { inherit user config pkgs; };
in
{
imports = [
./dock
./brewery.nix
];
# It me
users.users.${user} = {
name = "${user}";
home = "/Users/${user}";
isHidden = false;
shell = pkgs.zsh;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILCEBZrQ9F3nLhEM9uqdPijut11vhYkdmLtj7gT/zgV3 Key Nov 2024"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA9vrzEHmWEX5sCVsp6J4tVrxEzzqMSRkijHEfVg2WrC cardno:36_431_811"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG5BytZleG7m1926MSNwVXyPJ0QD5Z919cFCp22BN5hV cardno:35_775_013"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAl/jn18uVPJ9Uyv8gqk80gVQaMHrcd1b+B/SB/6RsX8 cardno:36_431_751"
"sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAILVdAx+U1xhcJmh1hRaF0CVB0ivIF/U0oIbAWYPwko4iAAAABHNzaDo= Yubikey 35775013"
"sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIIjnJyJUDnia6ZWPRa5iSBKCb+DMGmFtiFa+9gkeiTwQAAAABHNzaDo= Yubikey 36431751"
"sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIFhuPQUHUHchx8wHVCciMi6etzZStkpECbG/r/1imy+kAAAABHNzaDo= Yubikey 36431881"
];
};
# Enable home-manager
home-manager = {
useGlobalPkgs = true;
users.${user} =
{
pkgs,
config,
lib,
...
}:
{
home = {
enableNixpkgsReleaseCheck = false;
packages = pkgs.callPackage ./packages.nix { inherit llm-agents; };
file = additionalFiles // {
"emacs-launcher.command".source = myEmacsLauncher;
};
stateVersion = "23.11";
};
home.activation.ensureNpmCliTools = import ./npm.nix { inherit lib pkgs; };
catppuccin = {
autoEnable = true;
enable = true;
flavor = "mocha";
};
programs = {
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;
enableDefaultConfig = false;
settings = {
"*" = {
forwardAgent = false;
addKeysToAgent = "no";
compression = false;
serverAliveInterval = 0;
serverAliveCountMax = 3;
hashKnownHosts = false;
userKnownHostsFile = "~/.ssh/known_hosts";
controlMaster = "no";
controlPath = "~/.ssh/master-%r@%n:%p";
controlPersist = "no";
};
"moonunit.kolkman.org" = {
hostname = "moonunit.kolkman.org";
user = "root";
port = 2222;
};
};
includes = [
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux "/home/${user}/.ssh/config_external")
(lib.mkIf pkgs.stdenv.hostPlatform.isDarwin "/Users/${user}/.ssh/config_external")
];
};
gpg = {
enable = true;
settings = {
default-key = "01B157D574FEDBB2";
no-emit-version = true;
auto-key-retrieve = true;
personal-digest-preferences = "SHA512 SHA384 SHA256 SHA224";
};
};
zsh = {
enable = true;
autocd = false;
cdpath = [ "~/.local/share/src" ];
oh-my-zsh = {
enable = true;
plugins = [ ];
theme = "mrtazz";
};
initContent =
let
zshConfigEarlyInit = lib.mkOrder 500 ''
ulimit -n 524288
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
if [[ "$TERM" == "alacritty" ]]; then
export TERMINFO_DIRS="$HOME/.nix-profile/share/terminfo:/run/current-system/sw/share/terminfo:/nix/var/nix/profiles/default/share/terminfo:/usr/share/terminfo"
if ! infocmp alacritty >/dev/null 2>&1; then
export TERM="xterm-256color"
fi
fi
# GPGAgent for SSH
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
# Define variables for directories
export PATH=$HOME/.local/bin:$PATH
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
export PATH=$HOME/.cargo/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="vim"
export EDITOR="emacs -nw"
export VISUAL="emacs"
# RMAPI remarkable
RMAPI_CONFIG=/Users/olaf/.config/rmapi
e() {
emacs -nw "$@"
}
# nix shortcuts
shell() {
nix-shell '<nixpkgs>' -A "$1"
}
# pnpm is a javascript package manager
alias pn=pnpm
alias px=pnpx
'';
zshConfigLastInit = lib.mkOrder 1500 ''
# Always color ls and group directories
alias ls='ls --color=auto'
'';
in
lib.mkMerge [
zshConfigEarlyInit
zshConfigLastInit
];
};
git = {
enable = true;
ignores = [ "*.swp" ];
lfs = {
enable = true;
};
settings = {
init.defaultBranch = "main";
core = {
editor = "vim";
autocrlf = "input";
};
commit.gpgsign = false;
pull.rebase = true;
rebase.autoStash = true;
user = {
name = "olaf";
email = "olaf@xolx.nl";
};
};
signing = {
format = "openpgp";
key = null;
signByDefault = 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
'';
};
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
'';
};
};
services = {
gpg-agent = {
enable = true;
enableSshSupport = true;
extraConfig = ''
default-cache-ttl 600
max-cache-ttl 7200
pinentry-program /Users/olaf/.nix-profile/bin/pinentry-mac
'';
};
};
# Marked broken Oct 20, 2022 check later to remove this
# https://github.com/nix-community/home-manager/issues/3344
manual.manpages.enable = false;
};
};
# Fully declarative dock using the latest from Nix Store
local = {
dock = {
enable = true;
entries = [
{ path = "/System/Applications/Launchpad.app/"; }
{ path = "/System/Applications/Mail.app/"; }
{ path = "/Applications/MailMate.app/"; }
{ path = "/Applications/1Password.app/"; }
{ path = "/Applications/Bitwarden.app"; }
{ path = "/Applications/Calendar.app/"; }
{ path = "/Applications/Notes.app/"; }
{ path = "/Applications/Firefox.app/"; }
{ path = "/Applications/Slack.app/"; }
{
path = "/Applications/zoom.us.app/";
options = " -l Zoom";
}
{ path = "/System/Applications/Messages.app/"; }
{ path = "/Applications/iTerm.app/"; }
{ path = "/Applications/Fantastical.app/"; }
{ path = "${pkgs.alacritty}/Applications/Alacritty.app/"; }
# { path = "/Applications/Spotify.app/"; }
{ path = "/Applications/Qobuz.app/"; }
{ path = "/System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app/"; }
{
path = "/Applications/Brave Browser.app/";
options = "-l Brave";
}
{ path = "/System/Applications/Photos.app/"; }
{ path = "/System/Applications/System Settings.app/"; }
{ path = "/Applications/Signal.app/"; }
{ path = "/Applications/WhatsApp.app/"; }
{ path = "/Applications/Ice\ Cubes.app/"; }
{
path = "/Applications/Jellyfin Media Player.app/";
options = "-l Jellyfin";
}
{ path = "/Applications/Visual Studio Code.app/"; }
{ path = "/Applications/Home Assistant.app/"; }
{ path = "/Applications/reMarkable.app/"; }
{ path = "/Applications/LibreOffice.app/"; }
{ path = "/Applications/Microsoft Word.app/"; }
{ path = "/Applications/Microsoft PowerPoint.app/"; }
{ path = "/Applications/Microsoft Teams.app/"; }
{ path = "/Applications/Monal.app/"; }
{ path = "/System/Applications/Utilities/Screen Sharing.app/"; }
{ path = "/run/current-system/Applications/Emacs.app/"; }
{ path = "/run/current-system/Applications/Zotero.app"; }
{
path = "/Applications/";
section = "others";
options = "--sort name --view grid --display stack";
}
{
path = toString myEmacsLauncher;
section = "others";
options = "-l EmacsLauncher";
}
{
path = "${config.users.users.${user}.home}/.local/share/";
section = "others";
options = "--sort name --view grid --display folder";
}
{
# path = "${config.users.users.${user}.home}/.local/share/downloads";
path = "${config.users.users.${user}.home}/Downloads/";
section = "others";
options = "--sort name --view grid --display stack";
}
];
};
};
}