{ lib, stdenv, rustPlatform, fetchFromGitea, openssl, pkg-config, protobuf, cacert, nixosTests, }: let generic = { version, hash, cargoHash, cargoPatches ? [ ], eol ? false, broken ? false, }: rustPlatform.buildRustPackage { pname = "garage"; inherit version; src = fetchFromGitea { domain = "git.deuxfleurs.fr"; owner = "Deuxfleurs"; repo = "garage"; rev = "v${version}"; inherit hash; }; postPatch = '' # Starting in 0.9.x series, Garage is using mold in local development # and this leaks in this packaging, we remove it to use the default linker. rm .cargo/config.toml || true ''; inherit cargoHash cargoPatches; nativeBuildInputs = [ protobuf pkg-config ]; buildInputs = [ openssl ]; checkInputs = [ cacert ]; OPENSSL_NO_VENDOR = true; # See https://git.deuxfleurs.fr/Deuxfleurs/garage/src/tag/v0.8.2/nix/compile.nix#L192-L198 # on version changes for checking if changes are required here buildFeatures = [ "kubernetes-discovery" "bundled-libs" ] ++ lib.optional (lib.versionOlder version "1.0") "sled" ++ [ "metrics" "k2v" "telemetry-otlp" "lmdb" "sqlite" "consul-discovery" ]; # To make integration tests pass, we include the optional k2v feature here, # but in buildFeatures only for version 0.8+, where it's enabled by default. # See: https://garagehq.deuxfleurs.fr/documentation/reference-manual/k2v/ checkFeatures = [ "k2v" "kubernetes-discovery" "bundled-libs" ] ++ lib.optional (lib.versionOlder version "1.0") "sled" ++ [ "lmdb" "sqlite" ]; disabledTests = [ # Upstream told us this test is flakey. "k2v::poll::test_poll_item" ]; passthru.tests = lib.optionalAttrs (lib.versionAtLeast version "1") nixosTests."garage_${lib.versions.major version}"; meta = { description = "S3-compatible object store for small self-hosted geo-distributed deployments"; changelog = "https://git.deuxfleurs.fr/Deuxfleurs/garage/releases/tag/v${version}"; homepage = "https://garagehq.deuxfleurs.fr"; license = lib.licenses.agpl3Only; maintainers = with lib.maintainers; [ adamcstephens nickcao _0x4A6F teutat3s ]; knownVulnerabilities = (lib.optional eol "Garage version ${version} is EOL"); inherit broken; mainProgram = "garage"; }; }; in rec { garage_0_9_4 = generic { version = "0.9.4"; hash = "sha256-2ZaxenwaVGYYUjUJaGgnGpZNQprQV9+Jns2sXM6cowk="; cargoHash = "sha256-ittesFz1GUGipQecsmMA+GEaVoUY+C9DtEvsO0HFNCc="; cargoPatches = [ ./update-time.patch ]; eol = true; }; garage_1_2_0 = generic { version = "1.2.0"; hash = "sha256-JoOwCbChSL7mjegnLHOH2Abfmsnw9BwNsjFj7nqBN6o="; cargoHash = "sha256-vcvD0Fn/etnAuXrM3+rj16cqpEmW2nzRmrjXsftKTFE="; }; garage_2_0_0 = generic { version = "2.0.0"; hash = "sha256-dn7FoouF+5qmW6fcC20bKQSc6D2G9yrWdBK3uN3bF58="; cargoHash = "sha256-6VM/EesrUIaQOeDGqzb0kOqMz4hW7zBJUnaRQ9C3cqc="; }; garage_0_9 = garage_0_9_4; garage_1 = garage_1_2_0; garage_2 = garage_2_0_0; garage = garage_1; }