All Projects → mbbx6spp → Sinatra On Nix

mbbx6spp / Sinatra On Nix

An example Sinatra project using Nix to configure the development environment

Labels

Projects that are alternatives of or similar to Sinatra On Nix

Kubernix
Single dependency Kubernetes clusters for local testing, experimenting and development
Stars: ✭ 545 (+4092.31%)
Mutual labels:  nix
Nixpkgs
Nix Packages collection
Stars: ✭ 8,322 (+63915.38%)
Mutual labels:  nix
Nix Haskell Hls
Nix builds of Haskell Language Server
Stars: ✭ 24 (+84.62%)
Mutual labels:  nix
Reflex Platform
A curated package set and set of tools that let you build Haskell packages so they can run on a variety of platforms. reflex-platform is built on top of the nix package manager.
Stars: ✭ 602 (+4530.77%)
Mutual labels:  nix
Simple Twitter
A bare-bones Twitter clone implemented in a single file
Stars: ✭ 698 (+5269.23%)
Mutual labels:  nix
Nix Aurora
Nix on Aurora on Mesos
Stars: ✭ 6 (-53.85%)
Mutual labels:  nix
Awesome Nix
😎 A curated list of the best resources in the Nix community [[email protected]]
Stars: ✭ 388 (+2884.62%)
Mutual labels:  nix
Nixops
NixOps is a tool for deploying to NixOS machines in a network or cloud.
Stars: ✭ 838 (+6346.15%)
Mutual labels:  nix
Nix Darwin
nix modules for darwin
Stars: ✭ 700 (+5284.62%)
Mutual labels:  nix
Nixsap
Stars: ✭ 23 (+76.92%)
Mutual labels:  nix
Dotfiles
Zsh, Karabiner, VS Code, Sublime, Neovim, Nix
Stars: ✭ 634 (+4776.92%)
Mutual labels:  nix
Fractalide
Reusable Reproducible Composable Software
Stars: ✭ 670 (+5053.85%)
Mutual labels:  nix
Kevin Nix
NixOS for the Samsung Chromebook Plus (kevin)
Stars: ✭ 18 (+38.46%)
Mutual labels:  nix
Hnix
A Haskell re-implementation of the Nix expression language
Stars: ✭ 573 (+4307.69%)
Mutual labels:  nix
Life
A Nix configuration for macOS and Linux
Stars: ✭ 25 (+92.31%)
Mutual labels:  nix
Nix
Nix, the purely functional package manager
Stars: ✭ 5,291 (+40600%)
Mutual labels:  nix
Nix Config
My Nix configuration files
Stars: ✭ 5 (-61.54%)
Mutual labels:  nix
Haskell Nix
Nix and Haskell in production
Stars: ✭ 860 (+6515.38%)
Mutual labels:  nix
Configs
My configuration files
Stars: ✭ 26 (+100%)
Mutual labels:  nix
Dotfiles
Configuration files (.emacs)
Stars: ✭ 22 (+69.23%)
Mutual labels:  nix

Sinatra on Nix

Example Sinatra project using Nix to configure it.

Prerequisites

  • Nix 1.11+

Getting Started

$ cd path/to/this/clone
$ ./devenv
$ bundle install --path=.bundle

To start the Puma server running the App Sinatra web application and redis-server:

$ env RACK_ENV=bench0 bundle exec foreman start

In another terminal you can run benchmark via wrk:

$ ./bench
...

Note that all the following are installed:

  • Ruby v2.3.1p112
  • Redis v3.0.7
  • Bundler v1.12.5
  • wrk (mystery meat 2012 version because Go projects just are this way?)

Plus all of their transitive dependencies. Every time you run ./devenv with the pinned channel (peek inside the script devenv) you will get the exact same binaries on your OS/Arch pair, every time.

This is the power of Nix.

Package Definition

See Ruby Nix package definition (default.nix) for an example of how we would specify a Nix expression for the distributable dependencies for the application. We build the Puma Rubygems dependency with native Ruby/C setup.

Shell/Development Environment Definition

See Development environment definition (shell.nix) to see how we can write a Nix expression to specify a fully bootstrappable (only requirement is Nix tooling available in currently environment, nothing else) development environment.

We could have started off this project with the command line approximation of a dev environment for this project like so:

nix-shell -p ruby bundler bundix

This would have brought into scope the ruby tooling to get us started without a Nix expression initially.

Then we would have proceeded as Ruby developers with common startup steps for initializing a Ruby project like so:

$ echo "source 'https://rubygems.org'" > Gemfile
$ echo  >> Gemfile
$ echo "gem 'sinatra'"  >> Gemfile
# More dependencies
$ bundle package --path .bundle
# Generate gemsets.nix expression with dependencies included
$ bundix -d

Bundix is just a Nix expression encapsulating the dependencies defined in the Gemfile* files maintained/generated in accordance with the bundler tooling.

More information on managing Ruby projects can be found here: http://nixos.org/nixpkgs/manual/#sec-language-ruby

What's Next?

So what else can we do? Oh, I am so glad you asked...

  • Define Docker images using the same deterministic build/dependency management tooling Nix provides. See README.md here.

TODO:

  • AMI image example
  • Virtualbox image example
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].