mattermost: 6.3.6 -> 7.0.0
This commit is contained in:
parent
5e40d30200
commit
21738df66b
1 changed files with 44 additions and 94 deletions
|
@ -1,101 +1,51 @@
|
||||||
{ lib, stdenv, fetchurl, fetchFromGitHub, buildGoPackage, buildEnv
|
{ lib
|
||||||
|
, buildGo118Module
|
||||||
|
, fetchFromGitHub
|
||||||
|
, fetchurl
|
||||||
|
, nixosTests
|
||||||
|
}:
|
||||||
|
|
||||||
# The suffix for the Mattermost version.
|
buildGo118Module rec {
|
||||||
, versionSuffix ? "nixpkgs"
|
pname = "mattermost";
|
||||||
|
version = "7.0.0";
|
||||||
|
|
||||||
# The constant build date.
|
src = fetchFromGitHub {
|
||||||
, buildDate ? "1970-01-01"
|
owner = "mattermost";
|
||||||
|
repo = "mattermost-server";
|
||||||
# Set to true to set the build hash to the Nix store path.
|
rev = "v${version}";
|
||||||
, storePathAsBuildHash ? false }:
|
sha256 = "sha256-0sjVlN+YZDhIXxch4DUkvBGDS0KUdGFflT87z1/udd4=";
|
||||||
|
|
||||||
let
|
|
||||||
version = "6.3.6";
|
|
||||||
|
|
||||||
goPackagePath = "github.com/mattermost/mattermost-server";
|
|
||||||
|
|
||||||
mattermost-server-build = buildGoPackage rec {
|
|
||||||
pname = "mattermost-server";
|
|
||||||
inherit version goPackagePath;
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "mattermost";
|
|
||||||
repo = "mattermost-server";
|
|
||||||
rev = "v${version}";
|
|
||||||
sha256 = "905zxMucDTxxrLoh5ZoAExW4eFmi+xa98aI3EpJZ2Og=";
|
|
||||||
};
|
|
||||||
|
|
||||||
ldflags = [
|
|
||||||
"-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: {
|
webapp = fetchurl {
|
||||||
buildPhase = ''
|
url = "https://releases.mattermost.com/${version}/mattermost-${version}-linux-amd64.tar.gz";
|
||||||
origGo="$(type -p go)"
|
sha256 = "sha256-O2bJsj2YjeaRfqPrehgwn8bNHaYwqcrcU1htCYurPlw=";
|
||||||
|
|
||||||
# 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 = "JDsCDZEtbeBTYuzOSwrxFNRKXy+9KXirjaCz6ODP5uw=";
|
|
||||||
};
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out
|
|
||||||
tar --strip 1 --directory $out -xf $src \
|
|
||||||
mattermost/client \
|
|
||||||
mattermost/i18n \
|
|
||||||
mattermost/fonts \
|
|
||||||
mattermost/templates \
|
|
||||||
mattermost/config
|
|
||||||
|
|
||||||
# For some reason a bunch of these files are +x...
|
|
||||||
find $out -type f -exec chmod -x {} \;
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
vendorSha256 = "sha256-0sKuk0klxeep8J96RntDP9DHsVM4vrOmsKXiaWurVis=";
|
||||||
buildEnv {
|
|
||||||
name = "mattermost-${version}";
|
|
||||||
paths = [ mattermost-server mattermost-webapp ];
|
|
||||||
|
|
||||||
meta = with lib; {
|
subPackages = [ "cmd/mattermost" ];
|
||||||
description = "Open-source, self-hosted Slack-alternative";
|
|
||||||
homepage = "https://www.mattermost.org";
|
ldflags = [
|
||||||
sourceProvenance = with sourceTypes; [
|
"-s"
|
||||||
fromSource
|
"-w"
|
||||||
binaryNativeCode # mattermost-webapp
|
"-X github.com/mattermost/mattermost-server/v6/model.Version=${version}"
|
||||||
];
|
];
|
||||||
license = with licenses; [ agpl3 asl20 ];
|
|
||||||
maintainers = with maintainers; [ fpletz ryantm numinit ];
|
postInstall = ''
|
||||||
platforms = platforms.unix;
|
tar --strip 1 --directory $out -xf $webapp \
|
||||||
};
|
mattermost/{client,i18n,fonts,templates,config}
|
||||||
}
|
|
||||||
|
# For some reason a bunch of these files are executable
|
||||||
|
find $out/{client,i18n,fonts,templates,config} -type f -exec chmod -x {} \;
|
||||||
|
'';
|
||||||
|
|
||||||
|
passthru.tests.mattermost = nixosTests.mattermost;
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Mattermost is an open source platform for secure collaboration across the entire software development lifecycle";
|
||||||
|
homepage = "https://www.mattermost.org";
|
||||||
|
license = with licenses; [ agpl3 asl20 ];
|
||||||
|
maintainers = with maintainers; [ fpletz ryantm numinit kranzes ];
|
||||||
|
platforms = [ "x86_64-linux" ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue