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]