shell.nix
139 lines
| 4.4 KiB
| text/x-nix
|
NixLexer
r2824 | # This file contains the adjustments which are desired for a development | |||
# environment. | ||||
r1 | { pkgs ? (import <nixpkgs> {}) | |||
Martin Bornhold
|
r1132 | , pythonPackages ? "python27Packages" | ||
r2824 | , doCheck ? false | |||
Martin Bornhold
|
r1133 | , sourcesOverrides ? {} | ||
Martin Bornhold
|
r1132 | , doDevelopInstall ? true | ||
r4178 | , doReleaseInstall ? false | |||
r1 | }: | |||
let | ||||
Martin Bornhold
|
r1133 | # Get sources from config and update them with overrides. | ||
sources = (pkgs.config.rc.sources or {}) // sourcesOverrides; | ||||
r1 | ||||
Martin Bornhold
|
r1130 | enterprise-ce = import ./default.nix { | ||
r2824 | inherit | |||
pythonPackages | ||||
doCheck; | ||||
r1 | }; | |||
Martin Bornhold
|
r1130 | ce-pythonPackages = enterprise-ce.pythonPackages; | ||
r1 | ||||
Martin Bornhold
|
r1131 | # 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; | ||||
r4756 | doDI = doDevelopInstall && path != null; | |||
r2824 | ||||
Martin Bornhold
|
r1131 | in | ||
r2824 | # do develop installation with empty hosts to skip any package duplicates to | |||
# be replaced. This only pushes the package to be locally available | ||||
r4756 | pkgs.lib.optionalString doDI ('' | |||
r2824 | echo "[BEGIN] Develop install of '${attributeName}' from '${path}'" | |||
Martin Bornhold
|
r1131 | pushd ${path} | ||
python setup.py develop --prefix $tmp_path --allow-hosts "" | ||||
popd | ||||
r2824 | echo "[DONE] Develop install of '${attributeName}' from '${path}'" | |||
echo "" | ||||
Martin Bornhold
|
r1131 | ''); | ||
# 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"; | ||||
r4756 | doDI = doDevelopInstall && path != null && pkgs.lib.pathExists "${nixFile}"; | |||
r2824 | ||||
Martin Bornhold
|
r1131 | derivate = import "${nixFile}" { | ||
r3143 | inherit | |||
doCheck | ||||
pythonPackages; | ||||
Martin Bornhold
|
r1131 | }; | ||
in | ||||
r4756 | pkgs.lib.lists.optionals doDI ( | |||
r2824 | derivate.propagatedBuildInputs | |||
); | ||||
Martin Bornhold
|
r1131 | |||
r4756 | 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" | ||||
''); | ||||
Martin Bornhold
|
r1131 | developInstalls = [ "rhodecode-vcsserver" ]; | ||
r4756 | in enterprise-ce.override (attrs: rec { | |||
r1 | # Avoid that we dump any sources into the store when entering the shell and | |||
# make development a little bit more convenient. | ||||
src = null; | ||||
r2824 | # Add dependencies which are useful for the development environment. | |||
Martin Bornhold
|
r433 | buildInputs = | ||
attrs.buildInputs ++ | ||||
r4178 | (with ce-pythonPackages; | |||
[ ipdb ] | ||||
++ pkgs.lib.lists.optionals doReleaseInstall ( | ||||
[invoke bumpversion] | ||||
) | ||||
); | ||||
r1 | ||||
r2824 | # 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 = '' | ||||
r4756 | echo "Entering rhodecode-ce" | |||
r2824 | ||||
Martin Bornhold
|
r1130 | # Custom prompt to distinguish from other dev envs. | ||
r4756 | 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" | ||||
Martin Bornhold
|
r1130 | |||
r2824 | echo "Building frontend assets" | |||
r3176 | ${enterprise-ce.linkNodePackages} | |||
r2824 | ||||
Martin Bornhold
|
r1132 | # Setup a temporary directory. | ||
Martin Bornhold
|
r1130 | 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} | ||||
Martin Bornhold
|
r1132 | |||
r2824 | # Develop installation | |||
echo "[BEGIN]: develop install of rhodecode-enterprise-ce" | ||||
Martin Bornhold
|
r1130 | python setup.py develop --prefix $tmp_path --allow-hosts "" | ||
r2824 | ''; | |||
postShellHook = '' | ||||
echo "** Additional develop installs **" | ||||
r4756 | '' + pkgs.lib.strings.concatMapStrings optionalDevelopInstall developInstalls + '' | |||
'' + pkgs.lib.strings.concatMapStrings optionalBinDeps [ "rhodecode-vcsserver" ] + '' | ||||
r2824 | ''; | |||
Martin Bornhold
|
r1130 | |||
r1 | }) | |||