···1819- [GoToSocial](https://gotosocial.org/), an ActivityPub social network server, written in Golang. Available as [services.gotosocial](#opt-services.gotosocial.enable).
200021- [Anuko Time Tracker](https://github.com/anuko/timetracker), a simple, easy to use, open source time tracking system. Available as [services.anuko-time-tracker](#opt-services.anuko-time-tracker.enable).
2223- [sitespeed-io](https://sitespeed.io), a tool that can generate metrics (timings, diagnostics) for websites. Available as [services.sitespeed-io](#opt-services.sitespeed-io.enable).
···1819- [GoToSocial](https://gotosocial.org/), an ActivityPub social network server, written in Golang. Available as [services.gotosocial](#opt-services.gotosocial.enable).
2021+- [Typesense](https://github.com/typesense/typesense), a fast, typo-tolerant search engine for building delightful search experiences. Available as [services.typesense](#opt-services.typesense.enable).
22+23- [Anuko Time Tracker](https://github.com/anuko/timetracker), a simple, easy to use, open source time tracking system. Available as [services.anuko-time-tracker](#opt-services.anuko-time-tracker.enable).
2425- [sitespeed-io](https://sitespeed.io), a tool that can generate metrics (timings, diagnostics) for websites. Available as [services.sitespeed-io](#opt-services.sitespeed-io.enable).
···1+{ lib
2+, stdenv
3+, fetchurl
4+, autoPatchelfHook
5+, nixosTests
6+}:
7+let
8+ inherit (stdenv.hostPlatform) system;
9+ throwSystem = throw "Unsupported system: ${system}";
10+11+ sources = lib.importJSON ./sources.json;
12+ platform = sources.platforms.${system} or throwSystem;
13+ inherit (sources) version;
14+ inherit (platform) arch hash;
15+in
16+stdenv.mkDerivation {
17+ pname = "typesense";
18+ inherit version;
19+ src = fetchurl {
20+ url = "https://dl.typesense.org/releases/${version}/typesense-server-${version}-${arch}.tar.gz";
21+ inherit hash;
22+ };
23+24+ nativeBuildInputs = [
25+ autoPatchelfHook
26+ ];
27+28+ # The tar.gz contains no subdirectory
29+ sourceRoot = ".";
30+31+ installPhase = ''
32+ mkdir -p $out/bin
33+ cp $sourceRoot/typesense-server $out/bin
34+ '';
35+36+ passthru = {
37+ tests = { inherit (nixosTests) typesense; };
38+ updateScript = ./update.sh;
39+ };
40+41+ meta = with lib; {
42+ homepage = "https://typesense.org";
43+ description = "Typesense is a fast, typo-tolerant search engine for building delightful search experiences.";
44+ license = licenses.gpl3;
45+ # There has been an attempt at building this from source, which were deemed
46+ # unfeasible at the time of writing this (July 2023) for the following reasons.
47+ # - Pre 0.25 would have been possible, but typesense has switched to bazel for 0.25+,
48+ # so the build would break immediately next version
49+ # - The new bazel build has many issues, only some of which were fixable:
50+ # - preBuild requires export LANG="C.UTF-8", since onxxruntime contains a
51+ # unicode file path that is handled incorrectly and otherwise leads to a build failure
52+ # - bazel downloads extensions to the build systems at build time which have
53+ # invalid shebangs that need to be fixed by patching rules_foreign_cc through
54+ # bazel (so a patch in nix that adds a patch to the bazel WORKSPACE)
55+ # - WORKSPACE has to be patched to use system cmake and ninja instead of downloaded toolchains
56+ # - The cmake dependencies that are pulled in via bazel at build time will
57+ # try to download stuff via cmake again, which is not possible in the sandbox.
58+ # This is where I stopped trying for now.
59+ # XXX: retry once typesense has officially released their bazel based build.
60+ sourceProvenance = with sourceTypes; [ binaryNativeCode ];
61+ platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
62+ maintainers = with maintainers; [ oddlama ];
63+ };
64+}