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