dream2nix icon indicating copy to clipboard operation
dream2nix copied to clipboard

Need help building redoc (node package)

Open Hofsiedge opened this issue 2 years ago • 2 comments

I am trying to build redoc with dream2nix, this is what I managed to write so far:

project structure
.
├── flake.lock
├── flake.nix
└── packages
    ├── cypress
    │   └── default.nix
    └── redoc
        └── default.nix
flake.nix
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    dream2nix.url = "github:nix-community/dream2nix";
    redoc-src = {
      url = "github:Redocly/redoc?ref=v2.1.2";
      flake = false;
    };
    cypress-src = {
      url = "github:cypress-io/cypress?ref=v13.1.0";
      flake = false;
    };
  };

  outputs = {
    nixpkgs,
    dream2nix,
    ...
  } @ inputs: let
    system = "x86_64-linux";
  in {
    packages.${system} = dream2nix.lib.importPackages {
      projectRoot = ./.;
      projectRootFile = "flake.nix";
      packagesDir = ./packages;
      packageSets.nixpkgs = nixpkgs.legacyPackages.${system};
      specialArgs = {
        inherit
          (inputs)
          redoc-src
          cypress-src
          ;
      };
    };
  };
}
packages/redoc/default.nix
{
  dream2nix,
  config,
  redoc-src,
  ...
}: {
  imports = [
    dream2nix.modules.dream2nix.nodejs-package-lock
    dream2nix.modules.dream2nix.nodejs-granular
  ];

  name = "redoc";
  version = "2.1.2";

  deps = {nixpkgs, ...}: {
    inherit
      (nixpkgs)
      fetchFromGithub
      stdenv
      cypress
      ;
    inherit redoc-src;
  };

  mkDerivation = {
    src = config.deps.redoc-src;
    propagatedBuildInputs = [
      config.deps.cypress
    ];
  };
}

When I run nix build .#redoc this is the

output
error: builder for '/nix/store/gw37lk99j2ga1vy1dis54jfppi46icwf-cypress-13.1.0.drv' failed with exit code 1;
       last 10 log lines:
       > ----------
       >
       > URL: https://download.cypress.io/desktop/13.1.0?platform=linux&arch=x64
       > Error: getaddrinfo EAI_AGAIN download.cypress.io
       >
       > ----------
       >
       > Platform: linux-x64 (6.1.55)
       > Cypress Version: 13.1.0
       >
       For full logs, run 'nix log /nix/store/gw37lk99j2ga1vy1dis54jfppi46icwf-cypress-13.1.0.drv'.
error: 1 dependencies of derivation '/nix/store/65nbzpww6qhn85j35qfmcnw1slwr8zjq-redoc-2.1.2.drv' failed to build
cypress build logs

