Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodesPackages.insect: init at 5.4.0 #70652

Closed
wants to merge 2 commits into from
Closed

nodesPackages.insect: init at 5.4.0 #70652

wants to merge 2 commits into from

Conversation

teto
Copy link
Member

@teto teto commented Oct 7, 2019

a calculator that understands units (online demo at https://insect.sh/).

That's the first node package I am trying to package but I am kinda lost:
install fails with :

> insect@5.3.0 postinstall /nix/store/2nx32z7yz18238z1aaq4zbrbnfywsvd7-node_insect-5.3.0/lib/node_modules/insect
> bower --allow-root install && npm run browserify && npm run copy

sh: bower: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! insect@5.3.0 postinstall: `bower --allow-root install && npm run browserify && npm run copy`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the insect@5.3.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /build/.npm/_logs/2019-10-07T16_32_49_371Z-debug.log

After grepping a bit, I found that insect's package.json contains

"scripts": {
    "copy": "node copy",
    "browserify:watch": "pulp -w browserify --skip-entry-point -m Insect --standalone Insect -O -t insect.js",
    "browserify": "pulp browserify --skip-entry-point -m Insect --standalone Insect -O -t insect.js",
    "build": "pulp build -m Insect",
    "server": "live-server web --open",
    "test": "pulp test"
  },

I tried to remove these scripts entries but then it would fail at runtime with

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module './output/Insect/index.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/nix/store/8m3kfh6zi8pqvi6pblsgn6fm4jkhn5g0-node_insect-5.3.0/lib/node_modules/insect/index.js:3:14)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

should I package this with bower2nix instead ? or the package is broken for nix ? I precise I have no interest watsoever in the webapp, I just want to use the terminal component.

CC @svanderburg

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @

@teto
Copy link
Member Author

teto commented Oct 8, 2019

I managed to make it work imperatively so that's helpful for now.

Even though I added purescript as a buildInput (with #67875 so that it matches the requested version) it doesn't seem to detect purs (if I run nix-shell -A nodePackages_10_x.insect ~/nixpkgs, $ purs --version returns 0.13.3 and still tries to phone home

✖ Check if a prebuilt 0.13.3 binary is provided for linux
  Error: getaddrinfo ENOTFOUND github.com github.com:443
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
▬ Download the prebuilt PureScript binary
▬ Verify the prebuilt binary works correctly
▬ Save the downloaded binary to the npm cache directory

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! purescript@0.13.3 postinstall: `install-purescript --purs-ver=0.13.3`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the purescript@0.13.3 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /build/.npm/_logs/2019-10-08T08_33_54_813Z-debug.log

Now if I run nix-build with --option sandbox false, I get another error

✔ Download the prebuilt PureScript binary
⠋ Verify the prebuilt binary works correctly
  Save the downloaded binary to the npm cache directory

✖ Verify the prebuilt binary works correctly
  /nix/store/z1qa5bpmx2pm7dbqm1frma4ah857dlrj-node_insect-5.3.0/lib/node_mod…
  Error: spawn /nix/store/z1qa5bpmx2pm7dbqm1frma4ah857dlrj-node_insect-5.3.0/lib
/node_modules/insect/node_modules/purescript/purs.bin ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
▬ Save the downloaded binary to the npm cache directory

↓ Fallback: building from source

✖ Check if 'stack' command is available
  stack --allow-different-user --numeric-version
  Error: Command failed with exit code 2 (ENOENT): stack --allow-different-user 
--numeric-version
spawn stack ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
▬ Download the PureScript 0.13.3 source
▬ Ensure the appropriate GHC is installed
▬ Build a binary from source
▬ Save the built binary to the npm cache directory

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! purescript@0.13.3 postinstall: `install-purescript --purs-ver=0.13.3`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the purescript@0.13.3 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/nix-build-node_insect-5.3.0.drv-24/.npm/_logs/2019-10-08T08_38_55_268Z-debug.log

@teto
Copy link
Member Author

teto commented Oct 8, 2019

@justinwoo I wonder if you would know why npm install doesn't pick up the purescript interpreter purs in the build environment and still try to fetch it ? any workaround ?

@lilyball
Copy link
Member

I'd love to see insect be packaged but I don't understand anything about bower or how to make this work.

@lilyball
Copy link
Member

I noticed there's a bower2nix command but it seems like it's supposed to be used as part of a larger derivation so I don't know how to package up the output.

@teto teto mentioned this pull request Jan 13, 2020
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/help-packaging-a-node-package-insect-that-uses-bower/5602/1

Copy link
Member

@lilyball lilyball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With insect v5.4.0 we can now get this to work

Comment on lines 34 to 40
insect = nodePackages.insect.override {
buildInputs = [ nodePackages.pulp nodePackages.bower pkgs.purescript ];
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
insect = nodePackages.insect.override {
buildInputs = [ nodePackages.pulp nodePackages.bower pkgs.purescript ];
};
insect = nodePackages.insect.override (drv: {
nativeBuildInputs = drv.nativeBuildInputs or [] ++ [ pkgs.psc-package pkgs.purescript nodePackages.pulp ];
});

@@ -55,6 +55,7 @@
, "hueadm"
, "imapnotify"
, "indium"
, "insect"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this to v5.4.0, which gets rid of the bower dependency

@@ -2,7 +2,7 @@

{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-13_x"}:
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-8_x"}:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be fixed again.

@@ -13,13 +13,13 @@ let
sha512 = "nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==";
};
};
"ajv-6.10.2" = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't need to commit changes to the v12 or v13 package sets when you're just trying to update the v10 one.

@teto teto changed the title nodesPackages.insect: init at 5.3.0 nodesPackages.insect: init at 5.4.0 Jan 29, 2020
@teto teto marked this pull request as ready for review January 29, 2020 12:42
@teto
Copy link
Member Author

teto commented Jan 29, 2020

thanks for the help. The binary seems to work.

@@ -35,6 +35,10 @@ nodePackages // {
name = "bitwarden-cli-${drv.version}";
});

insect = nodePackages.insect.override {
nativeBuildInputs = [ pkgs.psc-package pkgs.purescript nodePackages.pulp ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if node2nix sets up any default nativeBuildInputs but just in case this really should be

  insect = nodePackages.insect.override (drv: {
    nativeBuildInputs = drv.nativeBuildInputs or [] ++ [ pkgs.psc-package pkgs.purescript nodePackages.pulp ];
  });

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but we don't want to step on its toes if buildNodePackage is ever updated in the future to start using nativeBuildInputs.

@lilyball lilyball mentioned this pull request Feb 25, 2020
10 tasks
@lilyball
Copy link
Member

Since this PR seems to have stalled out I submitted a new one as #81070

@teto teto closed this Feb 26, 2020
@teto teto deleted the insect branch February 26, 2020 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants