2023-07-15 17:15:38 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, buildNpmPackage
|
2024-02-29 20:09:43 +00:00
|
|
|
, nodejs_18
|
2023-07-15 17:15:38 +00:00
|
|
|
, coreutils
|
|
|
|
, ffmpeg-headless
|
|
|
|
, imagemagick_light
|
|
|
|
, procps
|
|
|
|
, python3
|
|
|
|
, xorg
|
2024-02-29 20:09:43 +00:00
|
|
|
, nix-update-script
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
# chromedriver is more efficient than geckodriver, but is available on less platforms.
|
|
|
|
|
|
|
|
, withChromium ? (lib.elem stdenv.hostPlatform.system chromedriver.meta.platforms)
|
|
|
|
, chromedriver
|
|
|
|
, chromium
|
|
|
|
|
|
|
|
, withFirefox ? (lib.elem stdenv.hostPlatform.system geckodriver.meta.platforms)
|
|
|
|
, geckodriver
|
|
|
|
, firefox
|
|
|
|
}:
|
|
|
|
assert (!withFirefox && !withChromium) -> throw "Either `withFirefox` or `withChromium` must be enabled.";
|
|
|
|
buildNpmPackage rec {
|
|
|
|
pname = "sitespeed-io";
|
2024-06-05 15:53:02 +00:00
|
|
|
version = "34.0.1";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "sitespeedio";
|
|
|
|
repo = "sitespeed.io";
|
|
|
|
rev = "v${version}";
|
2024-06-05 15:53:02 +00:00
|
|
|
hash = "sha256-yC/TlAJa71hbPYYuqPV+k3syGuo/VhnNjXmmxh47ySQ=";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
nodejs = nodejs_18;
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
postPatch = ''
|
|
|
|
ln -s npm-shrinkwrap.json package-lock.json
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Don't try to download the browser drivers
|
|
|
|
CHROMEDRIVER_SKIP_DOWNLOAD = true;
|
|
|
|
GECKODRIVER_SKIP_DOWNLOAD = true;
|
|
|
|
EDGEDRIVER_SKIP_DOWNLOAD = true;
|
|
|
|
|
|
|
|
dontNpmBuild = true;
|
|
|
|
npmInstallFlags = [ "--omit=dev" ];
|
2024-06-05 15:53:02 +00:00
|
|
|
npmDepsHash = "sha256-Q0cWxV5OOaG8Z3aM2j0HtD1e9yPFVDSRcMKBf/yscv4=";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mv $out/bin/sitespeed{.,-}io
|
|
|
|
mv $out/bin/sitespeed{.,-}io-wpr
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup =
|
|
|
|
let
|
|
|
|
chromiumArgs = lib.concatStringsSep " " [
|
|
|
|
"--browsertime.chrome.chromedriverPath=${lib.getExe chromedriver}"
|
|
|
|
"--browsertime.chrome.binaryPath=${lib.getExe chromium}"
|
|
|
|
];
|
|
|
|
firefoxArgs = lib.concatStringsSep " " [
|
|
|
|
"--browsertime.firefox.geckodriverPath=${lib.getExe geckodriver}"
|
|
|
|
"--browsertime.firefox.binaryPath=${lib.getExe firefox}"
|
|
|
|
# Firefox crashes if the profile template dir is not writable
|
|
|
|
"--browsertime.firefox.profileTemplate=$(mktemp -d)"
|
|
|
|
];
|
|
|
|
in
|
|
|
|
''
|
|
|
|
wrapProgram $out/bin/sitespeed-io \
|
|
|
|
--set PATH ${lib.makeBinPath ([
|
|
|
|
(python3.withPackages (p: [p.numpy p.opencv4 p.pyssim]))
|
|
|
|
ffmpeg-headless
|
|
|
|
imagemagick_light
|
|
|
|
xorg.xorgserver
|
|
|
|
procps
|
|
|
|
coreutils
|
|
|
|
])} \
|
|
|
|
${lib.optionalString withChromium "--add-flags '${chromiumArgs}'"} \
|
|
|
|
${lib.optionalString withFirefox "--add-flags '${firefoxArgs}'"} \
|
|
|
|
${lib.optionalString (!withFirefox && withChromium) "--add-flags '-b chrome'"} \
|
|
|
|
${lib.optionalString (withFirefox && !withChromium) "--add-flags '-b firefox'"}
|
|
|
|
'';
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = nix-update-script { };
|
|
|
|
};
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Open source tool that helps you monitor, analyze and optimize your website speed and performance";
|
2023-07-15 17:15:38 +00:00
|
|
|
homepage = "https://sitespeed.io";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ misterio77 ];
|
|
|
|
platforms = lib.unique (geckodriver.meta.platforms ++ chromedriver.meta.platforms);
|
2023-08-04 22:07:22 +00:00
|
|
|
mainProgram = "sitespeed-io";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
}
|