From 43c9825e49d25fbd2c19abcdeb8f73aee8be2a4c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 14 May 2025 10:50:27 +0200 Subject: ... --- user-profiles/feeds/alot.config | 50 ------- user-profiles/feeds/default.nix | 11 -- user-profiles/feeds/imm-notmuch-insert.py | 52 ------- user-profiles/feeds/module.nix | 236 ------------------------------ user-profiles/tmux/default.nix | 10 +- user-profiles/tmux/tmux.conf | 9 +- user-profiles/utils.nix | 4 +- user-profiles/zsh/default.nix | 95 ++++++++---- user-profiles/zsh/zshrc | 6 - 9 files changed, 74 insertions(+), 399 deletions(-) delete mode 100644 user-profiles/feeds/alot.config delete mode 100644 user-profiles/feeds/default.nix delete mode 100644 user-profiles/feeds/imm-notmuch-insert.py delete mode 100644 user-profiles/feeds/module.nix (limited to 'user-profiles') diff --git a/user-profiles/feeds/alot.config b/user-profiles/feeds/alot.config deleted file mode 100644 index a14d4539..00000000 --- a/user-profiles/feeds/alot.config +++ /dev/null @@ -1,50 +0,0 @@ -attachment_prefix="~/Downloads" -bug_on_exit=true -editor_cmd="false" -tabwidth=2 -timestamp_format="%a %d %b %H:%M:%S %Y UTC%z" -auto_remove_unread=True -#initial_command="search ( tag:inbox ) AND NOT ( tag:killed )" -initial_command="search ( tag:inbox ) AND NOT ( is:link OR is:media OR is:killed )" - -[accounts] - [[private]] - realname = @realname@ - address = @address@ - -[bindings] -j = -k = -'g g' = -G = -I = search ( tag:inbox ) AND NOT ( is:killed ) -U = search ( tag:inbox ) AND NOT ( is:link OR is:media OR is:killed ) -V = search ( tag:inbox AND is:media OR ( is:live AND date:12h.. AND NOT is:unread ) ) AND NOT ( is:killed ) -W = search ( is:media ) AND NOT ( tag:inbox OR is:killed OR is:highlight ) -L = search ( tag:inbox AND is:link ) AND NOT ( is:killed ) - -h = move first -t = move up -n = move down -s = move last - [[search]] - a = - s = - - u = toggletags unread - i = toggletags inbox - j = untag unread,inbox - r = toggletags later - [[thread]] - s = - S = - n = - 'g j' = - 'g k' = - 'g l' = - w = save - W = save --all - 'g h' = move parent - 'g t' = move next sibling - 'g n' = move previous sibling - 'g s' = move first reply \ No newline at end of file diff --git a/user-profiles/feeds/default.nix b/user-profiles/feeds/default.nix deleted file mode 100644 index 82be90c7..00000000 --- a/user-profiles/feeds/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, flakeInputs, pkgs, lib, userName, customUtils, ... }: -{ - home-manager.users.${userName} = {...}: { - imports = [ - (customUtils.overrideModuleArgs - (import ./module.nix) - (inputs: inputs // { inherit flakeInputs; inherit (config.nixpkgs) system; }) - ) - ]; - }; -} diff --git a/user-profiles/feeds/imm-notmuch-insert.py b/user-profiles/feeds/imm-notmuch-insert.py deleted file mode 100644 index b7eed292..00000000 --- a/user-profiles/feeds/imm-notmuch-insert.py +++ /dev/null @@ -1,52 +0,0 @@ -#!@python@/bin/python - -import json -import sys -import subprocess -from io import BytesIO -from email.message import EmailMessage -import configparser -from os import environ -from datetime import * -from dateutil.tz import * -from dateutil.parser import isoparse -from html2text import html2text - -def main(): - notmuchConfig = configparser.ConfigParser() - notmuchConfig.read(environ.get('NOTMUCH_CONFIG')) - - callbackMessage = json.load(sys.stdin) - - msg = EmailMessage() - authors = ', '.join(map(lambda author: author['name'], callbackMessage['feed_item']['authors'])) - if authors: - msg['From'] = f"{callbackMessage['feed_definition']['title']} ({authors}) " - else: - msg['From'] = f"{callbackMessage['feed_definition']['title']} " - msg['To'] = f"{notmuchConfig['user']['name']} <{notmuchConfig['user']['primary_email']}>" - if 'title' in callbackMessage['feed_item'] and callbackMessage['feed_item']['title']: - msg['Subject'] = callbackMessage['feed_item']['title'] - msg['Item-Identifier'] = f"{callbackMessage['feed_item']['identifier']}" - for link in callbackMessage['feed_item']['links']: - msg.add_header('Link', link['uri']) - date = None - if 'date' in callbackMessage['feed_item']: - date = isoparse(callbackMessage['feed_item']['date']) - else: - date = datetime.now(tzlocal()) - msg['Date'] = date.strftime('%a, %e %b %Y %T %z') - - if 'content' in callbackMessage['feed_item'] and callbackMessage['feed_item']['content']: - msg.set_content(html2text(callbackMessage['feed_item']['content'])) - msg.add_alternative(callbackMessage['feed_item']['content'], subtype='html') - - - subprocess.run( - args=['notmuch', 'insert'], - check=True, - input=bytes(msg) - ) - -if __name__ == '__main__': - sys.exit(main()) diff --git a/user-profiles/feeds/module.nix b/user-profiles/feeds/module.nix deleted file mode 100644 index 63e827eb..00000000 --- a/user-profiles/feeds/module.nix +++ /dev/null @@ -1,236 +0,0 @@ -{ config, flakeInputs, pkgs, lib, system, ... }: - -with lib; - -let - inherit (flakeInputs.home-manager.lib) hm; - - databasePath = "${config.xdg.dataHome}/feeds"; - - imm = - let - hlib = pkgs.haskell.lib; - haskellPackages = pkgs.haskellPackages.override { - overrides = finalHaskell: prevHaskell: { - uri-bytestring = finalHaskell.callCabal2nix "uri-bytestring" (pkgs.fetchFromGitHub { - owner = "gkleen"; - repo = "uri-bytestring"; - rev = "5f7f32c8274bc4d1b81d99582f5148fe3e8b637e"; - sha256 = "XLanwyCDIlMuOkpE5LbTNOBfL+1kZX+URfj9Bhs1Nsc="; - fetchSubmodules = true; - }) {}; - atom-conduit = finalHaskell.callCabal2nix "atom-conduit" (pkgs.fetchFromGitHub { - owner = "gkleen"; - repo = "atom-conduit"; - rev = "022f0182a02373f87c06a0a09817c8c41efe2425"; - sha256 = "8yEyh3ymqkoM/YP+eBqPq1I5ofzj0Qn7ojL7IWx1DPo="; - fetchSubmodules = true; - }) {}; - rss-conduit = finalHaskell.callCabal2nix "rss-condit" (pkgs.fetchFromGitHub { - owner = "gkleen"; - repo = "rss-conduit"; - rev = "dbb0960a8d3dc519f1607aa0223b3a25a49282ef"; - sha256 = "Md1XApZWkdv4JvNoaVnjz0S85LbEC6w9U3PUcwXfu94="; - fetchSubmodules = true; - }) {}; - beam-core = hlib.doJailbreak (finalHaskell.callCabal2nix "beam-core" "${beamSrc}/beam-core" {}); - beam-migrate = hlib.doJailbreak (finalHaskell.callCabal2nix "beam-migrate" "${beamSrc}/beam-migrate" {}); - beam-sqlite = hlib.doJailbreak (finalHaskell.callCabal2nix "beam-sqlite" "${beamSrc}/beam-sqlite" {}); - - imm = finalHaskell.callCabal2nix "imm" (pkgs.fetchFromGitHub { - owner = "k0ral"; - repo = "imm"; - rev = "5033879667264cb44cee65671a66f6aa43f249e7"; - sha256 = "PG22caLQmAGhLZP49HsazuNd8IFKKaTuhXIQBD8v4Fs="; - fetchSubmodules = true; - }) {}; - }; - }; - beamSrc = pkgs.fetchFromGitHub { - owner = "haskell-beam"; - repo = "beam"; - rev = "efd464b079755a781c2bb7a2fc030d6c141bbb8a"; - sha256 = "8nTuBP/vD0L/qMo4h3XNrGZvpIwXuMVdj40j5gvHU6w="; - fetchSubmodules = true; - }; - in haskellPackages.imm; - immWrapped = pkgs.runCommand "${imm.name}-wrapped-${config.home.username}" - { nativeBuildInputs = with pkgs; [ makeWrapper ]; - } '' - mkdir -p $out/bin - makeWrapper ${imm}/bin/imm $out/bin/imm \ - --add-flags --callbacks=${notmuchCallbacks} - ''; - - notmuchCallbacks = pkgs.writeText "imm-callbacks-${config.home.username}.dhall" '' - [ { _executable = "${immNotmuchInsert}/bin/imm-notmuch-insert" - , _arguments = [] : List Text - } - ] - ''; - - immNotmuchInsert = pkgs.stdenv.mkDerivation rec { - name = "imm-notmuch-insert-${config.home.username}"; - src = ./imm-notmuch-insert.py; - - phases = [ "buildPhase" "checkPhase" "installPhase" "fixupPhase" ]; - - python = pkgs.python39.withPackages (ps: with ps; [ configparser python-dateutil html2text ]); - - nativeBuildInputs = with pkgs; [ makeWrapper ]; - - buildPhase = '' - substituteAll $src imm-notmuch-insert - ''; - - doCheck = true; - checkPhase = '' - ${python}/bin/python -m py_compile imm-notmuch-insert - ''; - - installPhase = '' - install -m 0755 -D -t $out/bin \ - imm-notmuch-insert - ''; - - fixupPhase = '' - wrapProgram $out/bin/imm-notmuch-insert \ - --prefix PATH : ${pkgs.notmuch}/bin \ - --set NOTMUCH_CONFIG ${configPath} - ''; - }; - - mkIniKeyValue = key: value: - let - tweakVal = v: - if isString v then - v - else if isList v then - concatMapStringsSep ";" tweakVal v - else if isBool v then - (if v then "true" else "false") - else - toString v; - in "${key}=${tweakVal value}"; - - notmuchIni = { - database = { path = databasePath; }; - - maildir = { synchronize_flags = false; }; - - new = { - ignore = []; - tags = ["new"]; - }; - - user = { - name = config.home.username; - primary_email = "${config.home.username}@imm.invalid"; - }; - - search = { exclude_tags = ["deleted"]; }; - }; - configPath = pkgs.writeText "notmuchrc" (generators.toINI { mkKeyValue = mkIniKeyValue; } notmuchIni); - - afewConfigDir = pkgs.symlinkJoin { - name = "afew-config"; - paths = [ - (pkgs.writeTextDir "config" '' - [InboxFilter] - '') - ]; - }; - - notmuchHooksDir = - let - afewHook = pkgs.writeShellScript "afew" '' - exec -- ${pkgs.afew}/bin/afew -c ${afewConfigDir} -C ${configPath} --tag --new -vv - ''; - in pkgs.linkFarm "notmuch-hooks" [ - { name = "post-new"; - path = afewHook; - } - { name = "post-insert"; - path = afewHook; - } - ]; - - notmuchWrapped = pkgs.runCommand "${pkgs.notmuch.name}-wrapped-${config.home.username}" - { nativeBuildInputs = with pkgs; [ makeWrapper ]; - } '' - mkdir -p $out/bin - makeWrapper ${pkgs.notmuch}/bin/notmuch $out/bin/notmuch-feeds \ - --set NOTMUCH_CONFIG ${configPath} - ''; - alotWrapped = pkgs.runCommand "${pkgs.alot.name}-wrapped-${config.home.username}" - { nativeBuildInputs = with pkgs; [ makeWrapper gnused ]; - } '' - mkdir -p $out/bin - makeWrapper ${pkgs.alot}/bin/alot $out/bin/alot-feeds \ - --prefix MAILCAPS : ${alotMailcaps} \ - --add-flags --config=${alotConfig} \ - --add-flags --notmuch-config=${configPath} - - mkdir $out/share - ln -s ${pkgs.alot}/share/alot $out/share - mkdir -p $out/share/applications - sed -r 's/alot/alot-feeds/g' ${pkgs.alot}/share/applications/alot.desktop > $out/share/applications/alot-feeds.desktop - mkdir -p $out/share/zsh/site-functions - sed -r 's/alot/alot-feeds/g' ${pkgs.alot}/share/zsh/site-functions/_alot > $out/share/zsh/site-functions/_alot-feeds - ''; - - alotConfig = pkgs.runCommand "alot" { - realname = notmuchIni.user.name; - address = notmuchIni.user.primary_email; - } "substituteAll ${./alot.config} $out"; - alotMailcaps = pkgs.writeText "mailcaps" '' - text/html; ${pkgs.lynx}/bin/lynx -dump -dont_wrap_pre -assume_charset=utf-8 -display_charset=utf-8 "%s"; nametemplate=%s.html; copiousoutput - ''; -in { - config = { - home.packages = [ immWrapped notmuchWrapped pkgs.notmuch.man alotWrapped ]; - - home.activation.createImm = hm.dag.entryAfter ["writeBoundary"] '' - $DRY_RUN_CMD mkdir -p $VERBOSE_ARG ${config.xdg.configHome}/imm - ''; - - home.activation.createFeedsDatabase = hm.dag.entryAfter ["linkGeneration" "writeBoundary"] '' - $DRY_RUN_CMD mkdir -p -m 0750 $VERBOSE_ARG ${databasePath} - $DRY_RUN_CMD mkdir -p $VERBOSE_ARG ${databasePath}/new ${databasePath}/cur ${databasePath}/tmp - if ! [[ -d ${databasePath}/.notmuch ]]; then - NOTMUCH_VERBOSE_ARG="--quiet" - if [[ -v VERBOSE ]]; then - NOTMUCH_VERBOSE_ARG="--verbose" - fi - NOTMUCH_CONFIG=${configPath} $DRY_RUN_CMD ${pkgs.notmuch}/bin/notmuch new $NOTMUCH_VERBOSE_ARG - fi - $DRY_RUN_CMD ln -Tsf $VERBOSE_ARG ${notmuchHooksDir} ${databasePath}/.notmuch/hooks - ''; - - systemd.user.services."logrotate-imm" = { - Unit = { - Description = "Rotate imm logfile"; - }; - Service = { - Type = "oneshot"; - ExecStart = '' - ${pkgs.logrotate}/bin/logrotate --state ${config.xdg.configHome}/imm/imm.logrotate ${pkgs.writeText "logrotate.conf" '' - ${config.xdg.configHome}/imm/imm.log { - rotate 5 - size 1024k - } - ''} - ''; - }; - }; - systemd.user.timers."logrotate-imm" = { - Timer = { - OnActiveSec = "6h"; - OnUnitActiveSec = "6h"; - }; - Install = { - WantedBy = ["default.target"]; - }; - }; - }; -} diff --git a/user-profiles/tmux/default.nix b/user-profiles/tmux/default.nix index 11c53788..dc4e791f 100644 --- a/user-profiles/tmux/default.nix +++ b/user-profiles/tmux/default.nix @@ -1,10 +1,11 @@ { userName, pkgs, lib, ... }: { - home-manager.users.${userName} = { + home-manager.users.${userName} = { config, ... }: { programs.tmux = { enable = true; clock24 = true; historyLimit = 50000; + mouse = true; extraConfig = lib.readFile (pkgs.stdenv.mkDerivation { name = "tmux.conf"; src = ./tmux.conf; @@ -13,11 +14,10 @@ phases = [ "installPhase" ]; - inherit (pkgs) zsh; - mandb = pkgs.man-db; - installPhase = '' - substituteAll $src $out + substitute $src $out \ + --subst-var-by zsh ${config.programs.zsh.package} \ + --subst-var-by man ${config.programs.man.package} ''; }); }; diff --git a/user-profiles/tmux/tmux.conf b/user-profiles/tmux/tmux.conf index 415d13e7..9e658800 100644 --- a/user-profiles/tmux/tmux.conf +++ b/user-profiles/tmux/tmux.conf @@ -1,23 +1,20 @@ -set-option -g history-limit 50000 set-option -g status-bg black set-option -g status-fg white set-option -g clock-mode-colour white -set-option -g clock-mode-style 24 set-option -g bell-action any -set-option -g default-shell @zsh@/bin/zsh +set-option -g default-shell @zsh@ set-option -g update-environment 'DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY PROMPT_INFO PATH PGHOST PGLOG' -set-option -g mouse on set-option -g set-clipboard on set-option -g terminal-overrides 'rxvt-uni*:XT:Ms=\E]52;%p1%s;%p2%s\007' set-environment -g LESS " -R " ## determine if we should enable 256-colour support -if "[[ ''${TERM} =~ 256color || ''${TERM} == fbterm || ''${TERM} =~ alacritty ]]" 'set -g default-terminal tmux-256color' +if "[[ ''${TERM} =~ 256color || ''${TERM} == fbterm || ''${TERM} =~ alacritty || ''${TERM} =~ kitty ]]" 'set -g default-terminal tmux-256color' set-option -g status-right "" -bind / command-prompt "split-window -h 'exec @mandb@/bin/man %%'" +bind / command-prompt "split-window -h 'exec @man@ %%'" bind C clock-mode bind r switch-client -r diff --git a/user-profiles/utils.nix b/user-profiles/utils.nix index 4b7c4d0f..da79e336 100644 --- a/user-profiles/utils.nix +++ b/user-profiles/utils.nix @@ -44,6 +44,8 @@ in { jq.enable = true; lesspipe.enable = true; + + man.enable = true; }; home.sessionVariables = { @@ -52,7 +54,7 @@ in { home.packages = with pkgs; [ autossh usbutils pciutils eza silver-searcher pwgen xkcdpass - unzip magic-wormhole qrencode tty-clock dnsutils openssl sshfs + unzip magic-wormhole dnsutils openssl sshfs psmisc mosh tree vnstat file pv bc zip nmap aspell aspellDicts.de aspellDicts.en borgbackup man-pages rsync socat inetutils yq cached-nix-shell persistent-nix-shell rage diff --git a/user-profiles/zsh/default.nix b/user-profiles/zsh/default.nix index 428e2459..973ff775 100644 --- a/user-profiles/zsh/default.nix +++ b/user-profiles/zsh/default.nix @@ -1,38 +1,69 @@ { userName, pkgs, customUtils, lib, config, ... }: -let - dotDir = ".config/zsh"; - p10kZsh = "${dotDir}/.p10k.zsh"; - cfg = config.home-manager.users.${userName}; -in { - home-manager.users.${userName} = { - programs.zsh = { - inherit dotDir; - enable = true; - autocd = true; - enableCompletion = true; +{ + config = { + home-manager.users.${userName} = let sysConfig = config; in { config, ... }: { + config = { + programs.zsh = { + dotDir = ".config/zsh"; + enable = true; + autocd = true; + enableCompletion = true; + enableVteIntegration = true; + history = { + append = true; + expireDuplicatesFirst = true; + extended = true; + findNoDups = true; + }; + syntaxHighlighting.enable = true; + zsh-abbr = { + enable = true; + abbreviations = { + re = "systemctl restart"; + ure = "systemctl --user restart"; + }; + globalAbbreviations = { + "L" = "| less"; + "S" = "&> /dev/null"; + "G" = "| grep"; + "B" = "&> /dev/null &"; + "BB" = "&> /dev/null &!"; + }; + }; - plugins = [ - { name = "powerlevel10k"; - file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; - src = pkgs.zsh-powerlevel10k; - } - ]; - initExtraFirst = '' - if [[ $TERM == "dumb" ]]; then - unsetopt zle - PS1='$ ' - return - fi - ''; - initExtraBeforeCompInit = '' - source "${cfg.home.homeDirectory}/${p10kZsh}" - ''; - initExtra = lib.mkAfter '' - source ${./zshrc} - source "${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" - ''; + plugins = [ + { name = "powerlevel10k"; + file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; + src = pkgs.zsh-powerlevel10k; + } + ]; + initContent = lib.mkMerge [ + (lib.mkBefore '' + if [[ $TERM == "dumb" ]]; then + unsetopt zle + PS1='$ ' + return + fi + '') + (lib.mkOrder 550 '' + source "$HOME/${config.xdg.configFile."zsh/.p10k.zsh".target}" + '') + (lib.mkAfter '' + source ${./zshrc} + '') + ]; + }; + + xdg.configFile."zsh/.p10k.zsh".source = ./p10k.zsh; + }; }; - home.file.${p10kZsh}.source = ./p10k.zsh; + programs.zsh.enable = true; + environment.pathsToLink = [ "/share/zsh" ]; + environment.shellAliases = lib.mkOverride 90 {}; + + nixpkgs.externalConfig.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "zsh-abbr" + ]; }; } diff --git a/user-profiles/zsh/zshrc b/user-profiles/zsh/zshrc index ed614182..af3aca64 100644 --- a/user-profiles/zsh/zshrc +++ b/user-profiles/zsh/zshrc @@ -33,9 +33,3 @@ zle -N self-insert url-quote-magic zle -N bracketed-paste bracketed-paste-magic setopt extended_glob - -alias -g L='| less' -alias -g S='&> /dev/null' -alias -g G='| grep' -alias -g B='&> /dev/null &' -alias -g BB='&> /dev/null &!' -- cgit v1.2.3