diff --git a/users/sterni/acme/plumb/default.nix b/users/sterni/acme/plumb/default.nix new file mode 100644 index 000000000..0477e48e9 --- /dev/null +++ b/users/sterni/acme/plumb/default.nix @@ -0,0 +1,39 @@ +{ pkgs, lib, ... }: + +pkgs.stdenvNoCC.mkDerivation { + name = "sterni-plumb"; + + src = builtins.path { + path = ./.; + filter = path: _: !(lib.hasSuffix "default.nix" path); + }; + + dontConfigure = true; + dontBuild = true; + + # The write will fail if there's something wrong with the rules, + # though it only detects some problems. + checkPhase = '' + runHook preInstall + export NAMESPACE="$(mktemp -d)" + 9 plumber -f & + pid="$!" + until [[ -e "$NAMESPACE/plumb" ]]; do + sleep 0.1 + done + 9 9p write plumb/rules < sterni.plumbing + kill "$pid" + runHook postInstall + ''; + doCheck = true; + checkInputs = [ + pkgs.plan9port + ]; + + installPhase = '' + runHook preInstall + mkdir -p "$out" + mv * "$out/" + runHook postInstall + ''; +} diff --git a/users/sterni/acme/plumb/man b/users/sterni/acme/plumb/man new file mode 100644 index 000000000..ddc2259c4 --- /dev/null +++ b/users/sterni/acme/plumb/man @@ -0,0 +1,4 @@ +# Man pages (taken from /plumb/basic), e.g. man(1) +type is text +data matches '([a-zA-Z¡-0-9_\-./]+)\(([1-8])\)' +plumb start rc -c 'man '$2' '$1' >[2=1] | nobs | plumb -i -d edit -a ''action=showdata filename=/man/'$1'('$2')''' diff --git a/users/sterni/acme/plumb/sterni.plumbing b/users/sterni/acme/plumb/sterni.plumbing new file mode 100644 index 000000000..42af1d5c8 --- /dev/null +++ b/users/sterni/acme/plumb/sterni.plumbing @@ -0,0 +1,12 @@ +# TODO(sterni): are rules for :linenumber etc. needed or acme default? +# TODO(sterni): file: urls +# TODO(sterni): xdg-open for mail addresses, images, pdfs etc. +# TODO(sterni): git + +editor = acme +include man + +depot = /home/lukas/src/depot +include tvl + +include urls diff --git a/users/sterni/acme/plumb/tvl b/users/sterni/acme/plumb/tvl new file mode 100644 index 000000000..0679917e7 --- /dev/null +++ b/users/sterni/acme/plumb/tvl @@ -0,0 +1,71 @@ +# TODO(sterni): document TVL short links, +# for now see //tools/cheddar, //web/atward, //tools/magrathea +# and //ops/modules/monorepo-gerrit. +# TODO(sterni): r/([0-9]+) + +# TVL short links that go to the browser, e.g. cl/8413, b/187 + +type is text +data matches 'cl/([0-9]+)' +data set https://cl.tvl.fyi/c/depot/+/$1 +plumb to web +plumb start web $data + +type is text +data matches 'b/([0-9]+)' +data set https://b.tvl.fyi/issues/$1 +plumb to web +plumb start web $data + +# TVL target short links + +# TODO(sterni): implement subtargets +# TODO(sterni): can we add an acme address to target paths somehow? + +# TODO(sterni): look at //tools/magrathea's parsing. +depotpathchar = '[^:.,!"'' ]' +depotpath = '//('$depotpathchar'+)' + +# TVL short links to files in depot, open in local editor, e.g. +# +# - //users/sterni/acme/plumb/tvl, +# - //default.nix, +# - //nix/readTree/README.md, +# - //tools/magrathea/mg.scm +# +# We impose the same restrictions for the initial path, +# but are liberal in the file name + +type is text +data matches '//('$depotchar'+/)?([^ ]*'$depotpathchar')' +arg isfile $depot/$1$2 +data set $file +plumb to edit +plumb client $editor + +# TVL short links to directories in depot, mapped to default.nix, e.g. //nix/readTree + +type is text +data matches $depotpath +arg isfile $depot/$1/default.nix +data set $file +plumb to edit +plumb client $editor + +# TVL short links to targets that aren't expressed by default.nix, e.g. //third_party/lisp/alexandria + +type is text +data matches $depotpath +arg isfile $depot/$1.nix +data set $file +plumb to edit +plumb client $editor + +# TVL short links to directories in depot (without default.nix), e.g. //ops/machines + +type is text +data matches $depotpath +arg isdir $depot/$1 +data set $dir +plumb to edit +plumb client $editor diff --git a/users/sterni/acme/plumb/urls b/users/sterni/acme/plumb/urls new file mode 100644 index 000000000..087743bcb --- /dev/null +++ b/users/sterni/acme/plumb/urls @@ -0,0 +1,7 @@ +# URLs, e.g. https://tvl.fyi +# Based on /plumb/basic, but with most protocols removed +# TODO(sterni): add default case to xdg-open +type is text +data matches '(https?)://[a-zA-Z0-9_@\-]+([.:][a-zA-Z0-9_@\-]+)*/?[a-zA-Z0-9_?,%#~&/\-+=]+([:.][a-zA-Z0-9_?,%#~&/\-+=]+)*' +plumb to web +plumb start web $0