mattermost: 5.37.5 -> 6.2.1
Add overridable arguments: - versionSuffix (default: nixpkgs) - buildDate (default: 1970-01-01) - storePathAsBuildHash (default: false)
This commit is contained in:
parent
f72a655920
commit
d1c4160076
1 changed files with 49 additions and 13 deletions
|
@ -1,35 +1,71 @@
|
|||
{ lib, stdenv, fetchurl, fetchFromGitHub, buildGoModule, buildEnv }:
|
||||
{ lib, stdenv, fetchurl, fetchFromGitHub, buildGo117Package, buildEnv
|
||||
|
||||
# The suffix for the Mattermost version.
|
||||
, versionSuffix ? "nixpkgs"
|
||||
|
||||
# The constant build date.
|
||||
, buildDate ? "1970-01-01"
|
||||
|
||||
# Set to true to set the build hash to the Nix store path.
|
||||
, storePathAsBuildHash ? false }:
|
||||
|
||||
let
|
||||
version = "5.37.5";
|
||||
version = "6.2.1";
|
||||
|
||||
mattermost-server = buildGoModule rec {
|
||||
goPackagePath = "github.com/mattermost/mattermost-server";
|
||||
|
||||
mattermost-server-build = buildGo117Package rec {
|
||||
pname = "mattermost-server";
|
||||
inherit version;
|
||||
inherit version goPackagePath;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "mattermost";
|
||||
repo = pname;
|
||||
repo = "mattermost-server";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-ddK7gxWl1arCtW2vqmon28AAeyZQPYlbGj3QtOlqtiU=";
|
||||
sha256 = "WjBsbW7aEI+MX2I1LrEJh8JgNQ4Do7PpeshXgaQAk1s=";
|
||||
};
|
||||
|
||||
vendorSha256 = null;
|
||||
doCheck = false;
|
||||
|
||||
ldflags = [
|
||||
"-s" "-w" "-X github.com/mattermost/mattermost-server/v${lib.versions.major version}/model.BuildNumber=${version}"
|
||||
"-s" "-w"
|
||||
"-X ${goPackagePath}/model.BuildNumber=${version}${lib.optionalString (versionSuffix != null) "-${versionSuffix}"}"
|
||||
"-X ${goPackagePath}/model.BuildDate=${buildDate}"
|
||||
"-X ${goPackagePath}/model.BuildEnterpriseReady=false"
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
mattermost-server = if storePathAsBuildHash then mattermost-server-build.overrideAttrs (orig: {
|
||||
buildPhase = ''
|
||||
origGo="$(type -p go)"
|
||||
|
||||
# Override the Go binary to set the build hash in -ldflags to $out.
|
||||
# Technically this is more accurate than a Git hash!
|
||||
# nixpkgs does not appear to support environment variables in ldflags
|
||||
# for go packages, so we have to rewrite -ldflags before calling go.
|
||||
go() {
|
||||
local args=()
|
||||
local ldflags="-X ${goPackagePath}/model.BuildHash=$out"
|
||||
local found=0
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == -ldflags=* ]] && [ $found -eq 0 ]; then
|
||||
arg="-ldflags=''${ldflags} ''${arg#-ldflags=}"
|
||||
found=1
|
||||
fi
|
||||
args+=("$arg")
|
||||
done
|
||||
"$origGo" "''${args[@]}"
|
||||
}
|
||||
|
||||
${orig.buildPhase}
|
||||
'';
|
||||
}) else mattermost-server-build;
|
||||
|
||||
mattermost-webapp = stdenv.mkDerivation {
|
||||
pname = "mattermost-webapp";
|
||||
inherit version;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://releases.mattermost.com/${version}/mattermost-${version}-linux-amd64.tar.gz";
|
||||
sha256 = "sha256-G6L8Ct6PtARg2LKxcoFyg9vrDJXIKGByxovquMc6p00=";
|
||||
sha256 = "pV/MwMCK8vMzASXuM1+ePcarIgrcNAkFLEdmPya911E=";
|
||||
};
|
||||
|
||||
installPhase = ''
|
||||
|
@ -52,7 +88,7 @@ in
|
|||
description = "Open-source, self-hosted Slack-alternative";
|
||||
homepage = "https://www.mattermost.org";
|
||||
license = with licenses; [ agpl3 asl20 ];
|
||||
maintainers = with maintainers; [ fpletz ryantm ];
|
||||
maintainers = with maintainers; [ fpletz ryantm numinit ];
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue