default.nix
171 lines
| 5.3 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@ | |||
{ pythonPackages ? "python27Packages" | ||||
r0 | , pythonExternalOverrides ? self: super: {} | |||
r472 | , doCheck ? false | |||
, ... | ||||
r0 | }: | |||
r472 | let pkgs_ = (import <nixpkgs> {}); in | |||
r0 | ||||
let | ||||
r116 | ||||
r472 | # TODO: Currently we ignore the passed in pkgs, instead we should use it | |||
# somehow as a base and apply overlays to it. | ||||
pkgs = import <nixpkgs> { | ||||
overlays = [ | ||||
(import ./pkgs/overlays.nix) | ||||
]; | ||||
inherit (pkgs_) | ||||
system; | ||||
}; | ||||
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" | ||||
"bower_components" "node_modules" | ||||
"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 | ||||
inherit (pkgs.lib) all isString attrValues; | ||||
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 | ||||
]; | ||||
# 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 | |||
ln -s ${self.python}/bin/python $out/bin | ||||
Martin Bornhold
|
r89 | ln -s ${self.pyramid}/bin/* $out/bin/ | ||
r0 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ | |||
# 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 | ||||
# correct version. | ||||
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 | ||||
r472 | echo "DONE: created symlinks into $out/bin" | |||
r0 | ||||
r226 | for file in $out/bin/*; | |||
do | ||||
r0 | wrapProgram $file \ | |||
r472 | --prefix PATH : $PATH \ | |||
--prefix PYTHONPATH : $PYTHONPATH \ | ||||
r0 | --set PYTHONHASHSEED random | |||
done | ||||
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 { | ||||
inherit pkgs; | ||||
inherit (pkgs) fetchurl fetchgit fetchhg; | ||||
}; | ||||
pythonVCSServerOverrides = import ./pkgs/python-packages-overrides.nix { | ||||
inherit pkgs basePythonPackages; | ||||
}; | ||||
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 | ||||