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

[Backport release-24.11] mattermost: allow overriding the webapp easily #373372

Merged
merged 1 commit into from
Jan 13, 2025
Merged
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
18 changes: 18 additions & 0 deletions nixos/tests/mattermost.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ import ./make-test-python.nix (
];
};
immutable = makeMattermost {
package = pkgs.mattermost.overrideAttrs (prev: {
webapp = prev.webapp.overrideAttrs (prevWebapp: {
# Ensure that users can add patches.
postPatch =
prevWebapp.postPatch or ""
+ ''
substituteInPlace channels/src/root.html --replace-fail "Mattermost" "Patched Mattermost"
'';
});
});
mutableConfig = false;
extraConfig.SupportSettings.HelpLink = "https://search.nixos.org";
};
Expand Down Expand Up @@ -94,6 +104,8 @@ import ./make-test-python.nix (
## Mutable node tests ##
mutable.wait_for_unit("mattermost.service")
mutable.wait_for_open_port(8065)
mutable.succeed("curl -L http://localhost:8065/index.html | grep '${siteName}'")
mutable.succeed("curl -L http://localhost:8065/index.html | grep 'Mattermost'")

# Get the initial config
mutable.succeed("${expectConfig ''.AboutLink == "https://nixos.org" and .HelpLink == "https://search.nixos.org"''}")
Expand All @@ -110,6 +122,8 @@ import ./make-test-python.nix (
## Mostly mutable node tests ##
mostlyMutable.wait_for_unit("mattermost.service")
mostlyMutable.wait_for_open_port(8065)
mostlyMutable.succeed("curl -L http://localhost:8065/index.html | grep '${siteName}'")
mostlyMutable.succeed("curl -L http://localhost:8065/index.html | grep 'Mattermost'")

# Get the initial config
mostlyMutable.succeed("${expectConfig ''.AboutLink == "https://nixos.org"''}")
Expand All @@ -126,6 +140,8 @@ import ./make-test-python.nix (
## Immutable node tests ##
immutable.wait_for_unit("mattermost.service")
immutable.wait_for_open_port(8065)
# Since we patched it, it doesn't replace the site name at runtime anymore
immutable.succeed("curl -L http://localhost:8065/index.html | grep 'Patched Mattermost'")

# Get the initial config
immutable.succeed("${expectConfig ''.AboutLink == "https://nixos.org" and .HelpLink == "https://search.nixos.org"''}")
Expand All @@ -143,6 +159,8 @@ import ./make-test-python.nix (
## Environment File node tests ##
environmentFile.wait_for_unit("mattermost.service")
environmentFile.wait_for_open_port(8065)
environmentFile.succeed("curl -L http://localhost:8065/index.html | grep '${siteName}'")
environmentFile.succeed("curl -L http://localhost:8065/index.html | grep 'Mattermost'")

# Settings in the environment file should override settings set otherwise
environmentFile.succeed("${expectConfig ''.AboutLink == "https://nixos.org"''}")
Expand Down
22 changes: 15 additions & 7 deletions pkgs/by-name/ma/mattermost/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
nix-update-script,
npm-lockfile-fix,
fetchNpmDeps,
diffutils,
jq,
nixosTests,
}:
Expand Down Expand Up @@ -94,7 +93,7 @@ buildGoModule rec {
runHook preInstall

mkdir -p $out
cp -r channels/dist/* $out
cp -a channels/dist/* $out

runHook postInstall
'';
Expand Down Expand Up @@ -123,11 +122,20 @@ buildGoModule rec {
];

postInstall = ''
mkdir -p $out/{client,i18n,fonts,templates,config}
cp -r ${webapp}/* $out/client/
cp -r ${src}/server/i18n/* $out/i18n/
cp -r ${src}/server/fonts/* $out/fonts/
cp -r ${src}/server/templates/* $out/templates/
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
'';
Expand Down
Loading