default.nix
243 lines
| 7.4 KiB
| text/x-nix
|
NixLexer
r1 | # Nix environment for the community edition | |||
# | ||||
# This shall be as lean as possible, just producing the Enterprise | ||||
# derivation. For advanced tweaks to pimp up the development environment we use | ||||
# "shell.nix" so that it does not have to clutter this file. | ||||
{ pkgs ? (import <nixpkgs> {}) | ||||
, pythonPackages ? "python27Packages" | ||||
, pythonExternalOverrides ? self: super: {} | ||||
, doCheck ? true | ||||
}: | ||||
let pkgs_ = pkgs; in | ||||
let | ||||
pkgs = pkgs_.overridePackages (self: super: { | ||||
# Override subversion derivation to | ||||
# - activate python bindings | ||||
# - set version to 1.8 | ||||
subversion = super.subversion18.override { | ||||
httpSupport = true; | ||||
pythonBindings = true; | ||||
python = self.python27Packages.python; | ||||
}; | ||||
}); | ||||
inherit (pkgs.lib) fix extends; | ||||
basePythonPackages = with builtins; if isAttrs pythonPackages | ||||
then pythonPackages | ||||
else getAttr pythonPackages pkgs; | ||||
r725 | buildBowerComponents = | |||
pkgs.buildBowerComponents or | ||||
(import ./pkgs/backport-16.03-build-bower-components.nix { inherit pkgs; }); | ||||
r1 | elem = builtins.elem; | |||
basename = path: with pkgs.lib; last (splitString "/" path); | ||||
startsWith = prefix: full: let | ||||
actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full; | ||||
in actualPrefix == prefix; | ||||
src-filter = path: type: with pkgs.lib; | ||||
let | ||||
ext = last (splitString "." path); | ||||
in | ||||
!elem (basename path) [ | ||||
r722 | ".git" ".hg" "__pycache__" ".eggs" | |||
"bower_components" "node_modules" | ||||
r723 | "build" "data" "result" "tmp"] && | |||
r1 | !elem ext ["egg-info" "pyc"] && | |||
r723 | # TODO: johbo: This check is wrong, since "path" contains an absolute path, | |||
# it would still be good to restore it since we want to ignore "result-*". | ||||
r1 | !startsWith "result" path; | |||
Martin Bornhold
|
r211 | sources = pkgs.config.rc.sources or {}; | ||
r724 | version = builtins.readFile ./rhodecode/VERSION; | |||
r1 | rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.; | |||
r708 | nodeEnv = import ./pkgs/node-default.nix { | |||
inherit pkgs; | ||||
r1 | }; | |||
r708 | nodeDependencies = nodeEnv.shell.nodeDependencies; | |||
r1 | ||||
r725 | bowerComponents = buildBowerComponents { | |||
r724 | name = "enterprise-ce-${version}"; | |||
r719 | generated = ./pkgs/bower-packages.nix; | |||
src = rhodecode-enterprise-ce-src; | ||||
}; | ||||
r1 | pythonGeneratedPackages = self: basePythonPackages.override (a: { | |||
inherit self; | ||||
}) | ||||
// (scopedImport { | ||||
self = self; | ||||
super = basePythonPackages; | ||||
inherit pkgs; | ||||
inherit (pkgs) fetchurl fetchgit; | ||||
} ./pkgs/python-packages.nix); | ||||
pythonOverrides = import ./pkgs/python-packages-overrides.nix { | ||||
inherit | ||||
basePythonPackages | ||||
pkgs; | ||||
}; | ||||
pythonLocalOverrides = self: super: { | ||||
rhodecode-enterprise-ce = | ||||
let | ||||
r720 | linkNodeAndBowerPackages = '' | |||
r1 | echo "Link node packages" | |||
rm -fr node_modules | ||||
r708 | mkdir node_modules | |||
# johbo: Linking individual packages allows us to run "npm install" | ||||
# inside of a shell to try things out. Re-entering the shell will | ||||
# restore a clean environment. | ||||
ln -s ${nodeDependencies}/lib/node_modules/* node_modules/ | ||||
r1 | echo "DONE: Link node packages" | |||
r720 | ||||
echo "Link bower packages" | ||||
rm -fr bower_components | ||||
mkdir bower_components | ||||
ln -s ${bowerComponents}/bower_components/* bower_components/ | ||||
echo "DONE: Link bower packages" | ||||
r1 | ''; | |||
in super.rhodecode-enterprise-ce.override (attrs: { | ||||
r241 | inherit | |||
doCheck | ||||
version; | ||||
r1 | name = "rhodecode-enterprise-ce-${version}"; | |||
r241 | releaseName = "RhodeCodeEnterpriseCE-${version}"; | |||
r1 | src = rhodecode-enterprise-ce-src; | |||
buildInputs = | ||||
attrs.buildInputs ++ | ||||
(with self; [ | ||||
r709 | pkgs.nodePackages.bower | |||
r1 | pkgs.nodePackages.grunt-cli | |||
pkgs.subversion | ||||
pytest-catchlog | ||||
Martin Bornhold
|
r218 | rhodecode-testdata | ||
r1 | ]); | |||
propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [ | ||||
rhodecode-tools | ||||
]); | ||||
# TODO: johbo: Make a nicer way to expose the parts. Maybe | ||||
# pkgs/default.nix? | ||||
passthru = { | ||||
r74 | inherit | |||
r719 | bowerComponents | |||
r720 | linkNodeAndBowerPackages | |||
r465 | myPythonPackagesUnfix | |||
pythonLocalOverrides; | ||||
r1 | pythonPackages = self; | |||
r720 | ||||
# johbo: Legacy support for the EE build mechanisms | ||||
linkNodeModules = linkNodeAndBowerPackages; | ||||
r1 | }; | |||
LC_ALL = "en_US.UTF-8"; | ||||
LOCALE_ARCHIVE = | ||||
if pkgs.stdenv ? glibc | ||||
then "${pkgs.glibcLocales}/lib/locale/locale-archive" | ||||
else ""; | ||||
# Somewhat snappier setup of the development environment | ||||
# TODO: move into shell.nix | ||||
# TODO: think of supporting a stable path again, so that multiple shells | ||||
# can share it. | ||||
shellHook = '' | ||||
tmp_path=$(mktemp -d) | ||||
export PATH="$tmp_path/bin:$PATH" | ||||
export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH" | ||||
mkdir -p $tmp_path/${self.python.sitePackages} | ||||
python setup.py develop --prefix $tmp_path --allow-hosts "" | ||||
r720 | '' + linkNodeAndBowerPackages; | |||
r1 | ||||
preCheck = '' | ||||
export PATH="$out/bin:$PATH" | ||||
''; | ||||
postCheck = '' | ||||
rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons | ||||
rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests | ||||
''; | ||||
r720 | preBuild = linkNodeAndBowerPackages + '' | |||
r1 | grunt | |||
rm -fr node_modules | ||||
''; | ||||
postInstall = '' | ||||
# python based programs need to be wrapped | ||||
ln -s ${self.supervisor}/bin/supervisor* $out/bin/ | ||||
ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ | ||||
ln -s ${self.PasteScript}/bin/paster $out/bin/ | ||||
r526 | ln -s ${self.channelstream}/bin/channelstream $out/bin/ | |||
r167 | ln -s ${self.pyramid}/bin/* $out/bin/ #*/ | |||
r1 | ||||
# rhodecode-tools | ||||
# TODO: johbo: re-think this. Do the tools import anything from enterprise? | ||||
ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/ | ||||
# note that condition should be restricted when adding further tools | ||||
for file in $out/bin/*; do #*/ | ||||
wrapProgram $file \ | ||||
--prefix PYTHONPATH : $PYTHONPATH \ | ||||
r167 | --prefix PATH : $PATH \ | |||
r1 | --set PYTHONHASHSEED random | |||
done | ||||
mkdir $out/etc | ||||
cp configs/production.ini $out/etc | ||||
echo "Writing meta information for rccontrol to nix-support/rccontrol" | ||||
mkdir -p $out/nix-support/rccontrol | ||||
cp -v rhodecode/VERSION $out/nix-support/rccontrol/version | ||||
echo "DONE: Meta information for rccontrol written" | ||||
# TODO: johbo: Make part of ac-tests | ||||
if [ ! -f rhodecode/public/js/scripts.js ]; then | ||||
echo "Missing scripts.js" | ||||
exit 1 | ||||
fi | ||||
if [ ! -f rhodecode/public/css/style.css ]; then | ||||
echo "Missing style.css" | ||||
exit 1 | ||||
fi | ||||
''; | ||||
}); | ||||
Martin Bornhold
|
r218 | rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" { | ||
inherit | ||||
doCheck | ||||
pkgs | ||||
pythonPackages; | ||||
r1 | }; | |||
}; | ||||
Martin Bornhold
|
r211 | rhodecode-testdata-src = sources.rhodecode-testdata or ( | ||
pkgs.fetchhg { | ||||
url = "https://code.rhodecode.com/upstream/rc_testdata"; | ||||
Martin Bornhold
|
r219 | rev = "v0.8.0"; | ||
sha256 = "0hy1ba134rq2f9si85yx7j4qhc9ky0hjzdk553s3q026i7km809m"; | ||||
Martin Bornhold
|
r211 | }); | ||
r1 | # Apply all overrides and fix the final package set | |||
myPythonPackagesUnfix = | ||||
(extends pythonExternalOverrides | ||||
(extends pythonLocalOverrides | ||||
(extends pythonOverrides | ||||
pythonGeneratedPackages))); | ||||
myPythonPackages = (fix myPythonPackagesUnfix); | ||||
in myPythonPackages.rhodecode-enterprise-ce | ||||