Create new Rails project $PROJECT_NAME:
$ nix-shell -p "ruby_3_0.withPackages (ps: with ps; [ rails ])" -p bundix -p sqlite \
--run "rails new $PROJECT_NAME --skip-bundle --webpacker react && \
cd $PROJECT_NAME && \
bundle config set force_ruby_platform true && \
bundle lock && \
bundix --ruby=ruby_3_0"Create shell.nix, replace $PROJECT_NAME with your project name:
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
env = bundlerEnv {
name = "$PROJECT_NAME-bundle";
gemdir = ./.;
ruby = ruby_3_0;
};
in mkShell {
buildInputs = [
env
env.wrappedRuby
# Additional utilities
sqlite
nodejs-16_x
yarn
];
}Post install:
$ rails webpacker:install
$ rails db:migrate