Giter VIP home page Giter VIP logo

rails-nix-sample's Introduction

Sample Rails App with Nix

This is a sample Rails application packaged with Nix, The Purely Functional Package Manager.

Development

You can enter the development environment by either running nix-shell at the project root (where there's the default.nix), or with direnv installed then just cd into the project.

Update Dependencies

If you add or removed some dependency, say after editing Gemfile, run bin/update-dependencies to get them updated.

Install in Nix Environment

To install the application into your Nix Environment, cd into the project directory then run:

nix-env --install -f default.nix

Afterwards, you can start the application server by running sample-rails-app-rails server, or get into the console with sample-rails-app-rails console. Other executables such as sample-rails-app-setup are available as well.

Use as a Package

You can also use this application as a dependent package, living under a system service such as Nginx + Passenger:

# NixOS Configuration
{ ... }:

let
  mkTheSampleRailsApp = import path/to/the/project/directory;
  app = mkTheSampleRailsApp {
    actionCable = {
      adapter = "redis";
      url = "redis://localhost:6379/0";
      channel_prefix = "sample-app-cable";
    };
  };
in {
  services.nginx = {
    virtualHosts."sample.rails.app" = {
      root = "${app}/public";
      extraConfig = ''
        passenger_enabled on;
        passenger_sticky_sessions on;
        passenger_ruby ${app.ruby}/bin/ruby;
        passenger_env_var GEM_HOME ${app.gemHome};
        passenger_env_var BUNDLE_GEMFILE ${app.bundleGemfile};
        passenger_env_var BUNDLE_PATH ${app.bundlePath};
        location /cable {
          passenger_app_group_name ${app.name}_action_cable;
          passenger_force_max_concurrent_requests_per_process 0;
        }
      '';
    };
  };
}

rails-nix-sample's People

Contributors

zetavg avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

brainrake

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.