nixpkgs/pkgs/servers/minio/default.nix
Johannes Schleifenbaum f05000302a
minio: set version to a valid datetime string
Co-authored-by: 06kellyjac <dev@j-k.io>
2021-05-11 12:28:48 +02:00

57 lines
1.6 KiB
Nix

{ lib, buildGoModule, fetchFromGitHub, nixosTests }:
let
# The web client verifies, that the server version is a valid datetime string:
# https://github.com/minio/minio/blob/3a0e7347cad25c60b2e51ff3194588b34d9e424c/browser/app/js/web.js#L51-L53
#
# Example:
# versionToTimestamp "2021-04-22T15-44-28Z"
# => "2021-04-22T15:44:28Z"
versionToTimestamp = version:
let
splitTS = builtins.elemAt (builtins.split "(.*)(T.*)" version) 1;
in
builtins.concatStringsSep "" [ (builtins.elemAt splitTS 0) (builtins.replaceStrings [ "-" ] [ ":" ] (builtins.elemAt splitTS 1)) ];
in
buildGoModule rec {
pname = "minio";
version = "2021-04-22T15-44-28Z";
src = fetchFromGitHub {
owner = "minio";
repo = "minio";
rev = "RELEASE.${version}";
sha256 = "147a4vgf2hdpbndska443axzvxx56bmc0011m3cq4ca1vm783k8q";
};
vendorSha256 = "0qj1zab97q8s5gy7a304wqi832y8m083cnk8hllz8lz9yjcw6q92";
doCheck = false;
subPackages = [ "." ];
patchPhase = ''
sed -i "s/Version.*/Version = \"${versionToTimestamp version}\"/g" cmd/build-constants.go
sed -i "s/ReleaseTag.*/ReleaseTag = \"RELEASE.${version}\"/g" cmd/build-constants.go
sed -i "s/CommitID.*/CommitID = \"${src.rev}\"/g" cmd/build-constants.go
'';
postConfigure = ''
export CGO_ENABLED=0
'';
buildFlagsArray = [
"-tags=kqueue"
];
passthru.tests.minio = nixosTests.minio;
meta = with lib; {
homepage = "https://www.minio.io/";
description = "An S3-compatible object storage server";
maintainers = with maintainers; [ eelco bachp ];
platforms = platforms.unix;
license = licenses.asl20;
};
}