Skip to content

Instantly share code, notes, and snippets.

@joefiorini
Created September 18, 2014 06:16
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joefiorini/aec2ae84b0d3c073dab8 to your computer and use it in GitHub Desktop.
Save joefiorini/aec2ae84b0d3c073dab8 to your computer and use it in GitHub Desktop.
Nix Expression for Running Rails Apps
with (import <nixpkgs> {});
stdenv.mkDerivation {
name = "717-app";
buildInputs = [ libiconv openssl ruby21 postgresql git nodejs ];
src = "/src/717";
builder = builtins.toFile "builder.sh" ''
set -e
source $stdenv/setup
export GEM_HOME=$out/.gems
export HOME=$out
export PATH=$out/.gems/bin:$PATH
export ICONV=/nix/store/3j8ixbc22mrz5bsb1jlchmiza8ahmpks-libiconv-1.13.1
echo "Performing setup in $src with ICONV $ICONV"
(cd $src &&
gem install --no-user-install --no-http-proxy --no-document bundler &&
bundle config build.nokogiri --with-iconv-dir=$ICONV &&
bundle install --path=.gems &&
npm install)
'';
shellHook = ''
export PGDATA=/var/srv/pg
export GEM_HOME=$out/.gems
export PATH=$out/.gems/bin:$PATH
if [ ! -d $PGDATA ]; then
initdb
fi
if [ $autostart-postgres ]; then
pg_ctl -D $PGDATA -l $src/log/pg.log start
trap 'pg_ctl -D $PGDATA stop' EXIT
fi
'';
system = "x86_64-darwin";
}
@Mayeu
Copy link

Mayeu commented Apr 14, 2015

Hi, I have try to modify your script to use the new bundlerEnv system, but I did not succeed. Could you take a look at what I did: https://www.mail-archive.com/nix-dev@lists.science.uu.nl/msg15388.html (link to my e-mail on the nix-dev list).

Thanks

@justgage
Copy link

justgage commented Aug 6, 2015

To get it semi-working I had to change ruby21 to ruby_2_1. It seems that you hard coded the PGDATA to some root directory. I haven't tried doing it somewhere else but is this required? I haven't tried running it with sudo (because I have another postgres installed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment