this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'main' of github.com:ian-h-chamberlain/dotfiles

+1739 -338
+1 -1
.config/bat/config
··· 1 - # --theme="Monokai Extended" 1 + --theme="Monokai Extended" 2 2 3 3 # This is not supported on all terminal emulators (like tmux, by default) 4 4 # --italic-text="always"
+11
.config/cargo/config.toml
··· 13 13 # "./target:/app/target", 14 14 # "test-runner-3ds:latest", 15 15 # ] 16 + [alias] 17 + # would be nice to make this default even for `cargo check` fully spelled out: 18 + c = "check --all-targets" 19 + cl = "clippy --all-targets" 20 + rr = "run --release" 21 + i = "install --locked" 22 + 23 + w = "watch -w src,crates --command run --clear" 24 + 25 + # This works slightly better than cargo-alias, but also only works on nightly :( 26 + aliases = "-Zunstable-options config get alias"
+11 -6
.config/fish/completions/cargo.fish
··· 26 26 end 27 27 end 28 28 29 - # Check command works the same as b/build basically so we can reuse those completions 29 + # Check command works the same as b/build basically so we can reuse those completions. Fixed in 4.0 30 30 # https://github.com/fish-shell/fish-shell/pull/10499 31 31 for x in check c 32 32 complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bench -a "(cargo bench --bench 2>&1 | string replace -rf '^\s+' '')" ··· 47 47 complete -c cargo -n "__fish_seen_subcommand_from 3ds" -f -a "$__fish_cargo_subcommands" 48 48 49 49 # This might be easier with https://github.com/fish-shell/fish-shell/issues/7107 50 - # But for now we just sub in `check` for `clippy` and fallback to regular completions 51 - function __fish_cmdline_clippy_as_check 50 + function __fish_cmdline_replace_cmd -a orig_cmd new_cmd 52 51 set -l cmd 53 52 # Not sure exactly why this works, but sudo.fish completion also uses this pattern: 54 53 set -l toks (commandline -opc) (commandline -ct) 55 54 for tok in $toks 56 - if test "$tok" = clippy 57 - set tok check 55 + if test "$tok" = $orig_cmd 56 + set tok $new_cmd 58 57 end 59 58 set -a cmd $tok 60 59 end 61 60 string join -- " " $cmd 62 61 end 63 62 63 + 64 + # Aliases / clippy 65 + # Just sub in `check` for `clippy` and fallback to regular completions 64 66 complete -c cargo -n "__fish_seen_subcommand_from clippy" \ 65 - -a '(complete --do-complete (__fish_cmdline_clippy_as_check))' 67 + -a '(complete --do-complete (__fish_cmdline_replace_cmd clippy check))' 68 + 69 + complete -c cargo -n "__fish_seen_subcommand_from t" \ 70 + -a '(complete --do-complete (__fish_cmdline_replace_cmd t test))'
+2
.config/fish/completions/git.exe.fish
··· 1 + # Mainly for WSL things to work... I could probably do this more programmatically but meh 2 + complete -c git.exe --wraps git
+21 -6
.config/fish/conf.d/50-config.fish
··· 36 36 # Set jq to show null/true/false as magenta instead of black or otherwise 37 37 set -gx JQ_COLORS "1;35:1;35:1;35:0;39:0;32:1;39:1;39" 38 38 39 + # Most of the default fish theme colors are fine, but escape sequences are a little too close 40 + # to some other colors; this makes them more like my editor 41 + set -g fish_color_escape "#AE81FF" 42 + 39 43 # Use `bat` as pager if it present 40 44 if command -qs bat 41 45 set -gx PAGER bat ··· 48 52 set sed gsed 49 53 end 50 54 51 - # wewlad: https://github.com/sharkdp/bat/issues/652 52 - # Pending better support from bat, just strip all overstrike chars 53 - # and rely on the syntax highlighting instead of underscores/bold 54 - set -gx MANPAGER \ 55 - "sh -c \"$sed -E -e 's#(.)\x08\1#\1#g' -e 's#_\x08(.)#\1#g' | bat --plain --language=Manpage\"" 55 + if command -qs batman 56 + command batman --export-env | source 57 + else 58 + # wewlad: https://github.com/sharkdp/bat/issues/652 59 + # Pending better support from bat, just strip all overstrike chars 60 + # and rely on the syntax highlighting instead of underscores/bold 61 + set -gx MANPAGER \ 62 + "sh -c \"$sed -E -e 's#(.)\x08\1#\1#g' -e 's#_\x08(.)#\1#g' | bat --plain --language=Manpage\"" 63 + end 56 64 end 57 65 58 66 # https://stackoverflow.com/a/39352670 ··· 81 89 $DEVKITARM/bin \ 82 90 $DEVKITPRO/tools/bin \ 83 91 ~/.cargo/bin \ 92 + ~/.config/cargo/bin \ 84 93 ~/.local/share/rbenv/shims \ 85 94 ~/.local/bin \ 86 95 $GOPATH/bin \ ··· 108 117 # Any explicit nix store paths should remain at the front, most likely 109 118 # introduced by e.g. `nix shell` or `nix develop` 110 119 if string match --quiet -- '/nix/store/*' "$pth" 111 - fish_add_path --global --prepend --move "$pth" 120 + fish_add_path --global --prepend --move --path "$pth" 112 121 end 122 + end 123 + 124 + # interactiveShellInit seems to be usable as its own sourceable file to do this 125 + # automatically in some later nixpkgs but for now just gonna add this manually 126 + if not contains /etc/fish/generated_completions -- $fish_complete_path 127 + set -a fish_complete_path /etc/fish/generated_completions 113 128 end 114 129 115 130 # https://github.com/nix-community/home-manager/issues/5602
-1
.config/fish/conf.d/51-envs.fish
··· 6 6 7 7 set -Ux PYENV_VIRTUALENV_DISABLE_PROMPT 1 8 8 9 - 10 9 if status is-interactive 11 10 # TODO: rtx activation can be inlined here, and replace pyenv/rbenv ideally 12 11 if command -qs rtx
+1 -1
.config/fish/conf.d/55-events.fish
··· 2 2 3 3 function __set_color_theme --on-event fish_preexec 4 4 # On macOS, this can change dynamically, so re-evaluate every time 5 - if test $YADM_OS = Darwin 5 + if test "$YADM_OS" = Darwin 6 6 if test "$(defaults read -g AppleInterfaceStyle 2>/dev/null)" != Dark 7 7 set -gx COLOR_THEME light 8 8 else
+9
.config/fish/functions/find_completions.fish
··· 1 + function find_completions 2 + for pth in $fish_complete_path 3 + set -l possible_completion "$pth/$argv[1].fish" 4 + if test -f $possible_completion 5 + echo $possible_completion 6 + break 7 + end 8 + end 9 + end
+31 -6
.config/fish/functions/fish_prompt.fish
··· 45 45 set __fish_prompt_nix "$white""($nix_icon nix) $__fish_prompt_normal" 46 46 end 47 47 48 + set -l __fish_prompt_direnv "" 49 + if set -q DIRENV_USED 50 + set -l direnv_dir (basename "$DIRENV_USED") 51 + if string match -q "flake:*" -- "$DIRENV_USED" 52 + set direnv_dir "$nix_icon $direnv_dir" 53 + set __fish_prompt_nix "" 54 + else 55 + set direnv_dir " $direnv_dir" 56 + end 57 + set -l direnv_dir (string shorten --max 15 -- "$direnv_dir") 58 + set __fish_prompt_direnv "$white""($direnv_dir) $__fish_prompt_normal" 59 + end 60 + 48 61 set -l prompt_hostname (prompt_hostname) 49 62 # Color hostname magenta if we're in a container, otherwise just use it as-is 50 63 if test -f /run/.containerenv # podman ··· 54 67 55 68 set -l prompt_os (uname) 56 69 if test "$YADM_DISTRO" = nixos 57 - set prompt_os "$nix_icon " 70 + set prompt_os "$nix_icon" 58 71 else if test $prompt_os = Darwin 59 - set prompt_os " " 60 - else if test $prompt_os = Linux # Maybe could special-case nixos here? 61 - set prompt_os " " 72 + set prompt_os "" 73 + else if test $prompt_os = Linux 74 + set prompt_os "" 62 75 else 63 76 set prompt_os "" 64 77 end 78 + if test "$YADM_OS" = WSL 79 + set prompt_os "$prompt_os  " 80 + end 65 81 66 82 set prompt_os "$white$prompt_os$__fish_prompt_normal" 67 83 68 84 set first_line ( 69 - echo -n -s "$prompt_os" "$__fish_prompt_pyenv" "$__fish_prompt_nix" \ 85 + echo -n -s "$prompt_os" \ 86 + "$__fish_prompt_pyenv" "$__fish_prompt_nix" "$__fish_prompt_direnv" \ 70 87 '[' "$USER" '@' "$prompt_hostname" ']' \ 71 88 ' ' "$__fish_prompt_cwd" (prompt_pwd) 72 89 ) ··· 101 118 102 119 set -g __fish_git_prompt_shorten_branch_len $remaining_char_count 103 120 104 - set -l vcs_prompt (__fish_vcs_prompt) 121 + 122 + set -l vcs_prompt 123 + if test "$YADM_OS" = WSL; and string match -q --regex '^/mnt/[a-z]/' $PWD 124 + if git rev-parse --show-toplevel &>/dev/null 125 + set vcs_prompt (set_color bryellow)" (-WSL-)"(set_color normal) 126 + end 127 + else 128 + set vcs_prompt (__fish_vcs_prompt) 129 + end 105 130 if string length -q -- $vcs_prompt 106 131 set first_line "$first_line""$vcs_prompt" 107 132 end
+11
.config/fish/functions/fork.fish
··· 1 + function fork 2 + if test "$YADM_OS" = WSL 3 + set -l args 4 + for arg in $argv 5 + set -a args (wslpath -w -- $arg) 6 + end 7 + command fork.exe $args 8 + else 9 + command fork $argv 10 + end 11 + end
+16 -4
.config/fish/functions/upfind.fish
··· 1 1 function upfind --description 'Finds a file with the given name, upwards' 2 + set -l usage "Usage: 3 + upfind [-a|--all] [-d DIR|--from=DIR] FILE" 4 + 5 + argparse --min-args=1 a/all d/from= -- $argv 6 + or begin 7 + echo $usage 8 + return 9 + end 10 + 2 11 set dir $PWD 3 - if set -q argv[2] 4 - set dir $argv[2] 12 + if set -q _flag_from 13 + set dir $_flag_from 5 14 end 6 15 7 16 test (builtin realpath --no-symlinks $dir) != / ··· 9 18 10 19 if test -e $dir/$argv[1] 11 20 builtin realpath --no-symlinks $dir/$argv[1] 12 - else 13 - upfind $argv[1] $dir/.. 21 + if not set -ql _flag_all 22 + return 23 + end 14 24 end 25 + 26 + upfind $argv[1] --from=$dir/.. 15 27 end
+3
.config/flake.code-workspace
··· 22 22 "path": "nixpkgs" 23 23 }, 24 24 { 25 + "path": "nvim" 26 + }, 27 + { 25 28 "path": "yadm/forkgit" 26 29 }, 27 30 {
+124 -29
.config/flake.lock
··· 38 38 "systems": "systems" 39 39 }, 40 40 "locked": { 41 + "lastModified": 1731533236, 42 + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", 43 + "owner": "numtide", 44 + "repo": "flake-utils", 45 + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", 46 + "type": "github" 47 + }, 48 + "original": { 49 + "owner": "numtide", 50 + "repo": "flake-utils", 51 + "type": "github" 52 + } 53 + }, 54 + "flake-utils_2": { 55 + "inputs": { 56 + "systems": "systems_2" 57 + }, 58 + "locked": { 41 59 "lastModified": 1710146030, 42 60 "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", 43 61 "owner": "numtide", ··· 51 69 "type": "github" 52 70 } 53 71 }, 54 - "flake-utils_2": { 72 + "flake-utils_3": { 55 73 "inputs": { 56 - "systems": "systems_2" 74 + "systems": "systems_3" 57 75 }, 58 76 "locked": { 59 77 "lastModified": 1726560853, ··· 69 87 "type": "github" 70 88 } 71 89 }, 90 + "flakey-profile": { 91 + "locked": { 92 + "lastModified": 1712898590, 93 + "narHash": "sha256-FhGIEU93VHAChKEXx905TSiPZKga69bWl1VB37FK//I=", 94 + "owner": "lf-", 95 + "repo": "flakey-profile", 96 + "rev": "243c903fd8eadc0f63d205665a92d4df91d42d9d", 97 + "type": "github" 98 + }, 99 + "original": { 100 + "owner": "lf-", 101 + "repo": "flakey-profile", 102 + "type": "github" 103 + } 104 + }, 72 105 "home-manager": { 73 106 "inputs": { 74 107 "nixpkgs": [ ··· 88 121 "ref": "feature/fish-session-vars-pkg", 89 122 "repo": "home-manager", 90 123 "type": "github" 124 + } 125 + }, 126 + "lix": { 127 + "flake": false, 128 + "locked": { 129 + "lastModified": 1738174211, 130 + "narHash": "sha256-eYmp1mKM4kULV1W+EBtCPk6LmKWl2REivaYfGRl+AWo=", 131 + "ref": "main", 132 + "rev": "64e33a7e09a0d1faacf2fd3f6ebd647fe4d8346a", 133 + "revCount": 17329, 134 + "type": "git", 135 + "url": "https://git.lix.systems/lix-project/lix.git" 136 + }, 137 + "original": { 138 + "ref": "main", 139 + "type": "git", 140 + "url": "https://git.lix.systems/lix-project/lix.git" 141 + } 142 + }, 143 + "lix-module": { 144 + "inputs": { 145 + "flake-utils": "flake-utils", 146 + "flakey-profile": "flakey-profile", 147 + "lix": [ 148 + "lix" 149 + ], 150 + "nixpkgs": [ 151 + "nixos-unstable" 152 + ] 153 + }, 154 + "locked": { 155 + "lastModified": 1738176840, 156 + "narHash": "sha256-NG3IRvRs3u3btVCN861FqHvgOwqcNT/Oy6PBG86F5/E=", 157 + "rev": "621aae0f3cceaffa6d73a4fb0f89c08d338d729e", 158 + "type": "tarball", 159 + "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/621aae0f3cceaffa6d73a4fb0f89c08d338d729e.tar.gz?rev=621aae0f3cceaffa6d73a4fb0f89c08d338d729e" 160 + }, 161 + "original": { 162 + "type": "tarball", 163 + "url": "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz" 91 164 } 92 165 }, 93 166 "nix-darwin": { ··· 97 170 ] 98 171 }, 99 172 "locked": { 100 - "lastModified": 1720845312, 101 - "narHash": "sha256-yPhAsJTpyoIPQZJGC8Fw8W2lAXyhLoTn+HP20bmfkfk=", 173 + "lastModified": 1738033138, 174 + "narHash": "sha256-qlIM8A3bdL9c6PexhpS+QyZLO9y/8a3V75HVyJgDE5Q=", 102 175 "owner": "LnL7", 103 176 "repo": "nix-darwin", 104 - "rev": "5ce8503cf402cf76b203eba4b7e402bea8e44abc", 177 + "rev": "349a74c66c596ef97ee97b4d80a3ca61227b6120", 105 178 "type": "github" 106 179 }, 107 180 "original": { 108 - "id": "nix-darwin", 109 - "type": "indirect" 181 + "owner": "LnL7", 182 + "repo": "nix-darwin", 183 + "type": "github" 110 184 } 111 185 }, 112 186 "nix-homebrew": { 113 187 "inputs": { 114 188 "brew-src": "brew-src", 115 - "flake-utils": "flake-utils", 189 + "flake-utils": "flake-utils_2", 116 190 "nix-darwin": [ 117 191 "nix-darwin" 118 192 ], ··· 136 210 }, 137 211 "nixos-unstable": { 138 212 "locked": { 139 - "lastModified": 1720768451, 140 - "narHash": "sha256-EYekUHJE2gxeo2pM/zM9Wlqw1Uw2XTJXOSAO79ksc4Y=", 213 + "lastModified": 1739736696, 214 + "narHash": "sha256-zON2GNBkzsIyALlOCFiEBcIjI4w38GYOb+P+R4S8Jsw=", 141 215 "owner": "NixOS", 142 216 "repo": "nixpkgs", 143 - "rev": "7e7c39ea35c5cdd002cd4588b03a3fb9ece6fad9", 217 + "rev": "d74a2335ac9c133d6bbec9fc98d91a77f1604c1f", 144 218 "type": "github" 145 219 }, 146 220 "original": { 147 - "id": "nixpkgs", 221 + "owner": "NixOS", 148 222 "ref": "nixos-unstable", 149 - "type": "indirect" 223 + "repo": "nixpkgs", 224 + "type": "github" 150 225 } 151 226 }, 152 227 "nixos-wsl": { 153 228 "inputs": { 154 229 "flake-compat": "flake-compat", 155 - "flake-utils": "flake-utils_2", 230 + "flake-utils": "flake-utils_3", 156 231 "nixpkgs": "nixpkgs" 157 232 }, 158 233 "locked": { ··· 188 263 }, 189 264 "nixpkgs-darwin": { 190 265 "locked": { 191 - "lastModified": 1720881915, 192 - "narHash": "sha256-uC/eDBJqbxuQzh0pYgbCtoCMjnKUFbJYkixeVDir5J8=", 266 + "lastModified": 1735564410, 267 + "narHash": "sha256-HB/FA0+1gpSs8+/boEavrGJH+Eq08/R2wWNph1sM1Dg=", 193 268 "owner": "NixOS", 194 269 "repo": "nixpkgs", 195 - "rev": "68c6b3ca5da36c8c579376099691f3fe51a0070c", 270 + "rev": "1e7a8f391f1a490460760065fa0630b5520f9cf8", 196 271 "type": "github" 197 272 }, 198 273 "original": { 199 - "id": "nixpkgs", 274 + "owner": "NixOS", 200 275 "ref": "nixpkgs-24.05-darwin", 201 - "type": "indirect" 276 + "repo": "nixpkgs", 277 + "type": "github" 202 278 } 203 279 }, 204 280 "nixpkgs-unstable": { 205 281 "locked": { 206 - "lastModified": 1725534445, 207 - "narHash": "sha256-Yd0FK9SkWy+ZPuNqUgmVPXokxDgMJoGuNpMEtkfcf84=", 282 + "lastModified": 1738136902, 283 + "narHash": "sha256-pUvLijVGARw4u793APze3j6mU1Zwdtz7hGkGGkD87qw=", 208 284 "owner": "NixOS", 209 285 "repo": "nixpkgs", 210 - "rev": "9bb1e7571aadf31ddb4af77fc64b2d59580f9a39", 286 + "rev": "9a5db3142ce450045840cc8d832b13b8a2018e0c", 211 287 "type": "github" 212 288 }, 213 289 "original": { 214 - "id": "nixpkgs", 290 + "owner": "NixOS", 215 291 "ref": "nixpkgs-unstable", 216 - "type": "indirect" 292 + "repo": "nixpkgs", 293 + "type": "github" 217 294 } 218 295 }, 219 296 "nixpkgs_2": { 220 297 "locked": { 221 - "lastModified": 1720691131, 222 - "narHash": "sha256-CWT+KN8aTPyMIx8P303gsVxUnkinIz0a/Cmasz1jyIM=", 298 + "lastModified": 1735563628, 299 + "narHash": "sha256-OnSAY7XDSx7CtDoqNh8jwVwh4xNL/2HaJxGjryLWzX8=", 223 300 "owner": "NixOS", 224 301 "repo": "nixpkgs", 225 - "rev": "a046c1202e11b62cbede5385ba64908feb7bfac4", 302 + "rev": "b134951a4c9f3c995fd7be05f3243f8ecd65d798", 226 303 "type": "github" 227 304 }, 228 305 "original": { 229 - "id": "nixpkgs", 306 + "owner": "NixOS", 230 307 "ref": "nixos-24.05", 231 - "type": "indirect" 308 + "repo": "nixpkgs", 309 + "type": "github" 232 310 } 233 311 }, 234 312 "root": { 235 313 "inputs": { 236 314 "home-manager": "home-manager", 315 + "lix": "lix", 316 + "lix-module": "lix-module", 237 317 "nix-darwin": "nix-darwin", 238 318 "nix-homebrew": "nix-homebrew", 239 319 "nixos-unstable": "nixos-unstable", ··· 259 339 } 260 340 }, 261 341 "systems_2": { 342 + "locked": { 343 + "lastModified": 1681028828, 344 + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 345 + "owner": "nix-systems", 346 + "repo": "default", 347 + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 348 + "type": "github" 349 + }, 350 + "original": { 351 + "owner": "nix-systems", 352 + "repo": "default", 353 + "type": "github" 354 + } 355 + }, 356 + "systems_3": { 262 357 "locked": { 263 358 "lastModified": 1681028828, 264 359 "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+123 -85
.config/flake.nix
··· 13 13 14 14 inputs = { 15 15 # Gah there's so many of these!!! 16 - nixpkgs.url = "flake:nixpkgs/nixos-24.05"; 17 - nixos-unstable.url = "flake:nixpkgs/nixos-unstable"; 16 + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; 17 + nixos-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; 18 18 19 - nixpkgs-darwin.url = "flake:nixpkgs/nixpkgs-24.05-darwin"; 20 - nixpkgs-unstable.url = "flake:nixpkgs/nixpkgs-unstable"; 19 + nixpkgs-darwin.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin"; 20 + nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 21 21 22 22 nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; 23 23 24 24 nix-darwin = { 25 - url = "flake:nix-darwin"; 25 + url = "github:LnL7/nix-darwin"; 26 26 inputs.nixpkgs.follows = "nixpkgs-darwin"; 27 27 }; 28 28 home-manager = { ··· 36 36 inputs.nixpkgs.follows = "nixpkgs-darwin"; 37 37 inputs.nix-darwin.follows = "nix-darwin"; 38 38 }; 39 + 40 + lix = { 41 + url = "git+https://git.lix.systems/lix-project/lix.git?ref=main"; 42 + flake = false; 43 + }; 44 + lix-module = { 45 + url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz"; 46 + inputs.nixpkgs.follows = "nixos-unstable"; 47 + inputs.lix.follows = "lix"; 48 + }; 39 49 }; 40 50 41 - outputs = inputs @ { self, nixpkgs, nix-darwin, home-manager, nix-homebrew, ... }: 51 + outputs = 52 + inputs@{ 53 + self, 54 + nixpkgs, 55 + nix-darwin, 56 + home-manager, 57 + nix-homebrew, 58 + ... 59 + }: 42 60 let 43 61 inherit (builtins) mapAttrs; 44 62 inherit (nixpkgs) lib; 45 63 46 64 # TODO: maybe use https://github.com/numtide/flake-utils to help abstract 47 65 # the per-system logic stuff... 48 - systems = { 66 + hosts = { 49 67 MacBook-Pro = { 50 68 system = "aarch64-darwin"; 51 69 user = "ianchamberlain"; ··· 92 110 }; 93 111 94 112 isDarwin = system: lib.hasSuffix "darwin" system; 95 - darwinSystems = lib.filterAttrs (_: { system, ... }: isDarwin system) systems; 113 + darwinSystems = lib.filterAttrs (_: { system, ... }: isDarwin system) hosts; 96 114 97 - nixosSystems = lib.filterAttrs (_: { nixos ? false, ... }: nixos) systems; 115 + isNixOS = host: host.nixos or false; 116 + nixosSystems = lib.filterAttrs (_: isNixOS) hosts; 98 117 99 - systemPkgs = system: 100 - if isDarwin system then 101 - inputs.nixpkgs-darwin.legacyPackages.${system} 118 + systemPkgsFor = 119 + host: 120 + if isDarwin host.system then 121 + inputs.nixpkgs-darwin.legacyPackages.${host.system} 102 122 else 103 - inputs.nixpkgs.legacyPackages.${system}; 123 + inputs.nixpkgs.legacyPackages.${host.system}; 104 124 105 - specialArgsFor = hostname: { 106 - inherit self; 107 - host = systems.${hostname} // { name = hostname; }; 108 - unstable = inputs.nixpkgs-unstable.legacyPackages.${systems.${hostname}.system}; 109 - }; 125 + unstablePkgsFor = 126 + host: 127 + if isNixOS host then 128 + inputs.nixos-unstable.legacyPackages.${host.system} 129 + else 130 + inputs.nixpkgs-unstable.legacyPackages.${host.system}; 131 + 132 + specialArgsFor = 133 + hostname: 134 + let 135 + # Since nixpkgs.pkgs is using 24.05, the nixosModule from lix-module is 136 + # unusable (depends on newer things), so we just manually apply this overlay on unstable: 137 + unstable = (unstablePkgsFor hosts.${hostname}).extend inputs.lix-module.overlays.default; 138 + 139 + in 140 + { 141 + inherit self unstable; 142 + host = hosts.${hostname} // { 143 + name = hostname; 144 + }; 145 + }; 110 146 in 111 147 { 112 148 lib = import ./nix/lib.nix (inputs // { inherit lib; }); 113 149 114 - darwinConfigurations = mapAttrs 115 - (hostname: { system, user, ... }: nix-darwin.lib.darwinSystem { 150 + darwinConfigurations = mapAttrs ( 151 + hostname: 152 + { system, user, ... }: 153 + nix-darwin.lib.darwinSystem { 116 154 inherit system; 117 155 specialArgs = specialArgsFor hostname; 118 156 ··· 141 179 } 142 180 ./nixpkgs/flake-overlays.nix 143 181 ]; 144 - }) 145 - darwinSystems; 182 + } 183 + ) darwinSystems; 146 184 147 - nixosConfigurations = mapAttrs 148 - (hostname: { system, user, wsl ? false, ... }: nixpkgs.lib.nixosSystem { 185 + nixosConfigurations = mapAttrs ( 186 + hostname: 187 + { 188 + system, 189 + user, 190 + wsl ? false, 191 + ... 192 + }: 193 + nixpkgs.lib.nixosSystem { 149 194 inherit system; 150 - specialArgs = specialArgsFor hostname; 195 + specialArgs = { 196 + inherit (inputs) lix-module; 197 + } // specialArgsFor hostname; 151 198 152 199 modules = [ 200 + # Disabled for now: https://git.lix.systems/lix-project/lix/issues/652 201 + # inputs.lix-module.nixosModules.default 153 202 inputs.nixos-wsl.nixosModules.default 154 - { 155 - wsl = nixpkgs.lib.mkIf wsl { 156 - enable = true; 157 - defaultUser = user; 158 - wslConf.network.hostname = hostname; 159 - }; 160 - } 161 - ./nixos/configuration.nix 162 203 home-manager.nixosModules.home-manager 163 204 { 164 205 home-manager = { ··· 168 209 extraSpecialArgs = specialArgsFor hostname; 169 210 }; 170 211 } 212 + ./nixos/configuration.nix 213 + ./nixpkgs/flake-overlays.nix 171 214 ]; 172 - }) 173 - nixosSystems; 215 + } 216 + ) nixosSystems; 174 217 175 - homeConfigurations = lib.mapAttrs' 176 - (hostname: { system, user, ... }: lib.nameValuePair 177 - "${user}@${hostname}" 178 - (if isDarwin system then 179 - # Expose the home configuration built by darwinModules.home-manager: 180 - let homeCfg = self.darwinConfigurations.${hostname}.config.home-manager.users.${user}; 181 - in { 218 + homeConfigurations = lib.mapAttrs' ( 219 + hostname: 220 + { system, user, ... }: 221 + lib.nameValuePair "${user}@${hostname}" ( 222 + if isDarwin system then 223 + # Expose the home configuration built by darwinModules.home-manager: 224 + let 225 + homeCfg = self.darwinConfigurations.${hostname}.config.home-manager.users.${user}; 226 + in 227 + { 182 228 inherit (homeCfg.home) activationPackage; 183 229 config = homeCfg; 184 230 } ··· 188 234 extraSpecialArgs = specialArgsFor hostname; 189 235 modules = [ 190 236 ./home-manager/home.nix 191 - ({ pkgs, ... }: { 192 - nix.package = inputs.nixpkgs-unstable.lix; 193 - }) 237 + { 238 + # nixos and darwin get this from the host configuration 239 + nix.package = inputs.unstable.lix; 240 + } 194 241 ./nixpkgs/flake-overlays.nix 195 242 ]; 196 - })) 197 - systems; 243 + } 244 + ) 245 + ) hosts; 198 246 199 247 darwinOptions = 200 248 let ··· 213 261 let 214 262 config = home-manager.lib.homeManagerConfiguration { 215 263 pkgs = inputs.nixpkgs-darwin.legacyPackages.aarch64-darwin; 216 - modules = [{ 217 - home.username = "dummy"; 218 - home.homeDirectory = /home/dummy; 219 - home.stateVersion = "20.09"; # TODO reference self 220 - }]; 264 + modules = [ 265 + { 266 + home.username = "dummy"; 267 + home.homeDirectory = /home/dummy; 268 + home.stateVersion = "20.09"; # TODO reference self 269 + } 270 + ]; 221 271 }; 222 272 in 223 273 config.options; 224 274 225 275 # Used for bootstrapping 226 - devShells = lib.mapAttrs' 227 - (_: { system, ... }: 228 - let pkgs = systemPkgs system; 229 - in lib.nameValuePair 230 - system 231 - { 232 - default = pkgs.mkShell { 233 - packages = with pkgs; [ 234 - cacert 235 - git 236 - git-crypt 237 - git-lfs 238 - gnupg 239 - yadm 240 - ]; 241 - }; 242 - } 243 - ) 244 - systems; 245 - 246 - 247 - packages = lib.mapAttrs' 248 - (_: { system, ... }: 276 + devShells = lib.mapAttrs' ( 277 + _: host: 278 + let 279 + pkgs = systemPkgsFor host; 280 + in 281 + lib.nameValuePair host.system { 282 + default = pkgs.mkShell { 283 + packages = with pkgs; [ 284 + cacert 285 + git 286 + git-crypt 287 + git-lfs 288 + gnupg 289 + yadm 290 + ]; 291 + }; 292 + } 293 + ) hosts; 249 294 250 - let pkgs = inputs.nixpkgs-unstable.legacyPackages.${system}; 251 - in lib.nameValuePair system 252 - { 253 - nix-extern-cmd = 254 - pkgs.callPackage ./nixpkgs/packages/nix-extern-cmd { 255 - nix = pkgs.lix; 256 - }; 257 - } 258 - ) 259 - systems; 295 + formatter = lib.mapAttrs' ( 296 + _: host: lib.nameValuePair host.system (unstablePkgsFor host).nixfmt-rfc-style 297 + ) hosts; 260 298 }; 261 299 }
+20
.config/gh/config.yml
··· 1 + # The current version of the config schema 2 + version: 1 3 + # What protocol to use when performing git operations. Supported values: ssh, https 4 + git_protocol: https 5 + # What editor gh should run when creating issues, pull requests, etc. If blank, will refer to environment. 6 + editor: 7 + # When to interactively prompt. This is a global config that cannot be overridden by hostname. Supported values: enabled, disabled 8 + prompt: enabled 9 + # Preference for editor-based interactive prompting. This is a global config that cannot be overridden by hostname. Supported values: enabled, disabled 10 + prefer_editor_prompt: disabled 11 + # A pager program to send command output to, e.g. "less". If blank, will refer to environment. Set the value to "cat" to disable the pager. 12 + pager: 13 + # Aliases allow you to create nicknames for gh commands 14 + aliases: 15 + co: pr checkout 16 + cpr: pr create --web --assignee @me 17 + # The path to a unix socket through which send HTTP connections. If blank, HTTP traffic will be handled by net/http.DefaultTransport. 18 + http_unix_socket: 19 + # What web browser gh should use when opening URLs. If blank, will refer to environment. 20 + browser:
+22 -11
.config/git/config
··· 1 1 [alias] 2 2 co = checkout 3 - br = branch 4 3 ci = commit 5 4 st = status 6 5 unstage = reset HEAD -- ··· 11 10 hardreset = reset --hard @{u} 12 11 fpush = push --force-with-lease 13 12 ld = log --pretty=format:\"%C(yellow)%h\\ %ad%C(red)%d\\ %C(reset)%s%C(blue)\\ [%cn]\" --decorate --date=relative 14 - lg = !sh -c 'git log --reverse --no-merges --pretty=format:\"%C(yellow)%h %C(reset)%s\" --decorate \"$1\"..HEAD' - 13 + lg = !bash -c 'git log --reverse --no-merges --pretty=format:\"%C(yellow)%h %C(reset)%s\" --decorate \"${1:-$(git default-branch)}\"..HEAD' - 15 14 sw = switch 16 15 softreset = reset --soft HEAD~ 17 16 default-branch = !git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@' 18 - branch-clean = !git branch --merged origin/\"$(git default-branch)\" | egrep -v \"[*+]|$(git default-branch)\\$\" | xargs -n 1 git branch --delete 17 + clean-branches = !git branch --merged origin/\"$(git default-branch)\" | egrep -v \"[*+]|$(git default-branch)\\$\" | xargs -n 1 git branch --delete 18 + clean-gone = !git branch --format '%(refname:short) %(upstream:track)' | awk '$2 == \"[gone]\" { print $1 }' | xargs -n 1 git branch -D 19 19 alias = "!sh -c '[ $# = 2 ] && git config --global alias.\"$1\" \"$2\" && exit 0 || echo \"usage: git alias <new alias> <original command>\" >&2 && exit 1' -" 20 20 aliases = "!echo [alias]; git config --get-regexp 'alias[.].*' | sed -E 's/alias[.]([^[:space:]]+)/\t\\1 =/'" 21 21 bc = branch-clean 22 22 bpull = !sh -c 'git fetch origin $1:$1' - 23 23 vdiff = difftool -d HEAD 24 24 conflicts = !sh -c 'git diff --name-only --diff-filter=U --line-prefix="$(git rev-parse --show-toplevel)/"' 25 - local-branch = "!git branch --format '%(refname:short) %(upstream:trackshort)' | awk '{if (!$2 || $2 == \"[gone]\") print $1;}'" 26 - local-branch-clean = "!for b in $(git local-branch); do echo \"$b\"; git ld --color=always \"$b\" \"^$(git default-branch)\" | sed \"s/^/ /\"; printf \"\\x1b[B\\x1b[m\\n\"; read -r -p \"Delete branch? [y/N]: \"; if [[ \"$REPLY\" =~ ^[Yy]$ ]]; then git branch -D \"$b\"; fi; done #" 27 25 # Helpers for quoting/unquoting git aliases, from https://stackoverflow.com/questions/38057261/git-config-alias-escaping 28 26 quote-string = "!read -r l; printf \\\"!; printf %s \"$l\" | sed 's/\\([\\\"]\\)/\\\\\\1/g'; printf \" #\\\"\\n\" #" 29 27 quote-string-undo = "!read -r l; printf %s \"$l\" | sed 's/\\\\\\([\\\"]\\)/\\1/g'; printf \"\\n\" #" ··· 35 33 sswitch = !sh -c 'git stash && git switch \"$@\" && git stash pop' - 36 34 ssw = sswitch 37 35 su = submodule update 38 - copy = !fish -c \"git diff $argv | fish_clipboard_copy\" - 39 - paste = !fish -c \"fish_clipboard_paste | git apply\" 36 + copy = !fish -c \"git diff --unified=3 $argv | fish_clipboard_copy\" -- 37 + paste = !fish -c \"fish_clipboard_paste | git apply $argv\" -- 40 38 ls = ls-files 39 + [tag] 40 + sort = version:refname 41 41 [core] 42 42 # editor unset, rely on $EDITOR to be set to my preference 43 43 quotePath = true 44 44 protectNTFS = false 45 - longpaths = true 46 - autocrlf = input 47 - symlinks = true 45 + longpaths = true 46 + # autocrlf = input # TODO: double check this in windows/wsl/etc 47 + symlinks = true 48 + [column] 49 + ui = auto 48 50 [diff] 49 51 tool = code 50 52 context = 5 53 + algorithm = histogram 54 + colorMoved = plain 55 + # May not necessarily want to keep this one: 56 + mnemonicPrefix = true 57 + renames = true 51 58 [difftool] 52 59 trustExitCode = true 53 60 prompt = false ··· 69 76 rebase = false 70 77 [commit] 71 78 gpgsign = true 79 + verbose = true 72 80 [gpg] 73 81 program = gpg 74 82 [checkout] ··· 83 91 editor = code 84 92 [advice] 85 93 detachedHead = false 86 - 94 + [help] 95 + autocorrect = prompt 87 96 [rerere] 88 97 enabled = true 98 + autoupdate = true 89 99 [rebase] 90 100 autoSquash = true 91 101 autoStash = true 102 + updateRefs = true 92 103 [filter "lfs"] 93 104 required = true 94 105 # Don't configure process filter, my wrapper doesn't work with it
+4
.config/git/ignore
··· 51 51 Network Trash Folder 52 52 Temporary Items 53 53 .apdisk 54 + 55 + # direnv 56 + .envrc 57 + .direnv
+35
.config/home-manager/direnv/default.nix
··· 1 + { config, unstable, ... }: 2 + { 3 + programs.direnv = { 4 + enable = true; 5 + nix-direnv = { 6 + enable = true; 7 + package = unstable.nix-direnv.override { 8 + nix = config.nix.package; 9 + }; 10 + }; 11 + 12 + config = { 13 + global = { 14 + strict_env = true; 15 + hide_env_diff = true; 16 + # https://github.com/direnv/direnv/wiki/Quiet-or-Silence-direnv 17 + # RIP, this was only implemented very recently and hasn't been released yet 18 + # https://github.com/direnv/direnv/pull/1336 19 + log_format = "\u001B[2mdirenv: %s\u001B[30m"; 20 + }; 21 + }; 22 + 23 + # See ./direnv-hook.fish 24 + enableFishIntegration = true; 25 + stdlib = builtins.readFile ./direnvrc; 26 + }; 27 + 28 + xdg.configFile = { 29 + # backwards compat with older direnv 30 + "direnv/config.toml".source = config.xdg.configFile."direnv/direnv.toml".source; 31 + 32 + # TODO: 33 + # "fish/conf.d/52-direnv.fish".source = ./direnv-hook.fish; 34 + }; 35 + }
+25
.config/home-manager/direnv/direnvrc
··· 1 + 2 + # Override use_flake to inject a helper variable for prompts 3 + # https://stackoverflow.com/a/1369211/14436105 4 + eval "$(echo "orig_use_flake()"; declare -f use_flake | tail -n +2)" 5 + function use_flake() { 6 + export DIRENV_USED="flake:''${1:-$(basename "$PWD")}" 7 + orig_use_flake "$@"; 8 + } 9 + 10 + # Convenience variable for generic prompt awareness 11 + export DIRENV_USED="direnv" 12 + 13 + 14 + # Helper to load extra flakes or nixpkgs into the environment (as if by `nix shell`). 15 + use_pkgs() { 16 + pkgs=() 17 + for pkg in "$@"; do 18 + if [[ "$pkg" = *#* || "$pkg" = *:* ]]; then 19 + pkgs+=("$pkg") 20 + else 21 + pkgs+=("nixpkgs#$pkg") 22 + fi 23 + done 24 + direnv_load nix shell "${pkgs[@]}" --command "$direnv" dump 25 + }
+157 -71
.config/home-manager/home.nix
··· 2 2 , config 3 3 , lib 4 4 , pkgs 5 - , unstable ? import <nixos-unstable> { } # backwards compat for non-flake 6 - , homeDirectory ? "/home/${config.home.user}" 5 + , unstable ? import <nixos-unstable> { } 6 + , # backwards compat for non-flake 7 + homeDirectory ? "/home/${config.home.user}" 8 + , host 7 9 , ... 8 10 }: 9 11 let ··· 12 14 13 15 nix-homebrew = (self.inputs or { }).nix-homebrew or null; 14 16 user = config.home.user or "ianchamberlain"; 17 + 18 + # ugh this will be different between nixos and others won't it 19 + 20 + packpathDirs = config.programs.neovim.finalPackage.packpathDirs; 21 + finalPackdir = (unstable.neovimUtils.packDir packpathDirs); 22 + packdirPackage = 23 + pkgs.runCommand "pack" { } # bash 24 + '' 25 + mkdir -p $out/opt/nvim/ 26 + ${lib.getExe pkgs.xorg.lndir} -silent ${finalPackdir} $out/opt/nvim/ 27 + ''; 15 28 in 16 29 { 17 - imports = [ 30 + imports = self.lib.existingPaths [ 18 31 ./macos-defaults.nix 19 32 ./default-apps.nix 33 + ./direnv 34 + # This is kinda janky but I guess it works... 35 + # https://github.com/nix-community/home-manager/issues/1906 36 + ./${if host.wsl then "" else "non-"}wsl.nix 37 + ./${host.class} 20 38 # ./firefox.nix # TODO 21 39 ]; 22 40 ··· 57 75 programs = { 58 76 # Let Home Manager install and manage itself. 59 77 home-manager.enable = true; 60 - 61 - bat.enable = true; 78 + bat = { 79 + enable = true; 80 + # Not working for whatever reason: 81 + extraPackages = with unstable.bat-extras; [ 82 + batdiff 83 + batman 84 + batgrep 85 + batwatch 86 + ]; 87 + }; 62 88 fd.enable = true; 63 89 fish.enable = true; 64 90 git.enable = true; 65 91 gpg.enable = true; 92 + helix = { 93 + enable = true; 94 + package = unstable.helix; 95 + settings = { 96 + theme = "monokai"; 97 + }; 98 + }; 66 99 htop.enable = true; 67 100 neovim = { 68 101 enable = true; 69 102 # https://github.com/NixOS/nixpkgs/issues/137829 70 103 package = unstable.neovim-unwrapped; 104 + 71 105 plugins = [ 72 - (unstable.vimPlugins.nvim-treesitter.withPlugins (p: with p; [ 73 - bash 74 - javascript 75 - nix 76 - python 77 - vimdoc 78 - xml 79 - ])) 106 + (unstable.vimPlugins.nvim-treesitter.withPlugins ( 107 + # Include default bundled languages as well here: 108 + # https://github.com/nvim-treesitter/nvim-treesitter/issues/3092 109 + plugins: with plugins; [ 110 + bash 111 + c 112 + comment 113 + cpp 114 + css 115 + csv 116 + diff 117 + dockerfile 118 + fish 119 + go 120 + html 121 + javascript 122 + json 123 + lua 124 + markdown 125 + nix 126 + printf 127 + python 128 + query 129 + regex 130 + rust 131 + toml 132 + typescript 133 + vim 134 + vimdoc 135 + xml 136 + ] 137 + )) 138 + ]; 139 + extraWrapperArgs = [ 140 + "--add-flags" 141 + # Move my configs to the front of path in order to pick up treesitter queries etc. 142 + # before the vim-pack-dir ones provided by nixpkgs / withPlugins 143 + (lib.escapeShellArgs [ 144 + # TODO: maybe these should use config.xdg.configHome 145 + "--cmd" 146 + "set runtimepath-=~/.config/nvim" 147 + "--cmd" 148 + "set runtimepath^=~/.config/nvim" 149 + "--cmd" 150 + "set packpath-=~/.config/nvim" 151 + "--cmd" 152 + "set packpath^=~/.config/nvim" 153 + ]) 80 154 ]; 81 155 }; 82 156 ripgrep.enable = true; ··· 103 177 104 178 # TODO: this should probably be handled by nix-homebrew and/or `brew completions link` 105 179 xdg.dataFile = lib.mkIf stdenv.isDarwin { 106 - "fish/vendor_completions.d/brew.fish".source = "${nix-homebrew.inputs.brew-src}/completions/fish/brew.fish"; 180 + "fish/vendor_completions.d/brew.fish".source = 181 + "${nix-homebrew.inputs.brew-src}/completions/fish/brew.fish"; 107 182 }; 108 183 109 184 services = { ··· 116 191 # }; 117 192 118 193 # syncthing.enable = true; 119 - 120 194 # For commit signing, git-crypt, etc. 121 195 gpg-agent = { 122 196 # https://github.com/nix-community/home-manager/issues/3864 123 197 # TODO: it would be nice to setup gpg-agent.conf on macOS properly 124 198 # during activation... Maybe nix-darwin has something? 125 199 enable = stdenv.isLinux; 126 - 127 200 defaultCacheTtl = 432000; # 5 days 128 201 maxCacheTtl = 432000; 129 - pinentryPackage = pkgs.pinentry-curses; 202 + pinentryPackage = lib.mkIf (!host.wsl) pkgs.pinentry-curses; 130 203 }; 131 204 }; 132 205 133 206 # See services.gpg-agent - manually set up conf file on macos instead 134 - home.file.".gnupg/gpg-agent.conf" = lib.mkIf stdenv.isDarwin { 135 - text = '' 136 - # Use nix-packaged pinentry-mac 137 - pinentry-program ${pkgs.pinentry_mac}/bin/pinentry-mac 138 - # Set TTL to 5 days for GPG passphrase prompt 139 - default-cache-ttl 432000 140 - max-cache-ttl 432000 141 - ''; 207 + home.file = { 208 + ".gnupg/gpg-agent.conf" = lib.mkIf stdenv.isDarwin { 209 + text = '' 210 + # Use nix-packaged pinentry-mac 211 + pinentry-program ${pkgs.pinentry_mac}/bin/pinentry-mac 212 + # Set TTL to 5 days for GPG passphrase prompt 213 + default-cache-ttl 432000 214 + max-cache-ttl 432000 215 + ''; 216 + }; 142 217 }; 143 218 144 - home.packages = with pkgs; [ 145 - buildifier 146 - clang-tools 147 - docker 148 - docker-compose 149 - docker-credential-helpers 150 - file 151 - gh 152 - git-crypt 153 - git-lfs 154 - go 155 - home-manager # omitted when nix-darwin module is in use, even with programs.home-manager enabled 156 - ncurses # Newer version including tset/reset, can understand tmux terminfo etc. 157 - nil 158 - nixpkgs-fmt 159 - openssh 160 - python3 161 - rustup 162 - shellcheck 163 - thefuck 164 - tmux 165 - tree 166 - unstable.lnav 167 - unstable.nixd 168 - unzip 169 - watch 170 - yadm 219 + home.packages = 220 + with pkgs; 221 + [ 222 + buildifier 223 + # unstable.bacon # also available as a flake if I need bleeding-edge 224 + clang-tools 225 + comby 226 + difftastic 227 + docker 228 + docker-compose 229 + docker-credential-helpers 230 + file 231 + packdirPackage # so I can reference it for Lua-LSP etc. 232 + gh 233 + git-crypt 234 + git-lfs 235 + go 236 + home-manager # omitted when nix-darwin module is in use, even with programs.home-manager enabled 237 + mold 238 + ncurses # Newer version including tset/reset, can understand tmux terminfo etc. 239 + nil 240 + nixpkgs-fmt 241 + unstable.nixfmt-rfc-style 242 + openssh 243 + python3 244 + rustup 245 + shellcheck 246 + thefuck 247 + tmux 248 + tree 249 + unstable.lnav 250 + unstable.nixd 251 + unzip 252 + watch 253 + yadm 171 254 172 - # Fish completions + path setup stuff, needed since I'm not letting 173 - # home-manager do all the shell setup for me. Most notably, this creates 174 - # ~/.nix-profile/etc/profile.d/nix.fish - don't remove without a replacement! 175 - # 176 - # This may cause trouble on nixOS but I can't remember why... 177 - config.nix.package 178 - ] 179 - ++ lib.optionals stdenv.isDarwin [ 180 - # Might also consider pinentry-touchid 181 - pinentry_mac 182 - swiftdefaultapps 183 - colima 184 - ] 185 - ++ lib.optionals stdenv.isLinux [ 186 - pinentry-curses 187 - ]; 255 + # Fish completions + path setup stuff, needed since I'm not letting 256 + # home-manager do all the shell setup for me. Most notably, this creates 257 + # ~/.nix-profile/etc/profile.d/nix.fish - don't remove without a replacement! 258 + # 259 + # This may cause trouble on nixOS but I can't remember why... 260 + config.nix.package 261 + ] 262 + ++ lib.optionals stdenv.isDarwin [ 263 + # Might also consider pinentry-touchid 264 + pinentry_mac 265 + swiftdefaultapps 266 + colima 267 + ] 268 + ++ lib.optionals stdenv.isLinux [ 269 + pinentry-curses 270 + ] 271 + ++ lib.optionals host.wsl [ 272 + podman # use podman --remote to access host WSL podman instance 273 + ]; 188 274 189 - home.sessionVariables = lib.mkIf 190 - (!stdenv.isDarwin) 191 - (self.lib.sslCertEnv "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"); 275 + home.sessionVariables = lib.mkIf (!stdenv.isDarwin) ( 276 + self.lib.sslCertEnv "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" 277 + ); 192 278 193 279 home.stateVersion = "20.09"; 194 280 }
+30
.config/home-manager/wsl/default.nix
··· 1 + { pkgs, lib, ... }: 2 + let 3 + pinentry-injector = pkgs.callPackage ./wsl/pinentry-injector/package.nix { }; 4 + 5 + # Request pinentry via Git-bash's GPG instead of pinentry-curses 6 + pinentry-wrapper = pkgs.writeShellApplication { 7 + name = "pinentry-win"; 8 + # TODO: PR these as inputs for nixpkgs#wslu itself? 9 + runtimeInputs = with pkgs; [ wslu coreutils gnused pinentry-injector ]; 10 + # TODO: if I write a real program to intercept stdin/stdout I can inject 11 + # a SETTITLE command using the key name for AutoType to work nicer. Ideally 12 + # cross-platform enough to work on native windows too 13 + text = /*bash*/ '' 14 + # Add wslpath to PATH (for wslu to work properly) 15 + export PATH=/bin:$PATH 16 + # Gpg4Win's pinentry-qt seems better behaved than plain pinentry from Git for Windows 17 + real_pinentry="$(wslpath "$(wslvar -s USERPROFILE)")/scoop/apps/gpg4win/current/Gpg4win/bin/pinentry.exe" 18 + exec "${lib.getExe pinentry-injector}" "$real_pinentry" "$@" 19 + ''; 20 + }; 21 + in 22 + { 23 + services.gpg-agent.pinentryPackage = pinentry-wrapper; 24 + 25 + home.file.".local/bin/xdg-open".source = lib.getExe' pkgs.wslu "wslview"; 26 + home.packages = with pkgs; [ 27 + wslu 28 + pinentry-wrapper 29 + ]; 30 + }
+19
.config/home-manager/wsl/pinentry-injector/package.nix
··· 1 + { pkgs, ... }: 2 + let 3 + name = "pinentry-injector"; 4 + version = "0.1.0"; 5 + in 6 + pkgs.buildGoModule { 7 + pname = name; 8 + inherit version; 9 + 10 + meta.mainProgram = "pinentry-injector"; 11 + 12 + # Since it's just a single-file zero-dependency app, generate go.mod on the fly 13 + # and pretend its dependencies are vendored. 14 + src = ./.; 15 + patchPhase = '' 16 + go mod init ian-h-chamberlain.com/pinentry-injector 17 + ''; 18 + vendorHash = null; 19 + }
+114
.config/home-manager/wsl/pinentry-injector/pinentry-injector.go
··· 1 + // A simple app to wrap `pinentry`, intercepting the description while looking 2 + // for an email address; if found it will be injected into the real pinentry's 3 + // title. 4 + // 5 + // This is probably insecure for some reason or other so use with care. 6 + 7 + package main 8 + 9 + import ( 10 + "bufio" 11 + "errors" 12 + "fmt" 13 + "io" 14 + "os" 15 + "os/exec" 16 + "regexp" 17 + ) 18 + 19 + func main() { 20 + err := run(os.Args[1], os.Args[1:]...) 21 + 22 + if err != nil { 23 + var exitErr *exec.ExitError 24 + if errors.As(err, &exitErr) { 25 + os.Exit(exitErr.ExitCode()) 26 + } else { 27 + os.Exit(1) 28 + } 29 + } 30 + } 31 + 32 + var emailRegex = regexp.MustCompile(`(?:%22|")(?P<name>.+?) <(?P<email>.+?)>(?:%22|")`) 33 + 34 + const emailAddressIndex = 2 35 + 36 + func run(realPinentry string, pinentryArgs ...string) (err error) { 37 + pinentry := exec.Command(realPinentry, pinentryArgs...) 38 + 39 + pinentryStdin, err := pinentry.StdinPipe() 40 + if err != nil { 41 + return err 42 + } 43 + defer pinentryStdin.Close() 44 + 45 + pinentryStdout, err := pinentry.StdoutPipe() 46 + if err != nil { 47 + return err 48 + } 49 + defer pinentryStdout.Close() 50 + 51 + if err = pinentry.Start(); err != nil { 52 + return err 53 + } 54 + defer func() { 55 + err = errors.Join(err, pinentry.Wait()) 56 + }() 57 + 58 + stdinScanner := bufio.NewScanner(os.Stdin) 59 + myStdin := make(chan string) 60 + go func() { 61 + for stdinScanner.Scan() { 62 + myStdin <- stdinScanner.Text() 63 + } 64 + close(myStdin) 65 + }() 66 + 67 + stdoutScanner := bufio.NewScanner(pinentryStdout) 68 + pinentryOut := make(chan string) 69 + go func() { 70 + for stdoutScanner.Scan() { 71 + pinentryOut <- stdoutScanner.Text() 72 + } 73 + close(pinentryOut) 74 + }() 75 + 76 + loop: 77 + for { 78 + fmt.Fprintln(os.Stderr, "waiting for input...") 79 + select { 80 + case inLine, ok := <-myStdin: 81 + if !ok { 82 + // EOF from client, pass it along by closing the pipe 83 + _ = pinentryStdin.Close() 84 + break loop 85 + } 86 + 87 + fmt.Fprintf(os.Stderr, "Got input line: %q\n", inLine) 88 + if email := emailRegex.FindStringSubmatch(inLine); email != nil { 89 + fmt.Fprintln(os.Stderr, "matched mail regex") 90 + io.WriteString(pinentryStdin, fmt.Sprintf("SETTITLE pinentry: <%s>\n", email[emailAddressIndex])) 91 + response := <-pinentryOut 92 + if response != "OK" { 93 + os.Stderr.WriteString("failed to settitle") 94 + break 95 + } 96 + } 97 + io.WriteString(pinentryStdin, inLine+"\n") 98 + 99 + case outLine, ok := <-pinentryOut: 100 + if !ok { 101 + break loop 102 + } 103 + fmt.Fprintf(os.Stderr, "Got output line: %q\n", outLine) 104 + fmt.Println(outLine) 105 + } 106 + 107 + } 108 + err = errors.Join(stdinScanner.Err(), stdoutScanner.Err()) 109 + if err != nil { 110 + fmt.Fprintf(os.Stderr, "Done: %s\n", err) 111 + } 112 + 113 + return err 114 + }
+54 -35
.config/nix-darwin/configuration.nix
··· 1 - { self, lib, config, pkgs, unstable, host, ... }: 1 + { 2 + self, 3 + lib, 4 + config, 5 + pkgs, 6 + unstable, 7 + host, 8 + ... 9 + }: 2 10 let 3 11 # https://discourse.nixos.org/t/ssl-ca-cert-error-on-macos/31171/6 4 12 # https://github.com/NixOS/nixpkgs/issues/66716 ··· 32 40 ]; 33 41 34 42 shells = [ pkgs.fish ]; 35 - loginShell = "${pkgs.fish}/bin/fish"; 43 + loginShell = "${lib.getExe pkgs.fish}"; 36 44 37 - etc = let homeDir = config.users.users.${host.user}.home; in { 38 - # Symlink to dotfiles flake for easier activation 39 - "nix-darwin/flake.nix".source = "${homeDir}/.config/flake.nix"; 40 - }; 45 + etc = 46 + let 47 + homeDir = config.users.users.${host.user}.home; 48 + in 49 + { 50 + # Symlink to dotfiles flake for easier activation 51 + "nix-darwin/flake.nix".source = "${homeDir}/.config/flake.nix"; 52 + }; 41 53 42 54 variables = mkIfWork systemCABundleEnv; 43 55 }; ··· 47 59 48 60 nix.package = unstable.lix; 49 61 # Necessary for using flakes on this system. 50 - nix.settings.experimental-features = [ "nix-command" "flakes" ]; 62 + nix.settings.experimental-features = [ 63 + "nix-command" 64 + "flakes" 65 + ]; 51 66 52 67 # Seems to be necessary on work laptop probably due to some MITM certs or something... 53 68 # Needs plumbing into launchd or /etc/profile I think, not working just yet... ··· 76 91 remapCapsLockToEscape = true; 77 92 78 93 /* 79 - # https://developer.apple.com/library/content/technotes/tn2450/_index.html 80 - userKeyMapping = let hex = lib.fromHexString; in [ 81 - # TODO: what is this mapping from?? Need to figure out what other ones 82 - # from currentHost defaults I care about, if any 83 - { 84 - HIDKeyboardModifierMappingSrc = hex "0xFF0100000003"; 85 - HIDKeyboardModifierMappingDst = hex "0x00FF00000003"; 86 - } 87 - ]; 88 - # */ 94 + # https://developer.apple.com/library/content/technotes/tn2450/_index.html 95 + userKeyMapping = let hex = lib.fromHexString; in [ 96 + # TODO: what is this mapping from?? Need to figure out what other ones 97 + # from currentHost defaults I care about, if any 98 + { 99 + HIDKeyboardModifierMappingSrc = hex "0xFF0100000003"; 100 + HIDKeyboardModifierMappingDst = hex "0x00FF00000003"; 101 + } 102 + ]; 103 + # 104 + */ 89 105 }; 90 106 91 107 # Set up apps after homebrew, so that everything we try to add should be installed ··· 105 121 "${appdir}/Stretchly.app" 106 122 "${appdir}/Syncthing.app" 107 123 ]; 108 - appEntries = map 109 - (app: { path = app; hidden = true; }) 110 - apps; 124 + appEntries = map (app: { 125 + path = app; 126 + hidden = true; 127 + }) apps; 111 128 112 129 # This somehow seems to be the only way to add apps to "Open at Login" that doesn't 113 130 # involve launchd, and there doesn't seem to be any `defaults` for it anymore 114 - updateEntries = /* javascript */ '' 115 - "use strict"; 116 - (() => { 117 - const se = Application("System Events"); 131 + updateEntries = # javascript 132 + '' 133 + "use strict"; 134 + (() => { 135 + const se = Application("System Events"); 118 136 119 - // https://stackoverflow.com/a/48026729 120 - while (se.loginItems.length > 0) { 121 - se.loginItems[0].delete(); 122 - } 137 + // https://stackoverflow.com/a/48026729 138 + while (se.loginItems.length > 0) { 139 + se.loginItems[0].delete(); 140 + } 123 141 124 - // This interface is strange... https://bru6.de/jxa/basics/working-with-objects/ 125 - for (const app of ${builtins.toJSON appEntries}) { 126 - se.loginItems.push(se.LoginItem(app)); 127 - } 128 - })() 129 - ''; 142 + // This interface is strange... https://bru6.de/jxa/basics/working-with-objects/ 143 + for (const app of ${builtins.toJSON appEntries}) { 144 + se.loginItems.push(se.LoginItem(app)); 145 + } 146 + })() 147 + ''; 130 148 in 131 - /* bash */ '' 149 + # bash 150 + '' 132 151 /usr/bin/osascript -l JavaScript -e ${lib.escapeShellArg updateEntries} 133 152 ''; 134 153 };
+33 -22
.config/nix/lib.nix
··· 3 3 # appropriate `pkgs`, but for now `self.lib` is good enough 4 4 { self, lib, ... }: 5 5 { 6 - /** Return the given value if non-null, otherwise the given `default` */ 7 - unwrapOr = default: v: 8 - if v == null then default else v; 6 + /** 7 + Return the given value if non-null, otherwise the given `default` 8 + */ 9 + unwrapOr = default: v: if v == null then default else v; 9 10 10 - /** Filter a list of paths to include only those that actually exist */ 11 + /** 12 + Filter a list of paths to include only those that actually exist 13 + */ 11 14 existingPaths = builtins.filter builtins.pathExists; 12 15 13 - /** Enable "escape sequences" in a string by (ab)using the builtin Nix JSON parser. 14 - For readability / sanity, this should probably only ever be used with a 15 - single-quoted '' literals for backslashes to work as expected. 16 - <https://github.com/NixOS/nix/issues/10082> 17 - */ 18 - unescape = s: 19 - let escaped = builtins.replaceStrings [ "\"" ] [ "\\\"" ] s; 20 - in builtins.fromJSON ''"${escaped}"''; 16 + /** 17 + Enable "escape sequences" in a string by (ab)using the builtin Nix JSON parser. 18 + For readability / sanity, this should probably only ever be used with a 19 + single-quoted '' literals for backslashes to work as expected. 20 + <https://github.com/NixOS/nix/issues/10082> 21 + */ 22 + unescape = 23 + s: 24 + let 25 + escaped = builtins.replaceStrings [ "\"" ] [ "\\\"" ] s; 26 + in 27 + builtins.fromJSON ''"${escaped}"''; 21 28 22 - /** com.apple.dock helpers */ 29 + /** 30 + com.apple.dock helpers 31 + */ 23 32 dock = with self.lib.dock; { 24 33 path-entry = path: { 25 34 tile-data = { ··· 30 39 }; 31 40 }; 32 41 33 - folder = path: lib.recursiveUpdate (path-entry path) { 34 - tile-data = { 35 - # Show as folder icon instead of stack etc. 36 - displayas = 1; 37 - # Use default appearance for contents, set 2 to force grid here 38 - showas = 0; 42 + folder = 43 + path: 44 + lib.recursiveUpdate (path-entry path) { 45 + tile-data = { 46 + # Show as folder icon instead of stack etc. 47 + displayas = 1; 48 + # Use default appearance for contents, set 2 to force grid here 49 + showas = 0; 50 + }; 51 + tile-type = "directory-tile"; 39 52 }; 40 - tile-type = "directory-tile"; 41 - }; 42 53 43 54 app-in-dir = dir: appName: path-entry "${dir}/${appName}.app"; 44 55 system-app = app-in-dir "/System/Applications"; ··· 55 66 56 67 Not which are needed / relevant all the time, but I've seen a bunch 57 68 of various resources refer to one or multiple of these... 58 - */ 69 + */ 59 70 sslCertEnv = caBundle: { 60 71 NIX_SSL_CERT_FILE = caBundle; 61 72 SSL_CERT_FILE = caBundle;
+82 -8
.config/nixos/configuration.nix
··· 1 - { config, lib, pkgs, host, ... }: 1 + { 2 + config, 3 + lib, 4 + pkgs, 5 + unstable, 6 + host, 7 + lix-module, 8 + ... 9 + }: 2 10 { 3 11 # TODO: when converting prismo, will probably import ./prismo.nix or something 4 12 imports = [ 5 - ./wsl.nix 13 + ./wsl 6 14 ]; 7 15 8 - nix.settings.experimental-features = [ "nix-command" "flakes" ]; 9 - nix.package = pkgs.lix; 16 + nix = { 17 + settings = { 18 + experimental-features = [ 19 + "nix-command" 20 + "flakes" 21 + ]; 22 + # Disable the global flake registry; nixpkgs came free with your cfg! 23 + # This might make more sense in home.nix to work on darwin etc too 24 + flake-registry = null; 25 + }; 26 + package = unstable.lix; 27 + 28 + # TODO: figure out a way to add registry entries so I can do e.g. 29 + # `nix run pkgs#htop` and get my custom htop instead of upstream 30 + registry.unstable.to = { 31 + type = "github"; 32 + owner = "NixOS"; 33 + repo = "nixpkgs"; 34 + ref = "nixos-unstable"; 35 + }; 36 + }; 10 37 11 38 time.timeZone = "America/New_York"; 12 39 40 + documentation.dev.enable = true; 13 41 environment = { 14 42 systemPackages = with pkgs; [ 15 43 git ··· 18 46 wget 19 47 ]; 20 48 21 - etc = let homeDir = config.users.users.${host.user}.home; in { 22 - # Symlink to dotfiles flake for easier activation 23 - "nixos/flake.nix".source = "${homeDir}/.config/flake.nix"; 49 + etc = 50 + let 51 + homeDir = config.users.users.${host.user}.home; 52 + in 53 + { 54 + # Symlink to dotfiles flake for easier activation 55 + "nixos/flake.nix".source = "${homeDir}/.config/flake.nix"; 56 + }; 57 + 58 + # Override the default aliases, I brought my own 59 + shellAliases = { 60 + ls = null; 61 + ll = null; 62 + l = null; 24 63 }; 25 64 }; 26 65 27 - programs.fish.enable = true; 66 + # Based on /bin/sh: 67 + # https://github.com/NixOS/nixpkgs/blob/8261f6e94510101738ab45f0b877f2993c7fb069/nixos/modules/config/shells-environment.nix#L213 68 + system.activationScripts.binbash = 69 + let 70 + bash = lib.getExe config.system.build.binsh; 71 + in 72 + lib.stringAfter [ "stdio" ] 73 + # bash 74 + '' 75 + mkdir -m 0755 -p /bin 76 + ln -sfn "${bash}" /bin/.bash.tmp 77 + mv /bin/.bash.tmp /bin/bash # atomically replace /bin/bash 78 + ''; 79 + 80 + systemd.coredump = { 81 + enable = true; 82 + # Explicit defaults: 83 + extraConfig = '' 84 + Storage=external 85 + Compress=yes 86 + # On 32-bit, the default is 1G instead of 32G. 87 + ProcessSizeMax=32G 88 + ExternalSizeMax=32G 89 + JournalSizeMax=767M 90 + MaxUse= 91 + KeepFree= 92 + EnterNamespace=no 93 + ''; 94 + }; 95 + 96 + programs = { 97 + fish = { 98 + enable = true; 99 + useBabelfish = true; 100 + }; 101 + }; 28 102 29 103 users.users.${host.user} = { 30 104 isNormalUser = true;
-14
.config/nixos/wsl.nix
··· 1 - { host, lib, pkgs, ... }: { 2 - imports = [ 3 - ./wsl/scoop.nix 4 - ]; 5 - 6 - wsl = lib.mkIf host.wsl { 7 - wslConf.user.default = host.user; 8 - }; 9 - 10 - programs.nix-ld = lib.mkIf host.wsl { 11 - enable = true; 12 - package = pkgs.nix-ld-rs; 13 - }; 14 - }
+53
.config/nixos/wsl/default.nix
··· 1 + { 2 + host, 3 + lib, 4 + pkgs, 5 + ... 6 + }: 7 + { 8 + imports = [ 9 + ./scoop.nix 10 + ]; 11 + 12 + config = lib.mkIf (host.wsl or false) { 13 + wsl = { 14 + enable = true; 15 + defaultUser = host.user; 16 + wslConf = { 17 + user.default = host.user; 18 + network.hostname = host.name; 19 + }; 20 + }; 21 + 22 + programs.nix-ld = { 23 + enable = true; 24 + package = pkgs.nix-ld-rs; 25 + }; 26 + 27 + users.groups.podman = { 28 + gid = 10; 29 + members = [ host.user ]; 30 + }; 31 + 32 + nixpkgs.overlays = [ 33 + (final: prev: { 34 + fish = prev.fish.overrideAttrs (old: { 35 + # Force WSL detection to avoid autocompleting .dll files, it seems to be broken in 3.x, possibly fixed in 4.0. 36 + # https://github.com/fish-shell/fish-shell/blob/3.7.1/src/common.cpp#L133 37 + # 38 + # This does have the side effect of using ¶ instead of ⏎ for newlines (and maybe also other side effects)... 39 + # https://github.com/fish-shell/fish-shell/commit/412c5aeaa63caa3534a0b966e3ad510969904dc6 40 + cmakeFlags = old.cmakeFlags ++ [ "-DWSL=ON" ]; 41 + }); 42 + }) 43 + ]; 44 + 45 + # Enable mDNS for reaching windows via .local hostname 46 + services.avahi = { 47 + enable = true; 48 + nssmdns4 = true; 49 + }; 50 + 51 + security.pki.certificates = [ ]; 52 + }; 53 + }
+60 -20
.config/nixpkgs/flake-overlays.nix
··· 7 7 8 8 It's *not* named overlays.nix so that it isn't picked up automatically by nix 9 9 commands. 10 - */ 11 - { ... }: 10 + */ 11 + { 12 + lib, 13 + unstable, 14 + pkgs, 15 + ... 16 + }: 12 17 let 13 - appendPatches = pkg: patches: 14 - pkg.overrideAttrs (old: { patches = (old.patches or [ ]) ++ patches; }); 18 + appendPatches = 19 + pkg: patches: 20 + pkg.overrideAttrs (old: { 21 + patches = (old.patches or [ ]) ++ patches; 22 + }); 15 23 in 16 24 { 17 25 nixpkgs.overlays = [ 18 - (final: prev: 19 - { 20 - htop = appendPatches prev.htop [ 21 - ./patches/htop/0001-Re-title-the-main-menu-bar-for-its-shortcuts.patch 26 + (final: prev: { 27 + htop = appendPatches prev.htop [ 28 + ./patches/htop/0001-Re-title-the-main-menu-bar-for-its-shortcuts.patch 29 + ]; 30 + 31 + # Pulling from unsable is probably not _really_ how overlays are meant to be used 32 + # and I should be calling unstable.extend or something, but meh it's fine for now 33 + nil = unstable.nil.overrideAttrs ( 34 + prev: 35 + let 36 + src = pkgs.fetchFromGitHub { 37 + owner = "oxalica"; 38 + repo = "nil"; 39 + rev = "2e24c9834e3bb5aa2a3701d3713b43a6fb106362"; 40 + hash = "sha256-DCIVdlb81Fct2uwzbtnawLBC/U03U2hqx8trqTJB7WA="; 41 + }; 42 + in 43 + { 44 + version = "2024-11-19"; 45 + inherit src; 46 + 47 + # https://wiki.nixos.org/wiki/Overlays#Rust_packages 48 + cargoDeps = prev.cargoDeps.overrideAttrs (_: { 49 + name = "oxalica-nil-vendor.tar.gz"; 50 + inherit src; 51 + outputHash = "sha256-qW6xqYVQbvZUL5mJAzh8T6udUYIpk8nKoOihoD1UmXA="; 52 + }); 53 + } 54 + ); 55 + 56 + # Some packages (mainly bash-based) get built as a wrapped "resholve" script, so we 57 + # actually want to patch the source of the unwrapped pre-resholve derivation (i.e. 58 + # the src attribute on the final derivation). 59 + 60 + yadm = prev.yadm.overrideAttrs (unresholved: { 61 + src = appendPatches unresholved.src [ 62 + (prev.fetchpatch { 63 + url = "https://github.com/TheLocehiliosan/yadm/pull/495.patch"; 64 + hash = "sha256-xIXqXo8pQywufvcfY+j3jne5WdYnS9/t5DQdpXAkZbo="; 65 + excludes = [ "test/*" ]; 66 + }) 22 67 ]; 68 + }); 23 69 24 - # Yadm gets built as a wrapped "resholve" script, so we actually 25 - # want to patch the source of the unwrapped pre-resholve derivation: 26 - yadm = prev.yadm.overrideAttrs (unresholved: { 27 - src = appendPatches unresholved.src [ 28 - (prev.fetchpatch { 29 - url = "https://github.com/TheLocehiliosan/yadm/pull/495.patch"; 30 - hash = "sha256-xIXqXo8pQywufvcfY+j3jne5WdYnS9/t5DQdpXAkZbo="; 31 - excludes = [ "test/*" ]; 32 - }) 33 - ]; 34 - }); 35 - }) 70 + nix-direnv = unstable.nix-direnv.overrideAttrs (unresholved: { 71 + src = appendPatches unresholved.src [ 72 + ./patches/nix-direnv/0001-Supress-stderr-for-nix-flake-archive.patch 73 + ]; 74 + }); 75 + }) 36 76 ]; 37 77 }
+30
.config/nixpkgs/patches/nix-direnv/0001-Supress-stderr-for-nix-flake-archive.patch
··· 1 + From 2c5351e39a30f7b0efd23436d4270204c92a0088 Mon Sep 17 00:00:00 2001 2 + From: Ian Chamberlain <ian.h.chamberlain@gmail.com> 3 + Date: Thu, 16 Jan 2025 11:43:36 -0500 4 + Subject: [PATCH] Supress stderr for `nix flake archive` 5 + 6 + Fixes #544 7 + --- 8 + direnvrc | 2 +- 9 + 1 file changed, 1 insertion(+), 1 deletion(-) 10 + 11 + diff --git a/direnvrc b/direnvrc 12 + index 68cef33..f5479e3 100644 13 + --- a/direnvrc 14 + +++ b/direnvrc 15 + @@ -310,11 +310,11 @@ use_flake() { 16 + # also add garbage collection root for source 17 + local flake_input_paths 18 + mkdir -p "$flake_inputs" 19 + flake_input_paths=$(_nix flake archive \ 20 + --json --no-write-lock-file \ 21 + - -- "$flake_uri") 22 + + -- "$flake_uri" 2>/dev/null) 23 + 24 + while [[ $flake_input_paths =~ /nix/store/[^\"]+ ]]; do 25 + local store_path="${BASH_REMATCH[0]}" 26 + _nix_add_gcroot "${store_path}" "${flake_inputs}/${store_path##*/}" 27 + flake_input_paths="${flake_input_paths/${store_path}/}" 28 + -- 29 + 2.44.1 30 +
+137
.config/nvim/after/plugin/vscode-custom.lua
··· 1 + if not vim.g.vscode then 2 + return 3 + end 4 + 5 + -- Disable regular syntax highlights, we only care about treesitter 6 + vim.cmd("syntax off") 7 + 8 + -- Languages without vscode highlighting: 9 + local enabled_langs = { "vimdoc", "query" } 10 + -- These languages have a vscode grammar/LSP, but not injection support; we can 11 + -- use treesitter's injection to supplement syntax highlighting (nice!) 12 + local injected_langs = VSCODE_INJECTED_LANGS 13 + 14 + local injection_disabled = { "markdown" } 15 + 16 + -- Wrap this whole thing in a pcall in case treesitter isn't installed 17 + local success, error = pcall(function() 18 + local ts_parsers = require("nvim-treesitter.parsers") 19 + 20 + for _, lang in pairs(ts_parsers.available_parsers()) do 21 + if ts_parsers.has_parser(lang) and not vim.list_contains(enabled_langs, lang) then 22 + -- Disable everything but injections + nvim-surround 23 + for _, query in ipairs({ "locals", "folds", "indents" }) do 24 + vim.treesitter.query.set(lang, query, "") 25 + end 26 + 27 + -- Keep highlights active for injected langs, that's the whole point 28 + if not vim.list_contains(injected_langs, lang) then 29 + vim.treesitter.query.set(lang, "highlights", "") 30 + end 31 + 32 + -- would love to do something like this but there doesn't seem to be 33 + -- a way to go back to parsed query from query info... 34 + --[[ 35 + local q = vim.treesitter.query.get(lang, "highlights") 36 + for _, pattern in pairs(q.info.patterns) do 37 + table.insert(pattern, { "injected?" }) 38 + end 39 + ]] 40 + 41 + if vim.list_contains(injection_disabled, lang) then 42 + vim.treesitter.query.set(lang, "injections", "") 43 + end 44 + end 45 + end 46 + 47 + -- Completely deregister everything vscode-neovim does for highlights 48 + vim.api.nvim_create_augroup("vscode.treesitter", { clear = true }) 49 + local hl_group = vim.api.nvim_create_augroup("vscode.highlight", { clear = true }) 50 + 51 + local function fixup_highlights() 52 + -- And then reimplement a subset of it (i.e. just global highlights) 53 + -- https://github.com/vscode-neovim/vscode-neovim/blob/master/runtime/lua/vscode/highlight.lua#L25 54 + -- Probably this could be upstreamed as a simple config option or something... 55 + for name, value in pairs({ 56 + ColorColumn = {}, 57 + CursorColumn = {}, 58 + CursorLine = {}, 59 + CursorLineNr = {}, 60 + Debug = {}, 61 + EndOfBuffer = {}, 62 + FoldColumn = {}, 63 + Folded = {}, 64 + LineNr = {}, 65 + LineNrAbove = {}, 66 + LineNrBelow = {}, 67 + MatchParen = {}, 68 + MsgArea = {}, 69 + MsgSeparator = {}, 70 + NonText = {}, 71 + Normal = {}, 72 + NormalFloat = {}, 73 + NormalNC = {}, 74 + NormalSB = {}, 75 + Question = {}, 76 + QuickFixLine = {}, 77 + Quote = {}, 78 + Sign = {}, 79 + SignColumn = {}, 80 + Substitute = {}, 81 + Visual = {}, 82 + VisualNC = {}, 83 + VisualNOS = {}, 84 + Whitespace = {}, 85 + 86 + -- make cursor visible for plugins that use fake cursor 87 + Cursor = { reverse = true }, 88 + 89 + ["@markup.link"] = {}, 90 + ["@markup.link.label"] = {}, 91 + ["@markup.link.url"] = {}, 92 + 93 + ["@markup.raw.markdown_inline"] = { 94 + fg = "#FD971F", 95 + bold = false, 96 + italic = false, 97 + }, 98 + ["@markup.strong"] = { fg = "#66D9EF", bold = true }, 99 + ["@markup.italic"] = { fg = "#66D9EF", italic = true }, 100 + }) do 101 + if vim.tbl_isempty(value) then 102 + vim.api.nvim_set_hl(0, name, { link = "VSCodeNone", force = true }) 103 + else 104 + vim.api.nvim_set_hl(0, name, value) 105 + end 106 + end 107 + end 108 + 109 + vim.api.nvim_create_autocmd({ "ColorScheme" }, { group = hl_group, callback = fixup_highlights }) 110 + 111 + vim.api.nvim_create_autocmd({ 112 + "BufEnter", 113 + "BufLeave", 114 + "WinEnter", 115 + "WinLeave", 116 + "BufWinEnter", 117 + "BufWinLeave", 118 + "WinScrolled", 119 + "FocusGained", 120 + "VimEnter", 121 + "UIEnter", 122 + }, { 123 + group = hl_group, 124 + callback = function() 125 + -- There are still some oddities with scrolling etc. for redraw, 126 + -- haven't quite figured out the details yet... 127 + vim.cmd("mode") 128 + vim.cmd("redraw!") 129 + end, 130 + }) 131 + 132 + fixup_highlights() 133 + end) 134 + 135 + if not success then 136 + vim.print("failed to do vscode-hl setup", error) 137 + end
+19
.config/nvim/after/queries/rust/injections.scm
··· 1 + ; extends 2 + 3 + ( 4 + (doc_comment) @injection.content 5 + (#set! injection.language "markdown_inline") 6 + (#set! injection.combined) 7 + ) 8 + 9 + ( 10 + (doc_comment) @injection.content 11 + (#set! injection.language "markdown") 12 + ; (#set! injection.combined) 13 + (#set! priority 110) 14 + ) 15 + 16 + ((macro_invocation 17 + macro: (identifier) @injection.language 18 + (token_tree) @injection.content) 19 + (#any-of? @injection.language "html" "json"))
+100 -17
.config/nvim/init.lua
··· 26 26 require("nvim-surround").setup() 27 27 require("ns-textobject").setup() 28 28 29 + -- Global, used in ./after/lua/vscode-custom.lua 30 + VSCODE_INJECTED_LANGS = {} 31 + 32 + -- Wrap this in a pcall in case treesitter isn't installed 33 + local success, error = pcall(function() 34 + -- langs without vscode equivalent, always enable highlights for these 35 + 36 + if vim.g.vscode then 37 + -- TODO: I'd love to figure out how to disable these at the top-level and only enable for injections 38 + VSCODE_INJECTED_LANGS = { "fish", "bash", "javascript", "vim", "regex", "markdown_inline", "markdown", "lua", "json" } 39 + end 40 + 41 + vim.treesitter.query.add_predicate("vscode?", function() 42 + return vim.g.vscode and true or false 43 + end, { force = true, all = true }) 44 + 45 + vim.treesitter.query.add_predicate("injected?", function(_match, _pattern, buf, pred) 46 + if type(buf) ~= "number" then 47 + return 48 + end 49 + 50 + local parser_ft = vim.filetype.match({ buf = buf }) 51 + local buf_ft = vim.filetype.match({ buf = vim.fn.bufnr() }) 52 + 53 + return buf_ft ~= parser_ft 54 + end, { force = true, all = true }) 55 + 56 + require("nvim-treesitter.configs").setup({ 57 + highlight = { 58 + enable = true, 59 + -- These can be disabled at the top level like this, but they're still allowed 60 + -- as injected languages so e.g. vim.cmd and nix injections work, without 61 + -- taking over highlights in vscode 62 + disable = VSCODE_INJECTED_LANGS, 63 + }, 64 + }) 65 + end) 66 + 67 + if not success then 68 + vim.print("Failed to pcall hl setup!", error) 69 + end 70 + 29 71 -- TODO: convert remainder of this to proper Lua config 30 72 31 73 -- Wrap this in a pcall in case treesitter isn't installed ··· 60 102 if not vim.g.vscode then 61 103 -- Default to dark mode if unset 62 104 vim.opt.background = os.getenv("COLOR_THEME") or "dark" 105 + 106 + if vim.fn.has("wsl") ~= 0 then 107 + vim.g.clipboard = { 108 + name = "WslClipboard", 109 + copy = { 110 + ["+"] = "clip.exe", 111 + ["*"] = "clip.exe", 112 + }, 113 + paste = { 114 + -- yeesh, is this really the only way to deal with this? See :h clipboard-wsl 115 + -- fish_clipboard_paste looks like it's doing basically the same thing too 116 + ["+"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', 117 + ["*"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', 118 + }, 119 + cache_enabled = false, 120 + } 121 + end 63 122 64 123 -- TODO: https://github.com/akinsho/git-conflict.nvim 65 124 else ··· 70 129 71 130 local group = vim.api.nvim_create_augroup("vscode-custom", {}) 72 131 73 - -- https://github.com/vscode-neovim/vscode-neovim/issues/1718 74 - vim.api.nvim_create_autocmd({ "VimEnter", "ModeChanged" }, { 75 - pattern = "*", 132 + -- rust-analyzer commands doesn't play super nice with neovim join/match brace; this autocmd 133 + -- setups up bindings to use the builtin motion commands in operator-pending mode 134 + vim.api.nvim_create_autocmd({ "FileType" }, { 135 + pattern = { "*.rs" }, 76 136 group = group, 77 - callback = function(args) 78 - vscode.call("setContext", { 79 - args = { "neovim.fullMode", vim.fn.mode(1) }, 80 - }) 137 + callback = function() 138 + vim.keymap.set({ "n", "v" }, "%", function() 139 + if vim.fn.state("o") ~= "" then 140 + vscode.action("rust-analyzer.matchingBrace") 141 + return "" 142 + end 143 + 144 + return "%" 145 + end, { silent = true, remap = true, expr = true }) 146 + 147 + vim.keymap.set({ "n", "v" }, "J", function() 148 + if vim.fn.state("o") ~= "" then 149 + vscode.action("rust-analyzer.joinLines") 150 + return "" 151 + end 152 + 153 + return "J" 154 + end, { silent = true, remap = true, expr = true }) 81 155 end, 82 156 }) 83 157 84 158 -- https://github.com/vscode-neovim/vscode-neovim/issues/1718#issuecomment-2078380657 85 - vim.keymap.set("n", "r", function() 86 - vscode.call("setContext", { 87 - args = { "neovim.fullMode", vim.fn.mode(1) .. "r" }, 88 - }) 89 - 90 - vim.api.nvim_feedkeys("r", "n", true) 91 - end) 92 159 93 160 -- Fix comment handling for AHK 94 161 vim.api.nvim_create_autocmd({ "BufEnter" }, { ··· 135 202 136 203 vim.cmd([[ 137 204 xnoremap <silent> <Esc> :<C-u>call VSCodeNotify('closeFindWidget')<CR> 205 + 138 206 nnoremap <silent> <Esc> :<C-u>call VSCodeNotify('closeFindWidget')<CR> 139 207 140 208 " Disable airline by pretending it's already loaded ··· 161 229 162 230 nmap <D-a> ggVG 163 231 164 - " Move cursor to end of line when making visual selection so % works as expected 165 - nmap V V$ 166 - 167 232 " Remap for append/insert with multi-cursor to avoid extra keystroke 168 233 xmap <expr> a visualmode() ==# 'v' ? 'a' : 'ma' 169 234 xmap <expr> A visualmode() ==# 'v' ? 'A' : 'mA' ··· 231 296 let g:loaded_airline = 1 232 297 ]]) 233 298 end 299 + 300 + -- Do this at the end so ColorScheme autocmds work: 301 + 302 + ---@diagnostic disable-next-line: missing-fields 303 + require("monokai-nightasty").setup({ 304 + on_highlights = function(highlights, colors) 305 + -- It seems like most syntaxes just use String for quotes, but 306 + -- for some (e.g. JSON) they are highlighted differently. 307 + -- This just forces them back to regular String highlight 308 + highlights.Quote = highlights.String 309 + 310 + -- More like the old vim highlighting: 311 + highlights.gitcommitSummary, highlights.gitcommitOverflow = 312 + highlights.gitcommitOverflow, highlights.gitcommitSummary 313 + end, 314 + }) 315 + 316 + vim.cmd.colorscheme("monokai-nightasty")
+5
.config/nvim/queries/lua/highlights.scm
··· 1 + ; Keywords 2 + ( 3 + "return" @function 4 + (#injected?) 5 + )
+124
.config/nvim/queries/markdown/highlights.scm
··· 1 + ;From MDeiml/tree-sitter-markdown & Helix 2 + (setext_heading 3 + (paragraph) @markup.heading.1 4 + (setext_h1_underline) @markup.heading.1) 5 + 6 + (setext_heading 7 + (paragraph) @markup.heading.2 8 + (setext_h2_underline) @markup.heading.2) 9 + 10 + (atx_heading 11 + (atx_h1_marker)) @markup.heading.1 12 + 13 + (atx_heading 14 + (atx_h2_marker)) @markup.heading.2 15 + 16 + (atx_heading 17 + (atx_h3_marker)) @markup.heading.3 18 + 19 + (atx_heading 20 + (atx_h4_marker)) @markup.heading.4 21 + 22 + (atx_heading 23 + (atx_h5_marker)) @markup.heading.5 24 + 25 + (atx_heading 26 + (atx_h6_marker)) @markup.heading.6 27 + 28 + (info_string) @label 29 + 30 + (pipe_table_header 31 + (pipe_table_cell) @markup.heading) 32 + 33 + (pipe_table_header 34 + "|" @punctuation.special) 35 + 36 + (pipe_table_row 37 + "|" @punctuation.special) 38 + 39 + (pipe_table_delimiter_row 40 + "|" @punctuation.special) 41 + 42 + (pipe_table_delimiter_cell) @punctuation.special 43 + 44 + ; Code blocks (conceal backticks and language annotation) 45 + ( 46 + (indented_code_block) @markup.raw.block 47 + (#not-vscode?)) 48 + 49 + ((fenced_code_block) @markup.raw.block 50 + (#set! priority 90) 51 + (#not-vscode?)) 52 + 53 + (fenced_code_block 54 + (fenced_code_block_delimiter) @markup.raw.block 55 + (#set! conceal "")) 56 + 57 + (fenced_code_block 58 + (info_string 59 + (language) @label 60 + (#set! conceal ""))) 61 + 62 + (link_destination) @markup.link.url 63 + 64 + [ 65 + (link_title) 66 + (link_label) 67 + ] @markup.link.label 68 + 69 + ((link_label) 70 + . 71 + ":" @punctuation.delimiter) 72 + 73 + [ 74 + (list_marker_plus) 75 + (list_marker_minus) 76 + (list_marker_star) 77 + (list_marker_dot) 78 + (list_marker_parenthesis) 79 + ] @markup.list 80 + 81 + ; NOTE: The following has been commented out due to issues with spaces in the 82 + ; list marker nodes generated by the parser. If those spaces ever get captured 83 + ; by a different node (e.g. block_continuation) we can safely re-add these 84 + ; conceals. 85 + ; ;; Conceal bullet points 86 + ; ([(list_marker_plus) (list_marker_star)] 87 + ; @punctuation.special 88 + ; (#offset! @punctuation.special 0 0 0 -1) 89 + ; (#set! conceal "•")) 90 + ; ([(list_marker_plus) (list_marker_star)] 91 + ; @punctuation.special 92 + ; (#any-of? @punctuation.special "+" "*") 93 + ; (#set! conceal "•")) 94 + ; ((list_marker_minus) 95 + ; @punctuation.special 96 + ; (#offset! @punctuation.special 0 0 0 -1) 97 + ; (#set! conceal "—")) 98 + ; ((list_marker_minus) 99 + ; @punctuation.special 100 + ; (#eq? @punctuation.special "-") 101 + ; (#set! conceal "—")) 102 + (thematic_break) @punctuation.special 103 + 104 + (task_list_marker_unchecked) @markup.list.unchecked 105 + 106 + (task_list_marker_checked) @markup.list.checked 107 + 108 + ((block_quote) @markup.quote 109 + (#set! priority 90)) 110 + 111 + ([ 112 + (plus_metadata) 113 + (minus_metadata) 114 + ] @keyword.directive 115 + (#set! priority 90)) 116 + 117 + [ 118 + (block_continuation) 119 + (block_quote_marker) 120 + ] @punctuation.special 121 + 122 + (backslash_escape) @string.escape 123 + 124 + (inline) @spell
+143
.config/nvim/queries/markdown_inline/highlights.scm
··· 1 + ; From MDeiml/tree-sitter-markdown 2 + 3 + ( 4 + (link_text (code_span)) @none 5 + (#vscode?) 6 + (#set! priority 110) 7 + ) 8 + 9 + ( 10 + (code_span 11 + (code_span_delimiter) @_delim 12 + (code_span_delimiter) @_delim) @_span 13 + (#not-eq? @_delim "```"); ignore ``` delimiters in vscode, e.g injected rust 14 + (#not-has-parent? @_span link_label link_text) 15 + (#vscode?) 16 + ) @markup.raw @nospell 17 + 18 + ( 19 + (code_span) @markup.raw @nospell 20 + (#not-vscode?) 21 + ) 22 + 23 + (emphasis) @markup.italic 24 + 25 + (strong_emphasis) @markup.strong 26 + 27 + (strikethrough) @markup.strikethrough 28 + 29 + (shortcut_link 30 + (link_text) @nospell) 31 + 32 + [ 33 + (backslash_escape) 34 + (hard_line_break) 35 + ] @string.escape 36 + 37 + ; Conceal codeblock and text style markers 38 + ([ 39 + (code_span_delimiter) 40 + (emphasis_delimiter) 41 + ] @conceal 42 + (#set! conceal "")) 43 + 44 + ; Conceal inline links 45 + (inline_link 46 + [ 47 + "[" 48 + "]" 49 + "(" 50 + (link_destination) 51 + ")" 52 + ] @markup.link 53 + (#set! conceal "")) 54 + 55 + [ 56 + (link_label) 57 + (link_text) 58 + (link_title) 59 + (image_description) 60 + ] @markup.link.label 61 + 62 + 63 + ((inline_link 64 + (link_destination) @_url) @_label 65 + (#set! @_label url @_url)) 66 + 67 + ((image 68 + (link_destination) @_url) @_label 69 + (#set! @_label url @_url)) 70 + 71 + ; Conceal image links 72 + (image 73 + [ 74 + "!" 75 + "[" 76 + "]" 77 + "(" 78 + (link_destination) 79 + ")" 80 + ] @markup.link 81 + (#set! conceal "")) 82 + 83 + ; Conceal full reference links 84 + (full_reference_link 85 + [ 86 + "[" 87 + "]" 88 + (link_label) 89 + ] @markup.link 90 + (#set! conceal "")) 91 + 92 + ; Conceal collapsed reference links 93 + (collapsed_reference_link 94 + [ 95 + "[" 96 + "]" 97 + ] @markup.link 98 + (#set! conceal "")) 99 + 100 + ; Conceal shortcut links 101 + (shortcut_link 102 + [ 103 + "[" 104 + "]" 105 + ] @markup.link 106 + (#set! conceal "")) 107 + 108 + [ 109 + (link_destination) 110 + (uri_autolink) 111 + (email_autolink) 112 + ] @markup.link.url @nospell 113 + 114 + ((uri_autolink) @_url 115 + (#offset! @_url 0 1 0 -1) 116 + (#set! @_url url @_url)) 117 + 118 + (entity_reference) @nospell 119 + 120 + ; Replace common HTML entities. 121 + ((entity_reference) @character.special 122 + (#eq? @character.special "&nbsp;") 123 + (#set! conceal " ")) 124 + 125 + ((entity_reference) @character.special 126 + (#eq? @character.special "&lt;") 127 + (#set! conceal "<")) 128 + 129 + ((entity_reference) @character.special 130 + (#eq? @character.special "&gt;") 131 + (#set! conceal ">")) 132 + 133 + ((entity_reference) @character.special 134 + (#eq? @character.special "&amp;") 135 + (#set! conceal "&")) 136 + 137 + ((entity_reference) @character.special 138 + (#eq? @character.special "&quot;") 139 + (#set! conceal "\"")) 140 + 141 + ((entity_reference) @character.special 142 + (#any-of? @character.special "&ensp;" "&emsp;") 143 + (#set! conceal " "))
.config/yadm/alt/.config/git/config.local##class.2work

This is a binary file and will not be displayed.

+3 -1
.config/yadm/alt/.gitattributes
··· 1 - .ssh/** filter=git-crypt diff=git-crypt 1 + .ssh/** filter=git-crypt diff=git-crypt 2 + .npmrc*2work* filter=git-crypt diff=git-crypt 3 +
.config/yadm/alt/.npmrc##class.2work,e.npmrc

This is a binary file and will not be displayed.

.config/yadm/alt/.ssh/config.local##class.2work

This is a binary file and will not be displayed.

+15
.config/yadm/alt/.vscode-server/data/Machine/settings.json##os.WSL
··· 1 + { 2 + "remote.WSL.useShellEnvironment": false, 3 + "files.eol": "\n", 4 + "vscode-neovim.useWSL": true, 5 + "nix.enableLanguageServer": true, 6 + 7 + "terminal.integrated.profiles.linux": { 8 + "Ubuntu (bash)": { 9 + "path": "wsl.exe", 10 + "args": [ "-d", "ubuntu", "--cd", "~" ], 11 + "icon": "terminal-linux", 12 + "color": "terminal.ansiMagenta", 13 + } 14 + }, 15 + }
+7
.cspell/default.txt
··· 3 3 archiver 4 4 argn 5 5 asyncio 6 + backnav'd 6 7 Bazel 7 8 bazelbuild 8 9 bazelisk ··· 14 15 capsys 15 16 CCache 16 17 CentOS 18 + CHAMI 17 19 Citra 18 20 citro 19 21 clippy 20 22 CMake 21 23 cmdbuf 24 + committerdate 22 25 concat 23 26 consts 24 27 coreutils ··· 39 42 dlig 40 43 dotfiles 41 44 dpad 45 + dplus 42 46 DUT 43 47 DUTs 44 48 eabi ··· 99 103 miri 100 104 mistsys 101 105 mkdir 106 + Monaspace 102 107 monokai 103 108 msvc 104 109 nalgebra ··· 217 222 webgl 218 223 wgpu 219 224 winit 225 + worktreepath 220 226 xargs 221 227 XQuartz 222 228 yadm 229 + yeesh 223 230 yoink 224 231 zhaofengli
+1
.gitattributes
··· 1 1 # Prevent breaking git with a bad config when it has conflicts 2 2 .gitconfig* merge=binary 3 + **/.config/git/config* merge=binary 3 4 **/lghub/settings.db diff=sqlite3 4 5 **/lghub/settings.db merge=keepTheir 5 6 *.pyz filter=lfs diff=lfs merge=lfs -text
+3
.gitmodules
··· 49 49 [submodule ".config/yadm/vendored/yadm"] 50 50 path = .config/yadm/vendored/yadm 51 51 url = https://github.com/TheLocehiliosan/yadm.git 52 + [submodule ".vim/pack/bundle/start/vim-textobj-variable-segment"] 53 + path = .vim/pack/bundle/start/vim-textobj-variable-segment 54 + url = https://github.com/Julian/vim-textobj-variable-segment.git 52 55 [submodule ".vim/pack/bundle/start/vim-fetch"] 53 56 path = .vim/pack/bundle/start/vim-fetch 54 57 url = https://github.com/wsdjeg/vim-fetch.git
+2
.local/bin/cargo-env
··· 1 + #!/usr/bin/env bash 2 + env
+33
.local/bin/git-br
··· 1 + #!/usr/bin/env bash 2 + 3 + ## In lieu of a more customizable --sort=... option, this is a shortcut to replace `git branch` which 4 + ## sorts first by a known prefix, then by committerdate. It 5 + ## Output format is based on the upstream implementation: 6 + ## <https://github.com/git/git/blob/08bdfd453584e489d5a551aecbdcb77584e1b958/builtin/branch.c#L386> 7 + 8 + set -euo pipefail 9 + 10 + # TODO: it might be nice to also support main/master as higher-ranked prefix here 11 + MY_PREFIX="ian" 12 + MINE="%(if:equals=refs/heads/${MY_PREFIX})%(refname:rstrip=-3)%(then)1%(else)0%(end)" 13 + DATE='%(committerdate:unix)' # TODO maybe also consider reverse-version-sorting by branch (i.e. ticket #) 14 + 15 + TAB=$'\t' 16 + 17 + # Unclear why %(color:normal) doesn't behave the same as the RGB color here, or why 18 + # this is set to some white color at all (since normal is green in my terminal settings). 19 + # There must be some magic in git's codebase that sets RGB when terminal support is detected. 20 + NORMAL_COLOR='%(color:#F8F8F2)' 21 + 22 + HEAD_PREFIX='*%(color:green)' 23 + WORKTREE_PREFIX='+%(color:cyan)' 24 + WORKTREE="%(if)%(worktreepath)%(then)${WORKTREE_PREFIX}%(else) %(end)" 25 + PREFIX="${NORMAL_COLOR}%(if)%(HEAD)%(then)${HEAD_PREFIX}%(else)${WORKTREE}%(end)" 26 + 27 + FORMAT='%(refname:lstrip=2)%(color:reset)%(if)%(symref)%(then) -> %(symref:short)%(end)' 28 + 29 + git branch --color \ 30 + --format="${DATE}${TAB}${MINE}${TAB}${PREFIX} ${FORMAT}" | 31 + sort -r -n -k2 -k1 | # sort by $MINE, then $DATE 32 + cut -d"$TAB" -f3 | # trim off the sort keys 33 + git column
+27
.local/bin/git-clean-squashed
··· 1 + #!/usr/bin/env bash 2 + 3 + ## Clean up local branches that were squash-merged into the main branch. Ported from 4 + ## <https://github.com/not-an-aardvark/git-delete-squashed/blob/master/bin/git-delete-squashed.js> 5 + 6 + set -euo pipefail 7 + 8 + DEFAULT_BRANCH=${1:-$(git default-branch)} 9 + 10 + # Skip checked-out branches with worktreepath 11 + git for-each-ref refs/heads/ --format='%(if)%(worktreepath)%(then)%(else)%(refname:short)%(end)' | 12 + while read -r branch; do 13 + [[ -z $branch || $branch = "$DEFAULT_BRANCH" ]] && continue 14 + 15 + ancestor=$(git merge-base "$DEFAULT_BRANCH" "$branch") 16 + tree=$(git rev-parse "$branch^{tree}") 17 + 18 + commit=$(git commit-tree "$tree" -p "$ancestor" -m "squash-clean: temporary commit") 19 + set -x 20 + echo "$branch" 21 + cherry_result=$(git cherry "$DEFAULT_BRANCH" "$commit") 22 + set +x 23 + 24 + if [[ "$cherry_result" = -* ]]; then 25 + echo git branch -D "$branch" 26 + fi 27 + done
.local/share/emacs/autosave/.gitkeep

This is a binary file and will not be displayed.

.local/share/gdb/.gitkeep

This is a binary file and will not be displayed.

+18
.vimrc
··· 3 3 set tabstop=4 4 4 set shiftwidth=4 5 5 set softtabstop=4 6 + set shiftround " lmao where has this been all my life T_T 6 7 7 8 set expandtab 8 9 set backspace=indent,eol,start ··· 17 18 set autoindent 18 19 filetype plugin indent on 19 20 21 + set smartcase 22 + 20 23 " Prevent '#' from forcing 0-indent for e.g. python + bash comments 21 24 " This should be used instead of smartindent 22 25 set cindent 23 26 set cinkeys-=0# 24 27 set indentkeys-=0# 25 28 29 + set wildmode=longest:full,full 30 + set wildoptions+=fuzzy 31 + cnoremap <M-BS> <C-w> 32 + cnoremap <M-d> <C-d> 33 + 26 34 if &diff 27 35 set diffopt+=iwhite 28 36 endif ··· 38 46 " Use newer info than the macOS builtin 39 47 let g:infoprg = '/usr/local/bin/info' 40 48 49 + " Common typos I make while trying to save a file. It's very unlikely i'll ever need to 50 + " name a file something like "\" or "'" and if I do I can use a space or :saveas 51 + cabbrev w\ w 52 + cabbrev w' w 53 + cabbrev w] w 54 + 55 + " Don't set textwidth to 99 by default. Rustfmt does the heavy lifting anyway 56 + let g:rust_recommended_style = 0 57 + 41 58 " filetype matching 42 59 augroup CustomFiletypes 43 60 autocmd! ··· 65 82 augroup END 66 83 67 84 " Augroups, must be before `syntax on` 85 + " TODO maybe disable this for vscode-nvim 68 86 augroup CustomTodo 69 87 autocmd! 70 88 autocmd Syntax * syntax match CustomTodo /\v<(TODO|FIXME|NOTE)/ containedin=.*Comment