##// END OF EJS Templates
packaging: switched to nix 20.03 packages and latest pip2nix code...
packaging: switched to nix 20.03 packages and latest pip2nix code - dependencies changed: atomicwrites==1.4.0 ipython==5.10.0 pytest==4.6.9 py==1.8.1 pytest-cov==2.8.1 pytest-sugar==0.9.3 pytest-runner==5.2.0 rhodecode-tools==2.0.0 ipython==5.10.0 mysqlclient==1.4.6 (change from mysql-python, which is deprecated) mako==1.1.2 lxml==4.5.0 click==7.1.2

File last commit:

r4756:2a5b3f8a python3
r4756:2a5b3f8a python3
Show More
shell.nix
139 lines | 4.4 KiB | text/x-nix | NixLexer
# This file contains the adjustments which are desired for a development
# environment.
{ pkgs ? (import <nixpkgs> {})
, pythonPackages ? "python27Packages"
, doCheck ? false
, sourcesOverrides ? {}
, doDevelopInstall ? true
, doReleaseInstall ? false
}:
let
# Get sources from config and update them with overrides.
sources = (pkgs.config.rc.sources or {}) // sourcesOverrides;
enterprise-ce = import ./default.nix {
inherit
pythonPackages
doCheck;
};
ce-pythonPackages = enterprise-ce.pythonPackages;
# This method looks up a path from `pkgs.config.rc.sources` and returns a
# shell script which does a `python setup.py develop` installation of it. If
# no path is found it will return an empty string.
optionalDevelopInstall = attributeName:
let
path = pkgs.lib.attrByPath [attributeName] null sources;
doDI = doDevelopInstall && path != null;
in
# do develop installation with empty hosts to skip any package duplicates to
# be replaced. This only pushes the package to be locally available
pkgs.lib.optionalString doDI (''
echo "[BEGIN] Develop install of '${attributeName}' from '${path}'"
pushd ${path}
python setup.py develop --prefix $tmp_path --allow-hosts ""
popd
echo "[DONE] Develop install of '${attributeName}' from '${path}'"
echo ""
'');
# This method looks up a path from `pkgs.config.rc.sources` and imports the
# default.nix file if it exists. It returns the list of build inputs. If no
# path is found it will return an empty list.
optionalDevelopInstallBuildInputs = attributeName:
let
path = pkgs.lib.attrByPath [attributeName] null sources;
nixFile = "${path}/default.nix";
doDI = doDevelopInstall && path != null && pkgs.lib.pathExists "${nixFile}";
derivate = import "${nixFile}" {
inherit
doCheck
pythonPackages;
};
in
pkgs.lib.lists.optionals doDI (
derivate.propagatedBuildInputs
);
optionalBinDeps = attributeName:
let
path = pkgs.lib.attrByPath [attributeName] null sources;
nixFile = "${path}/default.nix";
doDI = doDevelopInstall && path != null && pkgs.lib.pathExists "${nixFile}";
derivate = import "${nixFile}" {
inherit
doCheck
pythonPackages;
};
in
pkgs.lib.optionalString doDI (''
echo "Wrapping PATH with vcsserver vcs binaries"
export PATH="${derivate.vcs_pkgs.subversion}/bin:${derivate.vcs_pkgs.git}/bin:${derivate.pythonPackages.mercurial}/bin:$PATH"
'');
developInstalls = [ "rhodecode-vcsserver" ];
in enterprise-ce.override (attrs: rec {
# Avoid that we dump any sources into the store when entering the shell and
# make development a little bit more convenient.
src = null;
# Add dependencies which are useful for the development environment.
buildInputs =
attrs.buildInputs ++
(with ce-pythonPackages;
[ ipdb ]
++ pkgs.lib.lists.optionals doReleaseInstall (
[invoke bumpversion]
)
);
# place to inject some required libs from develop installs
propagatedBuildInputs =
attrs.propagatedBuildInputs ++
pkgs.lib.lists.concatMap optionalDevelopInstallBuildInputs developInstalls;
# Make sure we execute both hooks
shellHook = ''
runHook preShellHook
runHook postShellHook
'';
preShellHook = ''
echo "Entering rhodecode-ce"
# Custom prompt to distinguish from other dev envs.
export PS1="\n\[\033[1;32m\][rhodecode-ce-shell:\w]$\[\033[0m\] "
# Set locale
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive"
export LC_ALL="en_US.UTF-8"
echo "Building frontend assets"
${enterprise-ce.linkNodePackages}
# Setup a temporary directory.
tmp_path=$(mktemp -d)
export PATH="$tmp_path/bin:$PATH"
export PYTHONPATH="$tmp_path/${ce-pythonPackages.python.sitePackages}:$PYTHONPATH"
mkdir -p $tmp_path/${ce-pythonPackages.python.sitePackages}
# Develop installation
echo "[BEGIN]: develop install of rhodecode-enterprise-ce"
python setup.py develop --prefix $tmp_path --allow-hosts ""
'';
postShellHook = ''
echo "** Additional develop installs **"
'' + pkgs.lib.strings.concatMapStrings optionalDevelopInstall developInstalls + ''
'' + pkgs.lib.strings.concatMapStrings optionalBinDeps [ "rhodecode-vcsserver" ] + ''
'';
})