diff --git a/nixos/tests/mattermost.nix b/nixos/tests/mattermost.nix index 04df954eef1a6..a39033ced31d6 100644 --- a/nixos/tests/mattermost.nix +++ b/nixos/tests/mattermost.nix @@ -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"; }; @@ -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"''}") @@ -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"''}") @@ -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"''}") @@ -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"''}") diff --git a/pkgs/by-name/ma/mattermost/package.nix b/pkgs/by-name/ma/mattermost/package.nix index 87bbe84027130..61036a0fdb9ef 100644 --- a/pkgs/by-name/ma/mattermost/package.nix +++ b/pkgs/by-name/ma/mattermost/package.nix @@ -6,7 +6,6 @@ nix-update-script, npm-lockfile-fix, fetchNpmDeps, - diffutils, jq, nixosTests, }: @@ -94,7 +93,7 @@ buildGoModule rec { runHook preInstall mkdir -p $out - cp -r channels/dist/* $out + cp -a channels/dist/* $out runHook postInstall ''; @@ -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 '';