···18181919- [GoToSocial](https://gotosocial.org/), an ActivityPub social network server, written in Golang. Available as [services.gotosocial](#opt-services.gotosocial.enable).
20202121+- [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).
2222+2123- [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).
22242325- [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).
···11+{ lib
22+, stdenv
33+, fetchurl
44+, autoPatchelfHook
55+, nixosTests
66+}:
77+let
88+ inherit (stdenv.hostPlatform) system;
99+ throwSystem = throw "Unsupported system: ${system}";
1010+1111+ sources = lib.importJSON ./sources.json;
1212+ platform = sources.platforms.${system} or throwSystem;
1313+ inherit (sources) version;
1414+ inherit (platform) arch hash;
1515+in
1616+stdenv.mkDerivation {
1717+ pname = "typesense";
1818+ inherit version;
1919+ src = fetchurl {
2020+ url = "https://dl.typesense.org/releases/${version}/typesense-server-${version}-${arch}.tar.gz";
2121+ inherit hash;
2222+ };
2323+2424+ nativeBuildInputs = [
2525+ autoPatchelfHook
2626+ ];
2727+2828+ # The tar.gz contains no subdirectory
2929+ sourceRoot = ".";
3030+3131+ installPhase = ''
3232+ mkdir -p $out/bin
3333+ cp $sourceRoot/typesense-server $out/bin
3434+ '';
3535+3636+ passthru = {
3737+ tests = { inherit (nixosTests) typesense; };
3838+ updateScript = ./update.sh;
3939+ };
4040+4141+ meta = with lib; {
4242+ homepage = "https://typesense.org";
4343+ description = "Typesense is a fast, typo-tolerant search engine for building delightful search experiences.";
4444+ license = licenses.gpl3;
4545+ # There has been an attempt at building this from source, which were deemed
4646+ # unfeasible at the time of writing this (July 2023) for the following reasons.
4747+ # - Pre 0.25 would have been possible, but typesense has switched to bazel for 0.25+,
4848+ # so the build would break immediately next version
4949+ # - The new bazel build has many issues, only some of which were fixable:
5050+ # - preBuild requires export LANG="C.UTF-8", since onxxruntime contains a
5151+ # unicode file path that is handled incorrectly and otherwise leads to a build failure
5252+ # - bazel downloads extensions to the build systems at build time which have
5353+ # invalid shebangs that need to be fixed by patching rules_foreign_cc through
5454+ # bazel (so a patch in nix that adds a patch to the bazel WORKSPACE)
5555+ # - WORKSPACE has to be patched to use system cmake and ninja instead of downloaded toolchains
5656+ # - The cmake dependencies that are pulled in via bazel at build time will
5757+ # try to download stuff via cmake again, which is not possible in the sandbox.
5858+ # This is where I stopped trying for now.
5959+ # XXX: retry once typesense has officially released their bazel based build.
6060+ sourceProvenance = with sourceTypes; [ binaryNativeCode ];
6161+ platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
6262+ maintainers = with maintainers; [ oddlama ];
6363+ };
6464+}