-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
204 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
{ | ||
lib, | ||
buildGoModule, | ||
fetchFromGitHub, | ||
buildNpmPackage, | ||
nix-update-script, | ||
npm-lockfile-fix, | ||
fetchNpmDeps, | ||
jq, | ||
nixosTests, | ||
|
||
versionInfo, | ||
}: | ||
|
||
buildGoModule rec { | ||
pname = "mattermost"; | ||
inherit (versionInfo) version; | ||
|
||
src = fetchFromGitHub { | ||
owner = "mattermost"; | ||
repo = "mattermost"; | ||
rev = "v${version}"; | ||
hash = versionInfo.srcHash; | ||
postFetch = '' | ||
cd $out/webapp | ||
# Remove "+..." suffixes on versions. | ||
${lib.getExe jq} ' | ||
def desuffix(version): version | gsub("^(?<prefix>[^\\+]+)\\+.*$"; "\(.prefix)"); | ||
.packages |= map_values(if has("version") then .version = desuffix(.version) else . end) | ||
' < package-lock.json > package-lock.fixed.json | ||
${lib.getExe npm-lockfile-fix} package-lock.fixed.json | ||
rm -f package-lock.json | ||
mv package-lock.fixed.json package-lock.json | ||
''; | ||
}; | ||
|
||
# Needed because buildGoModule does not support go workspaces yet. | ||
# We use go 1.22's workspace vendor command, which is not yet available | ||
# in the default version of go used in nixpkgs, nor is it used by upstream: | ||
# https://github.com/mattermost/mattermost/issues/26221#issuecomment-1945351597 | ||
overrideModAttrs = ( | ||
_: { | ||
buildPhase = '' | ||
make setup-go-work | ||
go work vendor -e | ||
''; | ||
} | ||
); | ||
|
||
npmDeps = fetchNpmDeps { | ||
inherit src; | ||
sourceRoot = "${src.name}/webapp"; | ||
hash = versionInfo.npmDepsHash; | ||
makeCacheWritable = true; | ||
forceGitDeps = true; | ||
}; | ||
|
||
webapp = buildNpmPackage rec { | ||
pname = "mattermost-webapp"; | ||
inherit version src; | ||
|
||
sourceRoot = "${src.name}/webapp"; | ||
|
||
# Remove deprecated image-webpack-loader causing build failures | ||
# See: https://github.com/tcoopman/image-webpack-loader#deprecated | ||
postPatch = '' | ||
substituteInPlace channels/webpack.config.js \ | ||
--replace-fail 'options: {}' 'options: { disable: true }' | ||
''; | ||
|
||
npmDepsHash = npmDeps.hash; | ||
makeCacheWritable = true; | ||
forceGitDeps = true; | ||
|
||
npmRebuildFlags = [ "--ignore-scripts" ]; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
npm run build --workspace=platform/types | ||
npm run build --workspace=platform/client | ||
npm run build --workspace=platform/components | ||
npm run build --workspace=channels | ||
runHook postBuild | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out | ||
cp -a channels/dist/* $out | ||
runHook postInstall | ||
''; | ||
}; | ||
|
||
inherit (versionInfo) vendorHash; | ||
|
||
modRoot = "./server"; | ||
preBuild = '' | ||
make setup-go-work | ||
''; | ||
|
||
subPackages = [ "cmd/mattermost" ]; | ||
|
||
tags = [ "production" ]; | ||
|
||
ldflags = [ | ||
"-s" | ||
"-w" | ||
"-X github.com/mattermost/mattermost/server/public/model.Version=${version}" | ||
"-X github.com/mattermost/mattermost/server/public/model.BuildNumber=${version}-nixpkgs" | ||
"-X github.com/mattermost/mattermost/server/public/model.BuildDate=1970-01-01" | ||
"-X github.com/mattermost/mattermost/server/public/model.BuildHash=v${version}" | ||
"-X github.com/mattermost/mattermost/server/public/model.BuildHashEnterprise=none" | ||
"-X github.com/mattermost/mattermost/server/public/model.BuildEnterpriseReady=false" | ||
]; | ||
|
||
postInstall = '' | ||
shopt -s extglob | ||
mkdir -p $out/{i18n,fonts,templates,config} | ||
# Link in the client and copy the language packs. | ||
ln -sf $webapp $out/client | ||
cp -a $src/server/i18n/* $out/i18n/ | ||
# Fonts have the execute bit set, remove it. | ||
cp --no-preserve=mode $src/server/fonts/* $out/fonts/ | ||
# Don't copy the Makefile. | ||
cp -a $src/server/templates/!(Makefile) $out/templates/ | ||
# Generate the config. | ||
OUTPUT_CONFIG=$out/config/config.json \ | ||
go run -tags production ./scripts/config_generator | ||
''; | ||
|
||
passthru = { | ||
updateScript = nix-update-script { | ||
extraArgs = [ | ||
"--version-regex" | ||
versionInfo.regex | ||
"--override-filename" | ||
versionInfo.autoUpdate | ||
]; | ||
}; | ||
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; [ | ||
agpl3Only | ||
asl20 | ||
]; | ||
maintainers = with maintainers; [ | ||
ryantm | ||
numinit | ||
kranzes | ||
mgdelacroix | ||
fsagbuya | ||
]; | ||
mainProgram = "mattermost"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,169 +1,20 @@ | ||
{ | ||
lib, | ||
buildGoModule, | ||
fetchFromGitHub, | ||
buildNpmPackage, | ||
nix-update-script, | ||
npm-lockfile-fix, | ||
fetchNpmDeps, | ||
jq, | ||
nixosTests, | ||
callPackage, | ||
}: | ||
|
||
buildGoModule rec { | ||
pname = "mattermost"; | ||
# ESR releases only. | ||
# See https://docs.mattermost.com/upgrade/extended-support-release.html | ||
# When a new ESR version is available (e.g. 8.1.x -> 9.5.x), update | ||
# the version regex in passthru.updateScript as well. | ||
version = "9.11.6"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "mattermost"; | ||
repo = "mattermost"; | ||
rev = "v${version}"; | ||
hash = "sha256-G9RYktnnVXdhNWp8q+bNbdlHB9ZOGtnESnZVOA7lDvE="; | ||
postFetch = '' | ||
cd $out/webapp | ||
# Remove "+..." suffixes on versions. | ||
${lib.getExe jq} ' | ||
def desuffix(version): version | gsub("^(?<prefix>[^\\+]+)\\+.*$"; "\(.prefix)"); | ||
.packages |= map_values(if has("version") then .version = desuffix(.version) else . end) | ||
' < package-lock.json > package-lock.fixed.json | ||
${lib.getExe npm-lockfile-fix} package-lock.fixed.json | ||
rm -f package-lock.json | ||
mv package-lock.fixed.json package-lock.json | ||
''; | ||
}; | ||
|
||
# Needed because buildGoModule does not support go workspaces yet. | ||
# We use go 1.22's workspace vendor command, which is not yet available | ||
# in the default version of go used in nixpkgs, nor is it used by upstream: | ||
# https://github.com/mattermost/mattermost/issues/26221#issuecomment-1945351597 | ||
overrideModAttrs = ( | ||
_: { | ||
buildPhase = '' | ||
make setup-go-work | ||
go work vendor -e | ||
''; | ||
} | ||
); | ||
|
||
npmDeps = fetchNpmDeps { | ||
inherit src; | ||
sourceRoot = "${src.name}/webapp"; | ||
hash = "sha256-ysz38ywGxJ5DXrrcDmcmezKbc5Y7aug9jOWUzHRAs/0="; | ||
makeCacheWritable = true; | ||
forceGitDeps = true; | ||
}; | ||
|
||
webapp = buildNpmPackage rec { | ||
pname = "mattermost-webapp"; | ||
inherit version src; | ||
|
||
sourceRoot = "${src.name}/webapp"; | ||
|
||
# Remove deprecated image-webpack-loader causing build failures | ||
# See: https://github.com/tcoopman/image-webpack-loader#deprecated | ||
postPatch = '' | ||
substituteInPlace channels/webpack.config.js \ | ||
--replace-fail 'options: {}' 'options: { disable: true }' | ||
''; | ||
|
||
npmDepsHash = npmDeps.hash; | ||
makeCacheWritable = true; | ||
forceGitDeps = true; | ||
|
||
npmRebuildFlags = [ "--ignore-scripts" ]; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
npm run build --workspace=platform/types | ||
npm run build --workspace=platform/client | ||
npm run build --workspace=platform/components | ||
npm run build --workspace=channels | ||
runHook postBuild | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out | ||
cp -a channels/dist/* $out | ||
runHook postInstall | ||
''; | ||
}; | ||
|
||
vendorHash = "sha256-Gwv6clnq7ihoFC8ox8iEM5xp/us9jWUrcmqA9/XbxBE="; | ||
|
||
modRoot = "./server"; | ||
preBuild = '' | ||
make setup-go-work | ||
''; | ||
|
||
subPackages = [ "cmd/mattermost" ]; | ||
|
||
tags = [ "production" ]; | ||
|
||
ldflags = [ | ||
"-s" | ||
"-w" | ||
"-X github.com/mattermost/mattermost/server/public/model.Version=${version}" | ||
"-X github.com/mattermost/mattermost/server/public/model.BuildNumber=${version}-nixpkgs" | ||
"-X github.com/mattermost/mattermost/server/public/model.BuildDate=1970-01-01" | ||
"-X github.com/mattermost/mattermost/server/public/model.BuildHash=v${version}" | ||
"-X github.com/mattermost/mattermost/server/public/model.BuildHashEnterprise=none" | ||
"-X github.com/mattermost/mattermost/server/public/model.BuildEnterpriseReady=false" | ||
]; | ||
|
||
postInstall = '' | ||
shopt -s extglob | ||
mkdir -p $out/{i18n,fonts,templates,config} | ||
# Link in the client and copy the language packs. | ||
ln -sf $webapp $out/client | ||
cp -a $src/server/i18n/* $out/i18n/ | ||
# Fonts have the execute bit set, remove it. | ||
cp --no-preserve=mode $src/server/fonts/* $out/fonts/ | ||
# Don't copy the Makefile. | ||
cp -a $src/server/templates/!(Makefile) $out/templates/ | ||
# Generate the config. | ||
OUTPUT_CONFIG=$out/config/config.json \ | ||
go run -tags production ./scripts/config_generator | ||
''; | ||
|
||
passthru = { | ||
updateScript = nix-update-script { | ||
extraArgs = [ | ||
"--version-regex" | ||
"^v(9\.11\.[0-9]+)$" | ||
]; | ||
}; | ||
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; [ | ||
agpl3Only | ||
asl20 | ||
]; | ||
maintainers = with maintainers; [ | ||
ryantm | ||
numinit | ||
kranzes | ||
mgdelacroix | ||
fsagbuya | ||
]; | ||
mainProgram = "mattermost"; | ||
callPackage ./generic.nix { | ||
versionInfo = { | ||
# ESR releases only. | ||
# See https://docs.mattermost.com/upgrade/extended-support-release.html | ||
# When a new ESR version is available (e.g. 8.1.x -> 9.5.x), update | ||
# the version regex here as well. | ||
# | ||
# Ensure you also check ../mattermostLatest/package.nix. | ||
regex = "^v(9\.11\.[0-9]+)$"; | ||
version = "9.11.6"; | ||
srcHash = "sha256-G9RYktnnVXdhNWp8q+bNbdlHB9ZOGtnESnZVOA7lDvE="; | ||
vendorHash = "sha256-Gwv6clnq7ihoFC8ox8iEM5xp/us9jWUrcmqA9/XbxBE="; | ||
npmDepsHash = "sha256-ysz38ywGxJ5DXrrcDmcmezKbc5Y7aug9jOWUzHRAs/0="; | ||
autoUpdate = ./package.nix; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
callPackage, | ||
}: | ||
|
||
callPackage ../mattermost/generic.nix { | ||
versionInfo = { | ||
# Latest, non-RC releases only. | ||
# If the latest is an ESR (Extended Support Release), | ||
# duplicate it here to facilitate the update script. | ||
# See https://docs.mattermost.com/about/mattermost-server-releases.html | ||
# and make sure the version regex is up to date here. | ||
# Ensure you also check ../mattermost/package.nix for ESR releases. | ||
regex = "^v(10\.3\.[0-9]+)$"; | ||
version = "10.3.1"; | ||
srcHash = "sha256-nghwf9FgdqEDLkm8dKqhvY1SvALSZ8dasTDwMwbL5AI="; | ||
vendorHash = "sha256-G2IhU8/XSITjJKNu1Iwwoabm+hG9r3kLPtZnlzuKBD8="; | ||
npmDepsHash = "sha256-Dc+ZFQzRQoUnsZDnPs55gr6O82WwyuBEmCZYFAwW50M="; | ||
autoUpdate = ./package.nix; | ||
}; | ||
} |