nix log /nix/store/gw37lk99j2ga1vy1dis54jfppi46icwf-cypress-13.1.0.drv

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/3x65iq5ddqs6yr5c2qkpaikyr8b3b881-cypress-13.1.0.tgz-extracted
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "patchPhaseNodejs" }
patchPhaseNodejs
package.json: Pinning version '3.0.1' to '3.0.1' for dependency '@cypress/request'
package.json: Pinning version '1.2.4' to '1.2.4' for dependency '@cypress/xvfb'
package.json: Pinning version '16.18.48' to '16.18.48' for dependency '@types/node'
package.json: Pinning version '2.3.3' to '2.3.3' for dependency '@types/sizzle'
package.json: Pinning version '2.2.0' to '2.2.0' for dependency 'arch'
package.json: Pinning version '2.0.2' to '2.0.2' for dependency 'blob-util'
package.json: Pinning version '3.7.2' to '3.7.2' for dependency 'bluebird'
package.json: Pinning version '5.7.1' to '5.7.1' for dependency 'buffer'
package.json: Pinning version '2.3.0' to '2.3.0' for dependency 'cachedir'
package.json: Pinning version '4.1.2' to '4.1.2' for dependency 'chalk'
package.json: Pinning version '2.24.0' to '2.24.0' for dependency 'check-more-types'
package.json: Pinning version '3.1.0' to '3.1.0' for dependency 'cli-cursor'
package.json: Pinning version '0.6.3' to '0.6.3' for dependency 'cli-table3'
package.json: Pinning version '6.2.1' to '6.2.1' for dependency 'commander'
package.json: Pinning version '1.8.0' to '1.8.0' for dependency 'common-tags'
package.json: Pinning version '1.10.5' to '1.10.5' for dependency 'dayjs'
package.json: Pinning version '4.3.4' to '4.3.4' for dependency 'debug'
package.json: Pinning version '2.3.6' to '2.3.6' for dependency 'enquirer'
package.json: Pinning version '4.1.1' to '4.1.1' for dependency 'executable'
package.json: Pinning version '3.2.0' to '3.2.0' for dependency 'figures'
package.json: Pinning version '9.1.0' to '9.1.0' for dependency 'fs-extra'
package.json: Pinning version '3.2.1' to '3.2.1' for dependency 'getos'
package.json: Pinning version '3.0.0' to '3.0.0' for dependency 'is-ci'
package.json: Pinning version '0.4.0' to '0.4.0' for dependency 'is-installed-globally'
package.json: Pinning version '1.6.0' to '1.6.0' for dependency 'lazy-ass'
package.json: Pinning version '3.10.0' to '3.10.0' for dependency 'listr2'
package.json: Pinning version '4.17.21' to '4.17.21' for dependency 'lodash'
package.json: Pinning version '4.1.0' to '4.1.0' for dependency 'log-symbols'
package.json: Pinning version '1.2.8' to '1.2.8' for dependency 'minimist'
package.json: Pinning version '1.2.2' to '1.2.2' for dependency 'ospath'
package.json: Pinning version '5.6.0' to '5.6.0' for dependency 'pretty-bytes'
package.json: Pinning version '0.11.10' to '0.11.10' for dependency 'process'
package.json: Pinning version '3.0.0' to '3.0.0' for dependency 'request-progress'
package.json: Pinning version '7.5.4' to '7.5.4' for dependency 'semver'
package.json: Pinning version '8.1.1' to '8.1.1' for dependency 'supports-color'
package.json: Pinning version '0.2.1' to '0.2.1' for dependency 'tmp'
package.json: Pinning version '4.0.0' to '4.0.0' for dependency 'untildify'
package.json: Pinning version '2.10.0' to '2.10.0' for dependency 'yauzl'
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
installing: @cypress/.bin
installing: @cypress/request
installing: @cypress/xvfb
installing: @types/node
installing: @types/sinonjs__fake-timers
installing: @types/sizzle
installing: arch
installing: blob-util
installing: bluebird
installing: buffer
installing: cachedir
installing: chalk
installing: check-more-types
installing: cli-cursor
installing: cli-table3
installing: commander
installing: common-tags
installing: dayjs
installing: debug
installing: enquirer
installing: eventemitter2
installing: execa
installing: executable
installing: extract-zip
installing: figures
installing: fs-extra
installing: getos
installing: is-ci
installing: is-installed-globally
installing: lazy-ass
installing: listr2
installing: lodash
installing: log-symbols
installing: minimist
installing: ospath
installing: pretty-bytes
installing: process
installing: proxy-from-env
installing: request-progress
installing: semver
installing: supports-color
installing: tmp
installing: untildify
installing: yauzl
symlinking executable. dest: ../cypress/node_modules/extract-zip/cli.js; source: /build/package/.bin/extract-zip
symlinking executable. dest: ../cypress/node_modules/is-ci/bin.js; source: /build/package/.bin/is-ci
symlinking executable. dest: ../cypress/node_modules/semver/bin/semver.js; source: /build/package/.bin/semver
Symlinking transitive executables to /build/package/.bin
won't overwrite existing symlink /build/package/.bin/extract-zip. current target: ../cypress/node_modules/extract-zip/cli.js
won't overwrite existing symlink /build/package/.bin/is-ci. current target: ../cypress/node_modules/is-ci/bin.js
won't overwrite existing symlink /build/package/.bin/semver. current target: ../cypress/node_modules/semver/bin/semver.js
@nix { "action": "setPhase", "phase": "buildPhaseNodejs" }
buildPhaseNodejs
executing buildPhaseNodejs
npm WARN config production Use `--omit=dev` instead.

> [email protected] postinstall
> node index.js --exec install

Installing Cypress (version: 13.1.0)


The Cypress App could not be downloaded.

Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration

Otherwise, please check network connectivity and try again:

----------

URL: https://download.cypress.io/desktop/13.1.0?platform=linux&arch=x64
Error: getaddrinfo EAI_AGAIN download.cypress.io

----------

Platform: linux-x64 (6.1.55)
Cypress Version: 13.1.0

From what I understand, this issue seems to be caused by cypress package trying to download a binary during the build phase, which is impossible due to nix builds being isolated from network.

I guess I have to override cypress to include the binary from nixpkgs (and possibly edit the phase that downloads the binary)? How to do this with the new API? All the examples of using overrides seem to be for the old API unless I'm missing something

Aside from that, I can't build cypress with dream2nix because it uses yarn.lock instead of package-lock.json. How do I build a package like that?

packages/cypress/default.nix
{
  dream2nix,
  config,
  cypress-src,
  ...
}: {
  imports = [
    dream2nix.modules.dream2nix.nodejs-package-lock
    dream2nix.modules.dream2nix.nodejs-granular
  ];

  name = "cypress";
  version = "13.1.0";

  deps = {nixpkgs, ...}: {
    inherit
      (nixpkgs)
      fetchFromGithub
      stdenv
      cypress
      ;
    inherit cypress-src;
  };

  mkDerivation = {
    src = config.deps.cypress-src;
    propagatedBuildInputs = [
      config.deps.cypress
    ];
  };
}
...$: nix build .#cypress
error: getting status of '/nix/store/fmql3bxpi3sa1n6xfndnrrj19grblv0r-source/package-lock.json': No such file or directory

Hofsiedge avatar Sep 28 '23 12:09 Hofsiedge

Cypress is available in nixpkgs https://search.nixos.org/packages?channel=24.11&from=0&size=50&sort=relevance&type=packages&query=Cypress

adrian-gierakowski avatar Jan 04 '25 19:01 adrian-gierakowski

Last time I used cypress with nix had to do the following to prevent the npm cypress package from downloading the binary and use the one from nixpkgs instead

export CYPRESS_INSTALL_BINARY=0 export CYPRESS_RUN_BINARY=${self.cypress}/bin/Cypress

adrian-gierakowski avatar Jan 04 '25 19:01 adrian-gierakowski