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