From f3151320a3d4c0832443fdad8c3f6a874b0c66e3 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 11 Mar 2023 07:58:56 +0000 Subject: [PATCH] servo: shutup sane-deadlines warning --- hosts/by-name/servo/default.nix | 1 + hosts/common/home/zsh/default.nix | 234 ++++++++++++++++-------------- 2 files changed, 126 insertions(+), 109 deletions(-) diff --git a/hosts/by-name/servo/default.nix b/hosts/by-name/servo/default.nix index e8c24f60..6364c43e 100644 --- a/hosts/by-name/servo/default.nix +++ b/hosts/by-name/servo/default.nix @@ -17,6 +17,7 @@ sane.roles.build-machine = true; sane.persist.enable = true; + sane.zsh.showDeadlines = false; # ~/knowledge doesn't always exist sane.services.dyn-dns.enable = true; sane.services.wg-home.enable = true; sane.services.wg-home.ip = config.sane.hosts.by-name."servo".wg-home.ip; diff --git a/hosts/common/home/zsh/default.nix b/hosts/common/home/zsh/default.nix index c1486b9a..bff155bf 100644 --- a/hosts/common/home/zsh/default.nix +++ b/hosts/common/home/zsh/default.nix @@ -1,6 +1,8 @@ -{ pkgs, sane-lib, ... }: +{ config, lib, pkgs, sane-lib, ... }: let + inherit (lib) mkOption types; + cfg = config.sane.zsh; # powerlevel10k prompt config # p10k.zsh is the auto-generated config, and i overwrite those defaults here, below. p10k-overrides = '' @@ -26,120 +28,134 @@ let ''; in { - sane.user.persist.plaintext = [ - # we don't need to full zsh dir -- just the history file -- - # but zsh will sometimes backup the history file and we get fewer errors if we do proper mounts instead of symlinks. - # TODO: should be private? - ".local/share/zsh" - # cache gitstatus otherwise p10k fetched it from the net EVERY BOOT - ".cache/gitstatus" - ]; - - # zsh/prezto complains if zshrc doesn't exist; but it does allow an "empty" file. - sane.user.fs.".config/zsh/.zshrc" = sane-lib.fs.wantedText "# "; - - # enable zsh completions - environment.pathsToLink = [ "/share/zsh" ]; - - programs.zsh = { - enable = true; - histFile = "$HOME/.local/share/zsh/history"; - shellAliases = { - ":q" = "exit"; - # common typos - "cd.." = "cd .."; - "cd../" = "cd ../"; + options = { + sane.zsh = { + showDeadlines = mkOption { + type = types.bool; + default = true; + description = "show upcoming deadlines (frommy PKM) upon shell init"; + }; }; - setOptions = [ - # defaults: - "HIST_IGNORE_DUPS" - "SHARE_HISTORY" - "HIST_FCNTL_LOCK" - # disable `rm *` confirmations - "rmstarsilent" - ]; - - # .zshenv config: - shellInit = '' - ZDOTDIR=$HOME/.config/zsh - ''; - - # .zshrc config: - interactiveShellInit = - (builtins.readFile ./p10k.zsh) - + p10k-overrides - + prezto-init - + '' - # zmv is a way to do rich moves/renames, with pattern matching/substitution. - # see for an example: - autoload -Uz zmv - - HISTORY_IGNORE='(sane-shutdown *|sane-reboot *|rm *|nixos-rebuild.* switch)' - - # extra aliases - # TODO: move to `shellAliases` config? - function nd() { - mkdir -p "$1"; - pushd "$1"; - } - - ${pkgs.sane-scripts}/bin/sane-deadlines - - # auto-cd into any of these dirs by typing them and pressing 'enter': - hash -d 3rd="/home/colin/dev/3rd" - hash -d dev="/home/colin/dev" - hash -d knowledge="/home/colin/knowledge" - hash -d nixos="/home/colin/nixos" - hash -d nixpkgs="/home/colin/dev/3rd/nixpkgs" - hash -d ref="/home/colin/ref" - hash -d secrets="/home/colin/knowledge/secrets" - hash -d tmp="/home/colin/tmp" - hash -d uninsane="/home/colin/dev/uninsane" - hash -d Videos="/home/colin/Videos" - ''; - - syntaxHighlighting.enable = true; - vteIntegration = true; }; - # enable a command-not-found hook to show nix packages that might provide the binary typed. - programs.nix-index.enable = true; - programs.command-not-found.enable = false; #< mutually exclusive with nix-index + config = { + sane.user.persist.plaintext = [ + # we don't need to full zsh dir -- just the history file -- + # but zsh will sometimes backup the history file and we get fewer errors if we do proper mounts instead of symlinks. + # TODO: should be private? + ".local/share/zsh" + # cache gitstatus otherwise p10k fetched it from the net EVERY BOOT + ".cache/gitstatus" + ]; - # prezto = oh-my-zsh fork; controls prompt, auto-completion, etc. - # see: https://github.com/sorin-ionescu/prezto - # i believe this file is auto-sourced by the prezto init.zsh script. - sane.user.fs.".config/zsh/.zpreztorc" = sane-lib.fs.wantedText '' - zstyle ':prezto:*:*' color 'yes' + # zsh/prezto complains if zshrc doesn't exist; but it does allow an "empty" file. + sane.user.fs.".config/zsh/.zshrc" = sane-lib.fs.wantedText "# "; - # modules (they ship with prezto): - # ENVIRONMENT: configures jobs to persist after shell exit; other basic niceties - # TERMINAL: auto-titles terminal (e.g. based on cwd) - # EDITOR: configures shortcuts like Ctrl+U=undo, Ctrl+L=clear - # HISTORY: `history-stat` alias, setopts for good history defaults - # DIRECTORY: sets AUTO_CD, adds `d` alias to list directory stack, and `1`-`9` to cd that far back the stack - # SPECTRUM: helpers for term colors and styling. used by prompts? might be unnecessary - # UTILITY: configures aliases like `ll`, `la`, disables globbing for things like rsync - # adds aliases like `get` to fetch a file. also adds `http-serve` alias?? - # COMPLETION: tab completion. requires `utility` module prior to loading - # TODO: enable AUTO_PARAM_SLASH - zstyle ':prezto:load' pmodule \ - 'environment' \ - 'terminal' \ - 'editor' \ - 'history' \ - 'directory' \ - 'spectrum' \ - 'utility' \ - 'completion' \ - 'prompt' + # enable zsh completions + environment.pathsToLink = [ "/share/zsh" ]; - # default keymap. try also `vicmd` (vim normal mode, AKA "cmd mode") or `vi`. - zstyle ':prezto:module:editor' key-bindings 'emacs' + programs.zsh = { + enable = true; + histFile = "$HOME/.local/share/zsh/history"; + shellAliases = { + ":q" = "exit"; + # common typos + "cd.." = "cd .."; + "cd../" = "cd ../"; + }; + setOptions = [ + # defaults: + "HIST_IGNORE_DUPS" + "SHARE_HISTORY" + "HIST_FCNTL_LOCK" + # disable `rm *` confirmations + "rmstarsilent" + ]; - zstyle ':prezto:module:prompt' theme 'powerlevel10k' + # .zshenv config: + shellInit = '' + ZDOTDIR=$HOME/.config/zsh + ''; - # disable `mv` confirmation (and `rm`, too, unfortunately) - zstyle ':prezto:module:utility' safe-ops 'no' - ''; + # .zshrc config: + interactiveShellInit = + (builtins.readFile ./p10k.zsh) + + p10k-overrides + + prezto-init + + '' + # zmv is a way to do rich moves/renames, with pattern matching/substitution. + # see for an example: + autoload -Uz zmv + + HISTORY_IGNORE='(sane-shutdown *|sane-reboot *|rm *|nixos-rebuild.* switch)' + + # extra aliases + # TODO: move to `shellAliases` config? + function nd() { + mkdir -p "$1"; + pushd "$1"; + } + '' + + lib.optionalString cfg.showDeadlines '' + ${pkgs.sane-scripts}/bin/sane-deadlines + '' + + '' + # auto-cd into any of these dirs by typing them and pressing 'enter': + hash -d 3rd="/home/colin/dev/3rd" + hash -d dev="/home/colin/dev" + hash -d knowledge="/home/colin/knowledge" + hash -d nixos="/home/colin/nixos" + hash -d nixpkgs="/home/colin/dev/3rd/nixpkgs" + hash -d ref="/home/colin/ref" + hash -d secrets="/home/colin/knowledge/secrets" + hash -d tmp="/home/colin/tmp" + hash -d uninsane="/home/colin/dev/uninsane" + hash -d Videos="/home/colin/Videos" + ''; + + syntaxHighlighting.enable = true; + vteIntegration = true; + }; + + # enable a command-not-found hook to show nix packages that might provide the binary typed. + programs.nix-index.enable = true; + programs.command-not-found.enable = false; #< mutually exclusive with nix-index + + # prezto = oh-my-zsh fork; controls prompt, auto-completion, etc. + # see: https://github.com/sorin-ionescu/prezto + # i believe this file is auto-sourced by the prezto init.zsh script. + sane.user.fs.".config/zsh/.zpreztorc" = sane-lib.fs.wantedText '' + zstyle ':prezto:*:*' color 'yes' + + # modules (they ship with prezto): + # ENVIRONMENT: configures jobs to persist after shell exit; other basic niceties + # TERMINAL: auto-titles terminal (e.g. based on cwd) + # EDITOR: configures shortcuts like Ctrl+U=undo, Ctrl+L=clear + # HISTORY: `history-stat` alias, setopts for good history defaults + # DIRECTORY: sets AUTO_CD, adds `d` alias to list directory stack, and `1`-`9` to cd that far back the stack + # SPECTRUM: helpers for term colors and styling. used by prompts? might be unnecessary + # UTILITY: configures aliases like `ll`, `la`, disables globbing for things like rsync + # adds aliases like `get` to fetch a file. also adds `http-serve` alias?? + # COMPLETION: tab completion. requires `utility` module prior to loading + # TODO: enable AUTO_PARAM_SLASH + zstyle ':prezto:load' pmodule \ + 'environment' \ + 'terminal' \ + 'editor' \ + 'history' \ + 'directory' \ + 'spectrum' \ + 'utility' \ + 'completion' \ + 'prompt' + + # default keymap. try also `vicmd` (vim normal mode, AKA "cmd mode") or `vi`. + zstyle ':prezto:module:editor' key-bindings 'emacs' + + zstyle ':prezto:module:prompt' theme 'powerlevel10k' + + # disable `mv` confirmation (and `rm`, too, unfortunately) + zstyle ':prezto:module:utility' safe-ops 'no' + ''; + }; }