Skip to content

Commit

Permalink
mattermost: allow overriding the webapp easily
Browse files Browse the repository at this point in the history
Add a test since users will often want to make patches to the webapp.

(cherry picked from commit 13cd3a1)
  • Loading branch information
numinit authored and github-actions[bot] committed Jan 13, 2025
1 parent fc1a4f4 commit c7298a0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
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

0 comments on commit c7298a0

Please sign in to comment.