GithubHelp home page GithubHelp logo

isabella232 / bundix Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shopify/bundix

0.0 0.0 0.0 445 KB

Generates a Nix expression for your Bundler-managed application. [maintainer=@manveru]

Ruby 90.08% Nix 8.01% HTML 1.92%

bundix's Introduction

About

Bundix makes it easy to package your Bundler-enabled Ruby applications with the Nix package manager.

Installation

Installing from this repo:

nix-env -iA bundix

Please note that in order to actually use this gem you must have Nix installed.

Basic Usage

I recommend first reading the nixpkgs manual entry for Ruby as this README might become outdated, it's a short read right now, so you won't regret it.

  1. Making a gemset.nix

    Change to your project's directory and run this:

    bundix -l
    

    This will generate a gemset.nix file that you then can use in your bundlerEnv expression like this:

  2. Using nix-shell

    To try your package in nix-shell, create a default.nix like this:

    with (import <nixpkgs> {});
    let
      gems = bundlerEnv {
        name = "your-package";
        inherit ruby;
        gemdir = ./.;
      };
    in stdenv.mkDerivation {
      name = "your-package";
      buildInputs = [gems ruby];
    }

    and then simply run nix-shell.

  3. Proper packages

    To make a package for nixpkgs, you can try something like this:

    { stdenv, bundlerEnv, ruby }:
    let
      gems = bundlerEnv {
        name = "your-package";
        inherit ruby;
        gemdir  = ./.;
      };
    in stdenv.mkDerivation {
      name = "your-package";
      src = ./.;
      buildInputs = [gems ruby];
      installPhase = ''
        mkdir -p $out
        cp -r $src $out
      '';
    }

How & Why

I'd usually just tell you to read the code yourself, but the big picture is that bundix tries to fetch a hash for each of your bundle dependencies and store them all together in a format that Nix can understand and is then used by bundlerEnv.

I wrote this new version of bundix because I became frustrated with the poor performance of the old bundix, and wanted to save both time and bandwidth, as well as learn more about Nix.

For each gem, it first tries to look for an existing gem in the bundler cache (usually generated via bundle package), and if that fails it goes through each remote and tries to fetch the gem from there. If the remote happens to be rubygems.org we ask the API first for a hash of the gem, and then ask the Nix store whether we have this version already. Only if that also fails do we download the gem.

As an added bonus I also implemented parsing the gemset.nix if it already exists, and get hashes from there directly, that way updating an existing gemset.nix only takes a few seconds.

The output from bundix should be as stable as possible, to make auditing diffs easier, that's why I also implemented a pretty printer for the gemset.nix.

I hope you enjoy using bundix as much as I do, and if you don't, let me know.

Closing words

For any questions or suggestions, please file an issue on Github or ask in #nixos on Freenode.

Big thanks go out to Charles Strahan for his awesome work bringing Ruby to Nix, zimbatm for being a good rubber duck and tester, and Alexander Flatter for the original bundix. I couldn't have done this without you guys.

bundix's People

Contributors

manveru avatar cstrahan avatar alyssais avatar nyarly avatar aflatter avatar burke avatar lavoiesl avatar zimbatm avatar nonsequitur avatar ivanbrennan avatar bobvanderlinden avatar zoonfafer avatar pmahoney avatar pnelson avatar robx 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.