1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/pkgs/applications/networking/cluster/panamax/api/default.nix

77 lines
2.2 KiB
Nix
Raw Normal View History

2015-02-07 14:26:16 +00:00
{ stdenv, buildEnv, fetchgit, fetchurl, makeWrapper, bundlerEnv, bundler_HEAD
, ruby, libxslt, libxml2, sqlite, openssl, cacert, docker
2014-12-08 09:02:57 +00:00
, dataDir ? "/var/lib/panamax-api" }:
2015-01-07 01:40:55 +00:00
with stdenv.lib;
2014-12-08 09:02:57 +00:00
2015-03-18 13:12:13 +00:00
stdenv.mkDerivation rec {
name = "panamax-api-${version}";
version = "0.2.16";
env = bundlerEnv {
name = "panamax-api-gems-${version}";
inherit ruby;
gemset = ./gemset.nix;
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
buildInputs = [ openssl ];
};
bundler = bundler_HEAD.override { inherit ruby; };
2015-01-07 01:40:55 +00:00
database_yml = builtins.toFile "database.yml" ''
production:
adapter: sqlite3
database: <%= ENV["PANAMAX_DATABASE_PATH"] || "${dataDir}/db/mnt/db.sqlite3" %>
timeout: 5000
'';
2014-12-08 09:02:57 +00:00
2015-01-07 01:40:55 +00:00
src = fetchgit {
rev = "refs/tags/v${version}";
url = "git://github.com/CenturyLinkLabs/panamax-api";
2015-03-18 13:12:13 +00:00
sha256 = "1g75y25asj33gcczpb9iwnk6f7afm1xjqyw803rr3y2h7dm6jivy";
2015-01-07 01:40:55 +00:00
};
2014-12-08 09:02:57 +00:00
2015-02-07 14:26:16 +00:00
buildInputs = [ makeWrapper sqlite openssl env.ruby bundler ];
2014-12-08 09:02:57 +00:00
2015-01-07 01:40:55 +00:00
setSourceRoot = ''
mkdir -p $out/share
2015-02-07 14:26:16 +00:00
cp -R panamax-api $out/share/panamax-api
2015-01-07 01:40:55 +00:00
export sourceRoot="$out/share/panamax-api"
'';
2014-12-08 09:02:57 +00:00
2015-01-07 01:40:55 +00:00
postPatch = ''
find . -type f -exec sed -e 's|/usr/bin/docker|${docker}/bin/docker|g' -i "{}" \;
2014-12-08 09:02:57 +00:00
'';
2015-01-07 01:40:55 +00:00
configurePhase = ''
2014-12-08 09:02:57 +00:00
export HOME=$PWD
2015-02-07 14:26:16 +00:00
export GEM_HOME=${env}/${env.ruby.gemPath}
2014-12-08 09:02:57 +00:00
export RAILS_ENV=production
2015-01-07 01:40:55 +00:00
ln -sf ${database_yml} config/database.yml
2014-12-08 09:02:57 +00:00
'';
2015-01-07 01:40:55 +00:00
installPhase = ''
rm -rf log tmp
mv ./db ./_db
ln -sf ${dataDir}/{db,state/log,state/tmp} .
mkdir -p $out/bin
makeWrapper bin/bundle "$out/bin/bundle" \
--run "cd $out/share/panamax-api" \
2015-02-07 14:26:16 +00:00
--prefix "PATH" : "$out/share/panamax-api/bin:${env.ruby}/bin:$PATH" \
2015-01-07 01:40:55 +00:00
--prefix "HOME" : "$out/share/panamax-api" \
2015-02-07 14:26:16 +00:00
--prefix "GEM_HOME" : "${env}/${env.ruby.gemPath}" \
--prefix "SSL_CERT_FILE" : "${cacert}/etc/ssl/certs/ca-bundle.crt" \
2015-02-07 14:26:16 +00:00
--prefix "GEM_PATH" : "$out/share/panamax-api:${bundler}/${env.ruby.gemPath}"
2014-12-08 09:02:57 +00:00
'';
2015-01-07 01:40:55 +00:00
meta = with stdenv.lib; {
homepage = https://github.com/CenturyLinkLabs/panamax-api;
description = "The API behind The Panamax UI";
license = licenses.asl20;
maintainers = with maintainers; [ matejc offline ];
platforms = platforms.linux;
};
}