Created
September 18, 2014 06:16
-
-
Save joefiorini/aec2ae84b0d3c073dab8 to your computer and use it in GitHub Desktop.
Nix Expression for Running Rails Apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | |
} |
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
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/[email protected]/msg15388.html (link to my e-mail on the nix-dev list).Thanks