All Projects → areina → nix-new-rails-app

areina / nix-new-rails-app

Licence: other
Initialize Rails applications using Nix and development environments (nix-shell)

Programming Languages

Nix
1067 projects
shell
77523 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to nix-new-rails-app

nixcrates
DEPRECATED reads rust-lang/crates.io-index and outputs nix expressions into fractalide/nix-crates-index
Stars: ✭ 14 (-48.15%)
Mutual labels:  nix, nixos
dotfiles
Dotfiles for my NixOS system based on Dracula theme
Stars: ✭ 39 (+44.44%)
Mutual labels:  nix, nixos
nixos-tutorial
one hour, hands-on
Stars: ✭ 118 (+337.04%)
Mutual labels:  nix, nixos
nixery
Container registry which transparently builds images using the Nix package manager. Canonical repository is https://cs.tvl.fyi/depot/-/tree/tools/nixery
Stars: ✭ 1,365 (+4955.56%)
Mutual labels:  nix, nixos
dotfiles
No place like ~. Nix. All. The. Things.
Stars: ✭ 48 (+77.78%)
Mutual labels:  nix, nixos
nix-rice
A library to functionally define your configuration and theme (rice) with Nix
Stars: ✭ 43 (+59.26%)
Mutual labels:  nix, nixos
triton
Triton Operating System
Stars: ✭ 56 (+107.41%)
Mutual labels:  nix, nixos
nixdots
I have no idea what the hell I'm doing
Stars: ✭ 46 (+70.37%)
Mutual labels:  nix, nixos
nixos-on-arm
Cross Compiling NixOS to ARM as a replacement for Yocto
Stars: ✭ 129 (+377.78%)
Mutual labels:  nix, nixos
homeage
runtime decrypted age secrets for nix home manager
Stars: ✭ 43 (+59.26%)
Mutual labels:  nix, nixos
dotfiles
NixOS system config & Home-Manager user config
Stars: ✭ 43 (+59.26%)
Mutual labels:  nix, nixos
nix-config
NixOS configuration (also on WSL)
Stars: ✭ 51 (+88.89%)
Mutual labels:  nix, nixos
nixos-config
My NixOS configuration
Stars: ✭ 23 (-14.81%)
Mutual labels:  nix, nixos
nixpkgs-python-importer
Violate Nix philosophy, install Python packages mid-session with `from nixpkgs.scipy import scipy`.
Stars: ✭ 27 (+0%)
Mutual labels:  nix, nixos
base16.nix
Quickly theme programs in your favourite base16 colorscheme
Stars: ✭ 61 (+125.93%)
Mutual labels:  nix, nixos
deadnix
Scan Nix files for dead code
Stars: ✭ 121 (+348.15%)
Mutual labels:  nix, nixos
yants
Yet Another Nix Type System | Source has moved to https://git.tazj.in/tree/nix/yants
Stars: ✭ 35 (+29.63%)
Mutual labels:  nix, nixos
dotfiles
🏠
Stars: ✭ 53 (+96.3%)
Mutual labels:  nix, nixos
nix-bisect
Bisect nix builds. Status: alpha/proof of concept. You'll probably have to dig into the implementation if you want to use it. Built for personal use, lightly maintained. PRs welcome. Issues welcome, but I make no promises regarding responses or fix
Stars: ✭ 72 (+166.67%)
Mutual labels:  nix, nixos
nyx
⚙️Nix[OS] Configuration
Stars: ✭ 50 (+85.19%)
Mutual labels:  nix, nixos

Initialize a Rails application using Nix

Motivation

Recently, I needed to create a new Rails application, and now that I'm using NixOS and Nix, I had no idea about how to do it. Fortunately, Ruby development using Nix seemed solved, so I just needed a way to initialize a new Rails application with Nix and using its development environments.

This template will help you with the process, generating a new project with the latest version of Rails (5.0.1).

Usage

First of all, clone the project:

$ git clone https://github.com/areina/nix-new-rails-app.git my_new_rails_app

Automatic

There is a script script/init that executes all the necessary steps to have your new shiny Rails application initialized. I will describe all the steps below, and you can execute them manually if you prefer.

Manual

  1. Generate a Gemfile.lock with all necessary gems for creating a Rails app.

    $ nix-shell -p bundler --command "bundler lock"
    
  2. Generate a gemset.nix with nix packages definitions for those gems.

    $ $(nix-build '<nixpkgs>' -A bundix)/bin/bundix
    
  3. Initialize the rails app and generate a new Gemfile.lock with dependencies for this new app.

    $ nix-shell --command "rails new . --force --skip-bundle; bundler lock"
    
  4. Generate a new gemset.nix with all package dependencies for running your app

    $ $(nix-build '<nixpkgs>' -A bundix)/bin/bundix
    

At this point, your app is initialized. You can enter to your isolated development environment and run for example the rails server:

$ nix-shell
[nix-shell:...] $ rails server
=> Booting Puma
=> Rails 5.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.7.0 (ruby 2.3.3-p222), codename: Snowy Sagebrush
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

Visit http://localhost:3000 and you should see the Rails default page and in your shell something like this, confirming that we're using nix packages:

Started GET "/" for 127.0.0.1 at 2017-02-05 22:14:25 +0100
Processing by Rails::WelcomeController#index as HTML
  Parameters: {"internal"=>true}
  Rendering /nix/store/x5idkhdyk38i50fs4n6hbhv07ipm3vbz-rb/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /nix/store/x5idkhdyk38i50fs4n6hbhv07ipm3vbz-rb/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/templates/rails/welcome/index.html.erb (3.5ms)
Completed 200 OK in 14ms (Views: 6.4ms | ActiveRecord: 0.0ms)

Now that you're ready for hacking your new Rails app, remember removing the .git directory to be detached of this repo, and start tracking your own changes. You can execute script/eject or do it manually:

$ rm -rf .git/
$ rm -rf script/
# And probably you will like to init your own history :-)
$ git init
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].