default.nix
197 lines
| 5.8 KiB
| text/x-nix
|
NixLexer
r0 | # Nix environment for the community edition | |||
# | ||||
# This shall be as lean as possible, just producing the rhodecode-vcsserver | ||||
# derivation. For advanced tweaks to pimp up the development environment we use | ||||
# "shell.nix" so that it does not have to clutter this file. | ||||
r472 | args@ | |||
r639 | { system ? builtins.currentSystem | |||
, pythonPackages ? "python27Packages" | ||||
r0 | , pythonExternalOverrides ? self: super: {} | |||
r472 | , doCheck ? false | |||
, ... | ||||
r0 | }: | |||
r571 | let | |||
r639 | pkgs_ = args.pkgs or (import <nixpkgs> { inherit system; }); | |||
r571 | in | |||
r0 | ||||
let | ||||
r571 | pkgs = import <nixpkgs> { | |||
r472 | overlays = [ | |||
(import ./pkgs/overlays.nix) | ||||
]; | ||||
r570 | inherit | |||
(pkgs_) | ||||
r472 | system; | |||
r571 | }; | |||
r116 | ||||
r472 | # Works with the new python-packages, still can fallback to the old | |||
# variant. | ||||
basePythonPackagesUnfix = basePythonPackages.__unfix__ or ( | ||||
self: basePythonPackages.override (a: { inherit self; })); | ||||
r0 | ||||
r472 | # Evaluates to the last segment of a file system path. | |||
basename = path: with pkgs.lib; last (splitString "/" path); | ||||
r0 | ||||
r472 | # source code filter used as arugment to builtins.filterSource. | |||
r0 | src-filter = path: type: with pkgs.lib; | |||
let | ||||
ext = last (splitString "." path); | ||||
in | ||||
r472 | !builtins.elem (basename path) [ | |||
".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev" | ||||
r571 | "node_modules" "node_binaries" | |||
r472 | "build" "data" "result" "tmp"] && | |||
!builtins.elem ext ["egg-info" "pyc"] && | ||||
# 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-*". | ||||
!hasPrefix "result" path; | ||||
r0 | ||||
r472 | sources = | |||
let | ||||
r570 | inherit | |||
(pkgs.lib) | ||||
all | ||||
isString | ||||
attrValues; | ||||
r472 | sourcesConfig = pkgs.config.rc.sources or {}; | |||
in | ||||
# Ensure that sources are configured as strings. Using a path | ||||
# would result in a copy into the nix store. | ||||
assert all isString (attrValues sourcesConfig); | ||||
sourcesConfig; | ||||
version = builtins.readFile "${rhodecode-vcsserver-src}/vcsserver/VERSION"; | ||||
r0 | rhodecode-vcsserver-src = builtins.filterSource src-filter ./.; | |||
pythonLocalOverrides = self: super: { | ||||
r472 | rhodecode-vcsserver = | |||
let | ||||
releaseName = "RhodeCodeVCSServer-${version}"; | ||||
in super.rhodecode-vcsserver.override (attrs: { | ||||
inherit | ||||
doCheck | ||||
version; | ||||
r135 | ||||
r18 | name = "rhodecode-vcsserver-${version}"; | |||
r472 | releaseName = releaseName; | |||
r0 | src = rhodecode-vcsserver-src; | |||
r174 | dontStrip = true; # prevent strip, we don't need it. | |||
r0 | ||||
r472 | # expose following attributed outside | |||
r0 | passthru = { | |||
pythonPackages = self; | ||||
}; | ||||
r472 | propagatedBuildInputs = | |||
attrs.propagatedBuildInputs or [] ++ [ | ||||
pkgs.git | ||||
pkgs.subversion | ||||
]; | ||||
r496 | # set some default locale env variables | |||
LC_ALL = "en_US.UTF-8"; | ||||
LOCALE_ARCHIVE = | ||||
if pkgs.stdenv.isLinux | ||||
then "${pkgs.glibcLocales}/lib/locale/locale-archive" | ||||
else ""; | ||||
r472 | # Add bin directory to path so that tests can find 'vcsserver'. | |||
r0 | preCheck = '' | |||
export PATH="$out/bin:$PATH" | ||||
''; | ||||
r472 | # custom check phase for testing | |||
r135 | checkPhase = '' | |||
runHook preCheck | ||||
r472 | PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=vcsserver --cov-report=term-missing vcsserver | |||
r135 | runHook postCheck | |||
''; | ||||
r472 | postCheck = '' | |||
echo "Cleanup of vcsserver/tests" | ||||
rm -rf $out/lib/${self.python.libPrefix}/site-packages/vcsserver/tests | ||||
''; | ||||
r0 | postInstall = '' | |||
r472 | echo "Writing vcsserver meta information for rccontrol to nix-support/rccontrol" | |||
r0 | mkdir -p $out/nix-support/rccontrol | |||
cp -v vcsserver/VERSION $out/nix-support/rccontrol/version | ||||
r472 | echo "DONE: vcsserver meta information for rccontrol written" | |||
mkdir -p $out/etc | ||||
cp configs/production.ini $out/etc | ||||
echo "DONE: saved vcsserver production.ini into $out/etc" | ||||
r0 | ||||
r226 | # python based programs need to be wrapped | |||
r472 | mkdir -p $out/bin | |||
r567 | ln -s ${self.python}/bin/python $out/bin/ | |||
r0 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ | |||
r567 | ln -s ${self.pyramid}/bin/prequest $out/bin/ | |||
ln -s ${self.pyramid}/bin/pserve $out/bin/ | ||||
r0 | ||||
# Symlink version control utilities | ||||
# We ensure that always the correct version is available as a symlink. | ||||
# So that users calling them via the profile path will always use the | ||||
r567 | # correct version. Wrapping is required so those can "import" | |||
# vcsserver python hooks. | ||||
r472 | ||||
r0 | ln -s ${pkgs.git}/bin/git $out/bin | |||
ln -s ${self.mercurial}/bin/hg $out/bin | ||||
ln -s ${pkgs.subversion}/bin/svn* $out/bin | ||||
r567 | ||||
r472 | echo "DONE: created symlinks into $out/bin" | |||
r567 | DEPS="$out/bin/*" | |||
r0 | ||||
r567 | # wrap only dependency scripts, they require to have full PYTHONPATH set | |||
# to be able to import all packages | ||||
for file in $DEPS; | ||||
r226 | do | |||
r0 | wrapProgram $file \ | |||
r472 | --prefix PATH : $PATH \ | |||
--prefix PYTHONPATH : $PYTHONPATH \ | ||||
r0 | --set PYTHONHASHSEED random | |||
done | ||||
r567 | ||||
r472 | echo "DONE: vcsserver binary wrapping" | |||
r226 | ||||
r0 | ''; | |||
}); | ||||
}; | ||||
r472 | basePythonPackages = with builtins; | |||
if isAttrs pythonPackages then | ||||
pythonPackages | ||||
else | ||||
getAttr pythonPackages pkgs; | ||||
pythonGeneratedPackages = import ./pkgs/python-packages.nix { | ||||
r570 | inherit | |||
pkgs; | ||||
inherit | ||||
(pkgs) | ||||
fetchurl | ||||
fetchgit | ||||
fetchhg; | ||||
r472 | }; | |||
pythonVCSServerOverrides = import ./pkgs/python-packages-overrides.nix { | ||||
r570 | inherit | |||
pkgs | ||||
basePythonPackages; | ||||
r472 | }; | |||
r0 | # Apply all overrides and fix the final package set | |||
r472 | myPythonPackagesUnfix = with pkgs.lib; | |||
r0 | (extends pythonExternalOverrides | |||
(extends pythonLocalOverrides | ||||
r472 | (extends pythonVCSServerOverrides | |||
(extends pythonGeneratedPackages | ||||
basePythonPackagesUnfix)))); | ||||
myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix); | ||||
r0 | ||||
in myPythonPackages.rhodecode-vcsserver | ||||