Code Monkey home page Code Monkey logo

bower2nix's Introduction

bower2nix

Generate nix expressions to fetch bower dependencies.

Usage

usage: bower2nix [-h] [-v] [INPUT] [OUTPUT]

Generate nix expressions to fetch bower dependencies

Positional arguments:
  INPUT          The bower.json file (default: ./bower.json)
  OUTPUT         The output file to generate (default: stdout)

Optional arguments:
  -h, --help     Show this help message and exit.
  -v, --version  Show program's version number and exit.

Example

If you have a bower.json file like this:

{
  "name": "bower-test",
  "dependencies": {
    "angular": "~1.4.0"
  }
}

Then running bower2nix bower.json bower-generated.nix will generate something like this:

# bower-generated.nix
{ fetchbower, buildEnv }:
buildEnv { name = "bower-env"; ignoreCollisions = true; paths = [
  (fetchbower "angular" "1.4.9" "~1.4.0" "0a2754zsxv9dngpg08gkr9fdwv75y986av12q4drf1sm8p8cj6bs")
]; }

The resulting derivation is a union of all the downloaded bower packages (and their dependencies).

How to use in your project

Usually, you want a bower_components directory. This can be generated with bower install by pointing it at the environment of downloaded bower packages.

  bowerComponents = pkgs.stdenv.mkDerivation {
    name = "bower-test";
    generated = ./bower-generated.nix;
    src = mySources;
  };

The resulting derivation contains a bower_components directory which is ready to use in your project's build process.

There is a small example within the example subdirectory of this repo.

For more information, see the Nixpkgs manual (unstable version).

Fetch Bower

For testing purposes, a single package can be downloaded. For example: fetch-bower angular '~1.4.0' '1.4.8'. If no output directory is provided, the package attributes will be shown, and the package contents discarded.

usage: fetch-bower [-h] [-v] [--out DIR] NAME [TARGET] [VERSION]

Fetch a single bower dependency

Positional arguments:
  NAME               Package name
  TARGET             Target version range
  VERSION            Exact package version

Optional arguments:
  -h, --help         Show this help message and exit.
  -v, --version      Show program's version number and exit.
  --out DIR, -o DIR  Output directory

Requirements

bower2nix requires an ES6 interpreter to run. Practically, this means running NixOS 16.03 or higher because it includes Node.js 4.x.

Authors

  • Shea Levy @shlevy
  • Rodney Lorrimar @rvl

bower2nix's People

Contributors

rvl avatar shlevy avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.