packaging/guix/sbm.scm (5648 bytes)
1 ;;; sbm: bookmarks in a plain file, picked with dmenu or fzf. 2 ;;; 3 ;;; Build it out of this file: 4 ;;; 5 ;;; guix build -L packaging/guix sbm 6 ;;; guix shell -L packaging/guix sbm -- bm --list 7 ;;; 8 ;;; To send it upstream, move the package form into gnu/packages/, most 9 ;;; likely web.scm or suckless.scm, and drop the define-module header. 10 11 (define-module (sbm) 12 #:use-module (guix packages) 13 #:use-module (guix download) 14 #:use-module (guix gexp) 15 #:use-module (guix utils) 16 #:use-module (guix build-system gnu) 17 #:use-module ((guix licenses) #:prefix license:) 18 #:use-module (gnu packages base) 19 #:use-module (gnu packages curl) 20 #:use-module (gnu packages freedesktop) 21 #:use-module (gnu packages gawk) 22 #:use-module (gnu packages haskell-apps) 23 #:use-module (gnu packages suckless) 24 #:use-module (gnu packages terminals) 25 #:use-module (gnu packages version-control) 26 #:use-module (gnu packages web) 27 #:use-module (gnu packages xdisorg)) 28 29 (define-public sbm 30 (package 31 (name "sbm") 32 (version "0.3") 33 (source 34 (origin 35 (method url-fetch) 36 (uri (string-append "https://github.com/equwal/sbm" 37 "/archive/refs/tags/v" version ".tar.gz")) 38 (file-name (string-append name "-" version ".tar.gz")) 39 ;; No release tag exists yet, so there is nothing to hash. Replace 40 ;; SBM_SHA256_TBD with the base32 hash that this prints: 41 ;; guix download <the URL above> 42 (sha256 (base32 "SBM_SHA256_TBD")))) 43 (build-system gnu-build-system) 44 (arguments 45 (list 46 #:make-flags 47 #~(list (string-append "PREFIX=" #$output)) 48 #:phases 49 #~(modify-phases %standard-phases 50 ;; There is no configure script, and nothing is compiled: the 51 ;; upstream "all" target only prints a reminder. 52 (delete 'configure) 53 (delete 'build) 54 (replace 'check 55 (lambda* (#:key tests? #:allow-other-keys) 56 (when tests? 57 ;; "make check" also runs shellcheck when it is installed, 58 ;; which would make the result depend on the build 59 ;; environment. The suite scripts the menu, the clipboard 60 ;; and curl: no display, no network. 61 (invoke "sh" "test/run.sh")))) 62 (add-after 'install 'install-doc 63 (lambda _ 64 (let* ((doc (string-append #$output "/share/doc/" #$name "-" 65 #$version)) 66 (examples (string-append doc "/examples"))) 67 (install-file "README" doc) 68 (install-file "TODO" doc) 69 (install-file "usertags" examples) 70 (install-file "engines" examples)))) 71 (add-after 'install-doc 'wrap-programs 72 (lambda* (#:key inputs #:allow-other-keys) 73 ;; bm calls bm-title and bm-commit by name, so $output/bin 74 ;; goes on the PATH as well as the runtime programs. 75 (let ((path 76 (cons (string-append #$output "/bin") 77 (map (lambda (file) 78 (dirname (search-input-file inputs file))) 79 '("bin/awk" 80 "bin/fzf" 81 "bin/dmenu" 82 "bin/xclip" 83 "bin/wl-copy" 84 "bin/xdg-open" 85 "bin/curl" 86 "bin/jq" 87 "bin/git"))))) 88 (for-each (lambda (program) 89 (wrap-program program 90 `("PATH" ":" prefix ,path))) 91 (find-files (string-append #$output "/bin"))))))))) 92 (inputs 93 (list coreutils 94 gawk 95 ;; A menu is required and either will do; both are wrapped in, so 96 ;; bm picks dmenu when there is a display and fzf otherwise. 97 dmenu 98 fzf 99 ;; Clipboard. 100 xclip 101 wl-clipboard 102 ;; Optional, but cheap and wrapped in so the tools just work: 103 ;; curl (bm-title, bm-check), jq (bm-import of Chromium JSON 104 ;; files), git (bm-commit), xdg-utils (opening URLs). 105 curl 106 jq 107 git 108 xdg-utils)) 109 (native-inputs 110 (list shellcheck)) 111 (home-page "https://github.com/equwal/sbm") 112 (synopsis "Bookmark manager made of POSIX sh scripts, driven by dmenu or fzf") 113 (description 114 "sbm keeps bookmarks in one tab separated file: URL, description, tags. 115 @command{bm} picks one with dmenu, or with fzf on a bare terminal, and then 116 opens it, copies it, edits it or deletes it. Text that is no bookmark is 117 opened as an address or searched for on the web. 118 119 The rest are small filters that read and write bookmark lines: 120 @command{bm-import} turns a browser's bookmarks into bookmark lines, 121 @command{bm-check} reports dead links, @command{bm-html} writes a searchable 122 web page, @command{bm-migrate} converts the old file format, 123 @command{bm-title} prints a page's title and @command{bm-commit} keeps the 124 bookmark file's history in git. 125 126 Everything is POSIX sh and POSIX utilities. Nothing is compiled.") 127 ;; Upstream has not chosen a licence yet and ships no LICENSE file. 128 ;; Replace SBM_LICENSE_TBD with a variable from (guix licenses), for 129 ;; example license:gpl3+. As written this is an unbound variable and 130 ;; evaluation fails, which is what a placeholder should do. 131 (license license:SBM_LICENSE_TBD))) 132 133 sbm