Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: mattermost: split and build webapp from source #126629

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 13 additions & 57 deletions pkgs/servers/mattermost/default.nix
Original file line number Diff line number Diff line change
@@ -1,58 +1,14 @@
{ lib, stdenv, fetchurl, fetchFromGitHub, buildGoPackage, buildEnv }:

let
version = "5.32.1";

mattermost-server = buildGoPackage rec {
pname = "mattermost-server";
inherit version;

src = fetchFromGitHub {
owner = "mattermost";
repo = "mattermost-server";
rev = "v${version}";
sha256 = "BssrTfkIxUbXYXIfz9i+5b4rEYSzBim+/riK78m8Bxo=";
};

goPackagePath = "github.com/mattermost/mattermost-server";

buildFlagsArray = ''
-ldflags=
-X ${goPackagePath}/model.BuildNumber=nixpkgs-${version}
'';

{ lib, stdenv, mattermost-server, mattermost-webapp, buildEnv }:

buildEnv {
name = "mattermost-${mattermost-server.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 ];
platforms = platforms.unix;
};

mattermost-webapp = stdenv.mkDerivation {
pname = "mattermost-webapp";
inherit version;

src = fetchurl {
url = "https://releases.mattermost.com/${version}/mattermost-${version}-linux-amd64.tar.gz";
sha256 = "kRerl3fYRTrotj86AIFSor3GpjhABkCmego1ms9HmkQ=";
};

installPhase = ''
mkdir -p $out
tar --strip 1 --directory $out -xf $src \
mattermost/client \
mattermost/i18n \
mattermost/fonts \
mattermost/templates \
mattermost/config
'';
};

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 ];
platforms = platforms.unix;
};
}
}
31 changes: 31 additions & 0 deletions pkgs/servers/mattermost/server/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{ lib, stdenv, fetchFromGitHub, buildGoModule }:

buildGoModule rec {
pname = "mattermost-server";
version = "5.32.1";

src = fetchFromGitHub {
owner = "mattermost";
repo = pname;
rev = "v${version}";
hash = "sha256:BssrTfkIxUbXYXIfz9i+5b4rEYSzBim+/riK78m8Bxo=";
};

vendorSha256 = null;

# buildFlagsArray = ''
# -ldflags=
# -X ${goPackagePath}/model.BuildNumber=nixpkgs-${version}
# '';
Comment on lines +16 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# buildFlagsArray = ''
# -ldflags=
# -X ${goPackagePath}/model.BuildNumber=nixpkgs-${version}
# '';
# ldflags = [
# "-X ${goPackagePath}/model.BuildNumber=nixpkgs-${version}"
# ];


doCheck = false;

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 ];
platforms = platforms.unix;
};

}
Comment on lines +28 to +31
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
platforms = platforms.unix;
};
}
};
}

76 changes: 76 additions & 0 deletions pkgs/servers/mattermost/webapp/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{ lib
, stdenv
, fetchFromGitHub
, mkYarnModules
, nodejs
, yarn
, git
}:

let

yarnModules = pname: version: src: mkYarnModules {
pname = "${pname}-modules";
inherit version;
packageJSON = "${src}/package.json";
yarnLock = ./yarn.lock;
yarnNix = ./yarn.nix;
postBuild = ''
cp -r $out/deps/mattermost-webapp-modules/node_modules/* $out/node_modules/
'';
};

in

stdenv.mkDerivation rec {
pname = "mattermost-webapp";
version = "5.32.1";

src = fetchFromGitHub {
owner = "mattermost";
repo = pname;
rev = "v${version}";
sha256 = "sha256:1bw3sjk9mfp4jsgmk0jvsj1aklwckrp41xygl3kd8gwp58rdp2l2";
};

nativeBuildInputs = [
git
nodejs
];

postPatch = ''
substituteInPlace webpack.config.js --replace \
"JSON.stringify(childProcess.execSync('git rev-parse HEAD || echo dev').toString())" \
"\"e73500dab9c9dd584a035340575cf432ac2e50b1\""
'';

buildPhase = ''
ln -sf ${yarnModules pname version src}/node_modules node_modules
export NODE_OPTIONS='--unhandled-rejections=warn'
npm --update-notifier=false run build
'';

installPhase = ''
ls -la
mv dist $out
'';

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 ];
platforms = platforms.unix;
};

}

# installPhase = ''
# mkdir -p $out
# tar --strip 1 --directory $out -xf $src \
# mattermost/client \
# mattermost/i18n \
# mattermost/fonts \
# mattermost/templates \
# mattermost/config
# '';
Loading