diff options
author | Profpatsch <mail@profpatsch.de> | 2024-10-29T17·20+0100 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2024-12-10T15·34+0000 |
commit | 84e9c7f10423ecff48bb490e8889426a27329caf (patch) | |
tree | 0d1dac7be8275c4012b67f5476ef95e016dbad95 | |
parent | 1cc4200b3ed177bc45b143d9ac5110f7dcf74d24 (diff) |
feat(users/Profpatsch): add a example for omega search r/8994
Uses xapian under the hood to index the contents, then makes it searchable with a CGI binary on http://localhost:8080 We could in theory index every -doc output this way to get local documentation search for the current system (similar to `man-db`). Change-Id: I2588c8f100841cfbed570bb65d376b79747c06ee Reviewed-on: https://cl.tvl.fyi/c/depot/+/12710 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
-rw-r--r-- | users/Profpatsch/omega.nix | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/users/Profpatsch/omega.nix b/users/Profpatsch/omega.nix new file mode 100644 index 000000000000..39d27628c4a9 --- /dev/null +++ b/users/Profpatsch/omega.nix @@ -0,0 +1,62 @@ +{ depot, pkgs, lib, ... }: +let + + # fix: https://github.com/NixOS/nixpkgs/pull/352144 + omega-templates = pkgs.stdenv.mkDerivation { + name = "omega-templates"; + phases = [ "unpackPhase" "installPhase" ]; + src = pkgs.xapian-omega.src; + installPhase = '' + mkdir -p $out/share/omega + mv templates $out/share/omega + ''; + }; + + omega-test = pkgs.stdenv.mkDerivation { + name = "omega-test"; + phases = [ "installPhase" ]; + installPhase = '' + mkdir localhost + ln -sT localhost localhost:8080 + mkdir ./default + cp -r ${lib.getOutput "doc" pkgs.tipidee}/share/doc/tipidee ./default/tipidee + cp -r ${lib.getOutput "doc" pkgs.tipidee}/share/doc/tipidee ./localhost/tipidee + + ln -sT ${pkgs.writers.writeText "omega.conf" '' + database_dir ./omega.db + log_dir /tmp/omega.log + template_dir ${omega-templates}/share/omega/templates + ''} omega.conf + + ${pkgs.tipidee}/bin/tipidee-config -o tipidee.cdb -i ${pkgs.writers.writeText "tipidee.conf" '' + domain localhost + cgi /omega + ''} + + cp ${pkgs.xapian-omega}/lib/xapian-omega/bin/omega ./localhost + + mkdir omega.db + ${pkgs.xapian-omega}/bin/omindex --db ./omega.db/default --url / ./default + + mkdir -p $out + cp -r ./* $out + ''; + }; + + run-omega = pkgs.writers.writeBash "run-omega" '' + cd ${omega-test} + emptyenv -p \ + ${pkgs.s6-networking}/bin/s6-tcpserver 127.0.0.1 8080 \ + ${pkgs.s6-networking}/bin/s6-tcpserver-access \ + ${pkgs.tipidee}/bin/tipideed -f tipidee.cdb + ''; + + +in +{ + inherit + run-omega + omega-test + ; +} + |