From 7d02e09df6442d03ce5183f8e629669dbb1cf6e1 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Mon, 5 Jan 2026 22:02:20 +0100 Subject: [PATCH] clean up --- hosts/nixos/home-default.nix | 1 - modules/ntfy.nix | 52 ---------- modules/papis.nix | 179 ----------------------------------- modules/seq-command.nix | 59 ------------ 4 files changed, 291 deletions(-) delete mode 100644 modules/ntfy.nix delete mode 100644 modules/papis.nix delete mode 100644 modules/seq-command.nix diff --git a/hosts/nixos/home-default.nix b/hosts/nixos/home-default.nix index c3bbca2..c73510c 100644 --- a/hosts/nixos/home-default.nix +++ b/hosts/nixos/home-default.nix @@ -13,7 +13,6 @@ ../../modules/btop.nix ../../modules/claude-code.nix ../../modules/fonts.nix - ../../modules/seq-command.nix ]; home.username = "yanlin"; diff --git a/modules/ntfy.nix b/modules/ntfy.nix deleted file mode 100644 index 8e278ba..0000000 --- a/modules/ntfy.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ config, pkgs, lib, ... }: - -let - cfg = config.services.ntfy-custom; -in -{ - options.services.ntfy-custom = { - port = lib.mkOption { - type = lib.types.port; - default = 8080; - description = "Port for ntfy to listen on"; - }; - - baseUrl = lib.mkOption { - type = lib.types.str; - default = "https://ntfy.yanlincs.com"; - description = "Base URL for ntfy server"; - }; - }; - - config = { - services.ntfy-sh = { - enable = true; - settings = { - listen-http = ":${toString cfg.port}"; - base-url = cfg.baseUrl; - - # iOS push notification support - upstream-base-url = "https://ntfy.sh"; - - # Authentication - auth-file = "/var/lib/ntfy-sh/user.db"; - auth-default-access = "deny-all"; - - # File attachments - attachment-cache-dir = "/var/lib/ntfy-sh/attachments"; - }; - }; - - # Ensure required directories exist - systemd.tmpfiles.rules = [ - "d /var/lib/ntfy-sh 0755 ntfy-sh ntfy-sh -" - "d /var/lib/ntfy-sh/attachments 0755 ntfy-sh ntfy-sh -" - ]; - }; -} - -# NOTE: After deployment, manage users via ntfy CLI: -# sudo ntfy user add -# sudo ntfy user change-pass -# sudo ntfy access -# Example: sudo ntfy access alice "*" read-write diff --git a/modules/papis.nix b/modules/papis.nix deleted file mode 100644 index 5fab5d5..0000000 --- a/modules/papis.nix +++ /dev/null @@ -1,179 +0,0 @@ -{ pkgs, lib, ... }: - -let - # Platform-aware papis config directory - papisConfigDir = if pkgs.stdenv.isDarwin then "Library/Application Support/papis" else ".config/papis"; -in - -{ - # Install papis package - home.packages = [ - (pkgs.symlinkJoin { - name = "papis-wrapped"; - paths = [ - (pkgs.papis.overridePythonAttrs (old: { - doCheck = false; - })) - ]; - buildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/papis \ - --set PYTHONWARNINGS "ignore::UserWarning" - ''; - }) - ]; - # Papis configuration - home.file."${papisConfigDir}/config".text = '' - [settings] - default-library = main - editor = nvim - opentool = ${if pkgs.stdenv.isDarwin then "open -a Preview" else "evince"} - - # Document management - ref-format = {doc[author]}{doc[year]} - - # Search and display - sort-field = year - sort-reverse = True - match-format = {doc[tags]}{doc[author]}{doc[title]}{doc[year]} - - # Database and storage - database-backend = papis - use-git = False - - # Interface - fzf-binary = fzf - picktool = fzf - - [main] - dir = ~/Documents/app-state/papis - - # Local configuration for the main library - local-config-file = .papisrc - ''; - - # Create the papis library directory - home.activation.createPapisDir = '' - mkdir -p ~/Documents/app-state/papis - ''; - - # Papis bibliography template - home.file."${papisConfigDir}/templates/bibitem.template".text = '' - {doc[title]} ({doc[year]}). {doc[author]}. - Venue: {doc[journal]} {doc[booktitle]} {doc[eprinttype]} {doc[eprint]} {doc[eventtitle]} - Tags: {doc[tags]} - URL: {doc[url]} - --- - ''; - - # Papis BibTeX template - home.file."${papisConfigDir}/templates/bibtex.template".text = '' - @{doc[type]}{{{doc[ref]}, - author = {{{doc[author]}}}, - title = {{{doc[title]}}}, - year = {{{doc[year]}}}, - journal = {{{doc[journal]}}}, - booktitle = {{{doc[booktitle]}}}, - volume = {{{doc[volume]}}}, - number = {{{doc[number]}}}, - pages = {{{doc[pages]}}}, - doi = {{{doc[doi]}}}, - url = {{{doc[url]}}} - }} - ''; - - # Papis citation template - home.file."${papisConfigDir}/templates/citation.template".text = '' - {doc[author]}. "{doc[title]}." {doc[journal]}{doc[booktitle]} ({doc[year]}). - ''; - - # Shell aliases for papis workflow - programs.zsh.shellAliases = { - # Bibliography formatting - pals = "papis list --template \"$HOME/${papisConfigDir}/templates/bibitem.template\""; - - # Add new entry with bibtex - paadd = "papis add --from bibtex"; - - # Remove/delete entries - parm = "papis rm"; - - # BibTeX export - pabib = "papis list --template \"$HOME/${papisConfigDir}/templates/bibtex.template\""; - - # Citation formatting - pacite = "papis list --template \"$HOME/${papisConfigDir}/templates/citation.template\""; - - # File operations - paurl = "papis addto -u"; - - # Open documents - paopen = "papis open"; - - # Print document file path - papwd = "papis list --file"; - - # Cache management - pareset = "papis cache reset"; - }; - - # Shell functions for papis workflow - programs.zsh.initContent = '' - # Papis add file function - add file to existing document with proper parameter handling - pafile() { - if [ $# -lt 1 ]; then - echo "Usage: pafile [query]" - echo "Example: pafile paper.pdf # Interactive selection" - echo "Example: pafile paper.pdf \"einstein relativity\" # Direct match" - echo "Example: pafile /path/to/paper.pdf \"quantum\" # Absolute path" - return 1 - fi - - local filename="$1" - shift # Remove first argument - local query="$*" # All remaining arguments as query (empty if none) - - # Check if filename is absolute path or relative to Downloads - if [[ "$filename" == /* ]]; then - # Absolute path - if [ -n "$query" ]; then - papis addto -f "$filename" "$query" - else - papis addto -f "$filename" - fi - else - # Relative to Downloads - if [ -n "$query" ]; then - papis addto -f "$HOME/Downloads/$filename" "$query" - else - papis addto -f "$HOME/Downloads/$filename" - fi - fi - } - - # Papis tag function - rewrite tags using hash-separated format - patag() { - if [ $# -ne 2 ]; then - echo "Usage: patag \"tag1#tag2#tag3\" " - echo "Example: patag \"materials#ai4science\" amorphous" - echo "Example: patag \"quantum#computing\" \"author:einstein\"" - return 1 - fi - - local tags_string="$1" - local query="$2" - - # First, drop all existing tags - papis tag --drop "$query" - - # Add each tag individually by splitting on # - echo "$tags_string" | tr '#' '\n' | while read tag; do - # Trim whitespace - tag=$(echo "$tag" | xargs) - if [ -n "$tag" ]; then - papis tag --add "$tag" "$query" - fi - done - } - ''; -} diff --git a/modules/seq-command.nix b/modules/seq-command.nix deleted file mode 100644 index edeaf44..0000000 --- a/modules/seq-command.nix +++ /dev/null @@ -1,59 +0,0 @@ -{ pkgs, ... }: - -let - seqCommandScript = pkgs.writeShellScriptBin "seq-command" '' - gap=0 - file="" - - while [[ $# -gt 0 ]]; do - case "$1" in - --gap) - gap="$2" - shift 2 - ;; - *) - file="$1" - shift - ;; - esac - done - - if [[ -z "$file" || "$gap" -eq 0 ]]; then - echo "seq-command - Execute commands from a file sequentially with gaps" - echo "" - echo "Usage: seq-command --gap " - echo "" - echo "Options:" - echo " --gap Wait time between command executions" - echo "" - echo "The commands file is treated as a FIFO queue - each line is removed after execution." - exit 1 - fi - - file="$(realpath "$file")" - - if [[ ! -f "$file" ]]; then - echo "File not found: $file" - exit 1 - fi - - gap_seconds=$((gap * 60)) - - while [[ -s "$file" ]]; do - cmd="$(head -n 1 "$file")" - - if [[ -n "$cmd" ]]; then - zsh -i -c "$cmd" - fi - - tail -n +2 "$file" > "$file.tmp" && mv "$file.tmp" "$file" - - if [[ -s "$file" ]]; then - sleep "$gap_seconds" - fi - done - ''; -in -{ - home.packages = [ seqCommandScript ]; -}