packaging/nix/default.nix (3455 bytes)
1 { lib 2 , stdenvNoCC 3 , fetchFromGitHub 4 , makeWrapper 5 , gawk 6 , coreutils 7 , fzf 8 , dmenu 9 , xclip 10 , wl-clipboard 11 , xdg-utils 12 , curl 13 , jq 14 , git 15 # dmenu is X11 only, so it is off on Darwin and fzf carries the menu there. 16 , withDmenu ? stdenvNoCC.hostPlatform.isLinux 17 , withWaylandClipboard ? stdenvNoCC.hostPlatform.isLinux 18 # Optional at runtime: bm-title and bm-check (curl), bm-import of Chromium 19 # JSON files (jq), bm-commit (git). Cheap enough to keep on by default. 20 , withCurl ? true 21 , withJq ? true 22 , withGit ? true 23 }: 24 25 stdenvNoCC.mkDerivation (finalAttrs: { 26 pname = "sbm"; 27 version = "0.3"; 28 29 src = fetchFromGitHub { 30 owner = "equwal"; 31 repo = "sbm"; 32 rev = "v${finalAttrs.version}"; 33 # No release tag exists yet, so there is nothing to hash. Replace 34 # SBM_SHA256_TBD with the SRI hash; lib.fakeHash makes the build print 35 # the real one. The token is left here so it shows up in a grep. 36 hash = "SBM_SHA256_TBD"; 37 }; 38 39 nativeBuildInputs = [ makeWrapper ]; 40 41 # Nothing is compiled. The upstream "all" target only prints a reminder. 42 dontBuild = true; 43 44 doCheck = true; 45 46 checkPhase = '' 47 runHook preCheck 48 # "make check" also runs shellcheck when it is installed, which would 49 # make the result depend on what is in the build environment. The suite 50 # itself scripts the menu, the clipboard and curl: no display, no network. 51 sh test/run.sh 52 runHook postCheck 53 ''; 54 55 installPhase = '' 56 runHook preInstall 57 make install PREFIX="$out" 58 install -Dm444 README -t "$out/share/doc/sbm" 59 install -Dm444 TODO -t "$out/share/doc/sbm" 60 install -Dm444 usertags engines -t "$out/share/doc/sbm/examples" 61 runHook postInstall 62 ''; 63 64 postFixup = 65 let 66 runtimeDeps = 67 # fzf is always there: it is the menu that needs no display. 68 # xclip, wl-clipboard, dmenu and xdg-utils are X11 or Wayland 69 # programs and do not evaluate on Darwin. 70 [ gawk coreutils fzf ] 71 ++ lib.optionals stdenvNoCC.hostPlatform.isLinux [ xclip xdg-utils ] 72 ++ lib.optional withDmenu dmenu 73 ++ lib.optional withWaylandClipboard wl-clipboard 74 ++ lib.optional withCurl curl 75 ++ lib.optional withJq jq 76 ++ lib.optional withGit git; 77 in 78 '' 79 # bm calls bm-title and bm-commit by name, so $out/bin goes on the 80 # PATH as well as the runtime programs. 81 for f in "$out"/bin/*; do 82 wrapProgram "$f" \ 83 --prefix PATH : "$out/bin:${lib.makeBinPath runtimeDeps}" 84 done 85 ''; 86 87 meta = { 88 description = "Bookmark manager made of POSIX sh scripts, driven by dmenu or fzf"; 89 longDescription = '' 90 sbm keeps bookmarks in one tab separated file: URL, description, tags. 91 bm picks one from dmenu, or from fzf on a bare terminal, and opens it, 92 copies it, edits it or deletes it. Text that is no bookmark is opened as 93 an address or searched for on the web. The other programs are small 94 filters over bookmark lines: bm-import, bm-check, bm-html, bm-migrate, 95 bm-title and bm-commit. 96 ''; 97 homepage = "https://github.com/equwal/sbm"; 98 # Upstream has not chosen a licence yet and ships no LICENSE file. 99 # This must become lib.licenses.<id> (an attribute, not a string) before 100 # the package can go into nixpkgs; a string fails the meta check. 101 license = "SBM_LICENSE_TBD"; 102 mainProgram = "bm"; 103 maintainers = [ ]; 104 platforms = lib.platforms.unix; 105 }; 106 })