Skip to content

Instantly share code, notes, and snippets.

@goofansu
Created May 21, 2023 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofansu/c676a14143ed3c1124d3c92950a4df3b to your computer and use it in GitHub Desktop.
Save goofansu/c676a14143ed3c1124d3c92950a4df3b to your computer and use it in GitHub Desktop.
Nix: basic configuration for a newly created Rails 7 application
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
fi
use flake
PATH_add bin
{
description = "Rails 7 dev environment";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
in with pkgs; {
devShells.default = pkgs.mkShell {
packages = [ ruby_3_2 postgresql_14 redis ];
shellHook = ''
export PGDATA=$PWD/.pgdata
# Initialize MySQL data directory
if [ ! -d "$PGDATA" ]; then
initdb $PGDATA
fi
'';
};
});
}
web: bin/rails server -p 3000
css: bin/rails tailwindcss:watch
db: postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment