##// END OF EJS Templates
nix: Use vcsserver from config instead of using command line argument.
Martin Bornhold -
r1132:b75aafd5 default
parent child Browse files
Show More
@@ -1,103 +1,81 b''
1 1 { pkgs ? (import <nixpkgs> {})
2 , vcsserverPath ? "./../rhodecode-vcsserver"
3 , vcsserverNix ? "shell.nix"
2 , pythonPackages ? "python27Packages"
4 3 , doCheck ? true
4 , doDevelopInstall ? true
5 5 }:
6 6
7 7 let
8
9 # Convert vcsserverPath to absolute path.
10 vcsserverAbsPath =
11 if pkgs.lib.strings.hasPrefix "/" vcsserverPath then
12 builtins.toPath "${vcsserverPath}"
13 else
14 builtins.toPath ("${builtins.getEnv "PWD"}/${vcsserverPath}");
15
16 # Import vcsserver if nix file exists, otherwise set it to null.
17 vcsserver =
18 let
19 nixFile = "${vcsserverAbsPath}/${vcsserverNix}";
20 in
21 if pkgs.lib.pathExists "${nixFile}" then
22 builtins.trace
23 "Using local vcsserver from ${nixFile}"
24 import "${nixFile}" {inherit pkgs;}
25 else
26 null;
27
28 hasVcsserver = !isNull vcsserver;
8 sources = pkgs.config.rc.sources or {};
29 9
30 10 enterprise-ce = import ./default.nix {
31 inherit pkgs doCheck;
11 inherit pkgs pythonPackages doCheck;
32 12 };
33 13
34 14 ce-pythonPackages = enterprise-ce.pythonPackages;
35 15
36 16 # This method looks up a path from `pkgs.config.rc.sources` and returns a
37 17 # shell script which does a `python setup.py develop` installation of it. If
38 18 # no path is found it will return an empty string.
39 19 optionalDevelopInstall = attributeName:
40 20 let
41 21 path = pkgs.lib.attrByPath [attributeName] null sources;
42 22 doIt = doDevelopInstall && path != null;
43 23 in
44 24 pkgs.lib.optionalString doIt (
45 25 builtins.trace "Develop install of ${attributeName} from ${path}" ''
46 26 echo "Develop install of '${attributeName}' from '${path}' [BEGIN]"
47 27 pushd ${path}
48 28 python setup.py develop --prefix $tmp_path --allow-hosts ""
49 29 popd
50 30 echo "Develop install of '${attributeName}' from '${path}' [DONE]"
51 31 '');
52 32
53 33 # This method looks up a path from `pkgs.config.rc.sources` and imports the
54 34 # default.nix file if it exists. It returns the list of build inputs. If no
55 35 # path is found it will return an empty list.
56 36 optionalDevelopInstallBuildInputs = attributeName:
57 37 let
58 38 path = pkgs.lib.attrByPath [attributeName] null sources;
59 39 nixFile = "${path}/default.nix";
60 40 doIt = doDevelopInstall && path != null && pkgs.lib.pathExists "${nixFile}";
61 41 derivate = import "${nixFile}" {
62 42 inherit doCheck pkgs pythonPackages;
63 43 };
64 44 in
65 45 pkgs.lib.lists.optionals doIt derivate.propagatedNativeBuildInputs;
66 46
67 47 developInstalls = [ "rhodecode-vcsserver" ];
68 48
69 49 in enterprise-ce.override (attrs: {
70 50 # Avoid that we dump any sources into the store when entering the shell and
71 51 # make development a little bit more convenient.
72 52 src = null;
73 53
74 54 buildInputs =
75 55 attrs.buildInputs ++
76 pkgs.lib.optionals (hasVcsserver) vcsserver.propagatedNativeBuildInputs ++
56 pkgs.lib.lists.concatMap optionalDevelopInstallBuildInputs developInstalls ++
77 57 (with ce-pythonPackages; [
78 58 bumpversion
79 59 invoke
80 60 ipdb
81 61 ]);
82 62
83 63 # Somewhat snappier setup of the development environment
84 64 # TODO: think of supporting a stable path again, so that multiple shells
85 65 # can share it.
86 postShellHook = ''
66 preShellHook = enterprise-ce.linkNodeAndBowerPackages + ''
87 67 # Custom prompt to distinguish from other dev envs.
88 68 export PS1="\n\[\033[1;32m\][CE-shell:\w]$\[\033[0m\] "
89 69
70 # Setup a temporary directory.
90 71 tmp_path=$(mktemp -d)
91 72 export PATH="$tmp_path/bin:$PATH"
92 73 export PYTHONPATH="$tmp_path/${ce-pythonPackages.python.sitePackages}:$PYTHONPATH"
93 74 mkdir -p $tmp_path/${ce-pythonPackages.python.sitePackages}
75
76 # Develop installations
94 77 python setup.py develop --prefix $tmp_path --allow-hosts ""
95 '' + enterprise-ce.linkNodeAndBowerPackages +
96 pkgs.lib.strings.optionalString (hasVcsserver) ''
97 # Setup the vcsserver development egg.
98 pushd ${vcsserverAbsPath}
99 python setup.py develop --prefix $tmp_path --allow-hosts ""
100 popd
101 '';
78 echo "Additional develop installs"
79 '' + pkgs.lib.strings.concatMapStrings optionalDevelopInstall developInstalls;
102 80
103 81 })
General Comments 0
You need to be logged in to leave comments. Login now