Help packaging a node package 'insect' that uses bower

There’s a tool called insect that I’d really love to get in nixpkgs. I tried packaging it myself but couldn’t get it to work. The basic install instructions are just npm install -g insect, but if I try using node2nix it fails at the postinstall hook as it tries to invoke bower. If I manually expose bower to it, bower itself then fails as it tries to use the network. I tried packaging using a combination of bower2nix and node2nix but I couldn’t figure out how to get it to work.

Someone else has also attempted this same thing and submitted a draft PR nodesPackages.insect: init at 5.4.0 by teto · Pull Request #70652 · NixOS/nixpkgs · GitHub. They appear to have just done the node2nix approach without using bower2nix.

I don’t have any familiarity with bower at all and merely mashing together the node2nix and bower2nix outputs didn’t work. I would really love it if someone who’s more familiar with these tools could help.

2 Likes

Just saw this in my GitHub notifications for whatever reason. I was going to suggest just using the npm published package, but now I realize that it actually does tries to make everything build via bower. I wonder if it wouldn’t just be a whole lot less work to fork the original repo or just override the steps that use bower. I can try to put some example things together soon and those might serve as some pointer to making this easier to bundle?

I made an example here GitHub - justinwoo/insect at soba

See https://github.com/justinwoo/insect/blob/968e0b6895500b8ccbf0b7b8192049fcb2c8d51a/FORK-NOTES.md

Here is a fork of insect which does the following:

* Remove the need for bower, pushing deps to psc-package or npm
* Introduce a nix shell that can install psc-package dependencies in the format needed by psc-package and pulp
* Has pulp run using psc-package

You should be able to get everything running doing

> nix-shell --run 'npm install'

> npm start

There’s not too much involved, so you can dig into shell.nix and start prying out things you need yourself. You can also eventually get rid of pulp usage entirely by preparing args for purs bundle yourself, so that you don’t have to copy over psc-package dependencies into the local directory, but it’s not quite necessary afaict.

Hopefully this can be a reference for when choosing how to package up insect.

1 Like

I appreciate this. I’m not really sure where to go from here though, as I don’t particularly want to maintain a fork, and given that the upstream author chose to use bower I’m not sure if they’re open to ditching that just to make Nix packaging easier.

I don’t think many people really “chose” bower, it was just chosen for them. I don’t see very much that would require a big amount of work to maintain a fork from the original project, but the other question is if it’s at all worth it to have everyone build the project from the PureScript sources. On the other hand, I do not think that a nixpkgs PR with a generated sources would be accepted, but I guess I would also ask if this is an important goal.

I signed myself up to help maintain that the project uses only psc-package and npm for deps: move to using psc-package and npm for bower deps by justinwoo · Pull Request #217 · sharkdp/insect · GitHub

From here it seems like there should just be a separate project that manages how the sources from upstream can be pulled down and then combined with nix tooling for installing the actual dependencies and running a specific build to get the output desired.

1 Like