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