Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save r-k-b/2485f977b476aa3f76a47329ce7f9ad4 to your computer and use it in GitHub Desktop.

Select an option

Save r-k-b/2485f977b476aa3f76a47329ce7f9ad4 to your computer and use it in GitHub Desktop.

Revisions

  1. r-k-b revised this gist Mar 9, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion shell.nix
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,6 @@ in pkgs.mkShell {

    shellHook = ''
    export CYPRESS_INSTALL_BINARY=0
    export CYPRESS_RUN_BINARY=$(which Cypress)
    export CYPRESS_RUN_BINARY=${pkgs.cypress}/bin/Cypress
    '';
    }
  2. r-k-b revised this gist Feb 15, 2021. 2 changed files with 7 additions and 3 deletions.
    9 changes: 7 additions & 2 deletions cypress-overlay.nix
    Original file line number Diff line number Diff line change
    @@ -8,11 +8,16 @@ final: prev: {
    installPhase = let
    old = "copyExtension(pathToExtension, extensionDest)";
    # This has only been tested against Cypress 6.0.0!
    new =
    newForChrome =
    "copyExtension(pathToExtension, extensionDest).then(() => fs_1.default.chmodAsync(extensionBg, 0o0644))";
    newForFirefox =
    "copyExtension(pathToExtension, extensionDest).then(() => fs.chmodAsync(extensionBg, 0o0644))";
    in ''
    sed -i 's/${old}/${new}/' \
    sed -i 's/${old}/${newForChrome}/' \
    ./resources/app/packages/server/lib/browsers/chrome.js
    sed -i 's/${old}/${newForFirefox}/' \
    ./resources/app/packages/server/lib/browsers/utils.js
    '' + oldAttrs.installPhase;
    });
    }
    1 change: 0 additions & 1 deletion shell.nix
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,3 @@ in pkgs.mkShell {
    export CYPRESS_RUN_BINARY=$(which Cypress)
    '';
    }

  3. r-k-b revised this gist Jan 21, 2021. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions cypress-overlay.nix
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    # When Cypress starts, it copies some files into `~/.config/Cypress/cy/production/browsers/chrome-stable/interactive/CypressExtension/`
    # from the Nix Store, one of which it attempts to modify immediately after.
    # As-is, this fails because the copied file keeps the read-only flag it had in
    # the Store.
    # Luckily, the code responsible is a plain text script that we can easily patch:
    final: prev: {
    cypress = prev.cypress.overrideAttrs (oldAttrs: {
    installPhase = let
  4. r-k-b revised this gist Jan 21, 2021. 2 changed files with 3 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions _use nixpkgs cypress binary before npms broken copy.md
    Original file line number Diff line number Diff line change
    @@ -45,5 +45,5 @@ Cypress Version: 6.2.1
    EACCES: permission denied, open '/home/rkb/.config/Cypress/cy/production/browsers/chrome-stable/interactive/CypressExtension/background.js'
    ```

    apply [this patch](https://github.com/cypress-io/cypress/pull/5579/files) to [Cypress](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/development/web/cypress/default.nix) from within the shell.nix
    (or get it upstreamed?)
    ~~apply [this patch](https://github.com/cypress-io/cypress/pull/5579/files) to [Cypress](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/development/web/cypress/default.nix) from within the shell.nix
    (or get it upstreamed?)~~ done. Super hacky, but done!
    1 change: 1 addition & 0 deletions cypress-overlay.nix
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@ final: prev: {
    cypress = prev.cypress.overrideAttrs (oldAttrs: {
    installPhase = let
    old = "copyExtension(pathToExtension, extensionDest)";
    # This has only been tested against Cypress 6.0.0!
    new =
    "copyExtension(pathToExtension, extensionDest).then(() => fs_1.default.chmodAsync(extensionBg, 0o0644))";
    in ''
  5. r-k-b revised this gist Jan 21, 2021. 2 changed files with 14 additions and 3 deletions.
    12 changes: 12 additions & 0 deletions cypress-overlay.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    final: prev: {
    cypress = prev.cypress.overrideAttrs (oldAttrs: {
    installPhase = let
    old = "copyExtension(pathToExtension, extensionDest)";
    new =
    "copyExtension(pathToExtension, extensionDest).then(() => fs_1.default.chmodAsync(extensionBg, 0o0644))";
    in ''
    sed -i 's/${old}/${new}/' \
    ./resources/app/packages/server/lib/browsers/chrome.js
    '' + oldAttrs.installPhase;
    });
    }
    5 changes: 2 additions & 3 deletions shell.nix
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    { pkgs ? import <nixpkgs> { } }:

    pkgs.mkShell {
    let pkgs = import <nixpkgs> { overlays = [ (import ./cypress-overlay.nix) ]; };
    in pkgs.mkShell {
    name = "cypress-example";

    buildInputs = with pkgs; [
  6. r-k-b revised this gist Jan 21, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion _use nixpkgs cypress binary before npms broken copy.md
    Original file line number Diff line number Diff line change
    @@ -45,5 +45,5 @@ Cypress Version: 6.2.1
    EACCES: permission denied, open '/home/rkb/.config/Cypress/cy/production/browsers/chrome-stable/interactive/CypressExtension/background.js'
    ```

    apply [this patch](https://github.com/cypress-io/cypress/pull/5579/files) to Cypress from within the shell.nix
    apply [this patch](https://github.com/cypress-io/cypress/pull/5579/files) to [Cypress](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/development/web/cypress/default.nix) from within the shell.nix
    (or get it upstreamed?)
  7. r-k-b revised this gist Jan 21, 2021. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions _use nixpkgs cypress binary before npms broken copy.md
    Original file line number Diff line number Diff line change
    @@ -41,5 +41,9 @@ Cypress Version: 6.2.1

    # todo

    ```
    EACCES: permission denied, open '/home/rkb/.config/Cypress/cy/production/browsers/chrome-stable/interactive/CypressExtension/background.js'
    ```

    apply [this patch](https://github.com/cypress-io/cypress/pull/5579/files) to Cypress from within the shell.nix
    (or get it upstreamed?)
  8. r-k-b revised this gist Jan 21, 2021. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion _use nixpkgs cypress binary before npms broken copy.md
    Original file line number Diff line number Diff line change
    @@ -37,4 +37,9 @@ spawn /home/rkb/.cache/Cypress/6.2.1/Cypress/Cypress ENOENT
    Platform: linux (NixOS - )
    Cypress Version: 6.2.1
    ```
    ```

    # todo

    apply [this patch](https://github.com/cypress-io/cypress/pull/5579/files) to Cypress from within the shell.nix
    (or get it upstreamed?)
  9. r-k-b revised this gist Jan 21, 2021. No changes.
  10. r-k-b renamed this gist Jan 21, 2021. 1 changed file with 0 additions and 0 deletions.
  11. r-k-b created this gist Jan 21, 2021.
    40 changes: 40 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    Should help with avoiding errors like:

    ```text
    No version of Cypress is installed in: /home/rkb/.cache/Cypress/6.2.1/Cypress
    Please reinstall Cypress by running: cypress install
    ----------
    Cypress executable not found at: /home/rkb/.cache/Cypress/6.2.1/Cypress/Cypress
    ----------
    Platform: linux (NixOS - )
    Cypress Version: 6.2.1
    ```

    and

    ```text
    Cypress failed to start.
    This is usually caused by a missing library or dependency.
    The error below should indicate which dependency is missing.
    https://on.cypress.io/required-dependencies
    If you are using Docker, we provide containers with all required dependencies installed.
    ----------
    Command failed with ENOENT: /home/rkb/.cache/Cypress/6.2.1/Cypress/Cypress --no-sandbox --smoke-test --ping=459
    spawn /home/rkb/.cache/Cypress/6.2.1/Cypress/Cypress ENOENT
    ----------
    Platform: linux (NixOS - )
    Cypress Version: 6.2.1
    ```
    17 changes: 17 additions & 0 deletions shell.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    { pkgs ? import <nixpkgs> { } }:

    pkgs.mkShell {
    name = "cypress-example";

    buildInputs = with pkgs; [
    cypress
    (with dotnetCorePackages; combinePackages [ sdk_5_0 net_5_0 ])
    nodejs
    ];

    shellHook = ''
    export CYPRESS_INSTALL_BINARY=0
    export CYPRESS_RUN_BINARY=$(which Cypress)
    '';
    }