https://github.com/zetavg/rails-nix-sample
Minimum Rails app packaged by Nix
https://github.com/zetavg/rails-nix-sample
nix rails sample sample-project
Last synced: 2 months ago
JSON representation
Minimum Rails app packaged by Nix
- Host: GitHub
- URL: https://github.com/zetavg/rails-nix-sample
- Owner: zetavg
- Created: 2019-03-21T15:17:41.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-19T12:12:37.000Z (over 2 years ago)
- Last Synced: 2025-04-01T22:59:57.475Z (2 months ago)
- Topics: nix, rails, sample, sample-project
- Language: Nix
- Homepage: https://rails.sample.serv.cat/
- Size: 245 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sample Rails App with Nix
This is a sample Rails application packaged with [Nix, The Purely Functional Package Manager](https://nixos.org/nix/).
## 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](https://direnv.net/) 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:
```bash
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:
```nix
# 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;
}
'';
};
};
}
```