From bb1fbbdc005e9e10067407b541930ee196d4951b Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Thu, 19 Nov 2026 14:29:16 -0600 Subject: [PATCH] build(diigo-cache): ship the docs, and name the commit a build came from systemctl status's Docs: line now leads to the README, at a profile path that survives upgrades, and, for a build from a clean tree, to the commit's source on git.inference.coop. The version ends in the short rev (-dirty for a dirty tree), and share/doc/diigo-cache/REVISION holds the full one. pnpmDeps keeps version 0.0.0, so a new commit doesn't refetch the deps. Generated-by: Claude Opus 5.5 --- diigo-cache/flake.nix | 22 +++++++++++++++++++--- diigo-cache/nix/diigo-cache.service | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/diigo-cache/flake.nix b/diigo-cache/flake.nix index dfbdc93..969999b 100644 --- a/diigo-cache/flake.nix +++ b/diigo-cache/flake.nix @@ -10,6 +10,12 @@ pkgs = nixpkgs.legacyPackages.${system}; inherit (pkgs) lib; + # the commit a build came from; a dirty tree's ends in -dirty + shortRev = self.shortRev or self.dirtyShortRev or "unknown"; + # a clean tree's commit, whose source anyone can read; systemctl + # status lists it under Docs: + sourceUrl = lib.optionalString (self ? rev) "https://git.inference.coop/dckc/captoys/src/commit/${self.rev}/diigo-cache"; + # nixpkgs has no workerd of its own; wrangler carries a patched one workerd = pkgs.runCommand "workerd-${version}" { } '' @@ -39,7 +45,7 @@ diigo-cache = pkgs.stdenv.mkDerivation (finalAttrs: { pname = "diigo-cache"; - version = "0.0.0"; + version = "0.0.0-${shortRev}"; inherit src; sourceRoot = "${finalAttrs.src.name}/diigo-cache"; @@ -50,7 +56,9 @@ pkgs.wrangler ]; pnpmDeps = pkgs.fetchPnpmDeps { - inherit (finalAttrs) pname version src sourceRoot; + inherit (finalAttrs) pname src sourceRoot; + # not the rev: the deps don't change with each commit + version = "0.0.0"; pnpm = pkgs.pnpm_10; fetcherVersion = 3; hash = "sha256-sn/juOL2mhyy3i57GCUKA2X8SPyR9FwY4KoxdkgZa0M="; @@ -82,7 +90,15 @@ EOF chmod +x $out/bin/diigo-cache-serve cp ${./nix/diigo-cache.socket} $out/lib/systemd/system/diigo-cache.socket - cp ${./nix/diigo-cache.service} $out/lib/systemd/system/diigo-cache.service + substitute ${./nix/diigo-cache.service} $out/lib/systemd/system/diigo-cache.service \ + --replace-fail '@source@' '${sourceUrl}' + # the docs, at a path the profile keeps across upgrades + doc=$out/share/doc/diigo-cache + mkdir -p $doc + cp ${./README.md} $doc/README.md + cp ${./CONTRIBUTING.md} $doc/CONTRIBUTING.md + cp -r ${./doc} $doc/doc + echo ${self.rev or self.dirtyRev or "unknown"} > $doc/REVISION runHook postInstall ''; }); diff --git a/diigo-cache/nix/diigo-cache.service b/diigo-cache/nix/diigo-cache.service index 6cd72d8..d5229ef 100644 --- a/diigo-cache/nix/diigo-cache.service +++ b/diigo-cache/nix/diigo-cache.service @@ -1,5 +1,7 @@ [Unit] Description=diigo-cache and webapp (workerd) +# the profile's README, and the commit's source (a clean build's only) +Documentation=file:///nix/var/nix/profiles/diigo-cache/share/doc/diigo-cache/README.md @source@ Requires=diigo-cache.socket [Service]