about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/mattermost/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/servers/mattermost/default.nix')
-rw-r--r--nixpkgs/pkgs/servers/mattermost/default.nix127
1 files changed, 40 insertions, 87 deletions
diff --git a/nixpkgs/pkgs/servers/mattermost/default.nix b/nixpkgs/pkgs/servers/mattermost/default.nix
index 77ae99a9297e..20ffc299d018 100644
--- a/nixpkgs/pkgs/servers/mattermost/default.nix
+++ b/nixpkgs/pkgs/servers/mattermost/default.nix
@@ -1,97 +1,50 @@
-{ lib, stdenv, fetchurl, fetchFromGitHub, buildGoPackage, 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 = "6.3.3";
-
-  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 = "OSN8Bscgv7rPfKIfZ3ZnegdgsygFpSM7/vGWojj0P3k=";
-    };
+{ lib
+, buildGoModule
+, fetchFromGitHub
+, fetchurl
+, nixosTests
+}:
+
+buildGoModule rec {
+  pname = "mattermost";
+  version = "7.1.1";
+
+  src = fetchFromGitHub {
+    owner = "mattermost";
+    repo = "mattermost-server";
+    rev = "v${version}";
+    sha256 = "sha256-eo+NfV4S8utWdmYvp+F0sNlgptIC0zNXWXMrh7xfqN8=";
+  };
 
-    ldflags = [
-      "-s" "-w"
-      "-X ${goPackagePath}/model.BuildNumber=${version}${lib.optionalString (versionSuffix != null) "-${versionSuffix}"}"
-      "-X ${goPackagePath}/model.BuildDate=${buildDate}"
-      "-X ${goPackagePath}/model.BuildEnterpriseReady=false"
-    ];
+  webapp = fetchurl {
+    url = "https://releases.mattermost.com/${version}/mattermost-${version}-linux-amd64.tar.gz";
+    sha256 = "sha256-NqCZyUdbw3OrQRuPH6NSWYhHKG3R4QHlH9IVIbIPEeU=";
   };
 
-  mattermost-server = if storePathAsBuildHash then mattermost-server-build.overrideAttrs (orig: {
-    buildPhase = ''
-      origGo="$(type -p go)"
+  vendorSha256 = "sha256-98riYN6MaBsKyaueogjXI7x3Lcionk0xcGt4DH684QU=";
 
-      # 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[@]}"
-      }
+  subPackages = [ "cmd/mattermost" ];
 
-      ${orig.buildPhase}
-    '';
-  }) else mattermost-server-build;
+  ldflags = [
+    "-s"
+    "-w"
+    "-X github.com/mattermost/mattermost-server/v6/model.Version=${version}"
+  ];
 
-  mattermost-webapp = stdenv.mkDerivation {
-    pname = "mattermost-webapp";
-    inherit version;
+  postInstall = ''
+    tar --strip 1 --directory $out -xf $webapp \
+      mattermost/{client,i18n,fonts,templates,config}
 
-    src = fetchurl {
-      url = "https://releases.mattermost.com/${version}/mattermost-${version}-linux-amd64.tar.gz";
-      sha256 = "Og9DUGyE4cWYF7EQP/8szIrWM1Ldqnpqc+HW+L7XApo=";
-    };
+    # For some reason a bunch of these files are executable
+    find $out/{client,i18n,fonts,templates,config} -type f -exec chmod -x {} \;
+  '';
 
-    installPhase = ''
-      mkdir -p $out
-      tar --strip 1 --directory $out -xf $src \
-        mattermost/client \
-        mattermost/i18n \
-        mattermost/fonts \
-        mattermost/templates \
-        mattermost/config
+  passthru.tests.mattermost = nixosTests.mattermost;
 
-      # For some reason a bunch of these files are +x...
-      find $out -type f -exec chmod -x {} \;
-    '';
+  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; [ ryantm numinit kranzes ];
   };
-
-in
-  buildEnv {
-    name = "mattermost-${version}";
-    paths = [ mattermost-server mattermost-webapp ];
-
-    meta = with lib; {
-      description = "Open-source, self-hosted Slack-alternative";
-      homepage = "https://www.mattermost.org";
-      license = with licenses; [ agpl3 asl20 ];
-      maintainers = with maintainers; [ fpletz ryantm numinit ];
-      platforms = platforms.unix;
-    };
-  }
+}