Posted on October 30, 2017 by rodney
Tags: nerd, nix

I made a few bug fixes of bower2nix at the NixOS Hackathon on Monday. There are quite a few different ways dependencies and versions can be specified in bower so it’s a little effort to support all the combinations in use. I also added some regression tests which run on Travis CI against both the current NixOS release and the master branch.

Thankfully, the Bower package manager is quite old for a web development tool, so people have moved on to new and different things (currently it’s Yarn and Webpack), and I probably won’t have much more maintenance to do on bower2nix.

However if you need a quick way to grab a few javascript frontend dependencies for a web project, it’s still quite a useful tool. Install pkgs.nodePackages.bower and use it to generate a bower.json file with your dependencies. Then follow the instructions in the Nixpkgs manual to generate a Nix derivation which contains all the Bower dependencies.

The benefits of this are:

  1. It’s convenient to locate and install javascript packages (at least for packages which still have Bower builds).
  2. You don’t need to copy 3rd-party javascript into your source code repo (clean).
  3. Versions are frozen and the downloads are cached in your Nix store (reliable and fast).

I have used this just last week for my tour map web site. You can see an example default.nix there, in the context of a Haskell web frontend project.