2021-07-16 19:40:57 +00:00
{ alsa-lib
, autoPatchelfHook
, fetchzip
, gtk2
, gtk3
, lib
2024-10-04 16:56:33 +00:00
, buildPackages
2024-09-19 14:19:46 +00:00
, makeShellWrapper
2021-07-16 19:40:57 +00:00
, mesa
, nss
, stdenv
, udev
, unzip
, xorg
2024-09-26 11:04:55 +00:00
, darwin
2021-07-16 19:40:57 +00:00
} :
2020-04-24 23:36:52 +00:00
2023-03-30 22:05:00 +00:00
let
availableBinaries = {
x86_64-linux = {
platform = " l i n u x - x 6 4 " ;
2024-09-19 14:19:46 +00:00
checksum = " s h a 2 5 6 - z S / y M X N N Y l x g Y y U D o u 2 H a X u e t P o t q i O M 8 k v 1 Y 7 J o u C o = " ;
2023-03-30 22:05:00 +00:00
} ;
aarch64-linux = {
platform = " l i n u x - a r m 6 4 " ;
2024-09-19 14:19:46 +00:00
checksum = " s h a 2 5 6 - r B 0 a k 6 j Y n J M b 0 a H D L A y h a G o O F K 4 F X D L E O e o f N d W / W k 8 = " ;
2023-03-30 22:05:00 +00:00
} ;
2024-09-26 11:04:55 +00:00
aarch64-darwin = {
platform = " d a r w i n - a r m 6 4 " ;
checksum = " s h a 2 5 6 - L 2 r h t B / D I K 7 Q u m 2 Y N o W V B n 4 m f + D A 3 r b c B U f Z E E a / C 8 c = " ;
} ;
2023-03-30 22:05:00 +00:00
} ;
inherit ( stdenv . hostPlatform ) system ;
binary = availableBinaries . ${ system } or ( throw " c y p r e s s : N o b i n a r i e s a v a i l a b l e f o r s y s t e m ${ system } " ) ;
inherit ( binary ) platform checksum ;
in stdenv . mkDerivation rec {
2020-04-24 23:36:52 +00:00
pname = " c y p r e s s " ;
2024-09-19 14:19:46 +00:00
version = " 1 3 . 1 3 . 2 " ;
2020-04-24 23:36:52 +00:00
src = fetchzip {
2023-03-30 22:05:00 +00:00
url = " h t t p s : / / c d n . c y p r e s s . i o / d e s k t o p / ${ version } / ${ platform } / c y p r e s s . z i p " ;
sha256 = checksum ;
2024-09-26 11:04:55 +00:00
stripRoot = ! stdenv . isDarwin ;
2020-04-24 23:36:52 +00:00
} ;
# don't remove runtime deps
dontPatchELF = true ;
2024-10-04 16:56:33 +00:00
nativeBuildInputs =
[
unzip
makeShellWrapper
]
++ lib . optionals stdenv . 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 ; } )
] ;
2020-04-24 23:36:52 +00:00
2024-09-26 11:04:55 +00:00
buildInputs = lib . optionals stdenv . isLinux ( with xorg ; [
2021-07-16 19:40:57 +00:00
libXScrnSaver
libXdamage
libXtst
libxshmfence
nss
gtk2
alsa-lib
gtk3
2021-04-26 19:14:03 +00:00
mesa # for libgbm
2024-09-26 11:04:55 +00:00
] ) ++ lib . optionals stdenv . isDarwin ( with darwin . apple_sdk . frameworks ; [
Cocoa
CoreServices
CoreMedia
CoreAudio
AudioToolbox
AVFoundation
Foundation
ApplicationServices
] ) ;
2020-04-24 23:36:52 +00:00
2024-09-26 11:04:55 +00:00
runtimeDependencies = lib . optional stdenv . isLinux ( lib . getLib udev ) ;
2020-04-24 23:36:52 +00:00
installPhase = ''
2021-04-13 19:44:15 +00:00
runHook preInstall
2020-04-24 23:36:52 +00:00
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 ' { " v e r s i o n " : " % b " } ' $ version > $ out/bin/resources/app/package.json
# Cypress now looks for binary_state.json in bin
echo ' { " v e r i f i e d " : true } ' > $ out/binary_state.json
2024-09-26 11:04:55 +00:00
$ { if stdenv . isDarwin then ''
ln - s $ out/opt/cypress/Cypress.app/Contents/MacOS/Cypress $ out/bin/cypress
'' e l s e ''
ln - s $ out/opt/cypress/Cypress $ out/bin/cypress
'' }
2021-04-13 19:44:15 +00:00
runHook postInstall
2020-04-24 23:36:52 +00:00
'' ;
2024-09-26 11:04:55 +00:00
postFixup = lib . optionalString ( ! stdenv . isDarwin ) ''
2024-09-19 14:19:46 +00:00
# exit with 1 after 25.05
makeWrapper $ out/opt/cypress/Cypress $ out/bin/Cypress \
- - run ' echo " W a r n i n g : U s e t h e l o w e r c a s e c y p r e s s e x e c u t a b l e i n s t e a d o f t h e c a p i t a l i z e d o n e . " '
'' ;
2021-07-16 19:40:57 +00:00
passthru = {
updateScript = ./update.sh ;
tests = {
2023-03-30 22:05:00 +00:00
# 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
2021-07-16 19:40:57 +00:00
} ;
} ;
2021-01-15 22:18:51 +00:00
meta = with lib ; {
2020-04-24 23:36:52 +00:00
description = " F a s t , e a s y a n d r e l i a b l e t e s t i n g f o r a n y t h i n g t h a t r u n s i n a b r o w s e r " ;
homepage = " h t t p s : / / w w w . c y p r e s s . i o " ;
2022-09-22 12:36:57 +00:00
mainProgram = " C y p r e s s " ;
2022-06-26 10:26:21 +00:00
sourceProvenance = with sourceTypes ; [ binaryNativeCode ] ;
2020-04-24 23:36:52 +00:00
license = licenses . mit ;
2023-03-30 22:05:00 +00:00
platforms = lib . attrNames availableBinaries ;
2022-08-12 12:06:08 +00:00
maintainers = with maintainers ; [ tweber mmahut Crafter ] ;
2020-04-24 23:36:52 +00:00
} ;
}