nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 alsa-lib,
3 autoPatchelfHook,
4 fetchzip,
5 gtk2,
6 gtk3,
7 lib,
8 buildPackages,
9 makeShellWrapper,
10 libgbm,
11 nss,
12 stdenv,
13 udev,
14 unzip,
15}:
16
17let
18 availableBinaries = {
19 x86_64-linux = {
20 platform = "linux-x64";
21 hash = "sha256-oCTpVD7W1NHWD0nJBrgtmWZZozbcJeAfr7mn/JjqdcM=";
22 };
23 aarch64-linux = {
24 platform = "linux-arm64";
25 hash = "sha256-MIUVhWkfKN5056jhHN31h4dBcTHJI0iX+I2RbkNI80I=";
26 };
27 aarch64-darwin = {
28 platform = "darwin-arm64";
29 hash = "sha256-8qvMsC+tRKK12jC2r1A54kS/PZ6q+sErvLvTkse6Kn4=";
30 };
31 x86_64-darwin = {
32 platform = "darwin-x64";
33 hash = "sha256-cCLJloLcuCDgTEiMMJKY6rYiPPhZfFfqXFP5NAMhw4Q=";
34 };
35 };
36 inherit (stdenv.hostPlatform) system;
37 binary =
38 availableBinaries.${system} or (throw "cypress: No binaries available for system ${system}");
39 inherit (binary) platform hash;
40in
41stdenv.mkDerivation rec {
42 pname = "cypress";
43 version = "14.5.4";
44
45 src = fetchzip {
46 url = "https://cdn.cypress.io/desktop/${version}/${platform}/cypress.zip";
47 inherit hash;
48 stripRoot = !stdenv.hostPlatform.isDarwin;
49 };
50
51 # don't remove runtime deps
52 dontPatchELF = true;
53
54 nativeBuildInputs = [
55 unzip
56 makeShellWrapper
57 ]
58 ++ lib.optionals stdenv.hostPlatform.isLinux [
59 autoPatchelfHook
60 # override doesn't preserve splicing https://github.com/NixOS/nixpkgs/issues/132651
61 # Has to use `makeShellWrapper` from `buildPackages` even though `makeShellWrapper` from the inputs is spliced because `propagatedBuildInputs` would pick the wrong one because of a different offset.
62 (buildPackages.wrapGAppsHook3.override { makeWrapper = buildPackages.makeShellWrapper; })
63 ];
64
65 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
66 nss
67 alsa-lib
68 gtk3
69 libgbm
70 ];
71
72 runtimeDependencies = lib.optional stdenv.hostPlatform.isLinux (lib.getLib udev);
73
74 installPhase = ''
75 runHook preInstall
76
77 mkdir -p $out/bin $out/opt/cypress
78 cp -vr * $out/opt/cypress/
79 # Let's create the file binary_state ourselves to make the npm package happy on initial verification.
80 # Cypress now verifies version by reading bin/resources/app/package.json
81 mkdir -p $out/bin/resources/app
82 printf '{"version":"%b"}' $version > $out/bin/resources/app/package.json
83 # Cypress now looks for binary_state.json in bin
84 echo '{"verified": true}' > $out/binary_state.json
85 ${
86 if stdenv.hostPlatform.isDarwin then
87 ''
88 ln -s $out/opt/cypress/Cypress.app/Contents/MacOS/Cypress $out/bin/cypress
89 ''
90 else
91 ''
92 ln -s $out/opt/cypress/Cypress $out/bin/cypress
93 ''
94 }
95 runHook postInstall
96 '';
97
98 postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
99 # exit with 1 after 25.05
100 makeWrapper $out/opt/cypress/Cypress $out/bin/Cypress \
101 --run 'echo "Warning: Use the lowercase cypress executable instead of the capitalized one."'
102 '';
103
104 passthru = {
105 updateScript = ./update.sh;
106
107 tests = {
108 # We used to have a test here, but was removed because
109 # - it broke, and ofborg didn't fail https://github.com/NixOS/ofborg/issues/629
110 # - it had a large footprint in the repo; prefer RFC 92 or an ugly FOD fetcher?
111 # - the author switched away from cypress.
112 # To provide a test once more, you may find useful information in
113 # https://github.com/NixOS/nixpkgs/pull/223903
114 };
115 };
116
117 meta = {
118 description = "Fast, easy and reliable testing for anything that runs in a browser";
119 homepage = "https://www.cypress.io";
120 mainProgram = "Cypress";
121 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
122 license = lib.licenses.mit;
123 platforms = lib.attrNames availableBinaries;
124 maintainers = with lib.maintainers; [
125 tweber
126 mmahut
127 Crafter
128 jonhermansen
129 ];
130 };
131}